/**
  * 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;
 }
Пример #2
0
 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);
 }
 private static function loadLanguage($default = false)
 {
     $filename = self::getLanguageFilename($default);
     if (!file_exists($filename)) {
         return array();
     } else {
         return AEUtilINI::parse_ini_file($filename, false);
     }
 }
Пример #4
0
 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;
 }
Пример #5
0
 /**
  * Loads the current configuration off the database table
  * @param	int		$profile_id	The profile where to read the configuration from, defaults to current profile
  * @return	bool	True if everything was read properly
  */
 public function load_configuration($profile_id = null)
 {
     // Load Joomla! database class
     $db =& AEFactory::getDatabase($this->get_platform_database_options());
     // Get the active profile number, if no profile was specified
     if (is_null($profile_id)) {
         $profile_id = $this->get_active_profile();
     }
     // Initialize the registry
     $registry =& AEFactory::getConfiguration();
     $registry->reset();
     // Load the INI format local configuration dump off the database
     $sql = "SELECT " . $db->nameQuote('configuration') . ' FROM ' . $db->nameQuote('#__ak_profiles') . ' WHERE ' . $db->nameQuote('id') . ' = ' . $db->Quote($profile_id);
     $db->setQuery($sql);
     $ini_data_local = $db->loadResult();
     if (empty($ini_data_local) || is_null($ini_data_local)) {
         // No configuration was saved yet - store the defaults
         $this->save_configuration($profile_id);
     } else {
         // Configuration found. Convert to array format.
         if (function_exists('get_magic_quotes_runtime')) {
             if (@get_magic_quotes_runtime()) {
                 $ini_data_local = stripslashes($ini_data_local);
             }
         }
         // Decrypt the data if required
         $ini_data_local = AEUtilSecuresettings::decryptSettings($ini_data_local);
         $ini_data_local = AEUtilINI::parse_ini_file_php($ini_data_local, true, true);
         $ini_data = array();
         foreach ($ini_data_local as $section => $row) {
             if (!empty($row)) {
                 foreach ($row as $key => $value) {
                     $ini_data["{$section}.{$key}"] = $value;
                 }
             }
         }
         unset($ini_data_local);
         // Import the configuration array
         $registry->mergeArray($ini_data, false, false);
     }
     // Apply config overrides
     if (is_array($this->configOverrides) && !empty($this->configOverrides)) {
         AEFactory::getConfiguration()->mergeArray($this->configOverrides, false, false);
     }
     $registry->activeProfile = $profile_id;
 }
Пример #6
0
Файл: ini.php Проект: 01J/topm
 /**
  * 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;
 }
Пример #8
0
 /**
  * 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;
 }
Пример #9
0
	/**
	 * 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;
	}