diff --git a/adm/tabs/AdminCategories.php b/adm/tabs/AdminCategories.php index c27d6351..d0c75b29 100755 --- a/adm/tabs/AdminCategories.php +++ b/adm/tabs/AdminCategories.php @@ -1,6 +1,6 @@ table = 'category'; - $this->className = 'Category'; - $this->lang = true; - $this->edit = true; - $this->view = true; - $this->delete = true; + public function __construct() + { + global $cookie; - $this->fieldImageSettings = array('name' => 'image', 'dir' => 'c'); + $this->table = 'category'; + $this->className = 'Category'; + $this->lang = true; + $this->edit = true; + $this->view = true; + $this->delete = true; - $this->fieldsDisplay = array( - 'id_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30), - 'name' => array('title' => $this->l('Name'), 'width' => 100, 'small_title' => true), - 'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false), - 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'), - 'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false)); - - $this->_category = AdminCatalog::getCurrentCategory(); - $this->_filter = 'AND `id_parent` = '.(int)($this->_category->id); - $this->_select = 'position '; + $this->fieldImageSettings = array('name' => 'image', 'dir' => 'c'); - if ($this->_category->id == 1) { - $this->_orderBy = 'id_category'; - $this->_orderWay = 'DESC'; - } + $this->fieldsDisplay = array( + 'id_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30), + 'name' => array('title' => $this->l('Name'), 'width' => 100, 'small_title' => true), + 'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false), + 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'), + 'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false)); - parent::__construct(); - } + $this->_category = AdminCatalog::getCurrentCategory(); + $this->_filter = 'AND `id_parent` = '.(int)($this->_category->id); + $this->_select = 'position '; - public function displayListContent($token = NULL) - { - global $currentIndex, $cookie; - - if ($this->_category->id_parent == 1) { - $sub_categories = array(); - foreach ($this->_list as $key => $category_one) { - $subcategories = Category::getChildren($category_one['id_category'], $cookie->id_lang); + if ($this->_category->id == 1) { + $this->_orderBy = 'id_category'; + $this->_orderWay = 'DESC'; + } - if ($subcategories) { - foreach ($subcategories as $subcat) { - if(!is_array($this->_list[$key]['childs'])) { - $this->_list[$key]['childs'] = array(); - } - $category_tmp = new Category($subcat['id_category'], $cookie->id_lang); - $this->_list[$key]['childs'][] = get_object_vars($category_tmp); - } - } - } + parent::__construct(); + } - $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); + public function displayListContent($token = NULL) + { + global $currentIndex, $cookie; - $id_category = 1; // default categ + if ($this->_category->id_parent == 1) { + $sub_categories = array(); + foreach ($this->_list as $key => $category_one) { + $subcategories = Category::getChildren($category_one['id_category'], $cookie->id_lang); - $irow = 0; - if ($this->_list AND isset($this->fieldsDisplay['position'])) - { - $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list); - sort($positions); - } - if ($this->_list) - { - $isCms = false; - if (preg_match('/cms/Ui', $this->identifier)) - $isCms = true; - $keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : ''); - foreach ($this->_list AS $tr) - { - $id = $tr[$this->identifier]; - echo 'identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'> - '; - if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) - echo ''; - echo ''; - foreach ($this->fieldsDisplay AS $key => $params) - { - $tmp = explode('!', $key); - $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; - echo ' - noLink) OR !$this->noLink)) - echo ' onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : ''); - else - echo '>'; - if (isset($params['active']) AND isset($tr[$key])) - $this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product')); - elseif (isset($params['activeVisu']) AND isset($tr[$key])) - echo ''.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).''; - elseif (isset($params['position'])) - { - if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC') - { - echo ' - '.$this->l('Down').''; + if ($subcategories) { + foreach ($subcategories as $subcat) { + if(!is_array($this->_list[$key]['childs'])) { + $this->_list[$key]['childs'] = array(); + } + $category_tmp = new Category($subcat['id_category'], $cookie->id_lang); + $this->_list[$key]['childs'][] = get_object_vars($category_tmp); + } + } + } - echo ' - '.$this->l('Up').''; } - else - echo (int)($tr[$key] + 1); - } - elseif (isset($params['image'])) - { - // item_id is the product id in a product image context, else it is the image id. - $item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; - // If it's a product image - if (isset($tr['id_image'])) - { - $image = new Image((int)$tr['id_image']); - $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType; - }else - $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)($tr['id_image']) : '').'.'.$this->imageType; + $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType); - } - elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default']))) - echo ''.$tr[$key]).''; - elseif (isset($params['price'])) - echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false); - elseif (isset($params['float'])) - echo rtrim(rtrim($tr[$key], '0'), '.'); - elseif (isset($params['type']) AND $params['type'] == 'date') - echo Tools::displayDate($tr[$key], (int)$cookie->id_lang); - elseif (isset($params['type']) AND $params['type'] == 'datetime') - echo Tools::displayDate($tr[$key], (int)$cookie->id_lang, true); - elseif (isset($tr[$key])) - { - $echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]); - echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo; - } - else - echo '--'; + $id_category = 1; // default categ - echo (isset($params['suffix']) ? $params['suffix'] : ''). - ''; - } + $irow = 0; + if ($this->_list AND isset($this->fieldsDisplay['position'])) + { + $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list); + sort($positions); + } + if ($this->_list) + { + $isCms = false; + if (preg_match('/cms/Ui', $this->identifier)) + $isCms = true; + $keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : ''); + foreach ($this->_list AS $tr) + { + $id = $tr[$this->identifier]; + echo 'identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'> + '; + if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) + echo ''; + echo ''; + foreach ($this->fieldsDisplay AS $key => $params) + { + $tmp = explode('!', $key); + $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; + echo ' + noLink) OR !$this->noLink)) + echo ' onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : ''); + else + echo '>'; + if (isset($params['active']) AND isset($tr[$key])) + $this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product')); + elseif (isset($params['activeVisu']) AND isset($tr[$key])) + echo ''.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).''; + elseif (isset($params['position'])) + { + if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC') + { + echo ' + '.$this->l('Down').''; - if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) - { - echo ''; - if ($this->view) - $this->_displayViewLink($token, $id); - if ($this->edit) - $this->_displayEditLink($token, $id); - if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) - $this->_displayDeleteLink($token, $id); - if ($this->duplicate) - $this->_displayDuplicate($token, $id); - echo ''; - } - echo ''; + echo ' + '.$this->l('Up').''; } + else + echo (int)($tr[$key] + 1); + } + elseif (isset($params['image'])) + { + // item_id is the product id in a product image context, else it is the image id. + $item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; + // If it's a product image + if (isset($tr['id_image'])) + { + $image = new Image((int)$tr['id_image']); + $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType; + }else + $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)($tr['id_image']) : '').'.'.$this->imageType; - if ($tr['childs']) { - foreach ($tr['childs'] as $key => $child) { - $id = $child['id_category']; - echo ''; - echo '-'; - echo ''.$child['id_category'].''; - echo '-- '.$child['name'].''; - if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) { - echo ''; - if ($this->view) - $this->_displayViewLink($token, $id); - if ($this->edit) - $this->_displayEditLink($token, $id); - if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) - $this->_displayDeleteLink($token, $id); - if ($this->duplicate) - $this->_displayDuplicate($token, $id); - echo ''; - } - echo ''; - } - } - } - } - } else { - $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); + echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType); + } + elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default']))) + echo ''.$tr[$key]).''; + elseif (isset($params['price'])) + echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false); + elseif (isset($params['float'])) + echo rtrim(rtrim($tr[$key], '0'), '.'); + elseif (isset($params['type']) AND $params['type'] == 'date') + echo Tools::displayDate($tr[$key], (int)$cookie->id_lang); + elseif (isset($params['type']) AND $params['type'] == 'datetime') + echo Tools::displayDate($tr[$key], (int)$cookie->id_lang, true); + elseif (isset($tr[$key])) + { + $echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]); + echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo; + } + else + echo '--'; - $id_category = 1; // default categ + echo (isset($params['suffix']) ? $params['suffix'] : ''). + ''; + } - $irow = 0; - if ($this->_list AND isset($this->fieldsDisplay['position'])) - { - $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list); - sort($positions); - } - if ($this->_list) - { - $isCms = false; - - $ids_categories = array_map(function($elem) { - return $elem['id_category']; - }, $this->_list); - - $small_titles = array(); - foreach (Db::getInstance()->executeS(' - SELECT ex.`value`, ps.`id_category` - FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` ex - LEFT JOIN `'._DB_PREFIX_.'privatesale` ps on ex.`id_sale` = ps.`id_sale` - LEFT JOIN `'._DB_PREFIX_.'category` c on c.`id_category` = ps.`id_category` - WHERE ex.`id_field` = 1 - AND ex.`id_lang` = '. (int) $cookie->id_lang.' - AND c.`id_category` IN ('.implode(',', $ids_categories).') - ') as $key => $data) { - $small_titles[(int) $data['id_category']] = $data['value']; - } + if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) + { + echo ''; + if ($this->view) + $this->_displayViewLink($token, $id); + if ($this->edit) + $this->_displayEditLink($token, $id); + if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) + $this->_displayDeleteLink($token, $id); + if ($this->duplicate) + $this->_displayDuplicate($token, $id); + echo ''; + } + echo ''; - if (preg_match('/cms/Ui', $this->identifier)) - $isCms = true; - $keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : ''); - foreach ($this->_list AS $tr) - { - $id = $tr[$this->identifier]; - echo 'identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'> - '; - if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) - echo ''; - echo ''; - foreach ($this->fieldsDisplay AS $key => $params) - { - $tmp = explode('!', $key); - $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; - echo ' - noLink) OR !$this->noLink)) - echo ' onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : ''); - else - echo '>'; - if (isset($params['active']) AND isset($tr[$key])) - $this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product')); - elseif (isset($params['activeVisu']) AND isset($tr[$key])) - echo ''.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).''; - elseif (isset($params['position'])) - { - if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC') - { - echo ' - '.$this->l('Down').''; + if ($tr['childs']) { + foreach ($tr['childs'] as $key => $child) { + $id = $child['id_category']; + echo ''; + echo '-'; + echo ''.$child['id_category'].''; + echo '-- '.$child['name'].''; + if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) { + echo ''; + if ($this->view) + $this->_displayViewLink($token, $id); + if ($this->edit) + $this->_displayEditLink($token, $id); + if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) + $this->_displayDeleteLink($token, $id); + if ($this->duplicate) + $this->_displayDuplicate($token, $id); + echo ''; + } + echo ''; + } + } + } + } + } else { + $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - echo ' - '.$this->l('Up').''; } - else - echo (int)($tr[$key] + 1); - } - elseif (isset($params['image'])) - { - // item_id is the product id in a product image context, else it is the image id. - $item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; - // If it's a product image - if (isset($tr['id_image'])) - { - $image = new Image((int)$tr['id_image']); - $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType; - }else - $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)($tr['id_image']) : '').'.'.$this->imageType; + $id_category = 1; // default categ - echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType); - } - elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default']))) - echo ''.$tr[$key]).''; - elseif (isset($params['price'])) - echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false); - elseif (isset($params['float'])) - echo rtrim(rtrim($tr[$key], '0'), '.'); - elseif (isset($params['type']) AND $params['type'] == 'date') - echo Tools::displayDate($tr[$key], (int)$cookie->id_lang); - elseif (isset($params['type']) AND $params['type'] == 'datetime') - echo Tools::displayDate($tr[$key], (int)$cookie->id_lang, true); - elseif (isset($tr[$key])) - { - $echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]); - if(isset($params['small_title']) - && isset($small_titles[(int) $tr['id_category']]) - ) { - $echo .= ' - ' . $small_titles[(int) $tr['id_category']]. ''; - } - echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo; - } - else - echo '--'; + $irow = 0; + if ($this->_list AND isset($this->fieldsDisplay['position'])) + { + $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list); + sort($positions); + } + if ($this->_list) + { + $isCms = false; - echo (isset($params['suffix']) ? $params['suffix'] : ''). - ''; - } + $ids_categories = array_map(function($elem) { + return $elem['id_category']; + }, $this->_list); - if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) - { - echo ''; - if ($this->view) - $this->_displayViewLink($token, $id); - if ($this->edit) - $this->_displayEditLink($token, $id); - if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) - $this->_displayDeleteLink($token, $id); - if ($this->duplicate) - $this->_displayDuplicate($token, $id); - echo ''; - } - echo ''; - } - } - } + $small_titles = array(); + foreach (Db::getInstance()->executeS(' + SELECT ex.`value`, ps.`id_category` + FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` ex + LEFT JOIN `'._DB_PREFIX_.'privatesale` ps on ex.`id_sale` = ps.`id_sale` + LEFT JOIN `'._DB_PREFIX_.'category` c on c.`id_category` = ps.`id_category` + WHERE ex.`id_field` = 1 + AND ex.`id_lang` = '. (int) $cookie->id_lang.' + AND c.`id_category` IN ('.implode(',', $ids_categories).') + ') as $key => $data) { + $small_titles[(int) $data['id_category']] = $data['value']; + } + + if (preg_match('/cms/Ui', $this->identifier)) + $isCms = true; + $keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : ''); + foreach ($this->_list AS $tr) + { + $id = $tr[$this->identifier]; + echo 'identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'> + '; + if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) + echo ''; + echo ''; + foreach ($this->fieldsDisplay AS $key => $params) + { + $tmp = explode('!', $key); + $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; + echo ' + noLink) OR !$this->noLink)) + echo ' onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : ''); + else + echo '>'; + if (isset($params['active']) AND isset($tr[$key])) + $this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product')); + elseif (isset($params['activeVisu']) AND isset($tr[$key])) + echo ''.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).''; + elseif (isset($params['position'])) + { + if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC') + { + echo ' + '.$this->l('Down').''; + + echo ' + '.$this->l('Up').''; } + else + echo (int)($tr[$key] + 1); + } + elseif (isset($params['image'])) + { + // item_id is the product id in a product image context, else it is the image id. + $item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; + // If it's a product image + if (isset($tr['id_image'])) + { + $image = new Image((int)$tr['id_image']); + $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType; + }else + $path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)($tr['id_image']) : '').'.'.$this->imageType; + + echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType); + } + elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default']))) + echo ''.$tr[$key]).''; + elseif (isset($params['price'])) + echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false); + elseif (isset($params['float'])) + echo rtrim(rtrim($tr[$key], '0'), '.'); + elseif (isset($params['type']) AND $params['type'] == 'date') + echo Tools::displayDate($tr[$key], (int)$cookie->id_lang); + elseif (isset($params['type']) AND $params['type'] == 'datetime') + echo Tools::displayDate($tr[$key], (int)$cookie->id_lang, true); + elseif (isset($tr[$key])) + { + $echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]); + if(isset($params['small_title']) + && isset($small_titles[(int) $tr['id_category']]) + ) { + $echo .= ' - ' . $small_titles[(int) $tr['id_category']]. ''; + } + echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo; + } + else + echo '--'; + + echo (isset($params['suffix']) ? $params['suffix'] : ''). + ''; + } + + if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) + { + echo ''; + if ($this->view) + $this->_displayViewLink($token, $id); + if ($this->edit) + $this->_displayEditLink($token, $id); + if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete))) + $this->_displayDeleteLink($token, $id); + if ($this->duplicate) + $this->_displayDuplicate($token, $id); + echo ''; + } + echo ''; + } + } + } - } + } - public function displayList($token = NULL) - { - global $currentIndex; - - /* Display list header (filtering, pagination and column names) */ - $this->displayListHeader($token); - if (!sizeof($this->_list)) - echo ''.$this->l('No items found').''; + public function displayList($token = NULL) + { + global $currentIndex; - /* Show the content of the table */ - $this->displayListContent($token); + /* Display list header (filtering, pagination and column names) */ + $this->displayListHeader($token); + if (!sizeof($this->_list)) + echo ''.$this->l('No items found').''; - /* Close list table and submit button */ - $this->displayListFooter($token); - } + /* Show the content of the table */ + $this->displayListContent($token); - public function display($token = NULL) - { - global $currentIndex, $cookie; + /* Close list table and submit button */ + $this->displayListFooter($token); + } - $this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL); - echo '

'.(!$this->_listTotal ? ($this->l('There are no subcategories')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('subcategories') : $this->l('subcategory')))).' '.$this->l('in category').' "'.stripslashes($this->_category->getName()).'"

'; - if ($this->tabAccess['add'] === '1') - echo ' '.$this->l('Add a new subcategory').''; - echo '
'; - $this->displayList($token); - echo '
'; - } + public function display($token = NULL) + { + global $currentIndex, $cookie; - public function postProcess($token = NULL) - { - global $cookie, $currentIndex; + $this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL); + echo '

'.(!$this->_listTotal ? ($this->l('There are no subcategories')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('subcategories') : $this->l('subcategory')))).' '.$this->l('in category').' "'.stripslashes($this->_category->getName()).'"

'; + if ($this->tabAccess['add'] === '1') + echo ' '.$this->l('Add a new subcategory').''; + echo '
'; + $this->displayList($token); + echo '
'; + } - $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id); + public function postProcess($token = NULL) + { + global $cookie, $currentIndex; - if (Tools::isSubmit('submitAdd'.$this->table)) - { - if ($id_category = (int)(Tools::getValue('id_category'))) - { - if (!Category::checkBeforeMove($id_category, (int)(Tools::getValue('id_parent')))) - { - $this->_errors[] = Tools::displayError('Category cannot be moved here'); - return false; - } - } - } - /* Delete object */ - elseif (isset($_GET['delete'.$this->table])) - { - if ($this->tabAccess['delete'] === '1') - { - if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings)) - { - // check if request at least one object with noZeroObject - if (isset($object->noZeroObject) AND sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) - $this->_errors[] = Tools::displayError('You need at least one object.').' '.$this->table.'
'.Tools::displayError('You cannot delete all of the items.'); - else - { - if ($this->deleted) - { - $object->deleteImage(); - $object->deleted = 1; - if ($object->update()) - Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token').'&id_category='.(int)($object->id_parent)); - } - elseif ($object->delete()) - Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token').'&id_category='.(int)($object->id_parent)); - $this->_errors[] = Tools::displayError('An error occurred during deletion.'); - } - } - else - $this->_errors[] = Tools::displayError('An error occurred while deleting object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); - } - elseif (isset($_GET['position'])) - { - if ($this->tabAccess['edit'] !== '1') - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - elseif (!Validate::isLoadedObject($object = new Category((int)(Tools::getValue($this->identifier, Tools::getValue('id_category_to_move', 1)))))) - $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - if (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position')))) - $this->_errors[] = Tools::displayError('Failed to update the position.'); - else - Tools::redirectAdmin($currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier, Tools::getValue('id_category_parent', 1)))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCatalog')); - } - /* Delete multiple objects */ - elseif (Tools::getValue('submitDel'.$this->table)) - { - if ($this->tabAccess['delete'] === '1') - { - if (isset($_POST[$this->table.'Box'])) - { - $category = new Category(); - $result = true; - $result = $category->deleteSelection(Tools::getValue($this->table.'Box')); - if ($result) - { - $category->cleanPositions((int)(Tools::getValue('id_category'))); - Tools::redirectAdmin($currentIndex.'&conf=2&token='.Tools::getAdminTokenLite('AdminCatalog').'&id_category='.(int)(Tools::getValue('id_category'))); - } - $this->_errors[] = Tools::displayError('An error occurred while deleting selection.'); + $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id); - } - else - $this->_errors[] = Tools::displayError('You must select at least one element to delete.'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); - return; - } - parent::postProcess(); - } + if (Tools::isSubmit('submitAdd'.$this->table)) + { + if ($id_category = (int)(Tools::getValue('id_category'))) + { + if (!Category::checkBeforeMove($id_category, (int)(Tools::getValue('id_parent')))) + { + $this->_errors[] = Tools::displayError('Category cannot be moved here'); + return false; + } + } + } - protected function postImage($id) - { - $ret = parent::postImage($id); - if (($id_category = (int)(Tools::getValue('id_category'))) AND isset($_FILES) AND sizeof($_FILES) AND $_FILES['image']['name'] != NULL AND file_exists(_PS_CAT_IMG_DIR_.$id_category.'.jpg')) - { - $imagesTypes = ImageType::getImagesTypes('categories'); - foreach ($imagesTypes AS $k => $imageType) - imageResize(_PS_CAT_IMG_DIR_.$id_category.'.jpg', _PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])); - } - return $ret; - } + // @Override Antadis + /* Delete Image Thumb */ + elseif (isset($_GET['deleteImageThumb'])) + { + if (Validate::isLoadedObject($object = $this->loadObject())) { + $this->deleteImageThumb($object); + Tools::redirectAdmin($currentIndex.'&updatecategory&token='.Tools::getValue('token').'&id_category='.(int)($object->id)); + } - public function displayForm($token = NULL) - { - global $currentIndex, $cookie; - parent::displayForm(); + } + // @EndOverride Antadis - if (!($obj = $this->loadObject(true))) - return; - $active = $this->getFieldValue($obj, 'active'); - $customer_groups = $obj->getGroups(); + /* Delete object */ + elseif (isset($_GET['delete'.$this->table])) + { + if ($this->tabAccess['delete'] === '1') + { + if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings)) + { + // check if request at least one object with noZeroObject + if (isset($object->noZeroObject) AND sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) + $this->_errors[] = Tools::displayError('You need at least one object.').' '.$this->table.'
'.Tools::displayError('You cannot delete all of the items.'); + else + { + if ($this->deleted) + { + // @Override Antadis + $this->deleteImageThumb($object); + // @End Antadis + $object->deleteImage(); + $object->deleted = 1; + if ($object->update()) + Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token').'&id_category='.(int)($object->id_parent)); + } + elseif ($object->delete()) + Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token').'&id_category='.(int)($object->id_parent)); + $this->_errors[] = Tools::displayError('An error occurred during deletion.'); + } + } + else + $this->_errors[] = Tools::displayError('An error occurred while deleting object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); + } + else + $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); + } + elseif (isset($_GET['position'])) + { + if ($this->tabAccess['edit'] !== '1') + $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); + elseif (!Validate::isLoadedObject($object = new Category((int)(Tools::getValue($this->identifier, Tools::getValue('id_category_to_move', 1)))))) + $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); + if (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position')))) + $this->_errors[] = Tools::displayError('Failed to update the position.'); + else + Tools::redirectAdmin($currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier, Tools::getValue('id_category_parent', 1)))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCatalog')); + } + /* Delete multiple objects */ + elseif (Tools::getValue('submitDel'.$this->table)) + { + if ($this->tabAccess['delete'] === '1') + { + if (isset($_POST[$this->table.'Box'])) + { + $category = new Category(); + $result = true; + $result = $category->deleteSelection(Tools::getValue($this->table.'Box')); + if ($result) + { + $category->cleanPositions((int)(Tools::getValue('id_category'))); + Tools::redirectAdmin($currentIndex.'&conf=2&token='.Tools::getAdminTokenLite('AdminCatalog').'&id_category='.(int)(Tools::getValue('id_category'))); + } + $this->_errors[] = Tools::displayError('An error occurred while deleting selection.'); - echo ' -
- '.($obj->id ? '' : '').' -
'.$this->l('Category').' - -
'; - foreach ($this->_languages AS $language) - echo ' -
- id) ? ' onkeyup="copy2friendlyURLCategory();"' : '').' /> * - '.$this->l('Invalid characters:').' <>;=#{}  -
'; - - if(Module::isInstalled('categoryfamily')) { - // ADD category - require_once '..'._MODULE_DIR_.'categoryfamily/models/CategoryFamily.php'; - echo ''; + } + else + $this->_errors[] = Tools::displayError('You must select at least one element to delete.'); + } + else + $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); + return; + } + parent::postProcess(); + } - if (!empty($obj->id)) { - $data = CategoryFamilyCore::loadAssociations($obj->id, $cookie->id_lang); - echo ' -

'; - echo $data; - } - // ADD CATEGORY - else { - $familles = CategoryFamilyCore::getParentFamily($cookie->id_lang); - echo ' -

-
- -
-
- -
-

'; - } - } + 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.')); + } + } + // @End Antadis - echo '

-
- -
- - - - -
- -
'; - // Translations are not automatic for the moment ;) - $trads = array( - 'Home' => $this->l('Home'), - 'selected' => $this->l('selected'), - 'Collapse All' => $this->l('Collapse All'), - 'Expand All' => $this->l('Expand All'), - 'Toggle' => 'Masquer/Voir', - ); - echo Helper::renderAdminCategorieTree($trads, array(isset($obj->id_parent) ? $obj->id_parent : Tools::getValue('id_parent', 1)), 'id_parent', true); - echo '
- -
'; - foreach ($this->_languages AS $language){ - $data = htmlentities($this->getFieldValue($obj, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8'); - if(empty($data)) - $data = date('Y') . '-' . date('m'); - echo ' -
- -
'; - } - - echo '

-
- -
'; - echo $this->displayImage($obj->id, _PS_IMG_DIR_.'c/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)), true); - echo '
-

'.$this->l('Upload category logo from your computer').'

-
-

- -
'; - foreach ($this->_languages AS $language) - echo ' -
- - '.$this->l('Forbidden characters:').' <>;=#{}  -
'; - echo '

-
- -
'; - foreach ($this->_languages AS $language) - echo '
- - '.$this->l('Forbidden characters:').' <>;=#{}  -
'; - echo '

-
- -
'; - foreach ($this->_languages AS $language) - echo ' -
- - '.$this->l('Forbidden characters:').' <>;=#{}  -
'; - echo '

-
- -
'; - foreach ($this->_languages AS $language) - echo '
- * - '.$this->l('Only letters and the minus (-) character are allowed').'  -
'; - echo '

-
- -
'; - $groups = Group::getGroups((int)($cookie->id_lang)); - if (sizeof($groups)) - { - echo ' - - - - - - '; - $irow = 0; - foreach ($groups AS $group) - echo ' - - - - - '; - echo ' -
id) ? 'checked="checked" ' : '').' />'.$this->l('ID').''.$this->l('Group name').'
id))) ? 'checked="checked" ' : '').'/>'.$group['id_group'].'
-

'.$this->l('Mark all groups you want to give access to this category').'

- '; - } else - echo '

'.$this->l('No group created').'

'; + $ret = parent::postImage($id); + if (($id_category = (int)(Tools::getValue('id_category'))) AND isset($_FILES) AND sizeof($_FILES) AND $_FILES['image']['name'] != NULL AND file_exists(_PS_CAT_IMG_DIR_.$id_category.'.jpg')) + { + $imagesTypes = ImageType::getImagesTypes('categories'); + foreach ($imagesTypes AS $k => $imageType) + imageResize(_PS_CAT_IMG_DIR_.$id_category.'.jpg', _PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])); + } + return $ret; + } - - echo ' -
-
- -   -
-
* '.$this->l('Required field').'
-
-
-

'; - } + // @Adding Antadis + public function deleteImageThumb($object) + { + if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$object->id.'_thumb_vp.jpg')) { + unlink(_PS_ROOT_DIR_.'/img/c/'.$object->id.'_thumb_vp.jpg'); + } + } + // @End Antadis + + public function displayForm($token = NULL) + { + global $currentIndex, $cookie; + parent::displayForm(); + + if (!($obj = $this->loadObject(true))) + return; + $active = $this->getFieldValue($obj, 'active'); + $customer_groups = $obj->getGroups(); + + echo ' +
+ '.($obj->id ? '' : '').' +
'.$this->l('Category').' + +
'; + foreach ($this->_languages AS $language) + echo ' +
+ id) ? ' onkeyup="copy2friendlyURLCategory();"' : '').' /> * + '.$this->l('Invalid characters:').' <>;=#{}  +
'; + + if(Module::isInstalled('categoryfamily')) { + // ADD category + require_once '..'._MODULE_DIR_.'categoryfamily/models/CategoryFamily.php'; + echo ''; + + if (!empty($obj->id)) { + $data = CategoryFamilyCore::loadAssociations($obj->id, $cookie->id_lang); + echo ' +

'; + echo $data; + } + // ADD CATEGORY + else { + $familles = CategoryFamilyCore::getParentFamily($cookie->id_lang); + echo ' +

+
+ +
+
+ +
+

'; + } + } + + echo '

+
+ +
+ + + + +
+ +
'; + // Translations are not automatic for the moment ;) + $trads = array( + 'Home' => $this->l('Home'), + 'selected' => $this->l('selected'), + 'Collapse All' => $this->l('Collapse All'), + 'Expand All' => $this->l('Expand All'), + 'Toggle' => 'Masquer/Voir', + ); + echo Helper::renderAdminCategorieTree($trads, array(isset($obj->id_parent) ? $obj->id_parent : Tools::getValue('id_parent', 1)), 'id_parent', true); + echo '
+ +
'; + foreach ($this->_languages AS $language){ + $data = htmlentities($this->getFieldValue($obj, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8'); + if(empty($data)) + $data = date('Y') . '-' . date('m'); + echo ' +
+ +
'; + } + + echo '

+
+ +
'; + echo $this->displayImage($obj->id, _PS_IMG_DIR_.'c/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)), true); + echo '
+

'.$this->l('Upload category logo from your computer').'

+
+

'; + + // @Override Antadis + echo ' +
'; + if(file_exists(_PS_ROOT_DIR_.'/img/c/'.$obj->id.'_thumb_vp.jpg')) { + echo '
+ +

+ + Supprimer Supprimer +
'; + } + echo '
+

'.$this->l('Upload logo from your computer').'

+
+

'; + // @EndOverride Antadis + + echo ' +
'; + foreach ($this->_languages AS $language) + echo ' +
+ + '.$this->l('Forbidden characters:').' <>;=#{}  +
'; + echo '

+
+ +
'; + foreach ($this->_languages AS $language) + echo '
+ + '.$this->l('Forbidden characters:').' <>;=#{}  +
'; + echo '

+
+ +
'; + foreach ($this->_languages AS $language) + echo ' +
+ + '.$this->l('Forbidden characters:').' <>;=#{}  +
'; + echo '

+
+ +
'; + foreach ($this->_languages AS $language) + echo '
+ * + '.$this->l('Only letters and the minus (-) character are allowed').'  +
'; + echo '

+
+ +
'; + $groups = Group::getGroups((int)($cookie->id_lang)); + if (sizeof($groups)) + { + echo ' + + + + + + '; + $irow = 0; + foreach ($groups AS $group) + echo ' + + + + + '; + echo ' +
id) ? 'checked="checked" ' : '').' />'.$this->l('ID').''.$this->l('Group name').'
id))) ? 'checked="checked" ' : '').'/>'.$group['id_group'].'
+

'.$this->l('Mark all groups you want to give access to this category').'

+ '; + } else + echo '

'.$this->l('No group created').'

'; + + + echo ' +
+
+ +   +
+
* '.$this->l('Required field').'
+
+
+

'; + } } diff --git a/modules/categoryimg/left_img.tpl b/modules/categoryimg/left_img.tpl index 18b9f37f..23950bf8 100755 --- a/modules/categoryimg/left_img.tpl +++ b/modules/categoryimg/left_img.tpl @@ -3,7 +3,8 @@ {$category->name}
- + {* *} + {$category->name}
{if !$consumable}
diff --git a/override/controllers/ProductController.php b/override/controllers/ProductController.php index dfb9b8c5..47bbc752 100755 --- a/override/controllers/ProductController.php +++ b/override/controllers/ProductController.php @@ -12,7 +12,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), )); - + // assign date estimation from sale delay if (Module::isInstalled('privatesales_delay')) { if (!class_exists('SaleDelay')) { diff --git a/themes/site/product.tpl b/themes/site/product.tpl index 5365460e..f67704e2 100755 --- a/themes/site/product.tpl +++ b/themes/site/product.tpl @@ -204,7 +204,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
- +
{if $sale}
@@ -314,14 +314,14 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count}

-

{/if} - - + + {assign var="groupName" value="group_$id_attribute_group"} @@ -340,7 +340,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus {/foreach} - +

{/if} {/foreach}