add multilang on category img thumbs

This commit is contained in:
Marion Muszynski 2017-04-18 12:48:42 +02:00
parent 5d10aa4c72
commit 90dd61b5bb
9 changed files with 113 additions and 44 deletions

View File

@ -417,10 +417,10 @@ class AdminCategories extends AdminTab
// @Override Antadis
/* Delete Image Thumb */
elseif (isset($_GET['deleteImageThumb']))
elseif (isset($_GET['deleteImageThumb']) && isset($_GET['id_lang']))
{
if (Validate::isLoadedObject($object = $this->loadObject())) {
$this->deleteImageThumb($object);
$this->deleteImageThumb($object,$_GET['id_lang']);
Tools::redirectAdmin($currentIndex.'&updatecategory&token='.Tools::getValue('token').'&id_category='.(int)($object->id));
}
@ -442,7 +442,9 @@ class AdminCategories extends AdminTab
if ($this->deleted)
{
// @Override Antadis
$this->deleteImageThumb($object);
foreach (Language::getLanguages(FALSE) as $language) {
$this->deleteImageThumb($object, $language['id_lang']);
}
// @End Antadis
$object->deleteImage();
$object->deleted = 1;
@ -502,9 +504,22 @@ class AdminCategories extends AdminTab
protected function postImage($id)
{
// @Override Antadis
if (($id_category = (int)(Tools::getValue('id_category'))) && isset($_FILES['image_thumb']) && $_FILES['image_thumb']['name'] != NULL) {
if(!copy($_FILES['image_thumb']['tmp_name'], _PS_CAT_IMG_DIR_.$id_category.'_thumb_vp.jpg')) {
echo $this->displayError($this->l('An error occured during the image upload.'));
if($id_category = (int)(Tools::getValue('id_category'))) {
foreach (Language::getLanguages(FALSE) as $language) {
$id_lang = (int)$language['id_lang'];
if($id_lang == 3
&& (!isset($_FILES['image_thumb_'.$id_lang]) || $_FILES['image_thumb_'.$id_lang]['name'] == '')
&& (isset($_FILES['image_thumb_2']) && $_FILES['image_thumb_2']['name'] != '')
){
if(!copy($_FILES['image_thumb_2']['tmp_name'], _PS_CAT_IMG_DIR_.$id_category.'_thumb_vp_'.$id_lang.'.jpg')) {
echo $this->displayError($this->l('An error occured during the image upload.'));
}
}
elseif(isset($_FILES['image_thumb_'.$id_lang]) && $_FILES['image_thumb_'.$id_lang]['name'] != '') {
if(!copy($_FILES['image_thumb_'.$id_lang]['tmp_name'], _PS_CAT_IMG_DIR_.$id_category.'_thumb_vp_'.$id_lang.'.jpg')) {
echo $this->displayError($this->l('An error occured during the image upload.'));
}
}
}
}
// @End Antadis
@ -520,10 +535,10 @@ class AdminCategories extends AdminTab
}
// @Adding Antadis
public function deleteImageThumb($object)
public function deleteImageThumb($object, $id_lang)
{
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$object->id.'_thumb_vp.jpg')) {
unlink(_PS_ROOT_DIR_.'/img/c/'.$object->id.'_thumb_vp.jpg');
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$object->id.'_thumb_vp_'.(int)$id_lang.'.jpg')) {
unlink(_PS_ROOT_DIR_.'/img/c/'.$object->id.'_thumb_vp_'.(int)$id_lang.'.jpg');
}
}
// @End Antadis
@ -626,20 +641,39 @@ class AdminCategories extends AdminTab
<div class="clear"><br /></div>';
// @Override Antadis
echo ' <label>'.$this->l('Image logo:').' </label>
<div class="margin-form">';
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$obj->id.'_thumb_vp.jpg')) {
echo '<div id="image">
<img src="'.__PS_BASE_URI__.'img/c/'.$obj->id.'_thumb_vp.jpg" alt="" class="imgm">
<p></p>
<a href="'.$currentIndex.'&id_category='.$obj->id.'&token='.Tools::getAdminTokenLite('AdminCatalog').'&deleteImageThumb=1">
<img src="../img/admin/delete.gif" alt="Supprimer"> Supprimer</a>
</div>';
}
echo ' <br /><input type="file" name="image_thumb" />
<p>'.$this->l('Upload logo from your computer').'</p>
</div>
<div class="clear"><br /></div>';
echo '<label>'.$this->l('Image logo:').'</label>
<div class="margin-form translatable">';
foreach($this->_languages as $language) {
echo '
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">';
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$obj->id.'_thumb_vp_'.$language['id_lang'].'.jpg')) {
echo '<div id="image">
<img src="'.__PS_BASE_URI__.'img/c/'.$obj->id.'_thumb_vp_'.$language['id_lang'].'.jpg" alt="" class="imgm">
<p></p>
<a href="'.$currentIndex.'&id_category='.$obj->id.'&token='.Tools::getAdminTokenLite('AdminCatalog').'&deleteImageThumb=1&id_lang='.$language['id_lang'].'">
<img src="../img/admin/delete.gif" alt="Supprimer"> Supprimer</a>
</div>';
}
echo '<input id="image_thumb_'.$language['id_lang'].'" type="file" name="image_thumb_'.$language['id_lang'].'" />
</div>';
}
echo '<p class="clear"></p>
</div>';
// echo ' <label>'.$this->l('Image logo:').' </label>
// <div class="margin-form">';
// if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$obj->id.'_thumb_vp.jpg')) {
// echo '<div id="image">
// <img src="'.__PS_BASE_URI__.'img/c/'.$obj->id.'_thumb_vp.jpg" alt="" class="imgm">
// <p></p>
// <a href="'.$currentIndex.'&id_category='.$obj->id.'&token='.Tools::getAdminTokenLite('AdminCatalog').'&deleteImageThumb=1">
// <img src="../img/admin/delete.gif" alt="Supprimer"> Supprimer</a>
// </div>';
// }
// echo ' <br /><input type="file" name="image_thumb" />
// <p>'.$this->l('Upload logo from your computer').'</p>
// </div>
// <div class="clear"><br /></div>';
// @EndOverride Antadis
echo ' <label>'.$this->l('Meta title:').' </label>

View File

@ -1934,7 +1934,7 @@ class AdminProducts extends AdminTab
}
}
if ($array_categories['childrens']) {
if (isset($array_categories['childrens'])) {
foreach ($array_categories['childrens'] as $key => $children) {
$childrens = Category::getChildren((int) $children['id_category'], $cookie->id_lang);
$array_categories['childrens'][$key]['childrens'] = $childrens;
@ -1965,7 +1965,7 @@ class AdminProducts extends AdminTab
echo ' <label for="cat_'. $array_categories['id_category'] .'" style="font-weight:normal; float:none">' . $array_categories['name'] . '</label>';
}*/
if ($array_categories['childrens']) {
if (isset($array_categories['childrens'])) {
foreach ($array_categories['childrens'] as $key => $catchild) {
echo '<br />';
if ($catchild['id_category'] != $id_category) {
@ -2023,7 +2023,7 @@ class AdminProducts extends AdminTab
echo '<p><input type="submit" class="button" name="reordersub'.$this->table.'" value="'.$this->l('Order products').'" /></p>';
echo '<p>'.$this->l('Order by product name').'</p>';
}
if((int)$this->_category->id_oarent !=1 && $cookie->id_employee==1){
if((int)$this->_category->id_parent !=1 && $cookie->id_employee==1){
echo '<p>
<input type="submit" class="button" name="has_to_clean'.$this->table.'" value="'.$this->l('Produits à cleaner').'" />
<input type="submit" class="button" name="clean_position'.$this->table.'" value="'.$this->l('Clean positions').'" />

View File

@ -42,12 +42,23 @@ class CategoryImg extends Module {
}
}
}
if ($category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp.jpg') && $params['id_category'] != $category->id) {
if ($category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp_'.$id_lang.'.jpg') && $params['id_category'] != $category->id) {
$id_category_thumb = $params['id_category'];
} elseif ($category && $id_parent && file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_parent.'_thumb_vp_'.$id_lang.'.jpg') && $id_parent!= $category->id) {
$id_category_thumb = $id_parent;
} elseif ($category && $parent_bis && file_exists(_PS_ROOT_DIR_.'/img/c/'.$parent_bis.'_thumb_vp_'.$id_lang.'.jpg') && $parent_bis!= $category->id) {
$id_category_thumb = $parent_bis;
// keeping retrocompatibility
} elseif ($category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp.jpg') && $params['id_category'] != $category->id) {
$id_category_thumb = $params['id_category'];
} elseif ($category && $id_parent && file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_parent.'_thumb_vp.jpg') && $id_parent!= $category->id) {
$id_category_thumb = $id_parent;
} elseif ($category && $parent_bis && file_exists(_PS_ROOT_DIR_.'/img/c/'.$parent_bis.'_thumb_vp.jpg') && $parent_bis!= $category->id) {
$id_category_thumb = $parent_bis;
// End retrocompatibility
} else {
$id_category_thumb = $category->id;
}
@ -57,6 +68,7 @@ class CategoryImg extends Module {
$smarty->assign('consumable', ((int) _SHOP_PRIVATESALES_CONSUMABLE == (int) $sale->id)? true : false);
$smarty->assign('category', $category);
$smarty->assign('is_thumb_vp',(file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp.jpg')));
$smarty->assign('is_thumb_vp_lang',(file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp_'.$id_lang.'.jpg')));
$smarty->assign('id_category_thumb',$id_category_thumb);
return $this->display(__FILE__, 'left_img.tpl');
}

View File

@ -3,7 +3,9 @@
<img src="{$link->getCatImageLink($category->link_rewrite, $category->id, 'cover_vp')}" alt="{$category->name}" />
<div class="logo_cat">
{if $is_thumb_vp}
{if $is_thumb_vp_lang}
<img src="{$base_dir_ssl}img/c/{$id_category_thumb}_thumb_vp_{$cookie->id_lang}.jpg" alt="{$category->name}" />
{elseif $is_thumb_vp}
<img src="{$base_dir_ssl}img/c/{$id_category_thumb}_thumb_vp.jpg" alt="{$category->name}" />
{else}
<img src="{$base_dir_ssl}modules/privatesales/img/{$sale->id}/thumb_{$cookie->id_lang}.jpg" />

View File

@ -1,7 +1,7 @@
<?php
class CategoryController extends CategoryControllerCore {
public function preProcess() {
global $site_version_front;
global $site_version_front; $cookie;
parent::preProcess();
@ -14,7 +14,9 @@ class CategoryController extends CategoryControllerCore {
if(!empty($sale)){
$other_sales = $sale->getOthersSales(true, null, null, 'current', false, Configuration::get('PRIVATES_SHOW_PUBLIC'), '`date_start` desc', $site_version_front);
foreach ($other_sales as $key => &$s) {
if (file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$s['id_category'].'_thumb_vp.jpg')) {
if(file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$s['id_category'].'_thumb_vp_'.$cookie->id_lang.'.jpg')) {
$s['is_thumb_img_lang'] = true;
} elseif (file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$s['id_category'].'_thumb_vp.jpg')) {
$s['is_thumb_img'] = true;
} else {
$s['is_thumb_img'] = false;

View File

@ -32,12 +32,23 @@ class ProductController extends ProductControllerCore {
break;
}
}
if (isset($third_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$third_step_cat.'_thumb_vp.jpg')) {
if (isset($third_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$third_step_cat.'_thumb_vp_'.$cookie->id_lang.'.jpg')) {
$id_category_thumb = (int)$third_step_cat;
} elseif (isset($second_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$second_step_cat.'_thumb_vp_'.$cookie->id_lang.'.jpg')) {
$id_category_thumb = (int)$second_step_cat;
} elseif (isset($first_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$first_step_cat.'_thumb_vp_'.$cookie->id_lang.'.jpg')) {
$id_category_thumb = (int)$first_step_cat;
// Keeping retrocompatibility
} elseif (isset($third_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$third_step_cat.'_thumb_vp.jpg')) {
$id_category_thumb = (int)$third_step_cat;
} elseif (isset($second_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$second_step_cat.'_thumb_vp.jpg')) {
$id_category_thumb = (int)$second_step_cat;
} elseif (isset($first_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$first_step_cat.'_thumb_vp.jpg')) {
$id_category_thumb = (int)$first_step_cat;
// End retrocompatibility
} else {
// sale cat thumb
$id_category_thumb = $sale->id_category;
@ -50,6 +61,7 @@ class ProductController extends ProductControllerCore {
'HOOK_PRIVATESALES_PRODUCT' => Module::hookExec('privatesales_product', array('sale' => $sale)),
'is_sale_home' => ($sale? $sale->id_category == $id_category: FALSE),
'is_thumb_vp' => (file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp.jpg')),
'is_thumb_vp_lang' => (file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp_'.$cookie->id_lang.'.jpg')),
'id_category_thumb' => $id_category_thumb,
));

View File

@ -70,7 +70,7 @@ $(document).ready(function() {
fade: 0
});
});
if (($("#submenuw").length > 0)){
var positionElementInPage = $('#submenuw').offset().top;
$(window).scroll(
@ -84,10 +84,10 @@ $(document).ready(function() {
);
}
$('#privatesales_categories_block_left li span.parent').parent().addClass('active');
$('#privatesales_categories_block_left li span.parent').parent().addClass('active');
$('#privatesales_categories_block_left li span.parent').live('click', function(e){
e.preventDefault();
if($(this).parent().hasClass('active')){
if($(this).parent().hasClass('active')){
$(this).parent().children('ul').hide();
$(this).parent().removeClass('active');
}else{
@ -95,7 +95,7 @@ $(document).ready(function() {
$(this).parent().children('ul').show();
}
});
if($('#privatesales_categories_block_left').length > 0){
var elem = $('#privatesales_categories_block_left');
@ -105,11 +105,11 @@ $(document).ready(function() {
$(window).scroll(function(){
var scroll = $(window).scrollTop();
var marginApply = scroll + 10;
if(parseInt(scroll) >= parseInt(initial_position) ){
var position_menu_bas = $(elem).position().top + $(elem).height() + 10;
var position_center_bas = $('.main_category_vp').position().top + $('.main_category_vp').height() - 20;
var top_max = scroll + $(elem).height();
if(top_max > position_center_bas){
@ -125,14 +125,14 @@ $(document).ready(function() {
}
});
}
$(window).load(function() {
$('.flexslider').flexslider({
animation: "slide",
controlNav: false,
slideshow: false,
itemWidth: 300,
itemWidth: 300,
pauseOnHover : false,
mousewheel: false,
});
@ -144,14 +144,14 @@ $(document).ready(function() {
<div id="left_column" class="column left_vp">
{$HOOK_LEFT_COLUMN_VP}
{$HOOK_LEFT_COLUMN_VP}
</div>
{if isset($category)}
{if $category->id AND $category->active}
<div class="main_category_vp">
<div class="catHeadW">
<div class="catHeadW">
<div class="catHeadDescW">
{if $sale}
<div class="psales">
@ -239,7 +239,9 @@ $(document).ready(function() {
{foreach $other_sales as $sale}
<li>
<a href="{$link->getCategoryLink($sale['id_category'], $sale['link_rewrite'])|escape:'htmlall':'UTF-8'}">
{if $sale['is_thumb_img'] == true}
{if $sale['is_thumb_img_lang'] == true}
<img src="{$smarty.const.__PS_BASE_URI__}img/c/{$sale['id_category']}_thumb_vp_{$cookie->id_lang}.jpg" alt="{$sale['name']}" />
{elseif $sale['is_thumb_img'] == true}
<img src="{$smarty.const.__PS_BASE_URI__}img/c/{$sale['id_category']}_thumb_vp.jpg" alt="{$sale['name']}" />
{else}
<img src="{$smarty.const.__PS_BASE_URI__}modules/privatesales/img/{$sale['id_sale']}/thumb_{$cookie->id_lang}.jpg" alt="{$sale['name']}" />

View File

@ -208,7 +208,9 @@ var oneQuantityAvailableSentence = '{l s='Warning: 1 item in stock!' js=1}';
<div class="title_block">
<div class="content">
<div class="logo_vente">
{if $is_thumb_vp}
{if $is_thumb_vp_lang}
<img src="{$base_dir_ssl}img/c/{$id_category_thumb}_thumb_vp_{$cookie->id_lang}.jpg" height="80px"/>
{elseif $is_thumb_vp}
<img src="{$base_dir_ssl}img/c/{$id_category_thumb}_thumb_vp.jpg" height="80px"/>
{else}
<img src="{$base_dir_ssl}modules/privatesales/img/{$sale->id}/thumb_{$cookie->id_lang}.jpg" height="80px"/>

View File

@ -582,7 +582,10 @@ var oneQuantityAvailableSentence = '{l s='Warning: 1 item in stock!' js=1}';
{if $sale}
<div class="sale_img">
{if $is_thumb_vp}
{if $is_thumb_vp_lang}
<a class="cat_link" href="{$link->getCategoryLink($id_category_thumb, null, $cookie->id_lang)|escape:'htmlall':'UTF-8'}">
<img src="{$base_dir_ssl}img/c/{$id_category_thumb}_thumb_vp_{$cookie->id_lang}.jpg" alt="{$sale->title[$cookie->id_lang]}" />
{elseif $is_thumb_vp}
<a class="cat_link" href="{$link->getCategoryLink($id_category_thumb, null, $cookie->id_lang)|escape:'htmlall':'UTF-8'}">
<img src="{$base_dir_ssl}img/c/{$id_category_thumb}_thumb_vp.jpg" alt="{$sale->title[$cookie->id_lang]}" />
{else}