Current Path :
/
home
/
develito
/
public_html
/
components
/
com_abook
/
models
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/public_html/components/com_abook/models/tags.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'); class AbookModelTags extends JModelList { protected $_item = null; /** * Method to get a list of items. * * @return mixed An array of objects on success, false on failure. */ public function getItems() { // Invoke the parent getItems method to get the main list $items = parent::getItems(); for ($i = 0, $n = count($items); $i < $n; $i++) { $item = &$items[$i]; $this->_tagname($item->id); $item->tags=$this->_tagname; } return $items; } protected function getListQuery() { $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select required fields from the categories. $query->select($this->getState('list.select', '*')); $query->from('#__abtag_groups AS a'); // 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', 'name')).' '.$db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('site'); $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); // Load the parameters $params = $app->getParams(); $menuParams = new JRegistry; if ($menu = $app->getMenu()->getActive()) { $menuParams->loadString($menu->params); } $mergedParams = clone $menuParams; $mergedParams->merge($params); $this->setState('params', $mergedParams); // List state information $limit = $app->getUserStateFromRequest('abook.tags.list.'.$itemid.'.limit', 'limit', $params->get('tagspagination'), 'uint'); $this->setState('list.limit', $limit); $limitstart = $app->input->getVar('limitstart', 0, '', 'int'); $this->setState('list.start', $limitstart); $orderCol = $app->input->getCmd('filter_order', $params->get('tags_display_order','name')); $this->setState('list.ordering', $orderCol); $listOrder = $app->input->getCmd('filter_order_Dir', $params->get('tags_display_order_dir','ASC')); $this->setState('list.direction', $listOrder); $id = $app->input->getInt('id'); $this->setState('category.id', $id); $this->setState('filter.published', 1); $this->setState('filter.language', JLanguageMultilang::isEnabled()); } protected function _Tagname($idtaggroup) { // Lets load the content if it doesn't already exist $db = $this->getDbo(); $query = $db->getQuery(true); $query->select('t.*, count(bt.idbook) AS num'); $query->select("CASE WHEN CHAR_LENGTH(t.alias) THEN CONCAT_WS(':', t.id, t.alias) ELSE t.id END as slug"); $query->from('#__abtag AS t'); $query->leftjoin('#__abbooktag AS bt ON bt.idtag=t.id'); $query->where('t.id_taggroup = '. $db->escape((int) $idtaggroup)); $query->where('t.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); $query->group('t.id'); $query->order('name'); $this->_db->setQuery($query); $this->_tagname = $this->_db->loadObjectList(); return $this->_tagname; } }