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 '';
elseif (isset($params['position']))
{
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
{
echo '';
echo ''; }
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 '';
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 '--';
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 '
';
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'));
$id_category = 1; // default categ
$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 (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 '
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 '';
elseif (isset($params['position']))
{
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
{
echo '';
echo ''; }
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 '';
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').'
';
/* Show the content of the table */
$this->displayListContent($token);
/* Close list table and submit button */
$this->displayListFooter($token);
}
public function display($token = NULL)
{
global $currentIndex, $cookie;
$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()).'"