コード例 #1
0
ファイル: ini.php プロジェクト: andreas83/Videosharing
 /**
  * loads the config based on the type / source
  *
  * @param mixed $param
  *
  * @throws Config_Exception
  *
  * @return mixed
  */
 public function load($param = null)
 {
     try {
         if (empty($param['file'])) {
             throw new Config_Exception(_('No config file was give please, the parameter ' . $param, 0, 1, __METHOD__, __LINE__));
         }
         $this->config_file = (string) $param['file'];
         if (isset($param['process_sections'])) {
             $this->process_sections = (bool) $param['process_sections'];
         }
         if (isset($param['scanner_mode'])) {
             $this->scanner_mode = (int) $param['scanner_mode'];
         }
         $data = parse_ini_file($this->config_file, $this->process_sections, $this->scanner_mode);
         $this->main_node = new Config_Node(null, 'main_node');
         foreach ($data as $key => $group) {
             if (!is_array($group)) {
                 $main_node = new Config_Node($this->main_node, $key, $group);
                 $this->main_node->add_child($main_node);
                 continue;
             }
             $main_node = new Config_Node($this->main_node, $key, $key);
             foreach ($group as $name => $value) {
                 $node = new Config_Node($main_node, $name, $value);
                 $main_node->add_child($node);
             }
             $this->main_node->add_child($main_node);
         }
     } catch (Config_Exception $e) {
         throw $e;
     }
 }
コード例 #2
0
ファイル: nodelist.php プロジェクト: andreas83/Videosharing
 /**
  * @param Config_Node $node
  *
  * @return $this
  */
 public function add_node(Config_Node $node)
 {
     if ($node->get_parent() instanceof Config_Node) {
         $pos = $node->get_parent()->get_id();
     } else {
         $pos = md5($node->get_id());
     }
     $this->list[$pos][$node->get_key()] = $node;
     return $this;
 }
コード例 #3
0
ファイル: generic.php プロジェクト: andreas83/Videosharing
 /**
  * sets a specific parameter
  *
  * @param $key
  * @param $val
  * @return mixed
  */
 public function set($key, $val)
 {
     // set the variable
     if (empty($key)) {
         return $this;
     }
     $node = new Config_Node($this->main_node, $key, $val);
     $this->main_node->add_child($node);
     return $this;
 }