load() public method

Load Config File
public load ( string $file = '', boolean $use_sections = FALSE, boolean $fail_gracefully = FALSE ) : boolean
$file string Configuration file name
$use_sections boolean Whether configuration values should be loaded into their own section
$fail_gracefully boolean Whether to just return FALSE or display an error message
return boolean TRUE if the file was loaded correctly or FALSE on failure
コード例 #1
0
 public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 {
     // first we need to check if this is called before CI_controller
     // if yes, well just use default
     if (!class_exists('CI_controller')) {
         return parent::load($file, $use_sections, $fail_gracefully);
     }
     if (in_array($file, $this->is_loaded, TRUE)) {
         return $this->item($file);
     }
     $_module = Modules::$current;
     if ($path = modules::find($file, $_module, 'config')) {
         // this file expected contain $config var
         include $path;
         if (!isset($config) or !is_array($config)) {
             show_error("{$path} does not contain a valid config array");
         }
         log_message('debug', "File loaded: {$path}");
         $current_config =& $this->config;
         if ($use_sections === TRUE) {
             if (isset($current_config[$file])) {
                 $current_config[$file] = array_merge($current_config[$file], $config);
             } else {
                 $current_config[$file] = $config;
             }
         } else {
             $current_config = array_merge($current_config, $config);
         }
         $this->is_loaded[] = $file;
         unset($config);
         return $this->item($file);
     }
     return parent::load($file, $use_sections, $fail_gracefully);
 }
コード例 #2
0
ファイル: Config.php プロジェクト: pay-test/ci2
 public function load($file = 'config', $use_sections = FALSE, $fail_gracefully = FALSE, $_module = '')
 {
     if (in_array($file, $this->is_loaded, TRUE)) {
         return $this->item($file);
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $file) = Modules::find($file, $_module, 'config/');
     if ($path === FALSE) {
         parent::load($file, $use_sections, $fail_gracefully);
         return $this->item($file);
     }
     if ($config = Modules::load_file($file, $path, 'config')) {
         /* reference to the config array */
         $current_config =& $this->config;
         if ($use_sections === TRUE) {
             if (isset($current_config[$file])) {
                 $current_config[$file] = array_merge($current_config[$file], $config);
             } else {
                 $current_config[$file] = $config;
             }
         } else {
             $current_config = array_merge($current_config, $config);
         }
         $this->is_loaded[] = $file;
         unset($config);
         return $this->item($file);
     }
 }
コード例 #3
0
 /**
  * Load a config file - Overrides built-in CodeIgniter config file loader
  *
  * @param string $file
  * @param boolean $use_sections
  * @param boolean $fail_gracefully
  */
 function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 {
     parent::load($file, $use_sections, $fail_gracefully);
     //Local settings override permanent settings always.
     if (is_readable(FCPATH . 'config.local.php')) {
         parent::load('config.local.php', $use_sections, $fail_gracefully);
     }
 }
コード例 #4
0
ファイル: configurator.php プロジェクト: andrejjursa/fmfi-tis
 /**
  * Returns configuration array for given config file.
  * 
  * @param string $config name of config file without extension.
  * @return array<mixed> values of config file.
  */
 public function getConfigArray($config)
 {
     if (file_exists(APPPATH . 'config/' . $config . '.php')) {
         $configObject = new CI_Config();
         $configObject->load($config, TRUE);
         return $configObject->config[$config];
     }
     return NULL;
 }
コード例 #5
0
ファイル: Config.php プロジェクト: Moro3/duc
 public function load($file = 'config', $use_sections = FALSE, $fail_gracefully = FALSE, $_module = '')
 {
     //if (in_array($file, $this->is_loaded, TRUE)) return $this->item($file);
     //echo "Модуль до определения = $_module<br>";
     if ($_module === false) {
         $_module = '';
     } else {
         $_module or $_module = CI::$APP->router->fetch_module();
     }
     //echo "Модуль после определения = $_module<br>";
     list($path, $file) = Modules::find($file, $_module, 'config/');
     if ($path === FALSE) {
         parent::load($file, $use_sections, $fail_gracefully);
         return $this->item($file);
     }
     //echo "Путь - $path, файл-$file<br>";
     // добавлено для корректной работы уже загруженных файлов модулей
     $file_path = $path . $file . EXT;
     //echo "Данные $file_path:<br>";
     //print_r($this->item($file_path));
     //if (in_array($file_path, $this->is_loaded, TRUE)) return $this->item($file);
     // конец добавления
     if ($config = Modules::load_file($file, $path, 'config')) {
         /* reference to the config array */
         $current_config =& $this->config;
         if ($use_sections === TRUE) {
             if (isset($current_config[$file])) {
                 //$current_config[$file] = array_merge($current_config[$file], $config);
                 $current_config[$file] = $this->array_merge_recursive_distinct($current_config[$file], $config);
             } else {
                 $current_config[$file] = $config;
             }
         } else {
             $current_config = array_merge($current_config, $config);
         }
         //$this->is_loaded[] = $file;
         // исправлено на:
         $this->is_loaded[] = $file_path;
         unset($config);
         return $this->item($file);
     }
 }
コード例 #6
0
ファイル: Plain_Config.php プロジェクト: iweave/unmark
 /**
  * Load Config File
  *
  * @access  public
  * @param   string  the config file name
  * @param   boolean  if configuration values should be loaded into their own section
  * @param   boolean  true if errors should just return false, false if an error message should be displayed
  * @return  boolean if the file was loaded correctly
  */
 function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 {
     // Call default config loader
     $load = parent::load($file, $use_sections, true);
     // Now check for any custom configs
     $file = empty($file) ? 'config' : $file;
     $ext = pathinfo($file, PATHINFO_EXTENSION);
     $ext = empty($ext) ? '.php' : '';
     $file = $file . $ext;
     // Set the custom locations
     $locations = array();
     if (defined('ENVIRONMENT')) {
         array_push($locations, CUSTOMPATH . 'config/' . ENVIRONMENT . '/' . $file);
     }
     array_push($locations, CUSTOMPATH . 'config/' . $file);
     // Loop thru the locations
     // If found, load the file
     // Loop thru configs in there
     // If value is array, loop again to apply to avoid overwriting any existing configs (IE: adding a  new error code)
     foreach ($locations as $file) {
         if (file_exists($file)) {
             $load = true;
             include_once $file;
             if (isset($config) && is_array($config)) {
                 foreach ($config as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $kk => $vv) {
                             $this->config[$k][$kk] = $vv;
                         }
                     } else {
                         $this->config[$k] = $v;
                     }
                 }
                 unset($config);
             }
             break;
         }
     }
     // Return load
     return $load;
 }
コード例 #7
0
ファイル: MY_Config.php プロジェクト: asalce/wp-ci
 function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 {
     if ($app_path = WPCI::active_app_path(FALSE)) {
         $file_path = $app_path . '/config/' . $file . EXT;
         if (file_exists($file_path)) {
             if (in_array($file_path, $this->is_loaded, TRUE)) {
                 return TRUE;
             }
             @(include $file_path);
             if ($use_sections === TRUE) {
                 if (isset($this->config[$file])) {
                     $this->config[$file] = array_merge($this->config[$file], $config);
                 } else {
                     $this->config[$file] = $config;
                 }
             } else {
                 $this->config = array_merge($this->config, $config);
             }
             return TRUE;
         }
     }
     parent::load($file, $use_sections, $fail_gracefully);
 }