Example #1
0
 /** Load a configuration file
  *
  * @param 	string 	$folder
  * @param 	bool 	$is_assoc
  * @return Incube_Array */
 public function load_by_folder($folder, $is_assoc = true)
 {
     $files = FileExplorer::list_files($folder);
     $config = $is_assoc ? array() : new stdClass();
     foreach ($files as $file) {
         //PHP5.3 >>
         //$filename = basename($file, '.ini');
         //$filename = basename($file, '.xml');
         //$filename = strtolower(pathinfo($file, PATHINFO_FILENAME));
         //$path_parts = pathinfo($file);
         //$filename = strtolower($path_parts["filename"]);
         $path_parts = pathinfo($file);
         $ext = array_key_exists("extension", $path_parts) ? "." . $path_parts["extension"] : "";
         $filename = basename($file, $ext);
         if ($config_file = $this->load($folder . DIRECTORY_SEPARATOR . $file, $is_assoc)) {
             $is_assoc ? $config[$filename] = $config_file : $config->set($filename, $config_file);
         }
         unset($config_file);
     }
     return $is_assoc ? DataObject::from_array($config) : $config;
 }