* @author PrestaShop SA * @copyright 2017-2018 thirty bees * @copyright 2007-2016 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * PrestaShop is an internationally registered trademark & property of PrestaShop SA */ /** * Class ModuleGridEngineCore * * @since 1.0.0 */ class ModuleGridEngineCore extends Module { // @codingStandardsIgnoreStart protected $_type; private $_values; private static $_columns; // @codingStandardsIgnoreEnd /** * ModuleGridEngineCore constructor. * * @param null|string $type * * @since 1.0.0 * @version 1.0.0 Initial version */ public function __construct($type) { $this->_type = $type; } /** * @return bool * * @since 1.0.0 * @version 1.0.0 Initial version */ public function install() { if (!parent::install()) { return false; } return Configuration::updateValue('PS_STATS_GRID_RENDER', $this->name); } /** * @return array * * @since 1.0.0 * @version 1.0.0 Initial version */ public static function getGridEngines() { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( (new DbQuery()) ->select('m.`name`') ->from('module', 'm') ->leftJoin('module', 'm') ->leftJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`') ->where('h.`name` = \'displayAdminStatsGridEngine\'') ); $arrayEngines = []; foreach ($result as $module) { $instance = Module::getInstanceByName($module['name']); if (!$instance) { continue; } $arrayEngines[$module['name']] = [$instance->displayName, $instance->description]; } return $arrayEngines; } public static function hookGridEngine($params, $grider) { self::$_columns = $params['columns']; if (!isset($params['emptyMsg'])) $params['emptyMsg'] = 'Empty'; $customParams = ''; if (isset($params['customParams'])) { foreach ($params['customParams'] as $name => $value) { $customParams .= '&'.$name.'='.urlencode($value); } } $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 json_encode([ 'total' => $this->_totalCount, 'from' => min($this->_start + 1, $this->_totalCount), 'to' => min($this->_start + $this->_limit, $this->_totalCount), 'values' => $this->_values ]); exit; } }