/** * Queries and formats the data from the database to be used via DataTables. * * @param DB\Query $query Query instance. * @param array $params Query params. * * @static * * @return DB\Query */ public static function formatQuery(DB\Query $query, array $params) { $params['pagination']['page'] = isset($params['pagination']['page']) ? (int) $params['pagination']['page'] : 0; if (isset($params['pagination']['limit'])) { $params['pagination']['limit'] = intval($params['pagination']['limit']); } else { /* Get first pagination limit from the configuration. */ $pagination = Core\Helpers\YAML::get('pagination', 'cms'); $params['pagination']['limit'] = intval(current($pagination['limits'])); } $result = self::assignFilter($query, $params); $result = self::assignOrder($result, $params)->page($params['pagination']['page'], $params['pagination']['limit']); return $result; }
/** * Load Labels file. * * @param string $fileName Labels file name. * * @access private * * @return array */ private static function loadLabelsFile($fileName) { if (Core\Config()->CACHE['labels']) { $key = '_silla_' . Core\Config()->paths('mode') . '_labels_' . Core\Registry()->get('locale') . $fileName; $labels = Core\Cache()->fetch($key); if (!$labels) { $labels = Core\Helpers\YAML::getAll($fileName); Core\Cache()->store($key, $labels); } } else { $labels = Core\Helpers\YAML::getAll($fileName); } return $labels; }