Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-04-26 20:16:47 +02:00
commit 57ace83cc0
2 changed files with 58 additions and 70 deletions

View File

@ -125,28 +125,27 @@ class PMA_DBI_Drizzle implements PMA_DBI_Extension
$client_flags |= DRIZZLE_CAPABILITIES_SSL;
}
if (! $server) {
$link = @$this->_realConnect(
$drizzle, $cfg['Server']['host'],
$server_port, $server_socket, $user,
$password, false, $client_flags
);
// Retry with empty password if we're allowed to
if ($link == false && isset($cfg['Server']['nopassword'])
&& $cfg['Server']['nopassword'] && ! $is_controluser
) {
$link = @$this->_realConnect(
$drizzle, $cfg['Server']['host'], $server_port, $server_socket,
$user, null, false, $client_flags
);
}
} else {
$link = @$this->_realConnect(
if ($server) {
return @$this->_realConnect(
$drizzle, $server['host'], $server_port, $server_socket,
$user, $password
);
}
$link = @$this->_realConnect(
$drizzle, $cfg['Server']['host'], $server_port, $server_socket, $user,
$password, false, $client_flags
);
// Retry with empty password if we're allowed to
if ($link == false && isset($cfg['Server']['nopassword'])
&& $cfg['Server']['nopassword'] && ! $is_controluser
) {
$link = @$this->_realConnect(
$drizzle, $cfg['Server']['host'], $server_port, $server_socket,
$user, null, false, $client_flags
);
}
return $link;
}
@ -395,34 +394,6 @@ class PMA_DBI_Drizzle implements PMA_DBI_Extension
{
// Build an associative array for a type look up
$typeAr = array();
/*$typeAr[DRIZZLE_COLUMN_TYPE_DECIMAL] = 'real';
$typeAr[DRIZZLE_COLUMN_TYPE_NEWDECIMAL] = 'real';
$typeAr[DRIZZLE_COLUMN_TYPE_BIT] = 'int';
$typeAr[DRIZZLE_COLUMN_TYPE_TINY] = 'int';
$typeAr[DRIZZLE_COLUMN_TYPE_SHORT] = 'int';
$typeAr[DRIZZLE_COLUMN_TYPE_LONG] = 'int';
$typeAr[DRIZZLE_COLUMN_TYPE_FLOAT] = 'real';
$typeAr[DRIZZLE_COLUMN_TYPE_DOUBLE] = 'real';
$typeAr[DRIZZLE_COLUMN_TYPE_NULL] = 'null';
$typeAr[DRIZZLE_COLUMN_TYPE_TIMESTAMP] = 'timestamp';
$typeAr[DRIZZLE_COLUMN_TYPE_LONGLONG] = 'int';
$typeAr[DRIZZLE_COLUMN_TYPE_INT24] = 'int';
$typeAr[DRIZZLE_COLUMN_TYPE_DATE] = 'date';
$typeAr[DRIZZLE_COLUMN_TYPE_TIME] = 'date';
$typeAr[DRIZZLE_COLUMN_TYPE_DATETIME] = 'datetime';
$typeAr[DRIZZLE_COLUMN_TYPE_YEAR] = 'year';
$typeAr[DRIZZLE_COLUMN_TYPE_NEWDATE] = 'date';
$typeAr[DRIZZLE_COLUMN_TYPE_ENUM] = 'unknown';
$typeAr[DRIZZLE_COLUMN_TYPE_SET] = 'unknown';
$typeAr[DRIZZLE_COLUMN_TYPE_VIRTUAL] = 'unknown';
$typeAr[DRIZZLE_COLUMN_TYPE_TINY_BLOB] = 'blob';
$typeAr[DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB] = 'blob';
$typeAr[DRIZZLE_COLUMN_TYPE_LONG_BLOB] = 'blob';
$typeAr[DRIZZLE_COLUMN_TYPE_BLOB] = 'blob';
$typeAr[DRIZZLE_COLUMN_TYPE_VAR_STRING] = 'string';
$typeAr[DRIZZLE_COLUMN_TYPE_VARCHAR] = 'string';
$typeAr[DRIZZLE_COLUMN_TYPE_STRING] = 'string';
$typeAr[DRIZZLE_COLUMN_TYPE_GEOMETRY] = 'geometry';*/
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB] = 'blob';
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE] = 'date';

View File

@ -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;
}
}
?>