* @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; class GridHtml extends ModuleGridEngine { private $_values; private static $_columns; function __construct($type = null) { if ($type != null) parent::__construct($type); else { $this->name = 'gridhtml'; $this->tab = 'administration'; $this->version = '1.2.2'; $this->author = 'PrestaShop'; $this->need_instance = 0; Module::__construct(); $this->displayName = $this->l('Simple HTML table display'); $this->description = $this->l('Allows the statistics system to display data in a grid.'); } } function install() { return (parent::install() AND $this->registerHook('GridEngine')); } public static function hookGridEngine($params, $grider) { self::$_columns = $params['columns']; if (!isset($params['emptyMsg'])) $params['emptyMsg'] = 'Empty'; $html = ' '; foreach ($params['columns'] as $column) $html .= ''; $html .= '
'.$column['header'].'
'; return $html; } public function setColumnsInfos(&$infos) { } public function setValues($values) { $this->_values = $values; } public function setTitle($title) { $this->_title = $title; } public function setSize($width, $height) { $this->_width = $width; $this->_height = $height; } public function setTotalCount($totalCount) { $this->_totalCount = $totalCount; } public function setLimit($start, $limit) { $this->_start = (int)$start; $this->_limit = (int)$limit; } public function render() { echo Tools::jsonEncode(array( 'total' => $this->_totalCount, 'from' => min($this->_start + 1, $this->_totalCount), 'to' => min($this->_start + $this->_limit, $this->_totalCount), 'values' => $this->_values )); } }