[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/utils/ -> ConfigReader.php (source)

   1  <?php
   2  /*+**********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   ************************************************************************************/
  10  
  11  class ConfigReader {
  12  
  13      protected $properties = array();
  14      protected $name;
  15  
  16      static $propertiesCache = array();
  17  
  18      //TODO - Instead of path to file, we may have to support sending the array/map directly
  19      // which might be fetched from database or some other source. In that case, we will check
  20      // for the type of $source/$path and act accordingly.
  21  	function  __construct($path, $name, $force = false) {
  22          $this->load($path, $name, $force);
  23      }
  24  
  25  	function load($path, $name, $force = false) {
  26          $this->name = $path;
  27          if(!$force && self::$propertiesCache[$path]) {
  28              $this->properties = self::$propertiesCache[$path];
  29              return;
  30          }
  31          require $path;
  32          $this->properties = $$name;
  33          self::$propertiesCache[$path] = $this->properties;
  34      }
  35  
  36  	function setConfig($key, $value) {
  37          if(empty($key)) return;
  38          $this->properties[$key] = $value;
  39          //not neccessary for php5.x versions
  40          self::$propertiesCache[$this->name] = $this->properties;
  41      }
  42  
  43  	function getConfig($key) {
  44          if(empty($key)) return '';
  45          return $this->properties[$key];
  46      }
  47  }
  48  
  49  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1