public function displayListContent($token = NULL) { /* Display results in a table * * align : determine value alignment * prefix : displayed before value * suffix : displayed after value * image : object image * icon : icon determined by values * active : allow to toggle status */ global $currentIndex, $cookie; $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $irow = 0; if ($this->_list and isset($this->fieldsDisplay['position'])) { $positions = array_map(create_function('$elem', 'return intval($elem[\'position\']);'), $this->_list); sort($positions); } if ($this->_list) { foreach ($this->_list as $i => $tr) { $id = $tr[$this->identifier]; echo '<tr' . ($this->identifier == 'id_product' ? ' id="tr_' . (($id_category = intval(Tools::getValue('id_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) { echo '<td class="center"><input type="checkbox" name="' . $this->table . 'Box[]" value="' . $id . '" class="noborder" /></td>'; } foreach ($this->fieldsDisplay as $key => $params) { $tmp = explode('!', $key); $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; echo ' <td ' . (isset($params['position']) ? ' id="td_' . $id_category . '_' . $id . '"' : '') . ' class="pointer' . ((isset($params['position']) and $this->_orderBy == 'position') ? ' dragHandle' : '') . (isset($params['align']) ? ' ' . $params['align'] : '') . '" '; if (!isset($params['position'])) { 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])) { echo '<a href="' . $currentIndex . '&' . $this->identifier . '=' . $id . '&' . $params['active'] . (($id_category = intval(Tools::getValue('id_category')) and Tools::getValue('id_product')) ? '&id_category=' . $id_category : '') . '&token=' . ($token != NULL ? $token : $this->token) . '"> <img src="../img/admin/' . ($tr[$key] ? 'enabled.gif' : 'disabled.gif') . '" alt="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" title="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" /></a>'; } elseif (isset($params['activeVisu']) and isset($tr[$key])) { echo '<img src="../img/admin/' . ($tr[$key] ? 'enabled.gif' : 'disabled.gif') . '" alt="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" title="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" />'; } elseif (isset($params['position'])) { if ($this->_orderBy == 'position') { echo '<a' . (!($tr[$key] != $positions[sizeof($positions) - 1]) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&' . $this->identifier . '=' . $id . '&position=1' . ($id_category = intval(Tools::getValue('id_category')) ? '&id_category=' . $id_category : '') . '&token=' . ($token != NULL ? $token : $this->token) . '"> <img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'down' : 'up') . '.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a>'; echo '<a' . (!($tr[$key] != $positions[0]) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&' . $this->identifier . '=' . $id . '&position=0' . ($id_category = intval(Tools::getValue('id_category')) ? '&id_category=' . $id_category : '') . '&token=' . ($token != NULL ? $token : $this->token) . '"> <img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'up' : 'down') . '.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a>'; } else { echo intval($tr[$key] + 1); } } elseif (isset($params['image'])) { $image_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; echo cacheImage(_PS_IMG_DIR_ . $params['image'] . '/' . $image_id . (isset($tr['id_image']) ? '-' . intval($tr['id_image']) : '') . '.' . $this->imageType, $this->table . '_mini_' . $image_id . '.' . $this->imageType, 45, $this->imageType); } elseif (isset($params['icon']) and (isset($params['icon'][$tr[$key]]) or isset($params['icon']['default']))) { echo '<img src="../img/admin/' . (isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'] . '" alt="' . $tr[$key]) . '" title="' . $tr[$key] . '" />'; } elseif (isset($params['price'])) { echo Tools::displayPrice($tr[$key], isset($params['currency']) ? new Currency(intval($tr['id_currency'])) : $currency, false, false); } elseif (isset($params['float'])) { echo rtrim(rtrim($tr[$key], '0'), '.'); } elseif (isset($params['type']) and $params['type'] == 'date') { echo Tools::displayDate($tr[$key], $cookie->id_lang); } elseif (isset($params['type']) and $params['type'] == 'datetime') { echo Tools::displayDate($tr[$key], $cookie->id_lang, true); } elseif ($key == 'physical_products_quantity') { echo Category::countNbProductAndSub($tr['id_category'], $cookie->id_lang); } 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'] : '') . '</td>'; } if ($this->edit or $this->delete or $this->view and $this->view != 'noActionColumn') { echo '<td class="center" style="white-space: nowrap;">'; if ($this->view) { echo ' <a href="' . $currentIndex . '&' . $this->identifier . '=' . $id . '&view' . $this->table . '&token=' . ($token != NULL ? $token : $this->token) . '"> <img src="../img/admin/details.gif" border="0" alt="' . $this->l('View') . '" title="' . $this->l('View') . '" /></a>'; } if ($this->edit) { echo ' <a href="' . $currentIndex . '&' . $this->identifier . '=' . $id . '&update' . $this->table . '&token=' . ($token != NULL ? $token : $this->token) . '"> <img src="../img/admin/edit.gif" border="0" alt="' . $this->l('Edit') . '" title="' . $this->l('Edit') . '" /></a>'; } if ($this->delete and (!isset($this->_listSkipDelete) or !in_array($id, $this->_listSkipDelete))) { echo ' <a href="' . $currentIndex . '&' . $this->identifier . '=' . $id . '&delete' . $this->table . '&token=' . ($token != NULL ? $token : $this->token) . '" onclick="return confirm(\'' . $this->l('Delete item #', __CLASS__, TRUE, FALSE) . $id . ' ?\');"> <img src="../img/admin/delete.gif" border="0" alt="' . $this->l('Delete', __CLASS__, TRUE, FALSE) . '" title="' . $this->l('Delete', __CLASS__, TRUE, FALSE) . '" /></a>'; } $duplicate = $currentIndex . '&' . $this->identifier . '=' . $id . '&duplicate' . $this->table; if ($this->duplicate) { echo ' <a class="pointer" onclick="if (confirm(\'' . $this->l('Copy images too?', __CLASS__, TRUE, FALSE) . '\')) document.location = \'' . $duplicate . '&token=' . ($token != NULL ? $token : $this->token) . '\'; else document.location = \'' . $duplicate . '&noimage=1&token=' . ($token ? $token : $this->token) . '\';"> <img src="../img/admin/add.gif" border="0" alt="' . $this->l('Duplicate') . '" title="' . $this->l('Duplicate') . '" /></a>'; } echo '</td>'; } echo '</tr>'; } } }