| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: templates.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Menus 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant to the 9 * GNU General Public License, and as distributed it includes or is derivative 10 * of works licensed under the GNU General Public License or other free or open 11 * source software licenses. See COPYRIGHT.php for copyright notices and 12 * details. 13 */ 14 15 // no direct access 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 // Import library dependencies 19 require_once(dirname(__FILE__).DS.'extension.php'); 20 jimport( 'joomla.filesystem.folder' ); 21 22 /** 23 * Extension Manager Templates Model 24 * 25 * @package Joomla 26 * @subpackage Installer 27 * @since 1.5 28 */ 29 class InstallerModelTemplates extends InstallerModel 30 { 31 /** 32 * Extension Type 33 * @var string 34 */ 35 var $_type = 'template'; 36 37 /** 38 * Overridden constructor 39 * @access protected 40 */ 41 function __construct() 42 { 43 global $mainframe; 44 45 // Call the parent constructor 46 parent::__construct(); 47 48 // Set state variables from the request 49 $this->setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.templates.string", 'filter', '', 'string' )); 50 $this->setState('filter.client', $mainframe->getUserStateFromRequest( "com_installer.templates.client", 'client', -1, 'int' )); 51 } 52 53 function _loadItems() 54 { 55 global $mainframe, $option; 56 57 $db = &JFactory::getDBO(); 58 59 if ($this->_state->get('filter.client') < 0) { 60 $client = 'all'; 61 // Get the site templates 62 $templateDirs = JFolder::folders(JPATH_SITE.DS.'templates'); 63 64 for ($i=0; $i < count($templateDirs); $i++) { 65 $template = new stdClass(); 66 $template->folder = $templateDirs[$i]; 67 $template->client = 0; 68 $template->baseDir = JPATH_SITE.DS.'templates'; 69 70 if ($this->_state->get('filter.string')) { 71 if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { 72 $templates[] = $template; 73 } 74 } else { 75 $templates[] = $template; 76 } 77 } 78 // Get the admin templates 79 $templateDirs = JFolder::folders(JPATH_ADMINISTRATOR.DS.'templates'); 80 81 for ($i=0; $i < count($templateDirs); $i++) { 82 $template = new stdClass(); 83 $template->folder = $templateDirs[$i]; 84 $template->client = 1; 85 $template->baseDir = JPATH_ADMINISTRATOR.DS.'templates'; 86 87 if ($this->_state->get('filter.string')) { 88 if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { 89 $templates[] = $template; 90 } 91 } else { 92 $templates[] = $template; 93 } 94 } 95 } else { 96 $clientInfo =& JApplicationHelper::getClientInfo($this->_state->get('filter.client')); 97 $client = $clientInfo->name; 98 $templateDirs = JFolder::folders($clientInfo->path.DS.'templates'); 99 100 for ($i=0; $i < count($templateDirs); $i++) { 101 $template = new stdClass(); 102 $template->folder = $templateDirs[$i]; 103 $template->client = $clientInfo->id; 104 $template->baseDir = $clientInfo->path.DS.'templates'; 105 106 if ($this->_state->get('filter.string')) { 107 if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { 108 $templates[] = $template; 109 } 110 } else { 111 $templates[] = $template; 112 } 113 } 114 } 115 116 // Get a list of the currently active templates 117 $query = 'SELECT template' . 118 ' FROM #__templates_menu' . 119 ' WHERE 1'; 120 $db->setQuery($query); 121 $activeList = $db->loadResultArray(); 122 123 $rows = array(); 124 $rowid = 0; 125 // Check that the directory contains an xml file 126 foreach($templates as $template) 127 { 128 $dirName = $template->baseDir .DS. $template->folder; 129 $xmlFilesInDir = JFolder::files($dirName,'.xml$'); 130 131 foreach($xmlFilesInDir as $xmlfile) 132 { 133 $data = JApplicationHelper::parseXMLInstallFile($dirName . DS. $xmlfile); 134 135 $row = new StdClass(); 136 $row->id = $rowid; 137 $row->client_id = $template->client; 138 $row->directory = $template->folder; 139 $row->baseDir = $template->baseDir; 140 141 // Is the template active? 142 if (in_array($row->directory, $activeList)) { 143 $row->active = true; 144 } else { 145 $row->active = false; 146 } 147 148 if ($data) { 149 foreach($data as $key => $value) { 150 $row->$key = $value; 151 } 152 } 153 154 $row->checked_out = 0; 155 $row->jname = JString::strtolower( str_replace( ' ', '_', $row->name ) ); 156 157 $rows[] = $row; 158 $rowid++; 159 } 160 } 161 $this->setState('pagination.total', count($rows)); 162 // if the offset is greater than the total, then can the offset 163 if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { 164 $this->setState('pagination.offset',0); 165 } 166 167 if($this->_state->get('pagination.limit') > 0) { 168 $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); 169 } else { 170 $this->_items = $rows; 171 } 172 } 173 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |