本文整理汇总了PHP中ConfigFile::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFile::getConfig方法的具体用法?PHP ConfigFile::getConfig怎么用?PHP ConfigFile::getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::getConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfigFile
/**
* Creates config file
*
* @param ConfigFile $cf Config file instance
*
* @return string
*/
public static function getConfigFile(ConfigFile $cf)
{
$crlf = isset($_SESSION['eol']) && $_SESSION['eol'] == 'win' ? "\r\n" : "\n";
$conf = $cf->getConfig();
// header
$ret = '<?php' . $crlf . '/*' . $crlf . ' * Generated configuration file' . $crlf . ' * Generated by: phpMyAdmin ' . $GLOBALS['PMA_Config']->get('PMA_VERSION') . ' setup script' . $crlf . ' * Date: ' . date(DATE_RFC1123) . $crlf . ' */' . $crlf . $crlf;
//servers
if (!empty($conf['Servers'])) {
$ret .= self::getServerPart($cf, $crlf, $conf['Servers']);
unset($conf['Servers']);
}
// other settings
$persistKeys = $cf->getPersistKeysMap();
foreach ($conf as $k => $v) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $v, $crlf);
if (isset($persistKeys[$k])) {
unset($persistKeys[$k]);
}
}
// keep 1d array keys which are present in $persist_keys (config.values.php)
foreach (array_keys($persistKeys) as $k) {
if (mb_strpos($k, '/') === false) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $cf->getDefault($k), $crlf);
}
}
$ret .= '?' . '>';
return $ret;
}
示例2: testGetServerCount
/**
* Test for ConfigFile::getServerCount
*
* @return void
* @test
*/
public function testGetServerCount()
{
$this->object->set('Servers/1/x', 1);
$this->object->set('Servers/2/x', 2);
$this->object->set('Servers/3/x', 3);
$this->object->set('Servers/4/x', 4);
$this->object->set('ServerDefault', 3);
$this->assertEquals(
4,
$this->object->getServerCount()
);
$this->object->removeServer(2);
$this->object->removeServer(2);
$this->assertEquals(
2,
$this->object->getServerCount()
);
$this->assertLessThanOrEqual(
2,
$this->object->get('ServerDefault')
);
$this->assertEquals(
array('Servers' => array(1 => array('x' => 1), 2 => array('x' => 4))),
$this->object->getConfig()
);
$this->assertEquals(
array('Servers/1/x' => 1, 'Servers/2/x' => 4),
$this->object->getConfigArray()
);
}
示例3: getConfigFile
/**
* Creates config file
*
* @param ConfigFile $cf Config file instance
*
* @return string
*/
public static function getConfigFile(ConfigFile $cf)
{
$crlf = isset($_SESSION['eol']) && $_SESSION['eol'] == 'win' ? "\r\n" : "\n";
$c = $cf->getConfig();
// header
$ret = '<?php' . $crlf . '/*' . $crlf . ' * Generated configuration file' . $crlf . ' * Generated by: phpMyAdmin ' . $GLOBALS['PMA_Config']->get('PMA_VERSION') . ' setup script' . $crlf . ' * Date: ' . date(DATE_RFC1123) . $crlf . ' */' . $crlf . $crlf;
// servers
if ($cf->getServerCount() > 0) {
$ret .= "/* Servers configuration */{$crlf}\$i = 0;" . $crlf . $crlf;
foreach ($c['Servers'] as $id => $server) {
$ret .= '/* Server: ' . strtr($cf->getServerName($id) . " [{$id}] ", '*/', '-') . "*/" . $crlf . '$i++;' . $crlf;
foreach ($server as $k => $v) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= "\$cfg['Servers'][\$i]['{$k}'] = " . (is_array($v) && self::_isZeroBasedArray($v) ? self::_exportZeroBasedArray($v, $crlf) : var_export($v, true)) . ';' . $crlf;
}
$ret .= $crlf;
}
$ret .= '/* End of servers configuration */' . $crlf . $crlf;
}
unset($c['Servers']);
// other settings
$persistKeys = $cf->getPersistKeysMap();
foreach ($c as $k => $v) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $v, $crlf);
if (isset($persistKeys[$k])) {
unset($persistKeys[$k]);
}
}
// keep 1d array keys which are present in $persist_keys (config.values.php)
foreach (array_keys($persistKeys) as $k) {
if ($GLOBALS['PMA_String']->strpos($k, '/') === false) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $cf->getDefault($k), $crlf);
}
}
$ret .= '?' . '>';
return $ret;
}