public static function read($configFile, $allModuleInfo = false, $isCli = false, $pseudoScriptName = '')
 {
     $tempPath = jApp::tempBasePath();
     $configPath = jApp::configPath();
     if ($tempPath == '/') {
         throw new Exception('Application temp directory doesn\'t exist !', 3);
     }
     if (!is_writable($tempPath)) {
         throw new Exception('Application temp base directory is not writable -- (' . $tempPath . ')', 4);
     }
     if (!is_writable(jApp::logPath())) {
         throw new Exception('Application log directory is not writable -- (' . jApp::logPath() . ')', 4);
     }
     self::$commonConfig = jIniFile::read($configPath . 'defaultconfig.ini.php', true);
     $config = jIniFile::read(JELIX_LIB_CORE_PATH . 'defaultconfig.ini.php');
     if (self::$commonConfig) {
         self::_mergeConfig($config, self::$commonConfig);
     }
     if ($configFile != 'defaultconfig.ini.php') {
         if (!file_exists($configPath . $configFile)) {
             throw new Exception("Configuration file is missing -- {$configFile} ", 5);
         }
         if (false === ($userConfig = parse_ini_file($configPath . $configFile, true))) {
             throw new Exception("Syntax error in the configuration file -- {$configFile}", 6);
         }
         self::_mergeConfig($config, $userConfig);
     }
     $config = (object) $config;
     self::prepareConfig($config, $allModuleInfo, $isCli, $pseudoScriptName);
     self::$commonConfig = null;
     return $config;
 }
 /**
  * read the given ini file, for the current entry point, or for the entrypoint given
  * in $pseudoScriptName. Merge it with the content of defaultconfig.ini.php
  * It also calculates some options.
  * If you are in a CLI script but you want to load a configuration file for a web entry point
  * or vice-versa, you need to indicate the $pseudoScriptName parameter with the name of the entry point
  * @param string $configFile the config file name
  * @param boolean $allModuleInfo may be true for the installer, which needs all informations
  *                               else should be false, these extra informations are
  *                               not needed to run the application
  * @param boolean $isCli  indicate if the configuration to read is for a CLI script or no
  * @param string $pseudoScriptName the name of the entry point, relative to the base path,
  *              corresponding to the readed configuration
  * @return object an object which contains configuration values
  */
 public static function read($configFile, $allModuleInfo = false, $isCli = false, $pseudoScriptName = '')
 {
     $tempPath = jApp::tempBasePath();
     $configPath = jApp::configPath();
     if ($tempPath == '/') {
         // if it equals to '/', this is because realpath has returned false in the application.init.php
         // so this is because the path doesn't exist.
         throw new Exception('Application temp directory doesn\'t exist !', 3);
     }
     if (!is_writable($tempPath)) {
         throw new Exception('Application temp base directory is not writable -- (' . $tempPath . ')', 4);
     }
     if (!is_writable(jApp::logPath())) {
         throw new Exception('Application log directory is not writable -- (' . jApp::logPath() . ')', 4);
     }
     $config = jelix_read_ini(JELIX_LIB_CORE_PATH . 'defaultconfig.ini.php');
     self::$commonConfig = clone $config;
     @jelix_read_ini($configPath . 'defaultconfig.ini.php', $config);
     if ($configFile != 'defaultconfig.ini.php') {
         if (!file_exists($configPath . $configFile)) {
             throw new Exception("Configuration file is missing -- {$configFile}", 5);
         }
         if (false === @jelix_read_ini($configPath . $configFile, $config)) {
             throw new Exception("Syntax error in the configuration file -- {$configFile}", 6);
         }
     }
     self::prepareConfig($config, $allModuleInfo, $isCli, $pseudoScriptName);
     self::$commonConfig = null;
     return $config;
 }
Esempio n. 3
0
 /**
  * read the given ini file, for the current entry point, or for the entrypoint given
  * in $pseudoScriptName. Merge it with the content of defaultconfig.ini.php
  * It also calculates some options.
  * If you are in a CLI script but you want to load a configuration file for a web entry point
  * or vice-versa, you need to indicate the $pseudoScriptName parameter with the name of the entry point
  * @param string $configFile the config file name
  * @param boolean $allModuleInfo may be true for the installer, which needs all informations
  *                               else should be false, these extra informations are
  *                               not needed to run the application
  * @param boolean $isCli  indicate if the configuration to read is for a CLI script or no
  * @param string $pseudoScriptName the name of the entry point, relative to the base path,
  *              corresponding to the readed configuration
  * @return object an object which contains configuration values
  */
 public static function read($configFile, $allModuleInfo = false, $isCli = false, $pseudoScriptName = '')
 {
     $tempPath = jApp::tempBasePath();
     $configPath = jApp::configPath();
     if ($tempPath == '/') {
         // if it equals to '/', this is because realpath has returned false in the application.init.php
         // so this is because the path doesn't exist.
         throw new Exception('Application temp directory doesn\'t exist !', 3);
     }
     if (!is_writable($tempPath)) {
         throw new Exception('Application temp base directory (' . $tempPath . ') is not writable', 4);
     }
     self::$commonConfig = jIniFile::read($configPath . 'defaultconfig.ini.php', true);
     #if ENABLE_PHP_JELIX
     $config = jelix_read_ini(JELIX_LIB_CORE_PATH . 'defaultconfig.ini.php');
     @jelix_read_ini($configPath . 'defaultconfig.ini.php', $config);
     if ($configFile != 'defaultconfig.ini.php') {
         if (!file_exists($configPath . $configFile)) {
             throw new Exception("Config file {$configFile} is missing !", 5);
         }
         if (false === @jelix_read_ini($configPath . $configFile, $config)) {
             throw new Exception("Syntax error in the config file {$configFile} !", 6);
         }
     }
     #else
     $config = jIniFile::read(JELIX_LIB_CORE_PATH . 'defaultconfig.ini.php');
     if (self::$commonConfig) {
         self::_mergeConfig($config, self::$commonConfig);
     }
     if ($configFile != 'defaultconfig.ini.php') {
         if (!file_exists($configPath . $configFile)) {
             throw new Exception("Config file {$configFile} is missing !", 5);
         }
         if (false === ($userConfig = parse_ini_file($configPath . $configFile, true))) {
             throw new Exception("Syntax error in the config file {$configFile} !", 6);
         }
         self::_mergeConfig($config, $userConfig);
     }
     $config = (object) $config;
     #endif
     self::prepareConfig($config, $allModuleInfo, $isCli, $pseudoScriptName);
     self::$commonConfig = null;
     return $config;
 }