| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_installer 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 // No direct access 10 defined('_JEXEC') or die; 11 12 // Import library dependencies 13 jimport('joomla.application.component.modellist'); 14 15 /** 16 * Extension Manager Abstract Extension Model 17 * 18 * @abstract 19 * @package Joomla.Administrator 20 * @subpackage com_installer 21 * @since 1.5 22 */ 23 class InstallerModel extends JModelList 24 { 25 /** 26 * Constructor. 27 * 28 * @param array An optional associative array of configuration settings. 29 * @see JController 30 * @since 1.6 31 */ 32 public function __construct($config = array()) 33 { 34 if (empty($config['filter_fields'])) { 35 $config['filter_fields'] = array( 36 'name', 37 'client_id', 38 'enabled', 39 'type', 40 'folder', 41 'extension_id', 42 ); 43 } 44 45 parent::__construct($config); 46 } 47 48 /** 49 * Returns an object list 50 * 51 * @param string The query 52 * @param int Offset 53 * @param int The number of records 54 * @return array 55 */ 56 protected function _getList($query, $limitstart = 0, $limit = 0) 57 { 58 $ordering = $this->getState('list.ordering'); 59 $search = $this->getState('filter.search'); 60 // Replace slashes so preg_match will work 61 $search = str_replace('/', ' ', $search); 62 $db = $this->getDbo(); 63 64 if ($ordering == 'name' || (!empty($search) && stripos($search, 'id:') !== 0)) { 65 $db->setQuery($query); 66 $result = $db->loadObjectList(); 67 $lang = JFactory::getLanguage(); 68 $this->translate($result); 69 if (!empty($search)) { 70 foreach($result as $i=>$item) { 71 if (!preg_match("/$search/i", $item->name)) { 72 unset($result[$i]); 73 } 74 } 75 } 76 JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale()); 77 $total = count($result); 78 $this->cache[$this->getStoreId('getTotal')] = $total; 79 if ($total < $limitstart) { 80 $limitstart = 0; 81 $this->setState('list.start', 0); 82 } 83 return array_slice($result, $limitstart, $limit ? $limit : null); 84 } else { 85 $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction')); 86 $result = parent::_getList($query, $limitstart, $limit); 87 $this->translate($result); 88 return $result; 89 } 90 } 91 92 /** 93 * Translate a list of objects 94 * 95 * @param array The array of objects 96 * @return array The array of translated objects 97 */ 98 private function translate(&$items) 99 { 100 $lang = JFactory::getLanguage(); 101 foreach($items as &$item) { 102 if (strlen($item->manifest_cache)) { 103 $data = json_decode($item->manifest_cache); 104 if ($data) { 105 foreach($data as $key => $value) { 106 if ($key == 'type') { 107 // ignore the type field 108 continue; 109 } 110 $item->$key = $value; 111 } 112 } 113 } 114 $item->author_info = @$item->authorEmail .'<br />'. @$item->authorUrl; 115 $item->client = $item->client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); 116 $path = $item->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE; 117 switch ($item->type) { 118 case 'component': 119 $extension = $item->element; 120 $source = JPATH_ADMINISTRATOR . '/components/' . $extension; 121 $lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, false) 122 || $lang->load("$extension.sys", $source, null, false, false) 123 || $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) 124 || $lang->load("$extension.sys", $source, $lang->getDefault(), false, false); 125 break; 126 case 'file': 127 $extension = 'files_' . $item->element; 128 $lang->load("$extension.sys", JPATH_SITE, null, false, false) 129 || $lang->load("$extension.sys", JPATH_SITE, $lang->getDefault(), false, false); 130 break; 131 case 'library': 132 $extension = 'lib_' . $item->element; 133 $lang->load("$extension.sys", JPATH_SITE, null, false, false) 134 || $lang->load("$extension.sys", JPATH_SITE, $lang->getDefault(), false, false); 135 break; 136 case 'module': 137 $extension = $item->element; 138 $source = $path . '/modules/' . $extension; 139 $lang->load("$extension.sys", $path, null, false, false) 140 || $lang->load("$extension.sys", $source, null, false, false) 141 || $lang->load("$extension.sys", $path, $lang->getDefault(), false, false) 142 || $lang->load("$extension.sys", $source, $lang->getDefault(), false, false); 143 break; 144 case 'package': 145 $extension = $item->element; 146 $lang->load("$extension.sys", JPATH_SITE, null, false, false) 147 || $lang->load("$extension.sys", JPATH_SITE, $lang->getDefault(), false, false); 148 break; 149 case 'plugin': 150 $extension = 'plg_' . $item->folder . '_' . $item->element; 151 $source = JPATH_PLUGINS . '/' . $item->folder . '/' . $item->element; 152 $lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, false) 153 || $lang->load("$extension.sys", $source, null, false, false) 154 || $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) 155 || $lang->load("$extension.sys", $source, $lang->getDefault(), false, false); 156 break; 157 case 'template': 158 $extension = 'tpl_' . $item->element; 159 $source = $path . '/templates/' . $item->element; 160 $lang->load("$extension.sys", $path, null, false, false) 161 || $lang->load("$extension.sys", $source, null, false, false) 162 || $lang->load("$extension.sys", $path, $lang->getDefault(), false, false) 163 || $lang->load("$extension.sys", $source, $lang->getDefault(), false, false); 164 break; 165 } 166 if (!in_array($item->type, array('language', 'template', 'library'))) { 167 $item->name = JText::_($item->name); 168 } 169 settype($item->description, 'string'); 170 if (!in_array($item->type, array('language'))) { 171 $item->description = JText::_($item->description); 172 } 173 } 174 } 175 }
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 |