| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 4 * @license GNU General Public License version 2 or later; see LICENSE.txt 5 */ 6 7 defined('_JEXEC') or die; 8 9 jimport('joomla.application.component.modellist'); 10 11 /** 12 * Methods supporting a list of template extension records. 13 * 14 * @package Joomla.Administrator 15 * @subpackage com_templates 16 * @since 1.6 17 */ 18 class TemplatesModelTemplates extends JModelList 19 { 20 /** 21 * Constructor. 22 * 23 * @param array An optional associative array of configuration settings. 24 * @see JController 25 * @since 1.6 26 */ 27 public function __construct($config = array()) 28 { 29 if (empty($config['filter_fields'])) { 30 $config['filter_fields'] = array( 31 'id', 'a.id', 32 'name', 'a.name', 33 'folder', 'a.folder', 34 'element', 'a.element', 35 'checked_out', 'a.checked_out', 36 'checked_out_time', 'a.checked_out_time', 37 'state', 'a.state', 38 'enabled', 'a.enabled', 39 'access', 'a.access', 'access_level', 40 'ordering', 'a.ordering', 41 'client_id', 'a.client_id', 42 ); 43 } 44 45 parent::__construct($config); 46 } 47 48 /** 49 * Override parent getItems to add extra XML metadata. 50 * 51 * @since 1.6 52 */ 53 public function getItems() 54 { 55 $items = parent::getItems(); 56 57 foreach ($items as &$item) { 58 $client = JApplicationHelper::getClientInfo($item->client_id); 59 $item->xmldata = TemplatesHelper::parseXMLTemplateFile($client->path, $item->element); 60 } 61 return $items; 62 } 63 64 /** 65 * Build an SQL query to load the list data. 66 * 67 * @return JDatabaseQuery 68 * @since 1.6 69 */ 70 protected function getListQuery() 71 { 72 // Create a new query object. 73 $db = $this->getDbo(); 74 $query = $db->getQuery(true); 75 76 // Select the required fields from the table. 77 $query->select( 78 $this->getState( 79 'list.select', 80 'a.extension_id, a.name, a.element, a.client_id' 81 ) 82 ); 83 $query->from($db->quoteName('#__extensions').' AS a'); 84 85 // Filter by extension type. 86 $query->where($db->quoteName('type').' = '.$db->quote('template')); 87 88 // Filter by client. 89 $clientId = $this->getState('filter.client_id'); 90 if (is_numeric($clientId)) { 91 $query->where('a.client_id = '.(int) $clientId); 92 } 93 94 // Filter by search in title 95 $search = $this->getState('filter.search'); 96 if (!empty($search)) { 97 if (stripos($search, 'id:') === 0) { 98 $query->where('a.id = '.(int) substr($search, 3)); 99 } else { 100 $search = $db->Quote('%'.$db->escape($search, true).'%'); 101 $query->where('a.element LIKE '.$search.' OR a.name LIKE '.$search); 102 } 103 } 104 105 // Add the list ordering clause. 106 $query->order($db->escape($this->getState('list.ordering', 'a.folder')).' '.$db->escape($this->getState('list.direction', 'ASC'))); 107 108 return $query; 109 } 110 111 /** 112 * Method to get a store id based on model configuration state. 113 * 114 * This is necessary because the model is used by the component and 115 * different modules that might need different sets of data or different 116 * ordering requirements. 117 * 118 * @param string $id A prefix for the store id. 119 * @return string A store id. 120 * @since 1.6 121 */ 122 protected function getStoreId($id = '') 123 { 124 // Compile the store id. 125 $id .= ':'.$this->getState('filter.search'); 126 $id .= ':'.$this->getState('filter.client_id'); 127 128 return parent::getStoreId($id); 129 } 130 131 /** 132 * Method to auto-populate the model state. 133 * 134 * Note. Calling getState in this method will result in recursion. 135 * 136 * @since 1.6 137 */ 138 protected function populateState($ordering = null, $direction = null) 139 { 140 // Initialise variables. 141 $app = JFactory::getApplication('administrator'); 142 143 // Load the filter state. 144 $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); 145 $this->setState('filter.search', $search); 146 147 $clientId = $this->getUserStateFromRequest($this->context.'.filter.client_id', 'filter_client_id', null); 148 $this->setState('filter.client_id', $clientId); 149 150 // Load the parameters. 151 $params = JComponentHelper::getParams('com_templates'); 152 $this->setState('params', $params); 153 154 // List state information. 155 parent::populateState('a.element', 'asc'); 156 } 157 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |