set($action->name, $user->authorise($action->name, 'com_templates')); } return $result; } /** * Get a list of filter options for the application clients. * * @return array An array of JHtmlOption elements. */ public static function getClientOptions() { // Build the filter options. $options = array(); $options[] = JHtml::_('select.option', '0', JText::_('JSITE')); $options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR')); return $options; } /** * Get a list of filter options for the templates with styles. * * @return array An array of JHtmlOption elements. */ public static function getTemplateOptions($clientId = '*') { // Build the filter options. $db = JFactory::getDbo(); $query = $db->getQuery(true); if ($clientId != '*') { $query->where('client_id=' . (int) $clientId); } $query->select('element as value, name as text, extension_id as e_id') ->from('#__extensions') ->where('type = ' . $db->quote('template')) ->where('enabled = 1') ->order('client_id') ->order('name'); $db->setQuery($query); $options = $db->loadObjectList(); return $options; } public static function parseXMLTemplateFile($templateBaseDir, $templateDir) { $data = new JObject; // Check of the xml file exists $filePath = JPath::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml'); if (is_file($filePath)) { $xml = JInstaller::parseXMLInstallFile($filePath); if ($xml['type'] != 'template') { return false; } foreach ($xml as $key => $value) { $data->set($key, $value); } } return $data; } /** * @since 3.0 */ public static function getPositions($clientId, $templateDir) { $positions = array(); $templateBaseDir = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE; $filePath = JPath::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml'); if (is_file($filePath)) { // Read the file to see if it's a valid component XML file $xml = simplexml_load_file($filePath); if (!$xml) { return false; } // Check for a valid XML root tag. // Extensions use 'extension' as the root tag. Languages use 'metafile' instead if ($xml->getName() != 'extension' && $xml->getName() != 'metafile') { unset($xml); return false; } $positions = (array) $xml->positions; if (isset($positions['position'])) { $positions = $positions['position']; } else { $positions = array(); } } return $positions; } }