[-] BO : Fix bug #10689, could not set image legend in back office

This commit is contained in:
gRoussac
2013-10-27 22:49:25 +01:00
parent 9a3cfece69
commit 2dbaa5f73b
5 changed files with 60 additions and 18 deletions
+12 -2
View File
@@ -102,6 +102,11 @@ class QqUploadedFileForm
$image = new Image();
$image->id_product = (int)$product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$legends = Tools::getValue('legend');
if (is_array($legends))
foreach ($legends as $key => $legend)
if (!empty($legend))
$image->legend[(int)$key] = $legend;
if (!Image::getCover($image->id_product))
$image->cover = 1;
else
@@ -136,7 +141,7 @@ class QqUploadedFileForm
if (!$image->update())
return array('error' => Tools::displayError('Error while updating status'));
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName());
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName(), 'legend' => $image->legend);
return array('success' => $img);
}
@@ -184,6 +189,11 @@ class QqUploadedFileXhr
$image = new Image();
$image->id_product = (int)($product->id);
$image->position = Image::getHighestPosition($product->id) + 1;
$legends = Tools::getValue('legend');
if (is_array($legends))
foreach ($legends as $key => $legend)
if (!empty($legend))
$image->legend[(int)$key] = $legend;
if (!Image::getCover($image->id_product))
$image->cover = 1;
else
@@ -223,7 +233,7 @@ class QqUploadedFileXhr
if (!$image->update())
return array('error' => Tools::displayError('Error while updating status'));
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName());
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName(), 'legend' => $image->legend);
return array('success' => $img);
}
+4
View File
@@ -40,6 +40,9 @@ class ImageCore extends ObjectModel
/** @var boolean Image is cover */
public $cover;
/** @var string Legend */
public $legend;
/** @var string image extension */
public $image_format = 'jpg';
@@ -66,6 +69,7 @@ class ImageCore extends ObjectModel
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'shop' => true),
'legend' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
),
);