private static function loadConfig() { if (defined('JVERSION')) { $j16 = version_compare(JVERSION, '1.6.0', 'ge'); } else { $j16 = false; } $db =& AEFactory::getDatabase(); if (!$j16) { $sql = "SELECT " . $db->nameQuote('params') . " FROM " . $db->nameQuote('#__components') . " WHERE (" . $db->nameQuote('link') . " = " . $db->Quote('option=com_akeeba') . ") AND (" . $db->nameQuote('parent') . " = " . $db->Quote('0') . ")"; $db->setQuery($sql); $config_ini = $db->loadResult(); } else { $config_ini = null; } if ($db->getErrorNum() || is_null($config_ini)) { // Maybe it's Joomla! 1.6? $sql = "SELECT " . $db->nameQuote('params') . " FROM " . $db->nameQuote('#__extensions') . " WHERE (" . $db->nameQuote('type') . ' = ' . $db->Quote('component') . ') AND (' . $db->nameQuote('element') . " = " . $db->Quote('com_akeeba') . ")"; $db->setQuery($sql); $config_ini = $db->loadResult(); // OK, Joomla! 1.6 stores values JSON-encoded so, what do I do? Right! $config_ini = json_decode($config_ini, true); return $config_ini; } return AEUtilINI::parse_ini_file($config_ini, false, true); }
/** * Loads the scripting.ini and returns an array with the domains, the scripts and * the raw data * @return array */ public static function loadScripting() { static $scripting = null; if (empty($scripting)) { $ds = DIRECTORY_SEPARATOR; $ini_file_name = AEFactory::getAkeebaRoot() . $ds . 'core' . $ds . 'scripting.ini'; if (@file_exists($ini_file_name)) { $raw_data = AEUtilINI::parse_ini_file($ini_file_name, false); $domain_keys = explode('|', $raw_data['volatile.akeebaengine.domains']); $domains = array(); foreach ($domain_keys as $key) { $record = array('domain' => $raw_data['volatile.domain.' . $key . '.domain'], 'class' => $raw_data['volatile.domain.' . $key . '.class'], 'text' => $raw_data['volatile.domain.' . $key . '.text']); $domains[$key] = $record; } $script_keys = explode('|', $raw_data['volatile.akeebaengine.scripts']); $scripts = array(); foreach ($script_keys as $key) { $record = array('chain' => explode('|', $raw_data['volatile.scripting.' . $key . '.chain']), 'text' => $raw_data['volatile.scripting.' . $key . '.text']); $scripts[$key] = $record; } $scripting = array('domains' => $domains, 'scripts' => $scripts, 'data' => $raw_data); } else { $scripting = array(); } } return $scripting; }
private static function loadLanguage($default = false) { $filename = self::getLanguageFilename($default); if (!file_exists($filename)) { return array(); } else { return AEUtilINI::parse_ini_file($filename, false); } }
private function loadIconDefinitions($path) { $ret = array(); if (!@file_exists($path . '/views.ini')) { return $ret; } $ini_data = AEUtilINI::parse_ini_file($path . '/views.ini', true); if (!empty($ini_data)) { foreach ($ini_data as $view => $def) { $task = array_key_exists('task', $def) ? $def['task'] : null; $ret[$def['group']][] = $this->_makeIconDefinition($def['icon'], JText::_($def['label']), $view, $task); } } return $ret; }
/** * Parses a graphical interface INI file returning two arrays, one with the general * information of that configuration section and one with its configuration variables' * definitions. * * @param string $inifile Absolute path to engine INI file * @param array $information [out] The GUI information hash array * @param array $parameters [out] The parameters hash array * * @return bool True if the file was loaded */ public static function parseInterfaceINI($inifile, &$information, &$parameters) { if (!file_exists($inifile)) { return false; } $information = array('description' => ''); $parameters = array(); $inidata = AEUtilINI::parse_ini_file($inifile, true); foreach ($inidata as $section => $data) { if (is_array($data)) { if ($section == '_group') { // Parse information foreach ($data as $key => $value) { $information[$key] = $value; } } elseif (substr($section, 0, 1) != '_') { // Parse parameters $newparam = array('title' => '', 'description' => '', 'type' => 'string', 'default' => '', 'protected' => 0); foreach ($data as $key => $value) { $newparam[$key] = $value; } $parameters[$section] = $newparam; } } } return true; }
/** * Merges an engine INI file to the configuration. Each section defines a full * registry path (section.subsection.key). It searches each section for the * key named "default" and merges its value to the configuration. The other keys * are simply ignored. * @param string $inifile The absolute path to an INI file * @param bool $noOverride [optional] If true, values from the INI will not override the configuration * @return bool True on success */ public function mergeEngineINI($inifile, $noOverride = false) { if (!file_exists($inifile)) { return false; } $inidata = AEUtilINI::parse_ini_file($inifile, true); foreach ($inidata as $section => $nodes) { if (is_array($nodes)) { if (substr($section, 0, 1) != '_') { // Is this a protected node? $protected = false; if (array_key_exists('protected', $nodes)) { $protected = $nodes['protected']; } // If overrides are allowed, unprotect until we can set the value if (!$noOverride) { if (in_array($section, $this->protected_nodes)) { $pnk = array_search($section, $this->protected_nodes); unset($this->protected_nodes[$pnk]); } } if (array_key_exists('remove', $nodes)) { // Remove a node if it has "remove" set $this->remove($section); } elseif (isset($nodes['default'])) { if (!$noOverride) { // Update the default value if No Override is set $this->set($section, $nodes['default']); } elseif (is_null($this->get($section, null))) { // Set the default value if it does not exist $this->set($section, $nodes['default']); } } // Finally, if it's a protected node, enable the protection if ($protected) { $this->protected_nodes[] = $section; } else { $idx = array_search($section, $this->protected_nodes); if ($idx !== false) { unset($this->protected_nodes[$idx]); } } } } } return true; }
/** * Parses the installer INI files and returns an array of installers and their data * * @param boolean $forDisplay If true only returns the information relevant for displaying the GUI * * @return array */ public static function getInstallerList($forDisplay = false) { // This is a static cache which persists between subsequent calls, but not // between successive page loads. static $installer_list = array(); // Try to serve cached data first if (!empty($installer_list) && is_array($installer_list)) { if (count($installer_list) > 0) { return $installer_list; } } // Find absolute path to normal and plugins directories $path_list = array(AEPlatform::getInstance()->get_installer_images_path()); // Initialize the array where we store our data $installer_list = array(); // Loop for the paths where engines can be found foreach ($path_list as $path) { if (is_dir($path)) { if (is_readable($path)) { if ($handle = @opendir($path)) { while (false !== ($filename = @readdir($handle))) { if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . '/' . $filename)) { $data = AEUtilINI::parse_ini_file($path . '/' . $filename, true); if ($forDisplay) { $innerData = reset($data); if (array_key_exists('listinoptions', $innerData)) { if ($innerData['listinoptions'] == 0) { continue; } } } foreach ($data as $key => $values) { $installer_list[$key] = array(); foreach ($values as $key2 => $value) { $installer_list[$key][$key2] = $value; } } } } // while readdir @closedir($handle); } // if opendir } // if readable } // if is_dir } return $installer_list; }
/** * Merges an engine INI file to the configuration. Each section defines a full * registry path (section.subsection.key). It searches each section for the * key named "default" and merges its value to the configuration. The other keys * are simply ignored. * @param string $inifile The absolute path to an INI file * @param bool $noOverride [optional] If true, values from the INI will not override the configuration * @return bool True on success */ public function mergeEngineINI($inifile, $noOverride = false) { if(!file_exists($inifile)) return false; $inidata = AEUtilINI::parse_ini_file($inifile, true); foreach($inidata as $section => $nodes) { if(is_array($nodes)) { if( substr($section,0,1) != '_' ) { if(isset($nodes['default'])) { if(!$noOverride) { $this->set($section, $nodes['default']); } elseif( is_null($this->get($section, null)) ) { $this->set($section, $nodes['default']); } } } } } return true; }