Current Path :
/
home
/
develito
/
www
/
components
/
com_abook
/
models
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/www/components/com_abook/models/authors.php
<?php /** * @package Joomla * @subpackage Abook * @copyright (C) 2010-2019 Federica Ugolotti * @license GNU/GPL, see LICENSE.php * Abook is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License 3 * as published by the Free Software Foundation. * Abook is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with Abook; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // No direct access defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); jimport('joomla.application.categories'); class AbookModelAuthors extends JModelList { protected $_item = null; /** * Method to get a list of items. * * @return mixed An array of objects on success, false on failure. */ protected function getListQuery() { $params = $this->getState()->get('params'); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')); $query->from('#__abauthor AS a'); if ($this->state->params->get('author_name_display', 0) == 1){ $query->select('CONCAT(a.name, " ", a.lastname) AS name'); }else{ $query->select('CONCAT(a.lastname, " ", a.name) AS name'); } // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } // Add the list ordering clause. // $query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC'))); if ($this->getState('filter.letter')) { $query->where("a.lastname REGEXP '^".$db->escape($this->getState('filter.letter'))."'"); } if ($this->getState('filter.keyword') !='') { $query->where('LOWER( a.name ) LIKE "%'.$db->escape($this->getState('filter.keyword')).'%"'); } if ($this->getState('list.ordering') !='') { $query->order($db->escape($this->getState('list.ordering')). ' '.$db->escape($this->getState('list.direction'))); } return $query; } protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('site'); $jinput = JFactory::getApplication()->input; $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); // Load the parameters. Merge Global and Menu Item params into new object $params = $app->getParams(); $menuParams = new JRegistry; if ($menu = $app->getMenu()->getActive()) { $menuParams->loadString($menu->params); } $mergedParams = clone $menuParams; $mergedParams->merge($params); // Load the parameters. $this->setState('params', $mergedParams); // List state information $limit = $app->getUserStateFromRequest('abook.authors.list.limit', 'limit', $params->get('bookpagination')); $this->setState('list.limit', $limit); $limitstart = $app->input->get('limitstart', 0, 'uint'); $this->setState('list.start', $limitstart); $orderCol = $app->input->getCmd('filter_order', $params->get('author_display_order','lastname')); $this->setState('list.ordering', $orderCol); $listOrder = $app->input->getCmd('filter_order_Dir', $params->get('author_display_order_dir','ASC')); $this->setState('list.direction', $listOrder); $this->setState('filter.language',$app->getLanguageFilter()); $showSubcategories = $params->get('show_subcategory_book', '1'); $letter =$jinput->get('letter', '', 'WORD'); $this->setState('filter.letter', $letter); $this->setState('filter.keyword', $app->input->getString('filter-keyword')); $author=$app->getUserStateFromRequest('abook.category.list.' . $itemid . '.author', 'filter-author_id', $app->input->getInt('filter-author_id')); } }