本文整理汇总了PHP中Config::writeConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::writeConfig方法的具体用法?PHP Config::writeConfig怎么用?PHP Config::writeConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::writeConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']));
}
示例2: 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'));
}
示例3: WriteSettings
public function WriteSettings($configFilePath, $mergedSettings)
{
$this->CreateBackup($configFilePath);
if (!array_key_exists(Configuration::SETTINGS, $mergedSettings)) {
$mergedSettings = array(Configuration::SETTINGS => $mergedSettings);
}
$config = new Config();
$config->parseConfig($mergedSettings, 'PHPArray');
$config->writeConfig($configFilePath, 'PHPArray', $mergedSettings);
$this->AddErrorReporting($configFilePath);
}
示例4: 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');
}
示例5: config
function config()
{
if ($_POST) {
// Use the config lib to convert $_POST into something writable
$conf = Config::prepareConfigToWrite($_POST);
// Update config
Config::writeConfig($conf);
// Set flash message
Application::flash('success', 'App config updated!');
// Force redirect to reload app with new config
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
}
$this->loadView('admin/config', null, 'admin');
}
示例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
* $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;
}
示例7: array
/**
* test to ensure that special characters
* are written and read correctly
* IniCommented config class should quote all special chars
* except backslash and single quote
*
* note: parse_ini_file() will break array on double quote
*
*/
function test_iniFile()
{
$min = 32;
$max = 126;
for ($i = $min; $i <= $max; $i++) {
if ($i == 34 || $i == 36) {
// '"' (any version) and '$' (5.3) break the test
continue;
}
$aIni = array();
$aIni['test1'][$i] = 'test' . chr($i);
$aIni['test2'][$i] = chr($i) . 'test';
$aIni['test3'][$i] = 'te' . chr($i) . 'st';
$ini = MAX_PATH . '/var/test_' . $i . '.ini';
$oConfig = new Config();
$oConfig->parseConfig($aIni, 'phpArray');
$this->assertTrue($oConfig->writeConfig($ini, 'IniCommented'));
$aResult = @parse_ini_file($ini, true);
$this->assertEqual($aResult['test1'][$i], $aIni['test1'][$i], 'ERROR:' . $i);
$this->assertEqual($aResult['test2'][$i], $aIni['test2'][$i], 'ERROR:' . $i);
$this->assertEqual($aResult['test3'][$i], $aIni['test3'][$i], 'ERROR:' . $i);
@unlink($ini);
}
}
示例8: writePluginConfig
/**
* A method to write the configuration file for plugin. Also creates "fake"
* configuration files when required by multi-host installations.
*
* @static
* @param array $aConfig The configuration array to save as a configuration file.
* @param string $module The plugin module name (i.e. /plugins/module directory).
* @param string $package An optional plugin package name (i.e. /plugins/module/package
* directory). If not given, writes the module level
* configuration file path.
* @param string $name An optional plugin name (i.e. /plugins/module/package/plugin.plugin.php).
* If not given, writes the package level configuration file, or
* the module level configuration file, depending on the $package
* parameter.
* @return boolean True on success, false otherwise.
*/
function writePluginConfig($aConfig, $module, $package = null, $name = null)
{
$conf = $GLOBALS['_MAX']['CONF'];
// Prepare the config file for writing, using the delivery engine
// host as the hostname for the "real" config file
$url = @parse_url('http://' . $conf['webpath']['delivery']);
if (!isset($url['host'])) {
return false;
}
$deliveryHost = $url['host'];
$configFileName = MAX_Plugin::getConfigFileName($module, $package, $name, false, $deliveryHost);
if (!file_exists($configFileName)) {
MAX_Plugin::copyDefaultConfig($module, $package, $name);
}
// Create a new config class, parse the config array, and write to disk
$oConfig = new Config();
$oConfig->parseConfig($aConfig, 'phpArray');
$result = $oConfig->writeConfig($configFileName, 'inifile');
if ($result == false || PEAR::isError($result)) {
return false;
}
// Check the other possible host names, and write out the fake
// configuration files if different
$url = @parse_url('http://' . $conf['webpath']['admin']);
if (isset($url['host'])) {
$adminHost = $url['host'];
if ($adminHost != $deliveryHost) {
// Create fake file for this host
$configFileName = MAX_Plugin::getConfigFileName($module, $package, $name, false, $adminHost);
$aConfig = array('realConfig' => $deliveryHost);
$oConfig = new Config();
$oConfig->parseConfig($aConfig, 'phpArray');
if (!$oConfig->writeConfig($configFileName, 'inifile')) {
return false;
}
}
}
$url = @parse_url('http://' . $conf['webpath']['deliverySSL']);
if (isset($url['host'])) {
$deliverySslHost = $url['host'];
if ($deliverySslHost != $deliveryHost) {
// Create fake file for this host
$configFileName = MAX_Plugin::getConfigFileName($module, $package, $name, false, $deliverySslHost);
$aConfig = array('realConfig' => $deliveryHost);
$oConfig = new Config();
$oConfig->parseConfig($aConfig, 'phpArray');
if (!$oConfig->writeConfig($configFileName, 'inifile')) {
return false;
}
}
}
return true;
}
示例9: Config
if (!empty($_POST)) {
require_once 'includes/config.php';
require_once 'includes/database.php';
$config = new Config();
$db = new Database();
if ($config->checkPostData($_POST)) {
// if (!$db->createDatabase($_POST)) {
// $error = "The database could not be created, please verify your settings.";
// } else
if (!$db->createTable($_POST)) {
$error = "The database tables could not be created, please verify your settings.";
} else {
if (!$db->createAdmin($_POST)) {
$error = "The admin details could not be saved. Please verify.";
} else {
if (!$config->writeConfig($_POST)) {
$error = "The configuration file could not be written, \n please chmod the files to 0777";
} else {
if (!$config->createExtraction($_POST['base_url'])) {
$error = "The extraction js file could not be written, \n please chmod the files to 0777";
}
}
}
}
if (!isset($error)) {
header('Location: ' . $redirect_url . 'status.php?status=1');
exit;
}
} else {
$error = "Please fill out all the fields";
}
示例10: array
// Parses and writes an existing php array $conf
$conf['storage']['driver'] = 'sql';
$conf['storage']['params']['phptype'] = 'mysql';
$conf['storage']['params']['hostspec'] = 'localhost';
$conf['storage']['params']['username'] = 'mamasam';
$conf['storage']['params']['password'] = 'foobar';
$conf['menu']['apps'] = array('imp', 'turba');
$conf['stdcontent']['para'][0] = 'This is really cool !';
$conf['stdcontent']['para'][1] = 'It just rocks...';
$c = new Config();
$root =& $c->parseConfig($conf, 'phparray');
$storage =& $root->getItem('section', 'storage');
$storage->removeItem();
$root->addItem($storage);
echo '<pre>' . $root->toString('phparray', array('name' => 'test')) . '</pre>';
if ($c->writeConfig('/tmp/Config_Test.php', 'phparray', array('name' => 'test')) === true) {
echo 'Config written into /tmp/Config_Test.php';
}
// Making a php ini file with $storage only
$ini = new Config();
$iniRoot =& $ini->getRoot();
$iniRoot->addItem($storage);
$comment =& new Config_Container('comment', null, 'This is the php ini version of storage');
$iniRoot->addItem($comment, 'top');
$iniRoot->createBlank('after', $comment);
echo '<pre>' . $iniRoot->toString('inicommented') . '</pre>';
// Gonna make an array with it
echo '<pre>';
var_dump($iniRoot->toArray());
echo '</pre>';
// Now, I'll parse you php.ini file and make it a php array
示例11: writeDefaultConfigFile
function writeDefaultConfigFile($configPath, $configFile, $newHost)
{
$file = $configPath . '/default' . $configFile . '.conf.php';
if (!OA_Admin_Settings::isConfigWritable($file)) {
return false;
}
$aConfig = array('realConfig' => $newHost);
$oConfig = new Config();
$oConfigContainer =& $oConfig->parseConfig($aConfig, 'phpArray');
$oConfigContainer->createComment('*** DO NOT REMOVE THE LINE ABOVE ***', 'top');
$oConfigContainer->createComment('<' . '?php exit; ?>', 'top');
return $oConfig->writeConfig($file, 'IniCommented');
}
示例12: setupEnvironment
/**
* Creating the config file
*
* @param array $answers The $answers passed over from the run() method.
*
* @return bool True on success, otherwise false.
*/
function setupEnvironment($answers)
{
$this->_ui->outputData('Writing config file');
$config = new Config();
$root = $config->getRoot();
$root->createItem('directive', strtoupper('path_include'), '@php-dir@');
foreach ($this->settings as $setting) {
$root->createItem('directive', strtoupper($setting), $answers[$setting]);
}
$error_check = $config->writeConfig($this->_config_file, 'phpconstants', array('name' => 'config'));
if (PEAR::isError($error_check)) {
$this->_ui->outputData($error_check->getMessage());
return false;
}
$this->_ui->outputData('Config file written: ' . $this->_config_file);
return true;
}
示例13: writeLinksDotIni
/**
* A method to write a .links.ini file.
*
* @param string $file_links The path to the .links.ini file.
* @param array $link_array An array of all the links
* @return mixed PEAR_Error on error or true if ok.
*
* Array
* (
* [acls] => Array
* (
* [bannerid] => Array
* (
* [table] => banners
* [field] => bannerid
* )
*
* )
*
* )
*
* or
*
* Array
* (
* [acls] => Array
* (
* [bannerid] => banners:bannerid
*
* )
*
* )
*
*/
function writeLinksDotIni($file_links, $link_array)
{
$links = new Config();
$root =& $links->parseConfig($file_links, 'inifile');
$root = $root->toArray();
$root = $root['root'];
foreach ($link_array as $table => $array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = "{$v['table']}:{$v['field']}";
}
}
if (count($array)) {
$root[$table] = $array;
} else {
unset($root[$table]);
}
}
ksort($root);
$links = new Config();
$links->parseConfig($root, 'phparray');
return $links->writeConfig($file_links, 'inifile');
}
示例14: createAdmConfig
/**
* Create config for adm
*
*/
public function createAdmConfig($servarray)
{
//check for the directory structure
if (!file_exists($this->objConfig->getcontentBasePath() . 'adm/')) {
mkdir($this->objConfig->getcontentBasePath() . 'adm/', 0777);
}
// write the server list file
$cfile = $this->objConfig->getcontentBasePath() . 'adm/adm.xml';
if (!file_exists($cfile)) {
$conf = new Config_Container('section', 'adm');
//$servarray['name']);
$conf_serv =& $conf->createSection($servarray['name']);
$conf_serv->createDirective('servername', $servarray['name']);
$conf_serv->createDirective('serverapiurl', $servarray['url']);
$conf_serv->createDirective('serveremail', $servarray['email']);
$conf_serv->createDirective('regtime', date('r'));
$config = new Config();
$config->setRoot($conf);
// write the container to an XML document
$config->writeConfig($cfile, 'XML');
} else {
// update the xml with the new server
$root =& $config->parseConfig($cfile, 'XML', array('name' => 'adm'));
log_debug($root);
$conf_serv =& $root->createSection($servarray['name']);
$conf_serv->createDirective('servername', $servarray['name']);
$conf_serv->createDirective('serverapiurl', $servarray['url']);
$conf_serv->createDirective('serveremail', $servarray['email']);
$conf_serv->createDirective('regtime', date('r'));
$config = new Config();
$config->setRoot($root);
// write the container to an XML document
$config->writeConfig($cfile, 'XML');
}
}
示例15: saveToFile
/**
* Saves the folders into a config file that can be edited by hand.
* If you don't specify the config file, it will be determined
* automatically.
* Values that are NULL won't be saved.
*
* @param string $strFile The file to save the data into
* (ini file)
* @param boolean $bSaveAllSettings If all settings shall be saved
* that can be loaded, or only that settings,
* that have been retrieved by the user
*
* @return mixed True on success, PEAR_Error on failure
*
* @access public
*/
function saveToFile($strFile = null, $bSaveAllSettings = true)
{
$conf =& new Config_Container('section', 'paths');
if ($bSaveAllSettings) {
foreach ($this->arSettings as $strSetting) {
$strFunction = 'get' . $strSetting;
$strValue = $this->{$strFunction}();
$conf->createDirective(strtolower($strSetting), $strValue);
}
} else {
foreach ($this->arCache as $strId => $strValue) {
$conf->createDirective($strId, $strValue);
}
}
$config = new Config();
$config->setRoot($conf);
return $config->writeConfig($this->getDefaultConfigFile(), 'inifile');
}