| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: template.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Templates 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 /** 19 * @package Joomla 20 * @subpackage Templates 21 */ 22 class TemplatesHelper 23 { 24 function isTemplateDefault($template, $clientId) 25 { 26 $db =& JFactory::getDBO(); 27 28 // Get the current default template 29 $query = ' SELECT template ' 30 .' FROM #__templates_menu ' 31 .' WHERE client_id = ' . (int) $clientId 32 .' AND menuid = 0 '; 33 $db->setQuery($query); 34 $defaultemplate = $db->loadResult(); 35 36 return $defaultemplate == $template ? 1 : 0; 37 } 38 39 function isTemplateAssigned($template) 40 { 41 $db =& JFactory::getDBO(); 42 43 // check if template is assigned 44 $query = 'SELECT COUNT(*)' . 45 ' FROM #__templates_menu' . 46 ' WHERE client_id = 0' . 47 ' AND template = '.$db->Quote($template) . 48 ' AND menuid <> 0'; 49 $db->setQuery($query); 50 return $db->loadResult() ? 1 : 0; 51 } 52 53 function parseXMLTemplateFiles($templateBaseDir) 54 { 55 // Read the template folder to find templates 56 jimport('joomla.filesystem.folder'); 57 $templateDirs = JFolder::folders($templateBaseDir); 58 59 $rows = array(); 60 61 // Check that the directory contains an xml file 62 foreach ($templateDirs as $templateDir) 63 { 64 if(!$data = TemplatesHelper::parseXMLTemplateFile($templateBaseDir, $templateDir)){ 65 continue; 66 } else { 67 $rows[] = $data; 68 } 69 } 70 71 return $rows; 72 } 73 74 function parseXMLTemplateFile($templateBaseDir, $templateDir) 75 { 76 // Check of the xml file exists 77 if(!is_file($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml')) { 78 return false; 79 } 80 81 $xml = JApplicationHelper::parseXMLInstallFile($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml'); 82 83 if ($xml['type'] != 'template') { 84 return false; 85 } 86 87 $data = new StdClass(); 88 $data->directory = $templateDir; 89 90 foreach($xml as $key => $value) { 91 $data->$key = $value; 92 } 93 94 $data->checked_out = 0; 95 $data->mosname = JString::strtolower(str_replace(' ', '_', $data->name)); 96 97 return $data; 98 } 99 100 function createMenuList($template) 101 { 102 $db =& JFactory::getDBO(); 103 104 // get selected pages for $menulist 105 $query = 'SELECT menuid AS value' . 106 ' FROM #__templates_menu' . 107 ' WHERE client_id = 0' . 108 ' AND template = '.$db->Quote($template); 109 $db->setQuery($query); 110 $lookup = $db->loadObjectList(); 111 if (empty( $lookup )) { 112 $lookup = array( JHTML::_('select.option', '-1' ) ); 113 } 114 115 // build the html select list 116 $options = JHTML::_('menu.linkoptions'); 117 $result = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); 118 return $result; 119 } 120 }
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 |