[*] BO : AdminProducts find smallest images
This commit is contained in:
@@ -252,7 +252,7 @@
|
||||
<li style="float: left; width: {$imageWidth}px;">
|
||||
<input type="checkbox" name="id_image_attr[]" value="{$image.id_image}" id="id_image_attr_{$image.id_image}" />
|
||||
<label for="id_image_attr_{$image.id_image}" style="float: none;">
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$image.obj->getExistingImgPath()}-small_default.jpg" alt="{$image.legend|escape:'htmlall':'UTF-8'}" title="{$image.legend|escape:'htmlall':'UTF-8'}" />
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$image.obj->getExistingImgPath()}-{$imageType}.jpg" alt="{$image.legend|escape:'htmlall':'UTF-8'}" title="{$image.legend|escape:'htmlall':'UTF-8'}" />
|
||||
</label>
|
||||
</li>
|
||||
{/foreach}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
<tr id="image_id">
|
||||
<td style="padding: 4px;">
|
||||
<a href="{$smarty.const._THEME_PROD_DIR_}image_path.jpg" class="fancybox">
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$iso_lang}-default-small_default.jpg" alt="image_id" title="image_id" />
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$iso_lang}-default-{$imageType}.jpg" alt="image_id" title="image_id" />
|
||||
</a>
|
||||
</td>
|
||||
<td>legend</td>
|
||||
@@ -332,8 +332,8 @@
|
||||
function imageLine(id, path, position, cover, shops, legend)
|
||||
{
|
||||
line = $("#lineType").html();
|
||||
line = line.replace(/image_id/g, id);
|
||||
line = line.replace(/[a-z]{2}-default/g, path);
|
||||
line = line.replace(/image_id/g, legend);
|
||||
line = line.replace(/[a-z]{0,2}-default/g, path);
|
||||
line = line.replace(/image_path/g, path);
|
||||
line = line.replace(/image_position/g, position);
|
||||
line = line.replace(/legend/g, legend);
|
||||
|
||||
@@ -127,16 +127,20 @@ class ImageTypeCore extends ObjectModel
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
*/
|
||||
public static function getByNameNType($name, $type = null)
|
||||
public static function getByNameNType($name, $type = null, $order = null)
|
||||
{
|
||||
if (!isset(self::$images_types_name_cache[$name.'_'.$type]))
|
||||
if (!isset(self::$images_types_name_cache[$name.'_'.$type.'_'.$order]))
|
||||
{
|
||||
self::$images_types_name_cache[$name.'_'.$type] = Db::getInstance()->getRow('
|
||||
self::$images_types_name_cache[$name.'_'.$type.'_'.$order] = Db::getInstance()->getRow('
|
||||
SELECT `id_image_type`, `name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`
|
||||
FROM `'._DB_PREFIX_.'image_type`
|
||||
WHERE `name` = \''.pSQL($name).'\' '.(!is_null($type) ? 'AND `'.pSQL($type).'` = 1' : ''));
|
||||
WHERE
|
||||
`name` LIKE \''.pSQL($name).'\''
|
||||
.(!is_null($type) ? ' AND `'.pSQL($type).'` = 1' : '')
|
||||
.(!is_null($order) ? ' ORDER BY `'.bqSQL($order).'` ASC' : '')
|
||||
);
|
||||
}
|
||||
return self::$images_types_name_cache[$name.'_'.$type];
|
||||
return self::$images_types_name_cache[$name.'_'.$type.'_'.$order];
|
||||
}
|
||||
|
||||
public static function getFormatedName($name)
|
||||
|
||||
@@ -3595,6 +3595,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
foreach ($images as $k => $image)
|
||||
$images[$k] = new Image($image['id_image']);
|
||||
|
||||
|
||||
if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP)
|
||||
$current_shop_id = (int)$this->context->shop->id;
|
||||
else
|
||||
@@ -3617,6 +3618,12 @@ class AdminProductsControllerCore extends AdminController
|
||||
'languages' => $this->_languages,
|
||||
'default_language' => (int)Configuration::get('PS_LANG_DEFAULT')
|
||||
));
|
||||
|
||||
$type = ImageType::getByNameNType('%', 'products', 'height');
|
||||
if (isset($type['name']))
|
||||
$data->assign('imageType', $type['name']);
|
||||
else
|
||||
$data->assign('imageType', 'small_default');
|
||||
}
|
||||
else
|
||||
$this->displayWarning($this->l('You must save the product in this shop before adding images.'));
|
||||
@@ -3673,7 +3680,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
$data->assign('available_date', ($this->getFieldValue($product, 'available_date') != 0) ? stripslashes(htmlentities($this->getFieldValue($product, 'available_date'), $this->context->language->id)) : '0000-00-00');
|
||||
|
||||
$i = 0;
|
||||
$data->assign('imageType', ImageType::getByNameNType('small_default', 'products'));
|
||||
$type = ImageType::getByNameNType('%', 'products', 'height');
|
||||
if (isset($type['name']))
|
||||
$data->assign('imageType', $type['name']);
|
||||
else
|
||||
$data->assign('imageType', 'small_default');
|
||||
$data->assign('imageWidth', (isset($image_type['width']) ? (int)($image_type['width']) : 64) + 25);
|
||||
foreach ($images as $k => $image)
|
||||
{
|
||||
|
||||
@@ -291,51 +291,83 @@ class Blocktopmenu extends Module
|
||||
<br/>
|
||||
<a href="#" id="removeItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);"><< '.$this->l('Remove').'</a>
|
||||
</td>
|
||||
<td style="vertical-align:top;padding:5px 15px;">
|
||||
<h4 style="margin-top:5px;">'.$this->l('Change order').':</h4>
|
||||
<a href="#" id="menuOrderUp" class="button" style="font-size:20px;display:block;">↑</a><br/>
|
||||
<a href="#" id="menuOrderDown" class="button" style="font-size:20px;display:block;">↓</a><br/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="clear"> </div>
|
||||
<script type="text/javascript">
|
||||
function add()
|
||||
{
|
||||
$("#availableItems option:selected").each(function(i){
|
||||
var val = $(this).val();
|
||||
var text = $(this).text();
|
||||
text = text.replace(/(^\s*)|(\s*$)/gi,"");
|
||||
if (val == "PRODUCT")
|
||||
{
|
||||
val = prompt("'.$this->l('Set ID product').'");
|
||||
if (val == null || val == "" || isNaN(val))
|
||||
return;
|
||||
text = "'.$this->l('Product ID').' "+val;
|
||||
val = "PRD"+val;
|
||||
}
|
||||
$("#items").append("<option value=\""+val+"\">"+text+"</option>");
|
||||
});
|
||||
serialize();
|
||||
return false;
|
||||
}
|
||||
|
||||
function remove()
|
||||
{
|
||||
$("#items option:selected").each(function(i){
|
||||
$(this).remove();
|
||||
});
|
||||
serialize();
|
||||
return false;
|
||||
}
|
||||
|
||||
function serialize()
|
||||
{
|
||||
var options = "";
|
||||
$("#items option").each(function(i){
|
||||
options += $(this).val() + ",";
|
||||
});
|
||||
$("#itemsInput").val(options.substr(0, options.length - 1));
|
||||
}
|
||||
|
||||
function move(up)
|
||||
{
|
||||
var tomove = $("#items option:selected");
|
||||
if (tomove.length >1)
|
||||
{
|
||||
alert(\''.Tools::htmlentitiesUTF8($this->l('Please select just one item')).'\');
|
||||
return false;
|
||||
}
|
||||
if (up)
|
||||
tomove.prev().insertAfter(tomove);
|
||||
else
|
||||
tomove.next().insertBefore(tomove);
|
||||
serialize();
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#addItem").click(add);
|
||||
$("#availableItems").dblclick(add);
|
||||
$("#removeItem").click(remove);
|
||||
$("#items").dblclick(remove);
|
||||
function add()
|
||||
{
|
||||
$("#availableItems option:selected").each(function(i){
|
||||
var val = $(this).val();
|
||||
var text = $(this).text();
|
||||
text = text.replace(/(^\s*)|(\s*$)/gi,"");
|
||||
if (val == "PRODUCT")
|
||||
{
|
||||
val = prompt("'.$this->l('Set ID product').'");
|
||||
if (val == null || val == "" || isNaN(val))
|
||||
return;
|
||||
text = "'.$this->l('Product ID').' "+val;
|
||||
val = "PRD"+val;
|
||||
}
|
||||
$("#items").append("<option value=\""+val+"\">"+text+"</option>");
|
||||
});
|
||||
serialize();
|
||||
return false;
|
||||
}
|
||||
function remove()
|
||||
{
|
||||
$("#items option:selected").each(function(i){
|
||||
$(this).remove();
|
||||
});
|
||||
serialize();
|
||||
return false;
|
||||
}
|
||||
function serialize()
|
||||
{
|
||||
var options = "";
|
||||
$("#items option").each(function(i){
|
||||
options += $(this).val()+",";
|
||||
});
|
||||
$("#itemsInput").val(options.substr(0, options.length - 1));
|
||||
}
|
||||
$("#menuOrderUp").click(function(e){
|
||||
e.preventDefault();
|
||||
move(true);
|
||||
});
|
||||
$("#menuOrderDown").click(function(e){
|
||||
e.preventDefault();
|
||||
move();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<label for="s">'.$this->l('Search Bar').'</label>
|
||||
|
||||
Reference in New Issue
Block a user