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
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauriciofauth@gmail.com>2018-06-02 06:05:28 +0300
committerMaurício Meneghini Fauth <mauriciofauth@gmail.com>2018-06-05 03:25:24 +0300
commit010a72dc00b56fc26bb7d57718b63f82904ed800 (patch)
tree226227545bc4cfeddccf3dac14f2e55f95a867a5
parent463cc03f4493e411a193abe6919c3db44c5150df (diff)
Use camelCase for variable names
PhpMyAdmin\Config\* classes Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
-rw-r--r--libraries/classes/Config/ConfigFile.php86
-rw-r--r--libraries/classes/Config/Form.php50
-rw-r--r--libraries/classes/Config/FormDisplay.php390
-rw-r--r--libraries/classes/Config/FormDisplayTemplate.php159
-rw-r--r--libraries/classes/Config/Forms/BaseForm.php10
-rw-r--r--libraries/classes/Config/Forms/BaseFormList.php10
-rw-r--r--libraries/classes/Config/PageSettings.php40
-rw-r--r--libraries/classes/Config/Validator.php106
8 files changed, 428 insertions, 423 deletions
diff --git a/libraries/classes/Config/ConfigFile.php b/libraries/classes/Config/ConfigFile.php
index 968614a619..17a17cc123 100644
--- a/libraries/classes/Config/ConfigFile.php
+++ b/libraries/classes/Config/ConfigFile.php
@@ -79,11 +79,11 @@ class ConfigFile
/**
* Constructor
*
- * @param array|null $base_config base configuration read from
- * {@link PhpMyAdmin\Config::$base_config},
- * use only when not in PMA Setup
+ * @param array|null $baseConfig base configuration read from
+ * {@link PhpMyAdmin\Config::$base_config},
+ * use only when not in PMA Setup
*/
- public function __construct($base_config = null)
+ public function __construct($baseConfig = null)
{
// load default config values
$cfg = &$this->_defaultCfg;
@@ -99,8 +99,8 @@ class ConfigFile
}
}
- $this->_baseCfg = $base_config;
- $this->_isInSetup = is_null($base_config);
+ $this->_baseCfg = $baseConfig;
+ $this->_isInSetup = is_null($baseConfig);
$this->_id = 'ConfigFile' . $GLOBALS['server'];
if (!isset($_SESSION[$this->_id])) {
$_SESSION[$this->_id] = [];
@@ -191,49 +191,49 @@ class ConfigFile
/**
* Sets config value
*
- * @param string $path Path
- * @param mixed $value Value
- * @param string $canonical_path Canonical path
+ * @param string $path Path
+ * @param mixed $value Value
+ * @param string $canonicalPath Canonical path
*
* @return void
*/
- public function set($path, $value, $canonical_path = null)
+ public function set($path, $value, $canonicalPath = null)
{
- if ($canonical_path === null) {
- $canonical_path = $this->getCanonicalPath($path);
+ if ($canonicalPath === null) {
+ $canonicalPath = $this->getCanonicalPath($path);
}
// apply key whitelist
if ($this->_setFilter !== null
- && ! isset($this->_setFilter[$canonical_path])
+ && ! isset($this->_setFilter[$canonicalPath])
) {
return;
}
// if the path isn't protected it may be removed
- if (isset($this->_persistKeys[$canonical_path])) {
+ if (isset($this->_persistKeys[$canonicalPath])) {
Core::arrayWrite($path, $_SESSION[$this->_id], $value);
return;
}
- $default_value = $this->getDefault($canonical_path);
- $remove_path = $value === $default_value;
+ $defaultValue = $this->getDefault($canonicalPath);
+ $removePath = $value === $defaultValue;
if ($this->_isInSetup) {
// remove if it has a default value or is empty
- $remove_path = $remove_path
- || (empty($value) && empty($default_value));
+ $removePath = $removePath
+ || (empty($value) && empty($defaultValue));
} else {
// get original config values not overwritten by user
// preferences to allow for overwriting options set in
// config.inc.php with default values
- $instance_default_value = Core::arrayRead(
- $canonical_path,
+ $instanceDefaultValue = Core::arrayRead(
+ $canonicalPath,
$this->_baseCfg
);
// remove if it has a default value and base config (config.inc.php)
// uses default value
- $remove_path = $remove_path
- && ($instance_default_value === $default_value);
+ $removePath = $removePath
+ && ($instanceDefaultValue === $defaultValue);
}
- if ($remove_path) {
+ if ($removePath) {
Core::arrayRemove($path, $_SESSION[$this->_id]);
return;
}
@@ -272,9 +272,9 @@ class ConfigFile
{
$this->_flattenArrayResult = [];
array_walk($this->_defaultCfg, [$this, '_flattenArray'], '');
- $flat_cfg = $this->_flattenArrayResult;
+ $flatConfig = $this->_flattenArrayResult;
$this->_flattenArrayResult = null;
- return $flat_cfg;
+ return $flatConfig;
}
/**
@@ -290,13 +290,13 @@ class ConfigFile
// load config array and flatten it
$this->_flattenArrayResult = [];
array_walk($cfg, [$this, '_flattenArray'], '');
- $flat_cfg = $this->_flattenArrayResult;
+ $flatConfig = $this->_flattenArrayResult;
$this->_flattenArrayResult = null;
// save values map for translating a few user preferences paths,
// should be complemented by code reading from generated config
// to perform inverse mapping
- foreach ($flat_cfg as $path => $value) {
+ foreach ($flatConfig as $path => $value) {
if (isset($this->_cfgUpdateReadMapping[$path])) {
$path = $this->_cfgUpdateReadMapping[$path];
}
@@ -322,14 +322,14 @@ class ConfigFile
* exist in config.default.php ($cfg) and config.values.php
* ($_cfg_db['_overrides'])
*
- * @param string $canonical_path Canonical path
- * @param mixed $default Default value
+ * @param string $canonicalPath Canonical path
+ * @param mixed $default Default value
*
* @return mixed
*/
- public function getDefault($canonical_path, $default = null)
+ public function getDefault($canonicalPath, $default = null)
{
- return Core::arrayRead($canonical_path, $this->_defaultCfg, $default);
+ return Core::arrayRead($canonicalPath, $this->_defaultCfg, $default);
}
/**
@@ -466,16 +466,16 @@ class ConfigFile
if (!isset($_SESSION[$this->_id]['Servers'][$server])) {
return;
}
- $last_server = $this->getServerCount();
+ $lastServer = $this->getServerCount();
- for ($i = $server; $i < $last_server; $i++) {
+ for ($i = $server; $i < $lastServer; $i++) {
$_SESSION[$this->_id]['Servers'][$i]
= $_SESSION[$this->_id]['Servers'][$i + 1];
}
- unset($_SESSION[$this->_id]['Servers'][$last_server]);
+ unset($_SESSION[$this->_id]['Servers'][$lastServer]);
if (isset($_SESSION[$this->_id]['ServerDefault'])
- && $_SESSION[$this->_id]['ServerDefault'] == $last_server
+ && $_SESSION[$this->_id]['ServerDefault'] == $lastServer
) {
unset($_SESSION[$this->_id]['ServerDefault']);
}
@@ -489,11 +489,11 @@ class ConfigFile
public function getConfig()
{
$c = $_SESSION[$this->_id];
- foreach ($this->_cfgUpdateReadMapping as $map_to => $map_from) {
+ foreach ($this->_cfgUpdateReadMapping as $mapTo => $mapFrom) {
// if the key $c exists in $map_to
- if (Core::arrayRead($map_to, $c) !== null) {
- Core::arrayWrite($map_to, $c, Core::arrayRead($map_from, $c));
- Core::arrayRemove($map_from, $c);
+ if (Core::arrayRead($mapTo, $c) !== null) {
+ Core::arrayWrite($mapTo, $c, Core::arrayRead($mapFrom, $c));
+ Core::arrayRemove($mapFrom, $c);
}
}
return $c;
@@ -519,12 +519,12 @@ class ConfigFile
$c[$k] = $this->getDefault($this->getCanonicalPath($k));
}
- foreach ($this->_cfgUpdateReadMapping as $map_to => $map_from) {
- if (!isset($c[$map_from])) {
+ foreach ($this->_cfgUpdateReadMapping as $mapTo => $mapFrom) {
+ if (!isset($c[$mapFrom])) {
continue;
}
- $c[$map_to] = $c[$map_from];
- unset($c[$map_from]);
+ $c[$mapTo] = $c[$mapFrom];
+ unset($c[$mapFrom]);
}
return $c;
}
diff --git a/libraries/classes/Config/Form.php b/libraries/classes/Config/Form.php
index d3cb0f433c..0d3bc9c017 100644
--- a/libraries/classes/Config/Form.php
+++ b/libraries/classes/Config/Form.php
@@ -58,35 +58,35 @@ class Form
/**
* Constructor, reads default config values
*
- * @param string $form_name Form name
- * @param array $form Form data
- * @param ConfigFile $cf Config file instance
- * @param int $index arbitrary index, stored in Form::$index
+ * @param string $formName Form name
+ * @param array $form Form data
+ * @param ConfigFile $cf Config file instance
+ * @param int $index arbitrary index, stored in Form::$index
*/
public function __construct(
- $form_name,
+ $formName,
array $form,
ConfigFile $cf,
$index = null
) {
$this->index = $index;
$this->_configFile = $cf;
- $this->loadForm($form_name, $form);
+ $this->loadForm($formName, $form);
}
/**
* Returns type of given option
*
- * @param string $option_name path or field name
+ * @param string $optionName path or field name
*
- * @return string|null one of: boolean, integer, double, string, select, array
+ * @return string|null one of: boolean, integer, double, string, select, array
*/
- public function getOptionType($option_name)
+ public function getOptionType($optionName)
{
$key = ltrim(
mb_substr(
- $option_name,
- (int) mb_strrpos($option_name, '/')
+ $optionName,
+ (int) mb_strrpos($optionName, '/')
),
'/'
);
@@ -98,19 +98,19 @@ class Form
/**
* Returns allowed values for select fields
*
- * @param string $option_path Option path
+ * @param string $optionPath Option path
*
* @return array
*/
- public function getOptionValueList($option_path)
+ public function getOptionValueList($optionPath)
{
- $value = $this->_configFile->getDbEntry($option_path);
+ $value = $this->_configFile->getDbEntry($optionPath);
if ($value === null) {
- trigger_error("$option_path - select options not defined", E_USER_ERROR);
+ trigger_error("$optionPath - select options not defined", E_USER_ERROR);
return [];
}
if (!is_array($value)) {
- trigger_error("$option_path - not a static value list", E_USER_ERROR);
+ trigger_error("$optionPath - not a static value list", E_USER_ERROR);
return [];
}
// convert array('#', 'a', 'b') to array('a', 'b')
@@ -122,16 +122,16 @@ class Form
}
// convert value list array('a', 'b') to array('a' => 'a', 'b' => 'b')
- $has_string_keys = false;
+ $hasStringKeys = false;
$keys = [];
for ($i = 0, $nb = count($value); $i < $nb; $i++) {
if (!isset($value[$i])) {
- $has_string_keys = true;
+ $hasStringKeys = true;
break;
}
$keys[] = is_bool($value[$i]) ? (int)$value[$i] : $value[$i];
}
- if (! $has_string_keys) {
+ if (! $hasStringKeys) {
$value = array_combine($keys, $value);
}
@@ -151,7 +151,7 @@ class Form
*/
private function _readFormPathsCallback($value, $key, $prefix)
{
- static $group_counter = 0;
+ static $groupCounter = 0;
if (is_array($value)) {
$prefix .= $key . '/';
@@ -165,7 +165,7 @@ class Form
}
// add unique id to group ends
if ($value == ':group:end') {
- $value .= ':' . $group_counter++;
+ $value .= ':' . $groupCounter++;
}
$this->fields[] = $prefix . $value;
}
@@ -224,14 +224,14 @@ class Form
* Reads form settings and prepares class to work with given subset of
* config file
*
- * @param string $form_name Form name
- * @param array $form Form
+ * @param string $formName Form name
+ * @param array $form Form
*
* @return void
*/
- public function loadForm($form_name, array $form)
+ public function loadForm($formName, array $form)
{
- $this->name = $form_name;
+ $this->name = $formName;
$this->readFormPaths($form);
$this->readTypes();
}
diff --git a/libraries/classes/Config/FormDisplay.php b/libraries/classes/Config/FormDisplay.php
index 9f10d82b70..7166756a76 100644
--- a/libraries/classes/Config/FormDisplay.php
+++ b/libraries/classes/Config/FormDisplay.php
@@ -121,48 +121,48 @@ class FormDisplay
/**
* Registers form in form manager
*
- * @param string $form_name Form name
- * @param array $form Form data
- * @param int $server_id 0 if new server, validation; >= 1 if editing a server
+ * @param string $formName Form name
+ * @param array $form Form data
+ * @param int $serverId 0 if new server, validation; >= 1 if editing a server
*
* @return void
*/
- public function registerForm($form_name, array $form, $server_id = null)
+ public function registerForm($formName, array $form, $serverId = null)
{
- $this->_forms[$form_name] = new Form(
- $form_name,
+ $this->_forms[$formName] = new Form(
+ $formName,
$form,
$this->_configFile,
- $server_id
+ $serverId
);
$this->_isValidated = false;
- foreach ($this->_forms[$form_name]->fields as $path) {
- $work_path = $server_id === null
+ foreach ($this->_forms[$formName]->fields as $path) {
+ $workPath = $serverId === null
? $path
- : str_replace('Servers/1/', "Servers/$server_id/", $path);
- $this->_systemPaths[$work_path] = $path;
- $this->_translatedPaths[$work_path] = str_replace('/', '-', $work_path);
+ : str_replace('Servers/1/', "Servers/$serverId/", $path);
+ $this->_systemPaths[$workPath] = $path;
+ $this->_translatedPaths[$workPath] = str_replace('/', '-', $workPath);
}
}
/**
* Processes forms, returns true on successful save
*
- * @param bool $allow_partial_save allows for partial form saving
- * on failed validation
- * @param bool $check_form_submit whether check for $_POST['submit_save']
+ * @param bool $allowPartialSave allows for partial form saving
+ * on failed validation
+ * @param bool $checkFormSubmit whether check for $_POST['submit_save']
*
* @return boolean whether processing was successful
*/
- public function process($allow_partial_save = true, $check_form_submit = true)
+ public function process($allowPartialSave = true, $checkFormSubmit = true)
{
- if ($check_form_submit && !isset($_POST['submit_save'])) {
+ if ($checkFormSubmit && !isset($_POST['submit_save'])) {
return false;
}
// save forms
if (count($this->_forms) > 0) {
- return $this->save(array_keys($this->_forms), $allow_partial_save);
+ return $this->save(array_keys($this->_forms), $allowPartialSave);
}
return false;
}
@@ -185,8 +185,8 @@ class FormDisplay
$paths[] = $form->name;
// collect values and paths
foreach ($form->fields as $path) {
- $work_path = array_search($path, $this->_systemPaths);
- $values[$path] = $this->_configFile->getValue($work_path);
+ $workPath = array_search($path, $this->_systemPaths);
+ $values[$path] = $this->_configFile->getValue($workPath);
$paths[] = $path;
}
}
@@ -202,14 +202,14 @@ class FormDisplay
// change error keys from canonical paths to work paths
if (is_array($errors) && count($errors) > 0) {
$this->_errors = [];
- foreach ($errors as $path => $error_list) {
- $work_path = array_search($path, $this->_systemPaths);
+ foreach ($errors as $path => $errorList) {
+ $workPath = array_search($path, $this->_systemPaths);
// field error
- if (! $work_path) {
+ if (! $workPath) {
// form error, fix path
- $work_path = $path;
+ $workPath = $path;
}
- $this->_errors[$work_path] = $error_list;
+ $this->_errors[$workPath] = $errorList;
}
}
$this->_isValidated = true;
@@ -218,41 +218,41 @@ class FormDisplay
/**
* Outputs HTML for the forms under the menu tab
*
- * @param bool $show_restore_default whether to show "restore default"
- * button besides the input field
- * @param array &$js_default stores JavaScript code
- * to be displayed
- * @param array &$js will be updated with javascript code
- * @param bool $show_buttons whether show submit and reset button
+ * @param bool $showRestoreDefault whether to show "restore default"
+ * button besides the input field
+ * @param array &$jsDefault stores JavaScript code
+ * to be displayed
+ * @param array &$js will be updated with javascript code
+ * @param bool $showButtons whether show submit and reset button
*
* @return string $htmlOutput
*/
private function _displayForms(
- $show_restore_default,
- array &$js_default,
+ $showRestoreDefault,
+ array &$jsDefault,
array &$js,
- $show_buttons
+ $showButtons
) {
$htmlOutput = '';
$validators = Validator::getValidators($this->_configFile);
foreach ($this->_forms as $form) {
/* @var $form Form */
- $form_errors = isset($this->_errors[$form->name])
+ $formErrors = isset($this->_errors[$form->name])
? $this->_errors[$form->name] : null;
$htmlOutput .= FormDisplayTemplate::displayFieldsetTop(
Descriptions::get("Form_{$form->name}"),
Descriptions::get("Form_{$form->name}", 'desc'),
- $form_errors,
+ $formErrors,
['id' => $form->name]
);
foreach ($form->fields as $field => $path) {
- $work_path = array_search($path, $this->_systemPaths);
- $translated_path = $this->_translatedPaths[$work_path];
+ $workPath = array_search($path, $this->_systemPaths);
+ $translatedPath = $this->_translatedPaths[$workPath];
// always true/false for user preferences display
// otherwise null
- $userprefs_allow = isset($this->_userprefsKeys[$path])
+ $userPrefsAllow = isset($this->_userprefsKeys[$path])
? !isset($this->_userprefsDisallow[$path])
: null;
// display input
@@ -260,18 +260,18 @@ class FormDisplay
$form,
$field,
$path,
- $work_path,
- $translated_path,
- $show_restore_default,
- $userprefs_allow,
- $js_default
+ $workPath,
+ $translatedPath,
+ $showRestoreDefault,
+ $userPrefsAllow,
+ $jsDefault
);
// register JS validators for this field
if (isset($validators[$path])) {
- FormDisplayTemplate::addJsValidate($translated_path, $validators[$path], $js);
+ FormDisplayTemplate::addJsValidate($translatedPath, $validators[$path], $js);
}
}
- $htmlOutput .= FormDisplayTemplate::displayFieldsetBottom($show_buttons);
+ $htmlOutput .= FormDisplayTemplate::displayFieldsetBottom($showButtons);
}
return $htmlOutput;
}
@@ -279,33 +279,33 @@ class FormDisplay
/**
* Outputs HTML for forms
*
- * @param bool $tabbed_form if true, use a form with tabs
- * @param bool $show_restore_default whether show "restore default" button
- * besides the input field
- * @param bool $show_buttons whether show submit and reset button
- * @param string $form_action action attribute for the form
- * @param array|null $hidden_fields array of form hidden fields (key: field
- * name)
+ * @param bool $tabbedForm if true, use a form with tabs
+ * @param bool $showRestoreDefault whether show "restore default" button
+ * besides the input field
+ * @param bool $showButtons whether show submit and reset button
+ * @param string $formAction action attribute for the form
+ * @param array|null $hiddenFields array of form hidden fields (key: field
+ * name)
*
* @return string HTML for forms
*/
public function getDisplay(
- $tabbed_form = false,
- $show_restore_default = false,
- $show_buttons = true,
- $form_action = null,
- $hidden_fields = null
+ $tabbedForm = false,
+ $showRestoreDefault = false,
+ $showButtons = true,
+ $formAction = null,
+ $hiddenFields = null
) {
- static $js_lang_sent = false;
+ static $jsLangSent = false;
$htmlOutput = '';
$js = [];
- $js_default = [];
+ $jsDefault = [];
- $htmlOutput .= FormDisplayTemplate::displayFormTop($form_action, 'post', $hidden_fields);
+ $htmlOutput .= FormDisplayTemplate::displayFormTop($formAction, 'post', $hiddenFields);
- if ($tabbed_form) {
+ if ($tabbedForm) {
$tabs = [];
foreach ($this->_forms as $form) {
$tabs[$form->name] = Descriptions::get("Form_$form->name");
@@ -314,15 +314,15 @@ class FormDisplay
}
// validate only when we aren't displaying a "new server" form
- $is_new_server = false;
+ $isNewServer = false;
foreach ($this->_forms as $form) {
/* @var $form Form */
if ($form->index === 0) {
- $is_new_server = true;
+ $isNewServer = true;
break;
}
}
- if (! $is_new_server) {
+ if (! $isNewServer) {
$this->_validate();
}
@@ -331,30 +331,30 @@ class FormDisplay
// display forms
$htmlOutput .= $this->_displayForms(
- $show_restore_default,
- $js_default,
+ $showRestoreDefault,
+ $jsDefault,
$js,
- $show_buttons
+ $showButtons
);
- if ($tabbed_form) {
+ if ($tabbedForm) {
$htmlOutput .= FormDisplayTemplate::displayTabsBottom();
}
$htmlOutput .= FormDisplayTemplate::displayFormBottom();
// if not already done, send strings used for validation to JavaScript
- if (! $js_lang_sent) {
- $js_lang_sent = true;
- $js_lang = [];
+ if (! $jsLangSent) {
+ $jsLangSent = true;
+ $jsLang = [];
foreach ($this->_jsLangStrings as $strName => $strValue) {
- $js_lang[] = "'$strName': '" . Sanitize::jsFormat($strValue, false) . '\'';
+ $jsLang[] = "'$strName': '" . Sanitize::jsFormat($strValue, false) . '\'';
}
$js[] = "$.extend(PMA_messages, {\n\t"
- . implode(",\n\t", $js_lang) . '})';
+ . implode(",\n\t", $jsLang) . '})';
}
$js[] = "$.extend(defaultValues, {\n\t"
- . implode(",\n\t", $js_default) . '})';
+ . implode(",\n\t", $jsDefault) . '})';
$htmlOutput .= FormDisplayTemplate::displayJavascript($js);
return $htmlOutput;
@@ -363,55 +363,55 @@ class FormDisplay
/**
* Prepares data for input field display and outputs HTML code
*
- * @param Form $form Form object
- * @param string $field field name as it appears in $form
- * @param string $system_path field path, eg. Servers/1/verbose
- * @param string $work_path work path, eg. Servers/4/verbose
- * @param string $translated_path work path changed so that it can be
- * used as XHTML id
- * @param bool $show_restore_default whether show "restore default" button
- * besides the input field
- * @param bool|null $userprefs_allow whether user preferences are enabled
- * for this field (null - no support,
- * true/false - enabled/disabled)
- * @param array &$js_default array which stores JavaScript code
- * to be displayed
+ * @param Form $form Form object
+ * @param string $field field name as it appears in $form
+ * @param string $systemPath field path, eg. Servers/1/verbose
+ * @param string $workPath work path, eg. Servers/4/verbose
+ * @param string $translatedPath work path changed so that it can be
+ * used as XHTML id
+ * @param bool $showRestoreDefault whether show "restore default" button
+ * besides the input field
+ * @param bool|null $userPrefsAllow whether user preferences are enabled
+ * for this field (null - no support,
+ * true/false - enabled/disabled)
+ * @param array &$jsDefault array which stores JavaScript code
+ * to be displayed
*
* @return string HTML for input field
*/
private function _displayFieldInput(
Form $form,
$field,
- $system_path,
- $work_path,
- $translated_path,
- $show_restore_default,
- $userprefs_allow,
- array &$js_default
+ $systemPath,
+ $workPath,
+ $translatedPath,
+ $showRestoreDefault,
+ $userPrefsAllow,
+ array &$jsDefault
) {
- $name = Descriptions::get($system_path);
- $description = Descriptions::get($system_path, 'desc');
+ $name = Descriptions::get($systemPath);
+ $description = Descriptions::get($systemPath, 'desc');
- $value = $this->_configFile->get($work_path);
- $value_default = $this->_configFile->getDefault($system_path);
- $value_is_default = false;
- if ($value === null || $value === $value_default) {
- $value = $value_default;
- $value_is_default = true;
+ $value = $this->_configFile->get($workPath);
+ $valueDefault = $this->_configFile->getDefault($systemPath);
+ $valueIsDefault = false;
+ if ($value === null || $value === $valueDefault) {
+ $value = $valueDefault;
+ $valueIsDefault = true;
}
$opts = [
- 'doc' => $this->getDocLink($system_path),
- 'show_restore_default' => $show_restore_default,
- 'userprefs_allow' => $userprefs_allow,
- 'userprefs_comment' => Descriptions::get($system_path, 'cmt')
+ 'doc' => $this->getDocLink($systemPath),
+ 'show_restore_default' => $showRestoreDefault,
+ 'userprefs_allow' => $userPrefsAllow,
+ 'userprefs_comment' => Descriptions::get($systemPath, 'cmt')
];
- if (isset($form->default[$system_path])) {
- $opts['setvalue'] = $form->default[$system_path];
+ if (isset($form->default[$systemPath])) {
+ $opts['setvalue'] = $form->default[$systemPath];
}
- if (isset($this->_errors[$work_path])) {
- $opts['errors'] = $this->_errors[$work_path];
+ if (isset($this->_errors[$workPath])) {
+ $opts['errors'] = $this->_errors[$workPath];
}
$type = '';
@@ -436,7 +436,7 @@ class FormDisplay
case 'array':
$type = 'list';
$value = (array) $value;
- $value_default = (array) $value_default;
+ $valueDefault = (array) $valueDefault;
break;
case 'group':
// :group:end is changed to :group:end:{unique id} in Form class
@@ -450,61 +450,61 @@ class FormDisplay
}
return $htmlOutput;
case 'NULL':
- trigger_error("Field $system_path has no type", E_USER_WARNING);
+ trigger_error("Field $systemPath has no type", E_USER_WARNING);
return null;
}
// detect password fields
if ($type === 'text'
- && (mb_substr($translated_path, -9) === '-password'
- || mb_substr($translated_path, -4) === 'pass'
- || mb_substr($translated_path, -4) === 'Pass')
+ && (mb_substr($translatedPath, -9) === '-password'
+ || mb_substr($translatedPath, -4) === 'pass'
+ || mb_substr($translatedPath, -4) === 'Pass')
) {
$type = 'password';
}
// TrustedProxies requires changes before displaying
- if ($system_path == 'TrustedProxies') {
+ if ($systemPath == 'TrustedProxies') {
foreach ($value as $ip => &$v) {
if (!preg_match('/^-\d+$/', $ip)) {
$v = $ip . ': ' . $v;
}
}
}
- $this->_setComments($system_path, $opts);
+ $this->_setComments($systemPath, $opts);
// send default value to form's JS
- $js_line = '\'' . $translated_path . '\': ';
+ $jsLine = '\'' . $translatedPath . '\': ';
switch ($type) {
case 'text':
case 'short_text':
case 'number_text':
case 'password':
- $js_line .= '\'' . Sanitize::escapeJsString($value_default) . '\'';
+ $jsLine .= '\'' . Sanitize::escapeJsString($valueDefault) . '\'';
break;
case 'checkbox':
- $js_line .= $value_default ? 'true' : 'false';
+ $jsLine .= $valueDefault ? 'true' : 'false';
break;
case 'select':
- $value_default_js = is_bool($value_default)
- ? (int) $value_default
- : $value_default;
- $js_line .= '[\'' . Sanitize::escapeJsString($value_default_js) . '\']';
+ $valueDefaultJs = is_bool($valueDefault)
+ ? (int) $valueDefault
+ : $valueDefault;
+ $jsLine .= '[\'' . Sanitize::escapeJsString($valueDefaultJs) . '\']';
break;
case 'list':
- $js_line .= '\'' . Sanitize::escapeJsString(implode("\n", $value_default))
+ $jsLine .= '\'' . Sanitize::escapeJsString(implode("\n", $valueDefault))
. '\'';
break;
}
- $js_default[] = $js_line;
+ $jsDefault[] = $jsLine;
return FormDisplayTemplate::displayInput(
- $translated_path,
+ $translatedPath,
$name,
$type,
$value,
$description,
- $value_is_default,
+ $valueIsDefault,
$opts
);
}
@@ -523,13 +523,13 @@ class FormDisplay
$htmlOutput = '';
- foreach ($this->_errors as $system_path => $error_list) {
- if (isset($this->_systemPaths[$system_path])) {
- $name = Descriptions::get($this->_systemPaths[$system_path]);
+ foreach ($this->_errors as $systemPath => $errorList) {
+ if (isset($this->_systemPaths[$systemPath])) {
+ $name = Descriptions::get($this->_systemPaths[$systemPath]);
} else {
- $name = Descriptions::get('Form_' . $system_path);
+ $name = Descriptions::get('Form_' . $systemPath);
}
- $htmlOutput .= FormDisplayTemplate::displayErrors($name, $error_list);
+ $htmlOutput .= FormDisplayTemplate::displayErrors($name, $errorList);
}
return $htmlOutput;
@@ -548,12 +548,12 @@ class FormDisplay
}
$cf = $this->_configFile;
- foreach (array_keys($this->_errors) as $work_path) {
- if (!isset($this->_systemPaths[$work_path])) {
+ foreach (array_keys($this->_errors) as $workPath) {
+ if (!isset($this->_systemPaths[$workPath])) {
continue;
}
- $canonical_path = $this->_systemPaths[$work_path];
- $cf->set($work_path, $cf->getDefault($canonical_path));
+ $canonicalPath = $this->_systemPaths[$workPath];
+ $cf->set($workPath, $cf->getDefault($canonicalPath));
}
}
@@ -567,14 +567,14 @@ class FormDisplay
*/
private function _validateSelect(&$value, array $allowed)
{
- $value_cmp = is_bool($value)
+ $valueCmp = is_bool($value)
? (int) $value
: $value;
foreach ($allowed as $vk => $v) {
// equality comparison only if both values are numeric or not numeric
// (allows to skip 0 == 'string' equalling to true)
// or identity (for string-string)
- if (($vk == $value && !(is_numeric($value_cmp) xor is_numeric($vk)))
+ if (($vk == $value && !(is_numeric($valueCmp) xor is_numeric($vk)))
|| $vk === $value
) {
// keep boolean value as boolean
@@ -590,40 +590,40 @@ class FormDisplay
/**
* Validates and saves form data to session
*
- * @param array|string $forms array of form names
- * @param bool $allow_partial_save allows for partial form saving on
- * failed validation
+ * @param array|string $forms array of form names
+ * @param bool $allowPartialSave allows for partial form saving on
+ * failed validation
*
* @return boolean true on success (no errors and all saved)
*/
- public function save($forms, $allow_partial_save = true)
+ public function save($forms, $allowPartialSave = true)
{
$result = true;
$forms = (array) $forms;
$values = [];
- $to_save = [];
- $is_setup_script = $GLOBALS['PMA_Config']->get('is_setup');
- if ($is_setup_script) {
+ $toSave = [];
+ $isSetupScript = $GLOBALS['PMA_Config']->get('is_setup');
+ if ($isSetupScript) {
$this->_loadUserprefsInfo();
}
$this->_errors = [];
- foreach ($forms as $form_name) {
+ foreach ($forms as $formName) {
/* @var $form Form */
- if (isset($this->_forms[$form_name])) {
- $form = $this->_forms[$form_name];
+ if (isset($this->_forms[$formName])) {
+ $form = $this->_forms[$formName];
} else {
continue;
}
// get current server id
- $change_index = $form->index === 0
+ $changeIndex = $form->index === 0
? $this->_configFile->getServerCount() + 1
: false;
// grab POST values
- foreach ($form->fields as $field => $system_path) {
- $work_path = array_search($system_path, $this->_systemPaths);
- $key = $this->_translatedPaths[$work_path];
+ foreach ($form->fields as $field => $systemPath) {
+ $workPath = array_search($systemPath, $this->_systemPaths);
+ $key = $this->_translatedPaths[$workPath];
$type = $form->getOptionType($field);
// skip groups
@@ -639,7 +639,7 @@ class FormDisplay
} else {
$this->_errors[$form->name][] = sprintf(
__('Missing data for %s'),
- '<i>' . Descriptions::get($system_path) . '</i>'
+ '<i>' . Descriptions::get($systemPath) . '</i>'
);
$result = false;
continue;
@@ -647,15 +647,15 @@ class FormDisplay
}
// user preferences allow/disallow
- if ($is_setup_script
- && isset($this->_userprefsKeys[$system_path])
+ if ($isSetupScript
+ && isset($this->_userprefsKeys[$systemPath])
) {
- if (isset($this->_userprefsDisallow[$system_path])
+ if (isset($this->_userprefsDisallow[$systemPath])
&& isset($_POST[$key . '-userprefs-allow'])
) {
- unset($this->_userprefsDisallow[$system_path]);
+ unset($this->_userprefsDisallow[$systemPath]);
} elseif (!isset($_POST[$key . '-userprefs-allow'])) {
- $this->_userprefsDisallow[$system_path] = true;
+ $this->_userprefsDisallow[$systemPath] = true;
}
}
@@ -673,12 +673,12 @@ class FormDisplay
}
break;
case 'select':
- $successfully_validated = $this->_validateSelect(
+ $successfullyValidated = $this->_validateSelect(
$_POST[$key],
- $form->getOptionValueList($system_path)
+ $form->getOptionValueList($systemPath)
);
- if (! $successfully_validated) {
- $this->_errors[$work_path][] = __('Incorrect value!');
+ if (! $successfullyValidated) {
+ $this->_errors[$workPath][] = __('Incorrect value!');
$result = false;
continue;
}
@@ -689,35 +689,35 @@ class FormDisplay
break;
case 'array':
// eliminate empty values and ensure we have an array
- $post_values = is_array($_POST[$key])
+ $postValues = is_array($_POST[$key])
? $_POST[$key]
: explode("\n", $_POST[$key]);
$_POST[$key] = [];
- $this->_fillPostArrayParameters($post_values, $key);
+ $this->_fillPostArrayParameters($postValues, $key);
break;
}
// now we have value with proper type
- $values[$system_path] = $_POST[$key];
- if ($change_index !== false) {
- $work_path = str_replace(
+ $values[$systemPath] = $_POST[$key];
+ if ($changeIndex !== false) {
+ $workPath = str_replace(
"Servers/$form->index/",
- "Servers/$change_index/",
- $work_path
+ "Servers/$changeIndex/",
+ $workPath
);
}
- $to_save[$work_path] = $system_path;
+ $toSave[$workPath] = $systemPath;
}
}
// save forms
- if (!$allow_partial_save && !empty($this->_errors)) {
+ if (!$allowPartialSave && !empty($this->_errors)) {
// don't look for non-critical errors
$this->_validate();
return $result;
}
- foreach ($to_save as $work_path => $path) {
+ foreach ($toSave as $workPath => $path) {
// TrustedProxies requires changes before saving
if ($path == 'TrustedProxies') {
$proxies = [];
@@ -741,9 +741,9 @@ class FormDisplay
}
$values[$path] = $proxies;
}
- $this->_configFile->set($work_path, $values[$path], $path);
+ $this->_configFile->set($workPath, $values[$path], $path);
}
- if ($is_setup_script) {
+ if ($isSetupScript) {
$this->_configFile->set(
'UserprefsDisallow',
array_keys($this->_userprefsDisallow)
@@ -811,24 +811,24 @@ class FormDisplay
$this->_userprefsKeys = array_flip(UserFormList::getFields());
// read real config for user preferences display
- $userprefs_disallow = $GLOBALS['PMA_Config']->get('is_setup')
+ $userPrefsDisallow = $GLOBALS['PMA_Config']->get('is_setup')
? $this->_configFile->get('UserprefsDisallow', [])
: $GLOBALS['cfg']['UserprefsDisallow'];
- $this->_userprefsDisallow = array_flip($userprefs_disallow);
+ $this->_userprefsDisallow = array_flip($userPrefsDisallow);
}
/**
* Sets field comments and warnings based on current environment
*
- * @param string $system_path Path to settings
- * @param array &$opts Chosen options
+ * @param string $systemPath Path to settings
+ * @param array &$opts Chosen options
*
* @return void
*/
- private function _setComments($system_path, array &$opts)
+ private function _setComments($systemPath, array &$opts)
{
// RecodingEngine - mark unavailable types
- if ($system_path == 'RecodingEngine') {
+ if ($systemPath == 'RecodingEngine') {
$comment = '';
if (!function_exists('iconv')) {
$opts['values']['iconv'] .= ' (' . __('unavailable') . ')';
@@ -851,41 +851,41 @@ class FormDisplay
$opts['comment_warning'] = true;
}
// ZipDump, GZipDump, BZipDump - check function availability
- if ($system_path == 'ZipDump'
- || $system_path == 'GZipDump'
- || $system_path == 'BZipDump'
+ if ($systemPath == 'ZipDump'
+ || $systemPath == 'GZipDump'
+ || $systemPath == 'BZipDump'
) {
$comment = '';
$funcs = [
'ZipDump' => ['zip_open', 'gzcompress'],
'GZipDump' => ['gzopen', 'gzencode'],
'BZipDump' => ['bzopen', 'bzcompress']];
- if (!function_exists($funcs[$system_path][0])) {
+ if (!function_exists($funcs[$systemPath][0])) {
$comment = sprintf(
__(
'Compressed import will not work due to missing function %s.'
),
- $funcs[$system_path][0]
+ $funcs[$systemPath][0]
);
}
- if (!function_exists($funcs[$system_path][1])) {
+ if (!function_exists($funcs[$systemPath][1])) {
$comment .= ($comment ? '; ' : '') . sprintf(
__(
'Compressed export will not work due to missing function %s.'
),
- $funcs[$system_path][1]
+ $funcs[$systemPath][1]
);
}
$opts['comment'] = $comment;
$opts['comment_warning'] = true;
}
if (! $GLOBALS['PMA_Config']->get('is_setup')) {
- if (($system_path == 'MaxDbList' || $system_path == 'MaxTableList'
- || $system_path == 'QueryHistoryMax')
+ if (($systemPath == 'MaxDbList' || $systemPath == 'MaxTableList'
+ || $systemPath == 'QueryHistoryMax')
) {
$opts['comment'] = sprintf(
__('maximum %s'),
- $GLOBALS['cfg'][$system_path]
+ $GLOBALS['cfg'][$systemPath]
);
}
}
@@ -894,14 +894,14 @@ class FormDisplay
/**
* Copy items of an array to $_POST variable
*
- * @param array $post_values List of parameters
- * @param string $key Array key
+ * @param array $postValues List of parameters
+ * @param string $key Array key
*
* @return void
*/
- private function _fillPostArrayParameters(array $post_values, $key)
+ private function _fillPostArrayParameters(array $postValues, $key)
{
- foreach ($post_values as $v) {
+ foreach ($postValues as $v) {
$v = Util::requestString($v);
if ($v !== '') {
$_POST[$key][] = $v;
diff --git a/libraries/classes/Config/FormDisplayTemplate.php b/libraries/classes/Config/FormDisplayTemplate.php
index d89ae52055..8042498776 100644
--- a/libraries/classes/Config/FormDisplayTemplate.php
+++ b/libraries/classes/Config/FormDisplayTemplate.php
@@ -24,15 +24,18 @@ class FormDisplayTemplate
/**
* Displays top part of the form
*
- * @param string $action default: $_SERVER['REQUEST_URI']
- * @param string $method 'post' or 'get'
- * @param array|null $hidden_fields array of form hidden fields (key: field name)
+ * @param string $action default: $_SERVER['REQUEST_URI']
+ * @param string $method 'post' or 'get'
+ * @param array|null $hiddenFields array of form hidden fields (key: field name)
*
* @return string
*/
- public static function displayFormTop($action = null, $method = 'post', $hidden_fields = null)
- {
- static $has_check_page_refresh = false;
+ public static function displayFormTop(
+ $action = null,
+ $method = 'post',
+ $hiddenFields = null
+ ): string {
+ static $hasCheckPageRefresh = false;
if ($action === null) {
$action = $_SERVER['REQUEST_URI'];
@@ -45,13 +48,13 @@ class FormDisplayTemplate
$htmlOutput .= '<input type="hidden" name="tab_hash" value="" />';
// we do validation on page refresh when browser remembers field values,
// add a field with known value which will be used for checks
- if (! $has_check_page_refresh) {
- $has_check_page_refresh = true;
+ if (! $hasCheckPageRefresh) {
+ $hasCheckPageRefresh = true;
$htmlOutput .= '<input type="hidden" name="check_page_refresh" '
. ' id="check_page_refresh" value="" />' . "\n";
}
$htmlOutput .= Url::getHiddenInputs('', '', 0, 'server') . "\n";
- $htmlOutput .= Url::getHiddenFields((array)$hidden_fields, '', true);
+ $htmlOutput .= Url::getHiddenFields((array)$hiddenFields, '', true);
return $htmlOutput;
}
@@ -66,11 +69,11 @@ class FormDisplayTemplate
public static function displayTabsTop(array $tabs)
{
$items = [];
- foreach ($tabs as $tab_id => $tab_name) {
+ foreach ($tabs as $tabId => $tabName) {
$items[] = [
- 'content' => htmlspecialchars($tab_name),
+ 'content' => htmlspecialchars($tabName),
'url' => [
- 'href' => '#' . $tab_id,
+ 'href' => '#' . $tabId,
],
];
}
@@ -134,13 +137,13 @@ class FormDisplayTemplate
* o comment - (string) tooltip comment
* o comment_warning - (bool) whether this comments warns about something
*
- * @param string $path config option path
- * @param string $name config option name
- * @param string $type type of config option
- * @param mixed $value current value
- * @param string $description verbose description
- * @param bool $value_is_default whether value is default
- * @param array|null $opts see above description
+ * @param string $path config option path
+ * @param string $name config option name
+ * @param string $type type of config option
+ * @param mixed $value current value
+ * @param string $description verbose description
+ * @param bool $valueIsDefault whether value is default
+ * @param array|null $opts see above description
*
* @return string
*/
@@ -150,7 +153,7 @@ class FormDisplayTemplate
$type,
$value,
$description = '',
- $value_is_default = true,
+ $valueIsDefault = true,
$opts = null
) {
global $_FormDisplayGroup;
@@ -160,24 +163,24 @@ class FormDisplayTemplate
$icons = null;
}
- $is_setup_script = $GLOBALS['PMA_Config']->get('is_setup');
+ $isSetupScript = $GLOBALS['PMA_Config']->get('is_setup');
if ($icons === null) { // if the static variables have not been initialised
$icons = [];
// Icon definitions:
// The same indexes will be used in the $icons array.
// The first element contains the filename and the second
// element is used for the "alt" and "title" attributes.
- $icon_init = [
+ $iconInit = [
'edit' => ['b_edit', ''],
'help' => ['b_help', __('Documentation')],
'reload' => ['s_reload', ''],
'tblops' => ['b_tblops', '']
];
- if ($is_setup_script) {
+ if ($isSetupScript) {
// When called from the setup script, we don't have access to the
// sprite-aware getImage() function because the PMA_theme class
// has not been loaded, so we generate the img tags manually.
- foreach ($icon_init as $k => $v) {
+ foreach ($iconInit as $k => $v) {
$title = '';
if (! empty($v[1])) {
$title = ' title="' . $v[1] . '"';
@@ -191,7 +194,7 @@ class FormDisplayTemplate
}
} else {
// In this case we just use getImage() because it's available
- foreach ($icon_init as $k => $v) {
+ foreach ($iconInit as $k => $v) {
$icons[$k] = Util::getImage(
$v[0],
$v[1]
@@ -199,31 +202,31 @@ class FormDisplayTemplate
}
}
}
- $has_errors = isset($opts['errors']) && !empty($opts['errors']);
- $option_is_disabled = ! $is_setup_script && isset($opts['userprefs_allow'])
+ $hasErrors = isset($opts['errors']) && !empty($opts['errors']);
+ $optionIsDisabled = ! $isSetupScript && isset($opts['userprefs_allow'])
&& ! $opts['userprefs_allow'];
- $name_id = 'name="' . htmlspecialchars($path) . '" id="'
+ $nameId = 'name="' . htmlspecialchars($path) . '" id="'
. htmlspecialchars($path) . '"';
- $field_class = $type == 'checkbox' ? 'checkbox' : '';
- if (! $value_is_default) {
- $field_class .= ($field_class == '' ? '' : ' ')
- . ($has_errors ? 'custom field-error' : 'custom');
+ $fieldClass = $type == 'checkbox' ? 'checkbox' : '';
+ if (! $valueIsDefault) {
+ $fieldClass .= ($fieldClass == '' ? '' : ' ')
+ . ($hasErrors ? 'custom field-error' : 'custom');
}
- $field_class = $field_class ? ' class="' . $field_class . '"' : '';
- $tr_class = $_FormDisplayGroup > 0
+ $fieldClass = $fieldClass ? ' class="' . $fieldClass . '"' : '';
+ $trClass = $_FormDisplayGroup > 0
? 'group-field group-field-' . $_FormDisplayGroup
: '';
if (isset($opts['setvalue']) && $opts['setvalue'] == ':group') {
unset($opts['setvalue']);
$_FormDisplayGroup++;
- $tr_class = 'group-header-field group-header-' . $_FormDisplayGroup;
+ $trClass = 'group-header-field group-header-' . $_FormDisplayGroup;
}
- if ($option_is_disabled) {
- $tr_class .= ($tr_class ? ' ' : '') . 'disabled-field';
+ if ($optionIsDisabled) {
+ $trClass .= ($trClass ? ' ' : '') . 'disabled-field';
}
- $tr_class = $tr_class ? ' class="' . $tr_class . '"' : '';
+ $trClass = $trClass ? ' class="' . $trClass . '"' : '';
- $htmlOutput = '<tr' . $tr_class . '>';
+ $htmlOutput = '<tr' . $trClass . '>';
$htmlOutput .= '<th>';
$htmlOutput .= '<label for="' . htmlspecialchars($path) . '">' . $name
. '</label>';
@@ -236,7 +239,7 @@ class FormDisplayTemplate
$htmlOutput .= '</span>';
}
- if ($option_is_disabled) {
+ if ($optionIsDisabled) {
$htmlOutput .= '<span class="disabled-notice" title="';
$htmlOutput .= __(
'This setting is disabled, it will not be applied to your configuration.'
@@ -253,11 +256,11 @@ class FormDisplayTemplate
switch ($type) {
case 'text':
- $htmlOutput .= '<input type="text" class="all85" ' . $name_id . $field_class
+ $htmlOutput .= '<input type="text" class="all85" ' . $nameId . $fieldClass
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'password':
- $htmlOutput .= '<input type="password" class="all85" ' . $name_id . $field_class
+ $htmlOutput .= '<input type="password" class="all85" ' . $nameId . $fieldClass
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'short_text':
@@ -265,49 +268,49 @@ class FormDisplayTemplate
// an array here. No clue about its origin nor content, so let's avoid
// a notice on htmlspecialchars().
if (! is_array($value)) {
- $htmlOutput .= '<input type="text" size="25" ' . $name_id
- . $field_class . ' value="' . htmlspecialchars($value)
+ $htmlOutput .= '<input type="text" size="25" ' . $nameId
+ . $fieldClass . ' value="' . htmlspecialchars($value)
. '" />';
}
break;
case 'number_text':
- $htmlOutput .= '<input type="number" ' . $name_id . $field_class
+ $htmlOutput .= '<input type="number" ' . $nameId . $fieldClass
. ' value="' . htmlspecialchars((string) $value) . '" />';
break;
case 'checkbox':
- $htmlOutput .= '<span' . $field_class . '><input type="checkbox" ' . $name_id
+ $htmlOutput .= '<span' . $fieldClass . '><input type="checkbox" ' . $nameId
. ($value ? ' checked="checked"' : '') . ' /></span>';
break;
case 'select':
- $htmlOutput .= '<select class="all85" ' . $name_id . $field_class . '>';
+ $htmlOutput .= '<select class="all85" ' . $nameId . $fieldClass . '>';
$escape = !(isset($opts['values_escaped']) && $opts['values_escaped']);
- $values_disabled = isset($opts['values_disabled'])
+ $valuesDisabled = isset($opts['values_disabled'])
? array_flip($opts['values_disabled']) : [];
- foreach ($opts['values'] as $opt_value_key => $opt_value) {
+ foreach ($opts['values'] as $optValueKey => $optValue) {
// set names for boolean values
- if (is_bool($opt_value)) {
- $opt_value = mb_strtolower(
- $opt_value ? __('Yes') : __('No')
+ if (is_bool($optValue)) {
+ $optValue = mb_strtolower(
+ $optValue ? __('Yes') : __('No')
);
}
// escape if necessary
if ($escape) {
- $display = htmlspecialchars((string) $opt_value);
- $display_value = htmlspecialchars((string) $opt_value_key);
+ $display = htmlspecialchars((string) $optValue);
+ $displayValue = htmlspecialchars((string) $optValueKey);
} else {
- $display = $opt_value;
- $display_value = $opt_value_key;
+ $display = $optValue;
+ $displayValue = $optValueKey;
}
// compare with selected value
// boolean values are cast to integers when used as array keys
$selected = is_bool($value)
- ? (int) $value === $opt_value_key
- : $opt_value_key === $value;
- $htmlOutput .= '<option value="' . $display_value . '"';
+ ? (int) $value === $optValueKey
+ : $optValueKey === $value;
+ $htmlOutput .= '<option value="' . $displayValue . '"';
if ($selected) {
$htmlOutput .= ' selected="selected"';
}
- if (isset($values_disabled[$opt_value_key])) {
+ if (isset($valuesDisabled[$optValueKey])) {
$htmlOutput .= ' disabled="disabled"';
}
$htmlOutput .= '>' . $display . '</option>';
@@ -315,7 +318,7 @@ class FormDisplayTemplate
$htmlOutput .= '</select>';
break;
case 'list':
- $htmlOutput .= '<textarea cols="35" rows="5" ' . $name_id . $field_class
+ $htmlOutput .= '<textarea cols="35" rows="5" ' . $nameId . $fieldClass
. '>' . htmlspecialchars(implode("\n", $value)) . '</textarea>';
break;
}
@@ -327,7 +330,7 @@ class FormDisplayTemplate
$htmlOutput .= '<span class="' . $class . '" title="'
. htmlspecialchars($opts['comment']) . '">i</span>';
}
- if ($is_setup_script
+ if ($isSetupScript
&& isset($opts['userprefs_comment'])
&& $opts['userprefs_comment']
) {
@@ -346,7 +349,7 @@ class FormDisplayTemplate
. __('Restore default value') . '">' . $icons['reload'] . '</a>';
}
// this must match with displayErrors() in scripts/config.js
- if ($has_errors) {
+ if ($hasErrors) {
$htmlOutput .= "\n <dl class=\"inline_errors\">";
foreach ($opts['errors'] as $error) {
$htmlOutput .= '<dd>' . htmlspecialchars($error) . '</dd>';
@@ -354,7 +357,7 @@ class FormDisplayTemplate
$htmlOutput .= '</dl>';
}
$htmlOutput .= '</td>';
- if ($is_setup_script && isset($opts['userprefs_allow'])) {
+ if ($isSetupScript && isset($opts['userprefs_allow'])) {
$htmlOutput .= '<td class="userprefs-allow" title="' .
__('Allow users to customize this value') . '">';
$htmlOutput .= '<input type="checkbox" name="' . $path
@@ -364,7 +367,7 @@ class FormDisplayTemplate
};
$htmlOutput .= '/>';
$htmlOutput .= '</td>';
- } elseif ($is_setup_script) {
+ } elseif ($isSetupScript) {
$htmlOutput .= '<td>&nbsp;</td>';
}
$htmlOutput .= '</tr>';
@@ -445,42 +448,42 @@ class FormDisplayTemplate
/**
* Appends JS validation code to $js_array
*
- * @param string $field_id ID of field to validate
+ * @param string $fieldId ID of field to validate
* @param string|array $validators validators callback
- * @param array &$js_array will be updated with javascript code
+ * @param array &$jsArray will be updated with javascript code
*
* @return void
*/
- public static function addJsValidate($field_id, $validators, array &$js_array)
+ public static function addJsValidate($fieldId, $validators, array &$jsArray)
{
foreach ((array)$validators as $validator) {
$validator = (array)$validator;
- $v_name = array_shift($validator);
- $v_name = "PMA_" . $v_name;
- $v_args = [];
+ $vName = array_shift($validator);
+ $vName = "PMA_" . $vName;
+ $vArgs = [];
foreach ($validator as $arg) {
- $v_args[] = Sanitize::escapeJsString($arg);
+ $vArgs[] = Sanitize::escapeJsString($arg);
}
- $v_args = $v_args ? ", ['" . implode("', '", $v_args) . "']" : '';
- $js_array[] = "validateField('$field_id', '$v_name', true$v_args)";
+ $vArgs = $vArgs ? ", ['" . implode("', '", $vArgs) . "']" : '';
+ $jsArray[] = "validateField('$fieldId', '$vName', true$vArgs)";
}
}
/**
* Displays JavaScript code
*
- * @param array $js_array lines of javascript code
+ * @param array $jsArray lines of javascript code
*
* @return string
*/
- public static function displayJavascript(array $js_array)
+ public static function displayJavascript(array $jsArray)
{
- if (empty($js_array)) {
+ if (empty($jsArray)) {
return null;
}
return Template::get('javascript/display')->render(
- ['js_array' => $js_array,]
+ ['js_array' => $jsArray,]
);
}
diff --git a/libraries/classes/Config/Forms/BaseForm.php b/libraries/classes/Config/Forms/BaseForm.php
index fdd54c6fcc..204907079a 100644
--- a/libraries/classes/Config/Forms/BaseForm.php
+++ b/libraries/classes/Config/Forms/BaseForm.php
@@ -22,14 +22,14 @@ abstract class BaseForm extends FormDisplay
/**
* Constructor
*
- * @param ConfigFile $cf Config file instance
- * @param int|null $server_id 0 if new server, validation; >= 1 if editing a server
+ * @param ConfigFile $cf Config file instance
+ * @param int|null $serverId 0 if new server, validation; >= 1 if editing a server
*/
- public function __construct(ConfigFile $cf, $server_id = null)
+ public function __construct(ConfigFile $cf, $serverId = null)
{
parent::__construct($cf);
- foreach (static::getForms() as $form_name => $form) {
- $this->registerForm($form_name, $form, $server_id);
+ foreach (static::getForms() as $formName => $form) {
+ $this->registerForm($formName, $form, $serverId);
}
}
diff --git a/libraries/classes/Config/Forms/BaseFormList.php b/libraries/classes/Config/Forms/BaseFormList.php
index e8244f452e..f4a5d32ce5 100644
--- a/libraries/classes/Config/Forms/BaseFormList.php
+++ b/libraries/classes/Config/Forms/BaseFormList.php
@@ -78,17 +78,17 @@ class BaseFormList
/**
* Processes forms, returns true on successful save
*
- * @param bool $allow_partial_save allows for partial form saving
- * on failed validation
- * @param bool $check_form_submit whether check for $_POST['submit_save']
+ * @param bool $allowPartialSave allows for partial form saving
+ * on failed validation
+ * @param bool $checkFormSubmit whether check for $_POST['submit_save']
*
* @return boolean whether processing was successful
*/
- public function process($allow_partial_save = true, $check_form_submit = true)
+ public function process($allowPartialSave = true, $checkFormSubmit = true)
{
$ret = true;
foreach ($this->_forms as $form) {
- $ret = $ret && $form->process($allow_partial_save, $check_form_submit);
+ $ret = $ret && $form->process($allowPartialSave, $checkFormSubmit);
}
return $ret;
}
diff --git a/libraries/classes/Config/PageSettings.php b/libraries/classes/Config/PageSettings.php
index 820c0a35b2..ef21cb0101 100644
--- a/libraries/classes/Config/PageSettings.php
+++ b/libraries/classes/Config/PageSettings.php
@@ -64,8 +64,8 @@ class PageSettings
{
$this->userPreferences = new UserPreferences();
- $form_class = PageFormList::get($formGroupName);
- if (is_null($form_class)) {
+ $formClass = PageFormList::get($formGroupName);
+ if (is_null($formClass)) {
return;
}
@@ -81,32 +81,32 @@ class PageSettings
$cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
$this->userPreferences->pageInit($cf);
- $form_display = new $form_class($cf);
+ $formDisplay = new $formClass($cf);
// Process form
$error = null;
if (isset($_POST['submit_save'])
&& $_POST['submit_save'] == $formGroupName
) {
- $this->_processPageSettings($form_display, $cf, $error);
+ $this->_processPageSettings($formDisplay, $cf, $error);
}
// Display forms
- $this->_HTML = $this->_getPageSettingsDisplay($form_display, $error);
+ $this->_HTML = $this->_getPageSettingsDisplay($formDisplay, $error);
}
/**
* Process response to form
*
- * @param FormDisplay &$form_display Form
- * @param ConfigFile &$cf Configuration file
- * @param Message|null &$error Error message
+ * @param FormDisplay &$formDisplay Form
+ * @param ConfigFile &$cf Configuration file
+ * @param Message|null &$error Error message
*
* @return void
*/
- private function _processPageSettings(&$form_display, &$cf, &$error)
+ private function _processPageSettings(&$formDisplay, &$cf, &$error)
{
- if ($form_display->process(false) && !$form_display->hasErrors()) {
+ if ($formDisplay->process(false) && !$formDisplay->hasErrors()) {
// save settings
$result = $this->userPreferences->save($cf->getConfigArray());
if ($result === true) {
@@ -125,25 +125,25 @@ class PageSettings
/**
* Store errors in _errorHTML
*
- * @param FormDisplay &$form_display Form
- * @param Message|null &$error Error message
+ * @param FormDisplay &$formDisplay Form
+ * @param Message|null &$error Error message
*
* @return void
*/
- private function _storeError(&$form_display, &$error)
+ private function _storeError(&$formDisplay, &$error)
{
$retval = '';
if ($error) {
$retval .= $error->getDisplay();
}
- if ($form_display->hasErrors()) {
+ if ($formDisplay->hasErrors()) {
// form has errors
$retval .= '<div class="error config-form">'
. '<b>' . __(
'Cannot save settings, submitted configuration form contains '
. 'errors!'
) . '</b>'
- . $form_display->displayErrors()
+ . $formDisplay->displayErrors()
. '</div>';
}
$this->_errorHTML = $retval;
@@ -152,22 +152,22 @@ class PageSettings
/**
* Display page-related settings
*
- * @param FormDisplay &$form_display Form
- * @param Message &$error Error message
+ * @param FormDisplay &$formDisplay Form
+ * @param Message &$error Error message
*
* @return string
*/
- private function _getPageSettingsDisplay(&$form_display, &$error)
+ private function _getPageSettingsDisplay(&$formDisplay, &$error)
{
$response = Response::getInstance();
$retval = '';
- $this->_storeError($form_display, $error);
+ $this->_storeError($formDisplay, $error);
$retval .= '<div id="' . $this->_elemId . '">';
$retval .= '<div class="page_settings">';
- $retval .= $form_display->getDisplay(
+ $retval .= $formDisplay->getDisplay(
true,
true,
false,
diff --git a/libraries/classes/Config/Validator.php b/libraries/classes/Config/Validator.php
index dac79c0342..58954bcdc0 100644
--- a/libraries/classes/Config/Validator.php
+++ b/libraries/classes/Config/Validator.php
@@ -55,9 +55,9 @@ class Validator
// by user preferences, creating a new PhpMyAdmin\Config instance is a
// better idea than hacking into its code
$uvs = $cf->getDbEntry('_userValidators', []);
- foreach ($uvs as $field => $uv_list) {
- $uv_list = (array)$uv_list;
- foreach ($uv_list as &$uv) {
+ foreach ($uvs as $field => $uvList) {
+ $uvList = (array)$uvList;
+ foreach ($uvList as &$uv) {
if (!is_array($uv)) {
continue;
}
@@ -71,8 +71,8 @@ class Validator
}
}
$validators[$field] = isset($validators[$field])
- ? array_merge((array)$validators[$field], $uv_list)
- : $uv_list;
+ ? array_merge((array)$validators[$field], $uvList)
+ : $uvList;
}
return $validators;
}
@@ -87,7 +87,7 @@ class Validator
* o false - when no validators match name(s) given by $validator_id
*
* @param ConfigFile $cf Config file instance
- * @param string|array $validator_id ID of validator(s) to run
+ * @param string|array $validatorId ID of validator(s) to run
* @param array &$values Values to validate
* @param bool $isPostSource tells whether $values are directly from
* POST request
@@ -96,15 +96,15 @@ class Validator
*/
public static function validate(
ConfigFile $cf,
- $validator_id,
+ $validatorId,
array &$values,
$isPostSource
) {
// find validators
- $validator_id = (array) $validator_id;
+ $validatorId = (array) $validatorId;
$validators = static::getValidators($cf);
$vids = [];
- foreach ($validator_id as &$vid) {
+ foreach ($validatorId as &$vid) {
$vid = $cf->getCanonicalPath($vid);
if (isset($validators[$vid])) {
$vids[] = $vid;
@@ -116,13 +116,13 @@ class Validator
// create argument list with canonical paths and remember path mapping
$arguments = [];
- $key_map = [];
+ $keyMap = [];
foreach ($values as $k => $v) {
$k2 = $isPostSource ? str_replace('-', '/', $k) : $k;
$k2 = mb_strpos($k2, '/')
? $cf->getCanonicalPath($k2)
: $k2;
- $key_map[$k2] = $k;
+ $keyMap[$k2] = $k;
$arguments[$k2] = $v;
}
@@ -142,9 +142,9 @@ class Validator
continue;
}
- foreach ($r as $key => $error_list) {
+ foreach ($r as $key => $errorList) {
// skip empty values if $isPostSource is false
- if (! $isPostSource && empty($error_list)) {
+ if (! $isPostSource && empty($errorList)) {
continue;
}
if (! isset($result[$key])) {
@@ -152,30 +152,30 @@ class Validator
}
$result[$key] = array_merge(
$result[$key],
- (array)$error_list
+ (array)$errorList
);
}
}
}
// restore original paths
- $new_result = [];
+ $newResult = [];
foreach ($result as $k => $v) {
- $k2 = isset($key_map[$k]) ? $key_map[$k] : $k;
- $new_result[$k2] = $v;
+ $k2 = isset($keyMap[$k]) ? $keyMap[$k] : $k;
+ $newResult[$k2] = $v;
}
- return empty($new_result) ? true : $new_result;
+ return empty($newResult) ? true : $newResult;
}
/**
* Test database connection
*
- * @param string $host host name
- * @param string $port tcp port to use
- * @param string $socket socket to use
- * @param string $user username to use
- * @param string $pass password to use
- * @param string $error_key key to use in return array
+ * @param string $host host name
+ * @param string $port tcp port to use
+ * @param string $socket socket to use
+ * @param string $user username to use
+ * @param string $pass password to use
+ * @param string $errorKey key to use in return array
*
* @return bool|array
*/
@@ -185,7 +185,7 @@ class Validator
$socket,
$user,
$pass = null,
- $error_key = 'Server'
+ $errorKey = 'Server'
) {
if ($GLOBALS['cfg']['DBG']['demo']) {
// Connection test disabled on the demo server!
@@ -228,7 +228,7 @@ class Validator
if (! is_null($error)) {
$error .= ' - ' . error_get_last();
}
- return is_null($error) ? true : [$error_key => $error];
+ return is_null($error) ? true : [$errorKey => $error];
}
/**
@@ -377,12 +377,12 @@ class Validator
if (function_exists('error_clear_last')) {
/* PHP 7 only code */
error_clear_last();
- $last_error = null;
+ $lastError = null;
} else {
// As fallback we trigger another error to ensure
// that preg error will be different
@strpos();
- $last_error = error_get_last();
+ $lastError = error_get_last();
}
$matches = [];
@@ -390,10 +390,10 @@ class Validator
// a '/' is used as the delimiter for hide_db
@preg_match('/' . Util::requestString($values[$path]) . '/', '', $matches);
- $current_error = error_get_last();
+ $currentError = error_get_last();
- if ($current_error !== $last_error) {
- $error = preg_replace('/^preg_match\(\): /', '', $current_error['message']);
+ if ($currentError !== $lastError) {
+ $error = preg_replace('/^preg_match\(\): /', '', $currentError['message']);
return [$path => $error];
}
@@ -454,22 +454,22 @@ class Validator
/**
* Tests integer value
*
- * @param string $path path to config
- * @param array $values config values
- * @param bool $allow_neg allow negative values
- * @param bool $allow_zero allow zero
- * @param int $max_value max allowed value
- * @param string $error_string error message string
+ * @param string $path path to config
+ * @param array $values config values
+ * @param bool $allowNegative allow negative values
+ * @param bool $allowZero allow zero
+ * @param int $maxValue max allowed value
+ * @param string $errorString error message string
*
* @return string empty string if test is successful
*/
public static function validateNumber(
$path,
array $values,
- $allow_neg,
- $allow_zero,
- $max_value,
- $error_string
+ $allowNegative,
+ $allowZero,
+ $maxValue,
+ $errorString
) {
if (empty($values[$path])) {
return '';
@@ -478,11 +478,11 @@ class Validator
$value = Util::requestString($values[$path]);
if (intval($value) != $value
- || (! $allow_neg && $value < 0)
- || (! $allow_zero && $value == 0)
- || $value > $max_value
+ || (! $allowNegative && $value < 0)
+ || (! $allowZero && $value == 0)
+ || $value > $maxValue
) {
- return $error_string;
+ return $errorString;
}
return '';
@@ -576,16 +576,18 @@ class Validator
/**
* Validates upper bound for numeric inputs
*
- * @param string $path path to config
- * @param array $values config values
- * @param int $max_value maximal allowed value
+ * @param string $path path to config
+ * @param array $values config values
+ * @param int $maxValue maximal allowed value
*
* @return array
*/
- public static function validateUpperBound($path, array $values, $max_value)
+ public static function validateUpperBound($path, array $values, $maxValue)
{
- $result = $values[$path] <= $max_value;
- return [$path => ($result ? ''
- : sprintf(__('Value must be equal or lower than %s!'), $max_value))];
+ $result = $values[$path] <= $maxValue;
+ return [$path => ($result ? '' : sprintf(
+ __('Value must be equal or lower than %s!'),
+ $maxValue
+ ))];
}
}