【php开源代码栏目提醒】:以下是网学会员为您推荐的php开源代码-configure.php,希望本篇文章对您学习有所帮助。
<?php
/* SVN FILE: $Id: configure.php 4409 2007-02-02 13:20:59Z phpnut $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs
* @since Cake
PHP(tm) v 1.0.0.2363
* @version $Revision: 4409 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs
*/
class Configure extends Object {
/**
* Hold array with paths to view files
*
* @var array
* @access public
*/
var $viewPaths = array();
/**
* Hold array with paths to controller files
*
* @var array
* @access public
*/
var $controllerPaths = array();
/**
* Enter description here...
*
* @var array
* @access public
*/
var $modelPaths = array();
/**
* Enter description here...
*
* @var array
* @access public
*/
var $helperPaths = array();
/**
* Enter description here...
*
* @var array
* @access public
*/
var $componentPaths = array();
/**
* Enter description here...
*
* @var integer
* @access public
*/
var $debug = null;
/**
* Return a singleton instance of Configure.
*
* @return Configure instance
* @access public
*/
function &getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] =& new Configure;
$instance[0]->__loadBootstrap();
}
return $instance[0];
}
/**
* Used to write a dynamic var in the Configure instance.
*
* Usage
* Configure::write('One.key1', 'value of the Configure::One[key1]');
* Configure::write(array('One.key1' => 'value of the Configure::One[key1]'));
* Configure::write('One', array('key1'=>'value of the Configure::One[key1]', 'key2'=>'value of the Configure::One[key2]');
* Configure::write(array('One.key1' => 'value of the Configure::One[key1]', 'One.key2' => 'value of the Configure::One[key2]'));
*
* @param array $config
* @return void
* @access public
*/
function write($config, $value = null){
$_this =& Configure::getInstance();
if(!is_array($config) && $value !== null) {
$name = $_this->__configVarNames($config);
if(count($name) > 1){
$_this->{$name[0]}[$name[1]] = $value;
} else {
$_this->{$name[0]} = $value;
}
} else {
foreach($config as $names => $value){
$name = $_this->__configVarNames($names);
if(count($name) > 1){
$_this->{$name[0]}[$name[1]] = $value;
} else {
$_this->{$name[0]} = $value;
}
}
}
if ($config == 'debug' || (is_array($config) && in_array('debug', $config))) {
if ($_this->debug) {
error_reporting(E_ALL);
if (function_exists('ini_set')) {
ini_set('display_errors', 1);
}
} else {
error_reporting(0);
}
}
}
/**
* Used to read Configure::$var
*
* Usage
* Configure::read('Name'); will return all values for Name
* Configure::read('Name.key'); will return only the value of Configure::Name[key]
*
* @param string $var
* @return string value of Configure::$var
* @access public
*/
function read($var = 'debug'){
$_this =& Configure::getInstance();
if($var === 'debug') {
if(!isset($_this->debug)){
$_this->debug = DEBUG;
}
return $_this->debug;
}
$name = $_this->__configVarNames($var);
if(count($name) > 1){
if(isset($_this->{$name[0]}[$name[1]])) {
return $_this->{$name[0]}[$name[1]];
}
return null;
} else {
if(isset($_this->{$name[0]})) {
return $_this->{$name[0]};
}
return null;
}
}
/**
* Used to delete a var from the Configure instance.
*
* Usage:
* Configure::delete('Name'); will delete the entire Configure::Name
* Configure::delete('Name.key'); will delete only the Configure::Name[key]
*
* @param string $var the var to be deleted
* @return void
* @access public
*/
function delete($var = null){
$_this =& Configure::getInstance();
$name = $_this->__configVarNames($var);
if(count($name) > 1){
unset($_this->{$name[0]}[$name[1]]);
} else {
unset($_this