[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/config/src/ -> lmbConfTools.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/toolkit/src/lmbAbstractTools.class.php');
  10  lmb_require('limb/config/src/lmbIni.class.php');
  11  lmb_require('limb/config/src/lmbCachedIni.class.php');
  12  lmb_require('limb/config/src/lmbConf.class.php');
  13  
  14  @define('LIMB_CONF_INCLUDE_PATH', 'settings;limb/*/settings');
  15  
  16  /**

  17   * class lmbConfTools.

  18   *

  19   * @package config

  20   * @version $Id: lmbConfTools.class.php 5945 2007-06-06 08:31:43Z pachanga $

  21   */
  22  class lmbConfTools extends lmbAbstractTools
  23  {
  24    protected $confs = array();
  25  
  26    function setConf($name, $conf)
  27    {
  28      $this->confs[$this->_normalizeConfName($name)] = $conf;
  29    }
  30  
  31    function getConf($name)
  32    {
  33      $name = $this->_normalizeConfName($name);
  34  
  35      if(isset($this->confs[$name]))
  36        return $this->confs[$name];
  37  
  38      $ext = substr($name, strpos($name, '.'));
  39  
  40      if($ext == '.ini')
  41      {
  42        $file = $this->_locateFile($name);
  43        if(defined('LIMB_VAR_DIR'))
  44          $this->confs[$name] = new lmbCachedIni($file, LIMB_VAR_DIR . '/ini/');
  45        else
  46          $this->confs[$name] = new lmbIni($file);
  47      }
  48      elseif($ext == '.conf.php')
  49      {
  50        $this->confs[$name] = new lmbConf($this->_locateFile($name));
  51      }
  52      else
  53        throw new lmbException("'$ext' type configuration is not supported!");
  54  
  55      return $this->confs[$name];
  56    }
  57  
  58    protected function _locateFile($name)
  59    {
  60      return $this->toolkit->findFileAlias($name, LIMB_CONF_INCLUDE_PATH, 'config');
  61    }
  62  
  63    protected function _normalizeConfName($name)
  64    {
  65      if(strpos($name, '.') !== false)
  66        return $name;
  67      return "$name.conf.php";
  68    }
  69  }
  70  ?>


Generated: Mon Sep 8 04:35:41 2008 Cross-referenced by PHPXref 0.7