Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorHugues Peccatte <hugues.peccatte@gmail.com>2015-04-26 21:16:35 +0300
committerHugues Peccatte <hugues.peccatte@gmail.com>2015-04-26 21:16:35 +0300
commitc8b6f6950d2d417067fd1afac4048eb69ee735aa (patch)
treebfb03bc45d8f28ccc0a906af677232bf974a38b1 /setup
parent8e0d4f19c5b7676c56db8030a49cf591468811eb (diff)
Minor code refactor.
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Diffstat (limited to 'setup')
-rw-r--r--setup/lib/ConfigGenerator.class.php67
1 files changed, 42 insertions, 25 deletions
diff --git a/setup/lib/ConfigGenerator.class.php b/setup/lib/ConfigGenerator.class.php
index af83025691..5bcf43a859 100644
--- a/setup/lib/ConfigGenerator.class.php
+++ b/setup/lib/ConfigGenerator.class.php
@@ -25,44 +25,26 @@ class ConfigGenerator
$crlf = (isset($_SESSION['eol']) && $_SESSION['eol'] == 'win')
? "\r\n"
: "\n";
- $c = $cf->getConfig();
+ $conf = $cf->getConfig();
// header
$ret = '<?php' . $crlf
. '/*' . $crlf
. ' * Generated configuration file' . $crlf
. ' * Generated by: phpMyAdmin '
- . $GLOBALS['PMA_Config']->get('PMA_VERSION')
- . ' setup script' . $crlf
+ . $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']);
+ //servers
+ $ret .= self::_getServerPart($cf, $crlf, $conf['Servers']);
+ unset($conf['Servers']);
// other settings
$persistKeys = $cf->getPersistKeysMap();
- foreach ($c as $k => $v) {
+ foreach ($conf as $k => $v) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $v, $crlf);
if (isset($persistKeys[$k])) {
@@ -157,5 +139,40 @@ class ConfigGenerator
$ret .= ')';
return $ret;
}
+
+ /**
+ * Generate server part of config file
+ *
+ * @param ConfigFile $cf Config file
+ * @param string $crlf Carriage return char
+ * @param array $servers Servers list
+ *
+ * @return string
+ */
+ protected static function _getServerPart(ConfigFile $cf, $crlf, $servers)
+ {
+ if ($cf->getServerCount() === 0) {
+ return null;
+ }
+
+ $ret = "/* Servers configuration */$crlf\$i = 0;" . $crlf . $crlf;
+ foreach ($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;
+ return $ret;
+ }
}
?>