You Are Here : /var/www/virtual/tvarditsa.org/classes/ |
Current File : /var/www/virtual/tvarditsa.org/classes/vsiteconf.class.php |
<?php /** * VSite Framework for PHP * * This product includes PHP, freely available from * <{@link http://www.php.net/ http://www.php.net/}> * * @package VSite_Framework * @subpackage Configuration * @copyright Copyright (c) 2003, Valentin Sheiretsky * @license http://www.vsite.org/license.txt BSD-style license */ if (!defined("_VSITECONF_CLASS_")) { /** * @ignore */ define("_VSITECONF_CLASS_", 1); /** * Manage Framework classes configuration * * @version 1.0.4 * @author Valentin Sheiretsky <valio@vsite.org> * @package VSite_Framework */ class VsiteConf { /**#@+ * @access private * @var string */ var $style; var $confpath; /**#@-*/ /** * @var array */ var $_cfg = array(); /** * Constructor */ function __construct($style = '') { if (defined("VSITE_CONFIG_PATH")) { $this->confpath = realpath (VSITE_CONFIG_PATH); } else { $this->confpath = realpath (dirname(__FILE__) . '/../config'); } if ($style) $this->set_style ($style); } /** * @ignore */ function VsiteConf ($style = '') { $this->__construct($style); } /** * Read Configuration from file */ function join_conf ($new_cfg, $old_cfg) { if (!is_array($old_cfg)) $old_cfg = array(); if (is_array($new_cfg)) foreach ($new_cfg as $k => $v) $old_cfg[$k] = $v; return $old_cfg; } /** * Read Configuration from file */ function read_conf ($file, $old_cfg = NULL) { switch ($this->style) { case 'php': default: $this->_read_php_style ($file); } $old_cfg = $this->join_conf ($this->_cfg, $old_cfg); return $old_cfg; } /** * Set Configuration file style */ function set_style ($style) { $this->style = $style; } /** * Read PHP Style Configuration * @access private */ function _read_php_style ($file) { $file = $this->confpath . DIRECTORY_SEPARATOR . $file . '.conf.php'; if (is_file($file)) { $this->_cfg = array(); include ($file); $this->_cfg = $cfg; } } /** * Destructor */ function __destruct() { } } } // END CONFIG_CLASS ?>