本文整理汇总了PHP中Config::parseConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::parseConfig方法的具体用法?PHP Config::parseConfig怎么用?PHP Config::parseConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::parseConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseFile
/**
* Read menu file. Parse xml and initializate menu.
*
* @param menu string Configuration file
* @param cacheFile string Name of file where parsed config will be stored for faster loading
* @return void
*/
public function parseFile(RM_Account_iUser $obUser)
{
PROFILER_IN('Menu');
$cacheFile = $this->_filepath . '.' . L(NULL) . '.cached';
if ($this->_cache_enabled and file_exists($cacheFile) and filemtime($cacheFile) > filemtime($this->_filepath)) {
$this->_rootArray = unserialize(file_get_contents($cacheFile));
} else {
#
# Initializing PEAR config engine...
#
$old = error_reporting();
error_reporting($old & ~E_STRICT);
require_once 'Config.php';
$conf = new Config();
$this->_root = $conf->parseConfig($this->_filepath, 'XML');
if (PEAR::isError($this->_root)) {
error_reporting($old);
throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $this->_root->getMessage());
}
$this->_rootArray = $this->_root->toArray();
if ($this->_cache_enabled) {
file_put_contents($cacheFile, serialize($this->_rootArray));
}
}
$arr = array_shift($this->_rootArray);
$arr = $arr['menu'];
$this->_menuData['index'] = array();
// index for branches
$this->_menuData['default'] = array();
// default selected block of menu
$this->_menuData['tree'] = $this->formMenuArray($obUser, $arr['node']);
$this->_menuData['branches'] = array();
// tmp array, dont cached
PROFILER_OUT('Menu');
}
示例2: Config
function __construct($filename = null, $type = 'xml')
{
$this->type = $type;
$conf = new Config();
if (!is_null($filename)) {
//$filename = "notthere.conf";
$this->rootObj = @$conf->parseConfig($filename, $type);
if (PEAR::isError($this->rootObj)) {
print "message: " . $this->rootObj->getMessage() . "\n";
print "code: " . $this->rootObj->getCode() . "\n\n";
print "Backtrace:\n";
foreach ($this->rootObj->getBacktrace() as $caller) {
print_r($caller);
print $caller['class'] . $caller['type'];
print $caller['function'] . "() ";
print "line " . $caller['line'] . "\n";
}
die;
}
//print get_class( $this->rootObj )."\\\\ \n";;
} else {
$this->rootObj = new Config_Container('section', 'config');
$conf->setroot($this->rootObj);
}
}
示例3: array
/**
* The progress bar's UI extended model class constructor
*
* @param string $file file name of model properties
* @param string $type type of external ressource (phpArray, iniFile, XML ...)
*
* @since 1.0
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
*/
function HTML_Progress_Model($file, $type)
{
$this->_package = 'HTML_Progress';
if (!file_exists($file)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1));
}
$conf = new Config();
if (!$conf->isConfigTypeRegistered($type)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2));
}
$data = $conf->parseConfig($file, $type);
$structure = $data->toArray(false);
$this->_progress =& $structure['root'];
if (is_array($this->_progress['cell']['font-family'])) {
$this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']);
}
if (is_array($this->_progress['string']['font-family'])) {
$this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']);
}
$this->_orientation = $this->_progress['orientation']['shape'];
$this->_fillWay = $this->_progress['orientation']['fillway'];
if (isset($this->_progress['script']['file'])) {
$this->_script = $this->_progress['script']['file'];
} else {
$this->_script = null;
}
if (isset($this->_progress['cell']['count'])) {
$this->_cellCount = $this->_progress['cell']['count'];
} else {
$this->_cellCount = 10;
}
$this->_updateProgressSize();
}
示例4: __construct
public function __construct()
{
$this->config['app'] = Config::parseConfig('app');
define('TEMPLATE_PATH', APP_PATH . 'app/views/' . $this->config['app']->template . '/');
define('APP_URL', $this->config['app']->url . (empty($this->config['app']->index) ? '' : $this->config['app']->index . '/'));
define('ASSET_URL', $this->config['app']->url . 'app/views/' . $this->config['app']->template . '/');
define('CONTENT_URL', $this->config['app']->url . 'contents/');
}
示例5: perform
/**
* Control the main setup process
*
* @param array $data
*/
function perform($data)
{
// include PEAR Config class
include_once SF_BASE_DIR . 'modules/common/PEAR/Config.php';
$c = new Config();
$root =& $c->parseConfig($data, 'PHPArray');
// save the modified config array
$c->writeConfig(SF_BASE_DIR . 'modules/common/config/config.php', 'PHPArray', array('name' => 'this->B->sys'));
}
示例6: perform
/**
* Control the main setup process
*
* @param array $data
* $data['data'] Data (array or ...) to store
* $data['file'] File to store
* $data['var_name'] Name of the data array or ...
* $data['type'] Data type
*/
function perform($data = FALSE)
{
// include PEAR Config class
include_once SF_BASE_DIR . 'modules/common/PEAR/Config.php';
$c = new Config();
$root =& $c->parseConfig($data['data'], $data['type']);
// save the modified config array
$c->writeConfig($data['file'], $data['type'], array('name' => $data['var_name']));
}
示例7: loadConfiguration
/**
* Read the configuration file, parse its XML contents, and return the
* result as an array.
*
* @param string configFile The name of the configuration file.
* @return mixed The parsed configuration file as an array or PEAR_Error
* if the configuration file could not be read.
*/
function loadConfiguration($configFile)
{
$config = new Config();
$root =& $config->parseConfig($configFile, 'xml');
if (PEAR::isError($root)) {
return $root;
}
$root =& $root->toArray();
return $root['root'];
}
示例8: Config
function __construct($filename = null, $type = 'xml')
{
$this->type = $type;
$conf = new Config();
if (!is_null($filename)) {
$this->rootObj = $conf->parseConfig($filename, $type);
} else {
$this->rootObj = new Config_Container('section', 'config');
$conf->setroot($this->rootObj);
}
}
示例9: readConfigFile
function readConfigFile($site_name, $type = "xml")
{
global $PattenConfigDir;
$config = new Config();
$root =& $config->parseConfig($PattenConfigDir . $site_name . '.' . $type, $type);
if (PEAR::isError($root)) {
die($root->getMessage());
}
$data = $root->toArray();
return $data;
}
示例10: setDbConfig
public static function setDbConfig(Config $config = null)
{
if (empty($config)) {
if (empty(self::$dbConfig)) {
self::$dbConfig = Config::parseConfig(DEFAULT_CONFIG_PATH, CONFIG_PATH);
}
} else {
self::$dbConfig($config);
}
return self::$dbConfig;
}
示例11: configureTestFromArray
function configureTestFromArray($aConfigurationEntries, $configFilename)
{
$config = new Config();
$configContainer =& $config->parseConfig(CONFIG_TEMPLATE, 'inifile');
foreach ($aConfigurationEntries as $configurationEntry) {
$aConfigurationEntry = explode("=", $configurationEntry);
list($configurationKey, $configurationValue) = $aConfigurationEntry;
list($sectionName, $variableName) = explode('.', $configurationKey);
$section =& $configContainer->getItem('section', $sectionName);
$section->setDirective($variableName, $configurationValue);
}
$config->writeConfig($configFilename, 'inifile');
}
示例12: loadValuesFromPath
function loadValuesFromPath($path)
{
if (!is_file($path)) {
return array();
}
$config = new Config();
$configContainer = $config->parseConfig($path, $this->configType, $this->options);
if ($configContainer instanceof PEAR_Error) {
return array();
}
$rootConfig = $configContainer->toArray();
return $rootConfig["root"];
}
示例13: perform
/**
* Control the main setup process
*
* @param array $data
* $data['data'] Data (array or ...) to store
* $data['file'] File to store
* $data['var_name'] Name of the data array or ...
* $data['type'] Data type
* $data['reload'] Reload page if true
*
* @param array $data
*/
function perform(&$data)
{
// include PEAR Config class
include_once SF_BASE_DIR . 'modules/common/PEAR/Config.php';
$c = new Config();
$root =& $c->parseConfig($data['data'], $data['type']);
// save the modified config array
$c->writeConfig($data['file'], $data['type'], array('name' => $data['var_name']));
if ($data['reload'] == TRUE) {
// reload page
@header('Location: ' . SF_BASE_LOCATION . '/' . SF_CONTROLLER . '?' . SF_ADMIN_CODE . '=1');
exit;
}
return SF_IS_VALID_ACTION;
}
示例14: prepareScanningData
function prepareScanningData()
{
$old = error_reporting();
error_reporting($old & ~E_STRICT);
require_once 'Config.php';
$conf = new Config();
$root = $conf->parseConfig(dirname(__FILE__) . '/scan-data.xml', 'XML');
if (PEAR::isError($root)) {
error_reporting($old);
throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $root->getMessage());
}
$rootArray = $root->toArray();
$arr = $rootArray['root']['root'];
M('Db')->execBatch($arr['init']);
foreach ($arr['test'] as $test) {
$userId = $test["@"]['id'];
addReceipt($userId, $test['receipt']);
}
M('Db')->execBatch($arr['post_init']);
return $userId;
}
示例15: loadFromFile
/**
* Loads the directories from an ini file.
* If you don't specify the config file, it will be determined
* automatically.
*
* @access public
* @param string $strFile The file to load the data from (ini file)
* @return mixed True on success, PEAR_Error on failure
*/
function loadFromFile($strFile = null)
{
$strFile = $this->getDefaultConfigFile();
if (!file_exists($strFile)) {
//Not existing config file isn't an error
return true;
}
$conf = new Config();
$root =& $conf->parseConfig($strFile, 'inifile');
if (PEAR::isError($root)) {
return $root;
}
$arSettings = $root->toArray();
if (!isset($arSettings['root']['paths'])) {
return true;
}
foreach ($arSettings['root']['paths'] as $strId => $strValue) {
if ($strValue != '') {
$this->arCache[$strId] = $strValue;
}
}
return true;
}