public function __construct()
 {
     # load config from default.conf;
     if (file_exists(APPLICATION_CONFIG_DIR . 'default' . APPLICATION_CONFIG_EXT)) {
         # get configuration data
         include_once LIBS_DIR . '__Configuration' . WORKSPACE_SYSTEM_EXT;
         $tmp_config = new __Configuration(APPLICATION_CONFIG_DIR . 'default' . APPLICATION_CONFIG_EXT);
         if ($tmp_config->get_ini_config()) {
             $GLOBALS['__workspace_configuration'] = $tmp_config->ini_setting;
             if (isset($tmp_config->ini_setting['configs'])) {
                 $GLOBALS['__config_load_filename'] = $tmp_config->ini_setting['configs'];
             }
             if (isset($tmp_config->ini_setting['libs'])) {
                 $GLOBALS['__libs_load_filename'] = $tmp_config->ini_setting['libs'];
             }
             if (isset($tmp_config->ini_setting['etc'])) {
                 $GLOBALS['__etc_load_filename'] = $tmp_config->ini_setting['etc'];
             }
             if (isset($tmp_config->ini_setting['db'])) {
                 $GLOBALS['__db_login_info'] = $tmp_config->ini_setting['db'];
             }
         }
         $this->status = TRUE;
     } else {
         $this->status = FALSE;
         $GLOBALS['__workspace_system_info']['error_message'] = $tmp_config->error_message;
     }
 }
 public function parse($content, __Configuration &$configuration)
 {
     $return = true;
     $lines = preg_split('/\\r?\\n/', $content);
     $n = 0;
     $lastline = '';
     $current_section =& $configuration;
     foreach ($lines as $line) {
         $n++;
         if (preg_match('/^\\s*' . $this->_comment_symbol . '(.*?)\\s*$/', $line, $match)) {
             // a comment
             $current_section->createComment($match[1]);
         } elseif (trim($line) == '') {
             // a blank line
             $current_section->createBlank();
         } elseif (preg_match('/^\\s*([a-zA-Z0-9_\\-\\.\\s:]*)\\s*=\\s*(.*)\\s*$/', $line, $match)) {
             // a directive
             $values = $this->_quoteAndCommaParser($match[2]);
             if (count($values)) {
                 foreach ($values as $value) {
                     if ($value[0] == 'normal') {
                         $current_section->createProperty(trim($match[1]), $value[1]);
                     }
                     if ($value[0] == 'comment') {
                         $current_section->createComment(substr($value[1], 1));
                     }
                 }
             }
         } elseif (preg_match('/^\\s*\\[\\s*(.*)\\s*\\]\\s*$/', $line, $match)) {
             // a section
             $current_section =& $configuration->createSection($match[1]);
         } elseif (trim($line) == '') {
             $current_section =& $obj->container->createBlank();
         } else {
             throw new __ConfigurationException("Syntax error in '{$line}' at line {$n}.");
         }
     }
     return $return;
 }
 public function load($filename, __Configuration &$configuration)
 {
     //Set the name for current __Configuration as  the name of configuration file:
     $configuration->setName(strtoupper(basename($filename)));
     if (!file_exists($filename)) {
         throw new __ConfigurationException('Configuration file not found: "' . $filename . '"');
     }
     $current_section =& $configuration;
     $configuration_array = parse_ini_file($filename, true);
     if ($configuration_array === false) {
         throw new __ConfigurationException('Unknow configuration file format for : "' . $filename . '"');
     }
     foreach ($configuration_array as $key => $value) {
         if (is_array($value)) {
             $current_section =& $configuration->createSection($key);
             foreach ($value as $property => $content) {
                 $current_section->createProperty($property, $content);
             }
         } else {
             $current_section->createProperty($key, $value);
         }
     }
 }
 private function &_parseIncludes(__Configuration &$configuration, $basedir)
 {
     $configuration_section = $configuration->getSection('configuration');
     if ($configuration_section != null) {
         //read configuration directives before read other sections:
         $configuration_directives = $configuration_section->getSection('configuration-directives');
         if ($configuration_directives != null) {
             $this->_readConfigurationDirectives($configuration_directives);
         }
         //read the other sections:
         $sections = $configuration_section->getSections();
         foreach ($sections as $section) {
             switch (strtoupper($section->getName())) {
                 case 'INCLUDE':
                     $expression = $section->getProperty('#text')->getContent();
                     //finally, resolve the path:
                     $expression = __PathResolver::resolvePath($expression, $basedir);
                     if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE') && (strpos($expression, '...') !== false || strpos($expression, '*') !== false)) {
                         $this->_configuration_locators[$expression] = $expression;
                     }
                     $files_to_include = __FileResolver::resolveFiles($expression);
                     foreach ($files_to_include as $file_to_include) {
                         $included_configuration = $this->loadConfigurationFile($file_to_include);
                         $configuration->merge($included_configuration);
                         unset($included_configuration);
                     }
                     break;
             }
         }
     }
     return $configuration;
 }