getQuery(true); $query->select($db->quoteName('element', 'value')) ->select($db->quoteName('name', 'text')) ->select($db->quoteName('extension_id', 'e_id')) ->from($db->quoteName('#__extensions')) ->where($db->quoteName('type') . ' = ' . $db->quote('template')) ->where($db->quoteName('enabled') . ' = 1') ->order($db->quoteName('client_id') . ' ASC') ->order($db->quoteName('name') . ' ASC'); if ($clientId != '*') { $query->where($db->quoteName('client_id') . ' = ' . (int) $clientId); } $db->setQuery($query); $options = $db->loadObjectList(); return $options; } /** * TODO * * @param string $templateBaseDir TODO * @param string $templateDir TODO * * @return boolean|JObject */ 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; } /** * TODO * * @param integer $clientId TODO * @param string $templateDir TODO * * @return boolean|array * * @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 = (array) $positions['position']; } else { $positions = array(); } } return $positions; } }