[-] FO : Fix bug #PSCFV-7743 and #PSCFV-8286, bigpic source change
This commit is contained in:
@@ -340,26 +340,39 @@ class ProductControllerCore extends FrontController
|
||||
{
|
||||
$images = $this->product->getImages((int)$this->context->cookie->id_lang);
|
||||
$product_images = array();
|
||||
|
||||
if(isset($images[0]))
|
||||
$this->context->smarty->assign('mainImage', $images[0]);
|
||||
foreach ($images as $k => $image)
|
||||
{
|
||||
if ($image['cover'])
|
||||
{
|
||||
$this->context->smarty->assign('mainImage', $images[0]);
|
||||
$this->context->smarty->assign('mainImage', $image);
|
||||
$cover = $image;
|
||||
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$image['id_image']) : $image['id_image']);
|
||||
$cover['id_image_only'] = (int)$image['id_image'];
|
||||
}
|
||||
$product_images[(int)$image['id_image']] = $image;
|
||||
}
|
||||
|
||||
if (!isset($cover))
|
||||
$cover = array(
|
||||
'id_image' => $this->context->language->iso_code.'-default',
|
||||
'legend' => 'No picture',
|
||||
'title' => 'No picture'
|
||||
{
|
||||
if(isset($images[0]))
|
||||
{
|
||||
$cover = $images[0];
|
||||
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$images[0]['id_image']) : $images[0]['id_image']);
|
||||
$cover['id_image_only'] = (int)$images[0]['id_image'];
|
||||
}
|
||||
else
|
||||
$cover = array(
|
||||
'id_image' => $this->context->language->iso_code.'-default',
|
||||
'legend' => 'No picture',
|
||||
'title' => 'No picture'
|
||||
);
|
||||
}
|
||||
$size = Image::getSize(ImageType::getFormatedName('large'));
|
||||
$this->context->smarty->assign(array(
|
||||
'have_image' => Product::getCover((int)Tools::getValue('id_product')),
|
||||
'have_image' => isset($cover['id_image'])? array((int)$cover['id_image']) : Product::getCover((int)Tools::getValue('id_product')),
|
||||
'cover' => $cover,
|
||||
'imgWidth' => (int)$size['width'],
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
@@ -432,11 +445,37 @@ class ProductControllerCore extends FrontController
|
||||
else
|
||||
$combinations[$row['id_product_attribute']]['available_date'] = '';
|
||||
|
||||
if (isset($combination_images[$row['id_product_attribute']][0]['id_image']))
|
||||
$combinations[$row['id_product_attribute']]['id_image'] = $combination_images[$row['id_product_attribute']][0]['id_image'];
|
||||
else
|
||||
if (!isset($combination_images[$row['id_product_attribute']][0]['id_image']))
|
||||
$combinations[$row['id_product_attribute']]['id_image'] = -1;
|
||||
else
|
||||
{
|
||||
$combinations[$row['id_product_attribute']]['id_image'] = $id_image = (int)$combination_images[$row['id_product_attribute']][0]['id_image'];
|
||||
if ($row['default_on'] && $id_image > 0)
|
||||
{
|
||||
if (isset($this->context->smarty->tpl_vars['images']->value))
|
||||
$product_images = $this->context->smarty->tpl_vars['images']->value;
|
||||
if (is_array($product_images) && isset($product_images[$id_image]))
|
||||
{
|
||||
$product_images[$id_image]['cover'] = 1;
|
||||
$this->context->smarty->assign('mainImage', $product_images[$id_image]);
|
||||
if (count($product_images))
|
||||
$this->context->smarty->assign('images', $product_images);
|
||||
}
|
||||
if (isset($this->context->smarty->tpl_vars['cover']->value))
|
||||
$cover = $this->context->smarty->tpl_vars['cover']->value;
|
||||
if (is_array($cover) && is_array($product_images))
|
||||
{
|
||||
$product_images[$cover['id_image']]['cover'] = 0;
|
||||
if (isset($product_images[$id_image]))
|
||||
$cover = $product_images[$id_image];
|
||||
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$id_image) : (int)$id_image);
|
||||
$cover['id_image_only'] = (int)$id_image;
|
||||
$this->context->smarty->assign('cover', $cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wash attributes list (if some attributes are unavailables and if allowed to wash it)
|
||||
if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0)
|
||||
{
|
||||
@@ -616,4 +655,4 @@ class ProductControllerCore extends FrontController
|
||||
}
|
||||
return $specific_prices;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ function findCombination(firstTime)
|
||||
|
||||
//show the large image in relation to the selected combination
|
||||
if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
|
||||
displayImage($('.thumb_' + combinations[combination]['image']).parent());
|
||||
displayImage($('#thumb_' + combinations[combination]['image']).parent());
|
||||
|
||||
//show discounts values according to the selected combination
|
||||
if (combinations[combination]['idCombination'] && combinations[combination]['idCombination'] > 0)
|
||||
@@ -418,8 +418,12 @@ function displayImage(domAAroundImgThumb, no_animation)
|
||||
if (domAAroundImgThumb.attr('href'))
|
||||
{
|
||||
var newSrc = domAAroundImgThumb.attr('href').replace('thickbox','large');
|
||||
if ($('#bigpic').attr('src') != newSrc)
|
||||
if(typeof(bigpicSrc) == 'undefined' || bigpicSrc == '')
|
||||
bigpicSrc = $('#bigpic').attr('src');
|
||||
if (bigpicSrc != newSrc)
|
||||
{
|
||||
//fadeOut is too slow, displayImage can be called again before bigpic source has really changed so we use a global bigpicSrc
|
||||
bigpicSrc = newSrc;
|
||||
$('#bigpic').fadeOut((no_animation ? 0 : 'fast'), function(){
|
||||
$(this).attr('src', newSrc).show();
|
||||
if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
|
||||
@@ -468,24 +472,29 @@ function serialScrollFixLock(event, targeted, scrolled, items, position)
|
||||
function refreshProductImages(id_product_attribute)
|
||||
{
|
||||
$('#thumbs_list_frame').scrollTo('li:eq(0)', 700, {axis:'x'});
|
||||
$('#thumbs_list li').hide();
|
||||
|
||||
id_product_attribute = parseInt(id_product_attribute);
|
||||
|
||||
if (typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
|
||||
if (id_product_attribute > 0 && typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
|
||||
{
|
||||
$('#thumbs_list li').hide();
|
||||
$('#thumbs_list').trigger('goto', 0);
|
||||
for (var i = 0; i < combinationImages[id_product_attribute].length; i++)
|
||||
$('#thumbnail_' + parseInt(combinationImages[id_product_attribute][i])).show();
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
var thumb_width = $('#thumbs_list_frame >li').width() + parseInt($('#thumbs_list_frame >li').css('marginRight'));
|
||||
$('#thumbs_list_frame').width((parseInt((thumb_width)* i) + 3) + 'px'); // Bug IE6, needs 3 pixels more ?
|
||||
if (parseInt($('#thumbs_list_frame >li').length) != parseInt($('#thumbs_list_frame >li:visible').length))
|
||||
$('#wrapResetImages').show('slow');
|
||||
else
|
||||
$('#wrapResetImages').hide('slow');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#thumbnail_' + idDefaultImage).show();
|
||||
displayImage($('#thumbnail_' + idDefaultImage + ' a'));
|
||||
$('#thumbs_list li').show();
|
||||
if (parseInt($('#thumbs_list_frame >li').length) == parseInt($('#thumbs_list_frame >li:visible').length))
|
||||
$('#wrapResetImages').hide('slow');
|
||||
}
|
||||
|
||||
var thumb_width = $('#thumbs_list_frame >li').width() + parseInt($('#thumbs_list_frame >li').css('marginRight'));
|
||||
$('#thumbs_list_frame').width((parseInt((thumb_width) * $('#thumbs_list_frame >li').length)) + 'px');
|
||||
$('#thumbs_list').trigger('goto', 0);
|
||||
serialScrollFixLock('', '', '', '', 0);// SerialScroll Bug on goto 0 ?
|
||||
}
|
||||
@@ -548,6 +557,12 @@ $(document).ready(function()
|
||||
$('#customizedDatas').append(uploading_in_progress);
|
||||
});
|
||||
|
||||
original_url = window.location + '';
|
||||
first_url_check = true;
|
||||
bigpicSrc = $('#bigpic').attr('src');
|
||||
checkUrl();
|
||||
initLocationChange();
|
||||
|
||||
//init the price in relation of the selected attributes
|
||||
if (typeof productHasAttributes != 'undefined' && productHasAttributes)
|
||||
findCombination(true);
|
||||
@@ -563,11 +578,6 @@ $(document).ready(function()
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic'
|
||||
});
|
||||
original_url = window.location + '';
|
||||
first_url_check = true;
|
||||
checkUrl();
|
||||
initLocationChange();
|
||||
|
||||
});
|
||||
|
||||
function saveCustomization()
|
||||
@@ -668,12 +678,12 @@ function getProductAttribute()
|
||||
function initLocationChange(time)
|
||||
{
|
||||
if(!time) time = 500;
|
||||
setInterval(checkUrl, time);
|
||||
setInterval(checkUrl, time);
|
||||
}
|
||||
|
||||
function checkUrl()
|
||||
{
|
||||
if (original_url != window.url || first_url_check)
|
||||
if (original_url != window.location || first_url_check)
|
||||
{
|
||||
first_url_check = false;
|
||||
url = window.location + '';
|
||||
@@ -710,11 +720,11 @@ function checkUrl()
|
||||
if (count >= 0)
|
||||
{
|
||||
findCombination(false);
|
||||
original_url = window.location + '';
|
||||
original_url = url;
|
||||
}
|
||||
// no combination found = removing attributes from url
|
||||
else
|
||||
window.location = url.substring(0, url.indexOf('#'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
{assign var=imageIds value="`$product->id`-`$image.id_image`"}
|
||||
<li id="thumbnail_{$image.id_image}">
|
||||
<a href="{$link->getImageLink($product->link_rewrite, $imageIds, thickbox_default)}" rel="other-views" class="thickbox {if $smarty.foreach.thumbnails.first}shown{/if}" title="{$image.legend|htmlspecialchars}">
|
||||
<img class="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium_default')}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />
|
||||
<img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium_default')}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />
|
||||
</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
@@ -285,7 +285,7 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
{assign var="groupName" value="group_$id_attribute_group"}
|
||||
<div class="attribute_list">
|
||||
{if ($group.group_type == 'select')}
|
||||
<select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="attribute_select" onchange="findCombination();getProductAttribute();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};">
|
||||
<select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="attribute_select" onchange="findCombination();getProductAttribute();">
|
||||
{foreach from=$group.attributes key=id_attribute item=group_attribute}
|
||||
<option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
@@ -295,9 +295,9 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
{assign var="default_colorpicker" value=""}
|
||||
{foreach from=$group.attributes key=id_attribute item=group_attribute}
|
||||
<li{if $group.default == $id_attribute} class="selected"{/if}>
|
||||
<a id="color_{$id_attribute|intval}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}" style="background: {$colors.$id_attribute.value};" title="{$colors.$id_attribute.name}" onclick="colorPickerClick(this);getProductAttribute();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if}">
|
||||
<a id="color_{$id_attribute|intval}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}" style="background: {$colors.$id_attribute.value};" title="{$colors.$id_attribute.name}" onclick="colorPickerClick(this);getProductAttribute();">
|
||||
{if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}
|
||||
<img src="{$img_col_dir}{$id_attribute}.jpg" alt="{$colors.$id_attribute.name}" width="20" height="20" /><br>
|
||||
<img src="{$img_col_dir}{$id_attribute}.jpg" alt="{$colors.$id_attribute.name}" width="20" height="20" /><br />
|
||||
{/if}
|
||||
</a>
|
||||
</li>
|
||||
@@ -311,7 +311,7 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
<ul>
|
||||
{foreach from=$group.attributes key=id_attribute item=group_attribute}
|
||||
<li>
|
||||
<input type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();getProductAttribute();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if}">
|
||||
<input type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();getProductAttribute();" />
|
||||
<span>{$group_attribute|escape:'htmlall':'UTF-8'}</span>
|
||||
</li>
|
||||
{/foreach}
|
||||
@@ -613,7 +613,7 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
{if $field.type == 1}
|
||||
<li class="customizationUploadLine{if $field.required} required{/if}">
|
||||
<label for ="textField{$customizationField}">{assign var='key' value='textFields_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field} {if !empty($field.name)}{$field.name}{/if}{if $field.required}<sup>*</sup>{/if}</label>
|
||||
<textarea type="text" name="textField{$field.id_customization_field}" id="textField{$customizationField}" rows="1" cols="40" class="customization_block_input" />{if isset($textFields.$key)}{$textFields.$key|stripslashes}{/if}</textarea>
|
||||
<textarea type="text" name="textField{$field.id_customization_field}" id="textField{$customizationField}" rows="1" cols="40" class="customization_block_input">{if isset($textFields.$key)}{$textFields.$key|stripslashes}{/if}</textarea>
|
||||
</li>
|
||||
{counter}
|
||||
{/if}
|
||||
@@ -636,13 +636,10 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($packItems) && $packItems|@count > 0}
|
||||
<div id="blockpack">
|
||||
<h2>{l s='Pack content'}</h2>
|
||||
{include file="$tpl_dir./product-list.tpl" products=$packItems}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
Reference in New Issue
Block a user