Current Path :
/
home
/
develito
/
www
/
administrator
/
components
/
com_dmod
/
models
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/www/administrator/components/com_dmod/models/modules.php
<?php /** * @version $Id: modules.php 2011 vargas $ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access. defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); class DmodModelModules extends JModelList { public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'value', 'templates', ); } parent::__construct($config); } protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('administrator'); // Load the filter state. $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $state = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_state', '', 'string'); $this->setState('filter.state', $state); $module = $this->getUserStateFromRequest($this->context.'.filter.module', 'filter_module', '', 'string'); $this->setState('filter.module', $module); // Load the parameters. $params = JComponentHelper::getParams('com_dmod'); $this->setState('params', $params); // List state information. parent::populateState('value', 'asc'); } public function getItems() { if (!isset($this->items)) { $search = $this->getState('filter.search'); $state = $this->getState('filter.state'); $module = $this->getState('filter.module'); $ordering = $this->getState('list.ordering'); $direction = $this->getState('list.direction'); $limitstart = $this->getState('list.start'); $limit = $this->getState('list.limit'); $query = $this->_db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.note, a.position, a.module, a.published, a.access, a.ordering, a.publish_up, a.publish_down' ) ); $query->from('`#__modules` AS a'); // Join over the language $query->select('l.title AS language_title'); $query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language'); // Join over the extensions $query->select('e.name AS name'); $query->join('LEFT', '#__extensions AS e ON e.element = a.module'); $query->group('a.id'); $query->where('a.client_id = 0'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = '.(int) $access); } // Filter by published state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.published = '.(int) $state); } else if ($state === '') { $query->where('(a.published IN (0, 1))'); } // Filter by module $module = $this->getState('filter.module'); if ($module) { $query->where('a.module = '.$this->_db->Quote($module)); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = '.(int) substr($search, 3)); } else { $search = $this->_db->Quote('%'.$this->_db->getEscaped($search, true).'%'); $query->where('('.'a.title LIKE '.$search.' OR a.note LIKE '.$search.')'); } } //echo nl2br(str_replace('#__','jos_',$query)); $this->_db->setQuery((string)$query); $items = $this->_db->loadObjectList(); $this->total=count($items); $this->items = array_slice($items, $limitstart, $limit ? $limit : null); } return $this->items; } public function getTotal() { if (!isset($this->total)) { $this->getItems(); } return $this->total; } }