Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
cdc1554519
@ -3091,7 +3091,7 @@ function PMA_replaceBinaryContents($content)
|
||||
* @param binary $data GIS data
|
||||
* @param bool $includeSRID Add SRID to the WKT
|
||||
*
|
||||
* @return GIS data in Well Know Text format
|
||||
* @return string GIS data in Well Know Text format
|
||||
*/
|
||||
function PMA_asWKT($data, $includeSRID = false)
|
||||
{
|
||||
@ -3516,7 +3516,7 @@ function PMA_getGISDatatypes($upper_case = false)
|
||||
*
|
||||
* @param string $gis_string GIS string
|
||||
*
|
||||
* @return GIS data enclosed in 'GeomFromText' function
|
||||
* @return string GIS data enclosed in 'GeomFromText' function
|
||||
*/
|
||||
function PMA_createGISData($gis_string)
|
||||
{
|
||||
|
||||
@ -18,45 +18,45 @@ class ConfigFile
|
||||
* Stores default PMA config from config.default.php
|
||||
* @var array
|
||||
*/
|
||||
private $cfg;
|
||||
private $_cfg;
|
||||
|
||||
/**
|
||||
* Stores original PMA_Config object, not modified by user preferences
|
||||
* @var PMA_Config
|
||||
*/
|
||||
private $orgCfgObject;
|
||||
private $_orgCfgObject;
|
||||
|
||||
/**
|
||||
* Stores allowed values for non-standard fields
|
||||
* @var array
|
||||
*/
|
||||
private $cfgDb;
|
||||
private $_cfgDb;
|
||||
|
||||
/**
|
||||
* Keys which will be always written to config file
|
||||
* @var array
|
||||
*/
|
||||
private $persistKeys = array();
|
||||
private $_persistKeys = array();
|
||||
|
||||
/**
|
||||
* Changes keys while updating config in {@link updateWithGlobalConfig()}
|
||||
* or reading by {@link getConfig()} or {@link getConfigArray()}
|
||||
* @var array
|
||||
*/
|
||||
private $cfgUpdateReadMapping = array();
|
||||
private $_cfgUpdateReadMapping = array();
|
||||
|
||||
/**
|
||||
* Key filter for {@link set()}
|
||||
* @var array|null
|
||||
*/
|
||||
private $setFilter;
|
||||
private $_setFilter;
|
||||
|
||||
/**
|
||||
* Instance id (key in $_SESSION array, separate for each server -
|
||||
* ConfigFile{server id})
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
private $_id;
|
||||
|
||||
/**
|
||||
* Result for {@link _flattenArray()}
|
||||
@ -77,15 +77,15 @@ class ConfigFile
|
||||
private function __construct()
|
||||
{
|
||||
// load default config values
|
||||
$cfg = &$this->cfg;
|
||||
$cfg = &$this->_cfg;
|
||||
include './libraries/config.default.php';
|
||||
$cfg['fontsize'] = '82%';
|
||||
|
||||
// create PMA_Config to read config.inc.php values
|
||||
$this->orgCfgObject = new PMA_Config(CONFIG_FILE);
|
||||
$this->_orgCfgObject = new PMA_Config(CONFIG_FILE);
|
||||
|
||||
// load additional config information
|
||||
$cfg_db = &$this->cfgDb;
|
||||
$cfg_db = &$this->_cfgDb;
|
||||
include './libraries/config.values.php';
|
||||
|
||||
// apply default values overrides
|
||||
@ -95,9 +95,9 @@ class ConfigFile
|
||||
}
|
||||
}
|
||||
|
||||
$this->id = 'ConfigFile' . $GLOBALS['server'];
|
||||
if (!isset($_SESSION[$this->id])) {
|
||||
$_SESSION[$this->id] = array();
|
||||
$this->_id = 'ConfigFile' . $GLOBALS['server'];
|
||||
if (!isset($_SESSION[$this->_id])) {
|
||||
$_SESSION[$this->_id] = array();
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getOrgConfigObj()
|
||||
{
|
||||
return $this->orgCfgObject;
|
||||
return $this->_orgCfgObject;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,12 +129,14 @@ class ConfigFile
|
||||
* they are set to their default values (use only full paths)
|
||||
*
|
||||
* @param array $keys
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPersistKeys($keys)
|
||||
{
|
||||
// checking key presence is much faster than searching so move values
|
||||
// to keys
|
||||
$this->persistKeys = array_flip($keys);
|
||||
$this->_persistKeys = array_flip($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +146,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getPersistKeysMap()
|
||||
{
|
||||
return $this->persistKeys;
|
||||
return $this->_persistKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,45 +154,54 @@ class ConfigFile
|
||||
* this method to set up a filter on {@link set()} method
|
||||
*
|
||||
* @param array|null $keys array of allowed keys or null to remove filter
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAllowedKeys($keys)
|
||||
{
|
||||
if ($keys === null) {
|
||||
$this->setFilter = null;
|
||||
$this->_setFilter = null;
|
||||
return;
|
||||
}
|
||||
// checking key presence is much faster than searching so move values
|
||||
// to keys
|
||||
$this->setFilter = array_flip($keys);
|
||||
$this->_setFilter = array_flip($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets path mapping for updating config in
|
||||
* {@link updateWithGlobalConfig()} or reading
|
||||
* by {@link getConfig()} or {@link getConfigArray()}
|
||||
* @var array
|
||||
*
|
||||
* @param array $mapping
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCfgUpdateReadMapping(array $mapping)
|
||||
{
|
||||
$this->cfgUpdateReadMapping = $mapping;
|
||||
$this->_cfgUpdateReadMapping = $mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets configuration data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetConfigData()
|
||||
{
|
||||
$_SESSION[$this->id] = array();
|
||||
$_SESSION[$this->_id] = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets configuration data (overrides old data)
|
||||
*
|
||||
* @param array $cfg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setConfigData(array $cfg)
|
||||
{
|
||||
$_SESSION[$this->id] = $cfg;
|
||||
$_SESSION[$this->_id] = $cfg;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,6 +210,8 @@ class ConfigFile
|
||||
* @param string $path
|
||||
* @param mixed $value
|
||||
* @param string $canonical_path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($path, $value, $canonical_path = null)
|
||||
{
|
||||
@ -206,30 +219,32 @@ class ConfigFile
|
||||
$canonical_path = $this->getCanonicalPath($path);
|
||||
}
|
||||
// apply key whitelist
|
||||
if ($this->setFilter !== null && !isset($this->setFilter[$canonical_path])) {
|
||||
if ($this->_setFilter !== null
|
||||
&& ! isset($this->_setFilter[$canonical_path])
|
||||
) {
|
||||
return;
|
||||
}
|
||||
// remove if the path isn't protected and it's empty or has a default
|
||||
// value
|
||||
if (!isset($this->persistKeys[$canonical_path])) {
|
||||
if (!isset($this->_persistKeys[$canonical_path])) {
|
||||
$default_value = $this->getDefault($canonical_path);
|
||||
// we need original config values not overwritten by user
|
||||
// preferences to allow for overwriting options set in
|
||||
// config.inc.php with default values
|
||||
$instance_default_value = PMA_array_read(
|
||||
$canonical_path,
|
||||
$this->orgCfgObject->settings
|
||||
$this->_orgCfgObject->settings
|
||||
);
|
||||
if (($value === $default_value && (defined('PMA_SETUP')
|
||||
|| $instance_default_value === $default_value))
|
||||
|| (empty($value) && empty($default_value) && (defined('PMA_SETUP')
|
||||
|| empty($current_global)))
|
||||
) {
|
||||
PMA_array_remove($path, $_SESSION[$this->id]);
|
||||
PMA_array_remove($path, $_SESSION[$this->_id]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PMA_array_write($path, $_SESSION[$this->id], $value);
|
||||
PMA_array_write($path, $_SESSION[$this->_id], $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,6 +255,8 @@ class ConfigFile
|
||||
* @param mixed $value
|
||||
* @param mixed $key
|
||||
* @param mixed $prefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _flattenArray($value, $key, $prefix)
|
||||
{
|
||||
@ -260,7 +277,7 @@ class ConfigFile
|
||||
public function getFlatDefaultConfig()
|
||||
{
|
||||
$this->_flattenArrayResult = array();
|
||||
array_walk($this->cfg, array($this, '_flattenArray'), '');
|
||||
array_walk($this->_cfg, array($this, '_flattenArray'), '');
|
||||
$flat_cfg = $this->_flattenArrayResult;
|
||||
$this->_flattenArrayResult = null;
|
||||
return $flat_cfg;
|
||||
@ -271,6 +288,8 @@ class ConfigFile
|
||||
* (config will contain differences to defaults from config.defaults.php).
|
||||
*
|
||||
* @param array $cfg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateWithGlobalConfig(array $cfg)
|
||||
{
|
||||
@ -284,8 +303,8 @@ class ConfigFile
|
||||
// should be complemented by code reading from generated config
|
||||
// to perform inverse mapping
|
||||
foreach ($flat_cfg as $path => $value) {
|
||||
if (isset($this->cfgUpdateReadMapping[$path])) {
|
||||
$path = $this->cfgUpdateReadMapping[$path];
|
||||
if (isset($this->_cfgUpdateReadMapping[$path])) {
|
||||
$path = $this->_cfgUpdateReadMapping[$path];
|
||||
}
|
||||
$this->set($path, $value, $path);
|
||||
}
|
||||
@ -301,7 +320,7 @@ class ConfigFile
|
||||
*/
|
||||
public function get($path, $default = null)
|
||||
{
|
||||
return PMA_array_read($path, $_SESSION[$this->id], $default);
|
||||
return PMA_array_read($path, $_SESSION[$this->_id], $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +335,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getDefault($canonical_path, $default = null)
|
||||
{
|
||||
return PMA_array_read($canonical_path, $this->cfg, $default);
|
||||
return PMA_array_read($canonical_path, $this->_cfg, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +349,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getValue($path, $default = null)
|
||||
{
|
||||
$v = PMA_array_read($path, $_SESSION[$this->id], null);
|
||||
$v = PMA_array_read($path, $_SESSION[$this->_id], null);
|
||||
if ($v !== null) {
|
||||
return $v;
|
||||
}
|
||||
@ -360,7 +379,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getDbEntry($path, $default = null)
|
||||
{
|
||||
return PMA_array_read($path, $this->cfgDb, $default);
|
||||
return PMA_array_read($path, $this->_cfgDb, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -370,8 +389,8 @@ class ConfigFile
|
||||
*/
|
||||
public function getServerCount()
|
||||
{
|
||||
return isset($_SESSION[$this->id]['Servers'])
|
||||
? count($_SESSION[$this->id]['Servers'])
|
||||
return isset($_SESSION[$this->_id]['Servers'])
|
||||
? count($_SESSION[$this->_id]['Servers'])
|
||||
: 0;
|
||||
}
|
||||
|
||||
@ -382,9 +401,9 @@ class ConfigFile
|
||||
*/
|
||||
public function getServers()
|
||||
{
|
||||
return isset($_SESSION[$this->id]['Servers'])
|
||||
? $_SESSION[$this->id]['Servers']
|
||||
: null;
|
||||
return isset($_SESSION[$this->_id]['Servers'])
|
||||
? $_SESSION[$this->_id]['Servers']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,7 +415,7 @@ class ConfigFile
|
||||
*/
|
||||
function getServerDSN($server)
|
||||
{
|
||||
if (!isset($_SESSION[$this->id]['Servers'][$server])) {
|
||||
if (!isset($_SESSION[$this->_id]['Servers'][$server])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -430,7 +449,7 @@ class ConfigFile
|
||||
*/
|
||||
public function getServerName($id)
|
||||
{
|
||||
if (!isset($_SESSION[$this->id]['Servers'][$id])) {
|
||||
if (!isset($_SESSION[$this->_id]['Servers'][$id])) {
|
||||
return '';
|
||||
}
|
||||
$verbose = $this->get("Servers/$id/verbose");
|
||||
@ -445,24 +464,26 @@ class ConfigFile
|
||||
* Removes server
|
||||
*
|
||||
* @param int $server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeServer($server)
|
||||
{
|
||||
if (!isset($_SESSION[$this->id]['Servers'][$server])) {
|
||||
if (!isset($_SESSION[$this->_id]['Servers'][$server])) {
|
||||
return;
|
||||
}
|
||||
$last_server = $this->getServerCount();
|
||||
|
||||
for ($i = $server; $i < $last_server; $i++) {
|
||||
$_SESSION[$this->id]['Servers'][$i]
|
||||
= $_SESSION[$this->id]['Servers'][$i + 1];
|
||||
$_SESSION[$this->_id]['Servers'][$i]
|
||||
= $_SESSION[$this->_id]['Servers'][$i + 1];
|
||||
}
|
||||
unset($_SESSION[$this->id]['Servers'][$last_server]);
|
||||
unset($_SESSION[$this->_id]['Servers'][$last_server]);
|
||||
|
||||
if (isset($_SESSION[$this->id]['ServerDefault'])
|
||||
&& $_SESSION[$this->id]['ServerDefault'] >= 0
|
||||
if (isset($_SESSION[$this->_id]['ServerDefault'])
|
||||
&& $_SESSION[$this->_id]['ServerDefault'] >= 0
|
||||
) {
|
||||
unset($_SESSION[$this->id]['ServerDefault']);
|
||||
unset($_SESSION[$this->_id]['ServerDefault']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,8 +509,8 @@ class ConfigFile
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$c = $_SESSION[$this->id];
|
||||
foreach ($this->cfgUpdateReadMapping as $map_to => $map_from) {
|
||||
$c = $_SESSION[$this->_id];
|
||||
foreach ($this->_cfgUpdateReadMapping as $map_to => $map_from) {
|
||||
PMA_array_write($map_to, $c, PMA_array_read($map_from, $c));
|
||||
PMA_array_remove($map_from, $c);
|
||||
}
|
||||
@ -504,19 +525,19 @@ class ConfigFile
|
||||
public function getConfigArray()
|
||||
{
|
||||
$this->_flattenArrayResult = array();
|
||||
array_walk($_SESSION[$this->id], array($this, '_flattenArray'), '');
|
||||
array_walk($_SESSION[$this->_id], array($this, '_flattenArray'), '');
|
||||
$c = $this->_flattenArrayResult;
|
||||
$this->_flattenArrayResult = null;
|
||||
|
||||
$persistKeys = array_diff(
|
||||
array_keys($this->persistKeys),
|
||||
array_keys($this->_persistKeys),
|
||||
array_keys($c)
|
||||
);
|
||||
foreach ($persistKeys as $k) {
|
||||
$c[$k] = $this->getDefault($k);
|
||||
}
|
||||
|
||||
foreach ($this->cfgUpdateReadMapping as $map_to => $map_from) {
|
||||
foreach ($this->_cfgUpdateReadMapping as $map_to => $map_from) {
|
||||
if (!isset($c[$map_from])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class Form
|
||||
* Caches field types, indexed by field names
|
||||
* @var array
|
||||
*/
|
||||
private $fieldsTypes;
|
||||
private $_fieldsTypes;
|
||||
|
||||
/**
|
||||
* Constructor, reads default config values
|
||||
@ -67,8 +67,8 @@ class Form
|
||||
public function getOptionType($option_name)
|
||||
{
|
||||
$key = ltrim(substr($option_name, strrpos($option_name, '/')), '/');
|
||||
return isset($this->fieldsTypes[$key])
|
||||
? $this->fieldsTypes[$key]
|
||||
return isset($this->_fieldsTypes[$key])
|
||||
? $this->_fieldsTypes[$key]
|
||||
: null;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ class Form
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads fields' types to $this->fieldsTypes
|
||||
* Reads fields' types to $this->_fieldsTypes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -178,7 +178,7 @@ class Form
|
||||
$cf = ConfigFile::getInstance();
|
||||
foreach ($this->fields as $name => $path) {
|
||||
if (strpos($name, ':group:') === 0) {
|
||||
$this->fieldsTypes[$name] = 'group';
|
||||
$this->_fieldsTypes[$name] = 'group';
|
||||
continue;
|
||||
}
|
||||
$v = $cf->getDbEntry($path);
|
||||
@ -187,7 +187,7 @@ class Form
|
||||
} else {
|
||||
$type = gettype($cf->getDefault($path));
|
||||
}
|
||||
$this->fieldsTypes[$name] = $type;
|
||||
$this->_fieldsTypes[$name] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,8 @@ require_once './libraries/js_escape.lib.php';
|
||||
|
||||
/**
|
||||
* Form management class, displays and processes forms
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class FormDisplay
|
||||
{
|
||||
@ -29,7 +31,7 @@ class FormDisplay
|
||||
* Form list
|
||||
* @var Form[]
|
||||
*/
|
||||
private $forms = array();
|
||||
private $_forms = array();
|
||||
|
||||
/**
|
||||
* Stores validation errors, indexed by paths
|
||||
@ -37,49 +39,52 @@ class FormDisplay
|
||||
* [path] is a string storing error associated with single field
|
||||
* @var array
|
||||
*/
|
||||
private $errors = array();
|
||||
private $_errors = array();
|
||||
|
||||
/**
|
||||
* Paths changed so that they can be used as HTML ids, indexed by paths
|
||||
* @var array
|
||||
*/
|
||||
private $translated_paths = array();
|
||||
private $_translated_paths = array();
|
||||
|
||||
/**
|
||||
* Server paths change indexes so we define maps from current server
|
||||
* path to the first one, indexed by work path
|
||||
* @var array
|
||||
*/
|
||||
private $system_paths = array();
|
||||
private $_system_paths = array();
|
||||
|
||||
/**
|
||||
* Language strings which will be sent to PMA_messages JS variable
|
||||
* Will be looked up in $GLOBALS: str{value} or strSetup{value}
|
||||
* @var array
|
||||
*/
|
||||
private $js_lang_strings = array();
|
||||
private $_js_lang_strings = array();
|
||||
|
||||
/**
|
||||
* Tells whether forms have been validated
|
||||
* @var bool
|
||||
*/
|
||||
private $is_validated = true;
|
||||
private $_is_validated = true;
|
||||
|
||||
/**
|
||||
* Dictionary with user preferences keys
|
||||
* @var array
|
||||
*/
|
||||
private $userprefs_keys;
|
||||
private $_userprefs_keys;
|
||||
|
||||
/**
|
||||
* Dictionary with disallowed user preferences keys
|
||||
* @var array
|
||||
*/
|
||||
private $userprefs_disallow;
|
||||
private $_userprefs_disallow;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->js_lang_strings = array(
|
||||
$this->_js_lang_strings = array(
|
||||
'error_nan_p' => __('Not a positive number'),
|
||||
'error_nan_nneg' => __('Not a non-negative number'),
|
||||
'error_incorrect_port' => __('Not a valid port number'),
|
||||
@ -95,17 +100,19 @@ class FormDisplay
|
||||
* @param string $form_name
|
||||
* @param array $form
|
||||
* @param int $server_id 0 if new server, validation; >= 1 if editing a server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerForm($form_name, array $form, $server_id = null)
|
||||
{
|
||||
$this->forms[$form_name] = new Form($form_name, $form, $server_id);
|
||||
$this->is_validated = false;
|
||||
foreach ($this->forms[$form_name]->fields as $path) {
|
||||
$this->_forms[$form_name] = new Form($form_name, $form, $server_id);
|
||||
$this->_is_validated = false;
|
||||
foreach ($this->_forms[$form_name]->fields as $path) {
|
||||
$work_path = $server_id === null
|
||||
? $path
|
||||
: str_replace('Servers/1/', "Servers/$server_id/", $path);
|
||||
$this->system_paths[$work_path] = $path;
|
||||
$this->translated_paths[$work_path] = str_replace('/', '-', $work_path);
|
||||
$this->_system_paths[$work_path] = $path;
|
||||
$this->_translated_paths[$work_path] = str_replace('/', '-', $work_path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,8 +132,8 @@ class FormDisplay
|
||||
}
|
||||
|
||||
// save forms
|
||||
if (count($this->forms) > 0) {
|
||||
return $this->save(array_keys($this->forms), $allow_partial_save);
|
||||
if (count($this->_forms) > 0) {
|
||||
return $this->save(array_keys($this->_forms), $allow_partial_save);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -138,19 +145,19 @@ class FormDisplay
|
||||
*/
|
||||
private function _validate()
|
||||
{
|
||||
if ($this->is_validated) {
|
||||
if ($this->_is_validated) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cf = ConfigFile::getInstance();
|
||||
$paths = array();
|
||||
$values = array();
|
||||
foreach ($this->forms as $form) {
|
||||
foreach ($this->_forms as $form) {
|
||||
/* @var $form Form */
|
||||
$paths[] = $form->name;
|
||||
// collect values and paths
|
||||
foreach ($form->fields as $path) {
|
||||
$work_path = array_search($path, $this->system_paths);
|
||||
$work_path = array_search($path, $this->_system_paths);
|
||||
$values[$path] = $cf->getValue($work_path);
|
||||
$paths[] = $path;
|
||||
}
|
||||
@ -161,18 +168,18 @@ class FormDisplay
|
||||
|
||||
// change error keys from canonical paths to work paths
|
||||
if (is_array($errors) && count($errors) > 0) {
|
||||
$this->errors = array();
|
||||
$this->_errors = array();
|
||||
foreach ($errors as $path => $error_list) {
|
||||
$work_path = array_search($path, $this->system_paths);
|
||||
$work_path = array_search($path, $this->_system_paths);
|
||||
// field error
|
||||
if (!$work_path) {
|
||||
// form error, fix path
|
||||
$work_path = $path;
|
||||
}
|
||||
$this->errors[$work_path] = $error_list;
|
||||
$this->_errors[$work_path] = $error_list;
|
||||
}
|
||||
}
|
||||
$this->is_validated = true;
|
||||
$this->_is_validated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,14 +196,14 @@ class FormDisplay
|
||||
|
||||
$js = array();
|
||||
$js_default = array();
|
||||
$tabbed_form = $tabbed_form && (count($this->forms) > 1);
|
||||
$tabbed_form = $tabbed_form && (count($this->_forms) > 1);
|
||||
$validators = PMA_config_get_validators();
|
||||
|
||||
display_form_top();
|
||||
|
||||
if ($tabbed_form) {
|
||||
$tabs = array();
|
||||
foreach ($this->forms as $form) {
|
||||
foreach ($this->_forms as $form) {
|
||||
$tabs[$form->name] = PMA_lang("Form_$form->name");
|
||||
}
|
||||
display_tabs_top($tabs);
|
||||
@ -204,7 +211,7 @@ class FormDisplay
|
||||
|
||||
// valdiate only when we aren't displaying a "new server" form
|
||||
$is_new_server = false;
|
||||
foreach ($this->forms as $form) {
|
||||
foreach ($this->_forms as $form) {
|
||||
/* @var $form Form */
|
||||
if ($form->index === 0) {
|
||||
$is_new_server = true;
|
||||
@ -219,13 +226,13 @@ class FormDisplay
|
||||
$this->_loadUserprefsInfo();
|
||||
|
||||
// display forms
|
||||
foreach ($this->forms as $form) {
|
||||
foreach ($this->_forms as $form) {
|
||||
/* @var $form Form */
|
||||
$form_desc = isset($GLOBALS["strConfigForm_{$form->name}_desc"])
|
||||
? PMA_lang("Form_{$form->name}_desc")
|
||||
: '';
|
||||
$form_errors = isset($this->errors[$form->name])
|
||||
? $this->errors[$form->name] : null;
|
||||
$form_errors = isset($this->_errors[$form->name])
|
||||
? $this->_errors[$form->name] : null;
|
||||
display_fieldset_top(
|
||||
PMA_lang("Form_$form->name"),
|
||||
$form_desc,
|
||||
@ -234,12 +241,12 @@ class FormDisplay
|
||||
);
|
||||
|
||||
foreach ($form->fields as $field => $path) {
|
||||
$work_path = array_search($path, $this->system_paths);
|
||||
$translated_path = $this->translated_paths[$work_path];
|
||||
$work_path = array_search($path, $this->_system_paths);
|
||||
$translated_path = $this->_translated_paths[$work_path];
|
||||
// always true/false for user preferences display
|
||||
// otherwise null
|
||||
$userprefs_allow = isset($this->userprefs_keys[$path])
|
||||
? !isset($this->userprefs_disallow[$path])
|
||||
$userprefs_allow = isset($this->_userprefs_keys[$path])
|
||||
? !isset($this->_userprefs_disallow[$path])
|
||||
: null;
|
||||
// display input
|
||||
$this->_displayFieldInput(
|
||||
@ -269,7 +276,7 @@ class FormDisplay
|
||||
if (!$js_lang_sent) {
|
||||
$js_lang_sent = true;
|
||||
$js_lang = array();
|
||||
foreach ($this->js_lang_strings as $strName => $strValue) {
|
||||
foreach ($this->_js_lang_strings as $strName => $strValue) {
|
||||
$js_lang[] = "'$strName': '" . PMA_jsFormat($strValue, false) . '\'';
|
||||
}
|
||||
$js[] = "$.extend(PMA_messages, {\n\t" . implode(",\n\t", $js_lang) . '})';
|
||||
@ -324,8 +331,8 @@ class FormDisplay
|
||||
$opts['setvalue'] = $form->default[$system_path];
|
||||
}
|
||||
|
||||
if (isset($this->errors[$work_path])) {
|
||||
$opts['errors'] = $this->errors[$work_path];
|
||||
if (isset($this->_errors[$work_path])) {
|
||||
$opts['errors'] = $this->_errors[$work_path];
|
||||
}
|
||||
switch ($form->getOptionType($field)) {
|
||||
case 'string':
|
||||
@ -411,13 +418,13 @@ class FormDisplay
|
||||
public function displayErrors()
|
||||
{
|
||||
$this->_validate();
|
||||
if (count($this->errors) == 0) {
|
||||
if (count($this->_errors) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->errors as $system_path => $error_list) {
|
||||
if (isset($this->system_paths[$system_path])) {
|
||||
$path = $this->system_paths[$system_path];
|
||||
foreach ($this->_errors as $system_path => $error_list) {
|
||||
if (isset($this->_system_paths[$system_path])) {
|
||||
$path = $this->_system_paths[$system_path];
|
||||
$name = PMA_lang_name($path);
|
||||
} else {
|
||||
$name = $GLOBALS["strConfigForm_$system_path"];
|
||||
@ -434,16 +441,16 @@ class FormDisplay
|
||||
public function fixErrors()
|
||||
{
|
||||
$this->_validate();
|
||||
if (count($this->errors) == 0) {
|
||||
if (count($this->_errors) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cf = ConfigFile::getInstance();
|
||||
foreach (array_keys($this->errors) as $work_path) {
|
||||
if (!isset($this->system_paths[$work_path])) {
|
||||
foreach (array_keys($this->_errors) as $work_path) {
|
||||
if (!isset($this->_system_paths[$work_path])) {
|
||||
continue;
|
||||
}
|
||||
$canonical_path = $this->system_paths[$work_path];
|
||||
$canonical_path = $this->_system_paths[$work_path];
|
||||
$cf->set($work_path, $cf->getDefault($canonical_path));
|
||||
}
|
||||
}
|
||||
@ -500,11 +507,11 @@ class FormDisplay
|
||||
$this->_loadUserprefsInfo();
|
||||
}
|
||||
|
||||
$this->errors = array();
|
||||
$this->_errors = array();
|
||||
foreach ($forms as $form_name) {
|
||||
/* @var $form Form */
|
||||
if (isset($this->forms[$form_name])) {
|
||||
$form = $this->forms[$form_name];
|
||||
if (isset($this->_forms[$form_name])) {
|
||||
$form = $this->_forms[$form_name];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@ -514,8 +521,8 @@ class FormDisplay
|
||||
: false;
|
||||
// grab POST values
|
||||
foreach ($form->fields as $field => $system_path) {
|
||||
$work_path = array_search($system_path, $this->system_paths);
|
||||
$key = $this->translated_paths[$work_path];
|
||||
$work_path = array_search($system_path, $this->_system_paths);
|
||||
$key = $this->_translated_paths[$work_path];
|
||||
$type = $form->getOptionType($field);
|
||||
|
||||
// skip groups
|
||||
@ -529,7 +536,7 @@ class FormDisplay
|
||||
if ($type == 'boolean') {
|
||||
$_POST[$key] = false;
|
||||
} else {
|
||||
$this->errors[$form->name][] = sprintf(
|
||||
$this->_errors[$form->name][] = sprintf(
|
||||
__('Missing data for %s'),
|
||||
'<i>' . PMA_lang_name($system_path) . '</i>'
|
||||
);
|
||||
@ -539,13 +546,15 @@ class FormDisplay
|
||||
}
|
||||
|
||||
// user preferences allow/disallow
|
||||
if ($is_setup_script && isset($this->userprefs_keys[$system_path])) {
|
||||
if (isset($this->userprefs_disallow[$system_path])
|
||||
if ($is_setup_script
|
||||
&& isset($this->_userprefs_keys[$system_path])
|
||||
) {
|
||||
if (isset($this->_userprefs_disallow[$system_path])
|
||||
&& isset($_POST[$key . '-userprefs-allow'])
|
||||
) {
|
||||
unset($this->userprefs_disallow[$system_path]);
|
||||
unset($this->_userprefs_disallow[$system_path]);
|
||||
} else if (!isset($_POST[$key . '-userprefs-allow'])) {
|
||||
$this->userprefs_disallow[$system_path] = true;
|
||||
$this->_userprefs_disallow[$system_path] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,7 +583,7 @@ class FormDisplay
|
||||
$form->getOptionValueList($system_path)
|
||||
);
|
||||
if (! $successfully_validated) {
|
||||
$this->errors[$work_path][] = __('Incorrect value');
|
||||
$this->_errors[$work_path][] = __('Incorrect value');
|
||||
$result = false;
|
||||
continue;
|
||||
}
|
||||
@ -611,7 +620,7 @@ class FormDisplay
|
||||
}
|
||||
|
||||
// save forms
|
||||
if ($allow_partial_save || empty($this->errors)) {
|
||||
if ($allow_partial_save || empty($this->_errors)) {
|
||||
foreach ($to_save as $work_path => $path) {
|
||||
// TrustedProxies requires changes before saving
|
||||
if ($path == 'TrustedProxies') {
|
||||
@ -637,7 +646,10 @@ class FormDisplay
|
||||
$cf->set($work_path, $values[$path], $path);
|
||||
}
|
||||
if ($is_setup_script) {
|
||||
$cf->set('UserprefsDisallow', array_keys($this->userprefs_disallow));
|
||||
$cf->set(
|
||||
'UserprefsDisallow',
|
||||
array_keys($this->_userprefs_disallow)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -654,7 +666,7 @@ class FormDisplay
|
||||
*/
|
||||
public function hasErrors()
|
||||
{
|
||||
return count($this->errors) > 0;
|
||||
return count($this->_errors) > 0;
|
||||
}
|
||||
|
||||
|
||||
@ -722,13 +734,13 @@ class FormDisplay
|
||||
*/
|
||||
private function _loadUserprefsInfo()
|
||||
{
|
||||
if ($this->userprefs_keys === null) {
|
||||
$this->userprefs_keys = array_flip(PMA_read_userprefs_fieldnames());
|
||||
if ($this->_userprefs_keys === null) {
|
||||
$this->_userprefs_keys = array_flip(PMA_read_userprefs_fieldnames());
|
||||
// read real config for user preferences display
|
||||
$userprefs_disallow = defined('PMA_SETUP')
|
||||
? ConfigFile::getInstance()->get('UserprefsDisallow', array())
|
||||
: $GLOBALS['cfg']['UserprefsDisallow'];
|
||||
$this->userprefs_disallow = array_flip($userprefs_disallow);
|
||||
$this->_userprefs_disallow = array_flip($userprefs_disallow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user