';
/* Display column names and arrows for ordering (ASC, DESC) */
if (array_key_exists($this->identifier,$this->identifiersDnd) AND $this->_orderBy == 'position') {
$this->_html .= '
';
}
$this->_html .= 'identifier,$this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier,$this->identifiersDnd) AND ($this->_listTotal >= 2 && $this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0" style="width:100%;">
';
if ($this->delete)
$this->_html .= ' ';
$this->_html .= ' ';
foreach ($this->fieldsDisplay as $key => $params) {
$this->_html .= ' '.$params['title'];
if (!isset($params['orderby']) OR $params['orderby']) {
// Cleaning links
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
$this->currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', $this->currentIndex);
if ($this->_listTotal >= 2) {
$this->_html .= '
';
}
}
$this->_html .= ' ';
}
/* Check if object can be modified, deleted or detailed */
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
$this->_html .= ''.$this->l('Actions').' ';
$this->_html .= '
';
if ($this->delete)
$this->_html .= '--';
$this->_html .= ' ';
/* Javascript hack in order to catch ENTER keypress event */
$keyPress = 'onkeypress="formSubmit(event, \'submitFilterButton_'.$this->table.'\');"';
/* Filters (input, select, date or bool) */
foreach ($this->fieldsDisplay as $key => $params) {
$width = (isset($params['width']) ? ' style="width: '.(int)($params['width']).'px;"' : '');
$this->_html .= '';
if (!isset($params['type']))
$params['type'] = 'text';
$value = Tools::getValue($this->table.'Filter_'.(array_key_exists('filter_key', $params) ? $params['filter_key'] : $key));
if (isset($params['search']) AND !$params['search'])
{
$this->_html .= '-- ';
continue;
}
switch ($params['type'])
{
case 'bool':
$this->_html .= '
--
'.$this->l('Yes').'
'.$this->l('No').'
';
break;
case 'date':
case 'datetime':
if (is_string($value))
$value = unserialize($value);
if (!Validate::isCleanHtml($value[0]) OR !Validate::isCleanHtml($value[1]))
$value = '';
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
$nameId = str_replace('!', '__', $name);
includeDatepicker(array($nameId.'_0', $nameId.'_1'));
$this->_html .= $this->l('From').'
'.$this->l('To').' ';
break;
case 'select':
if (isset($params['filter_key']))
{
$this->_html .= '
-- ';
if (isset($params['select']) AND is_array($params['select']))
foreach ($params['select'] as $optionValue => $optionDisplay)
$this->_html .= 'table.'Filter_'.$params['filter_key']]) AND Tools::getValue($this->table.'Filter_'.$params['filter_key']) == $optionValue AND Tools::getValue($this->table.'Filter_'.$params['filter_key']) != '') ? ' selected="selected"' : '').'>'.$optionDisplay.' ';
$this->_html .= ' ';
break;
}
break;
case 'text':
default:
if (!Validate::isCleanHtml($value))
$value = '';
$this->_html .= ' ';
}
$this->_html .= '';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
$this->_html .= '-- ';
$this->_html .= '
';
}
public function displayListContent($token = null) {
global $cookie;
$currency = new Currency((int)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;
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];
$this->_html .= '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)))
$this->_html .= ' ';
$this->_html .= ' ';
foreach ($this->fieldsDisplay as $key => $params)
{
$tmp = explode('!', $key);
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
$this->_html .= '
no_link) OR !$this->no_link))
$this->_html .= ' onclick="document.location = \''.$this->currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token != null ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : '');
else
$this->_html .= '>';
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]))
$this->_html .= ' ';
elseif (isset($params['position']))
{
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
{
$this->_html .= '
';
$this->_html .= '
'; }
else
$this->_html .= (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;
$this->_html .= 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'])))
$this->_html .= ' ';
elseif (isset($params['price']))
$this->_html .= Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false);
elseif (isset($params['float']))
$this->_html .= rtrim(rtrim($tr[$key], '0'), '.');
elseif (isset($params['type']) AND $params['type'] == 'date')
$this->_html .= $tr[$key];
//$this->_html .= Tools::displayDate($tr[$key], (int)$cookie->id_lang);
elseif (isset($params['type']) AND $params['type'] == 'datetime')
$this->_html .= Tools::displayDate($tr[$key], (int)$cookie->id_lang, true);
elseif (isset($params['type']) AND $params['type'] == 'editable') {
// google merchant fix
if ($key == 'google_name') {
$languages = Language::getLanguages();
foreach ($languages as $language) {
$fieldName = $key . '_' . $tr['id'] . '_' . $language['id_lang'];
$googleName = 'google_name_' . $language['id_lang'];
$this->_html .= '';
$this->_html .= '
';
$this->_html .= ' ';
$this->_html .= '
';
$this->_html .= '
';
$this->_html .= '
';
}
}
else {
$this->_html .= ' ';
}
}
elseif (isset($tr[$key]))
{
$echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]);
$this->_html .= isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo;
}
else
$this->_html .= '--';
$this->_html .= (isset($params['suffix']) ? $params['suffix'] : '').
' ';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) {
$this->_html .= '';
if ($this->view)
$this->_displayViewLink($token, $id);
if ($this->edit)
$this->_displayEditLink($token, $id);
if ($this->delete)
$this->_displayDeleteLink($token, $id);
if ($this->duplicate)
$this->_displayDuplicate($token, $id);
$this->_html .= ' ';
}
$this->_html .= ' ';
}
}
}
public function displayListFooter($token = null) {
$this->_html .= '
';
if ($this->delete)
$this->_html .= '
';
$this->_html .= '