From 59f4ab5280791655a0d096b9f145557bffde4726 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 20:46:03 +0530 Subject: [PATCH 1/9] Fix docs --- libraries/common.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 6c53abf628..5ffca0375a 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -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) { From 1b7f991c9b745c9307461960dd5162e3705ee5e4 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 21:44:58 +0530 Subject: [PATCH 2/9] Prefix private instance variables with underscore --- libraries/config/ConfigFile.class.php | 102 +++++++++++++------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index 64bc72d7f4..50809fcf1c 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -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; } /** @@ -134,7 +134,7 @@ class ConfigFile { // 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 +144,7 @@ class ConfigFile */ public function getPersistKeysMap() { - return $this->persistKeys; + return $this->_persistKeys; } /** @@ -156,12 +156,12 @@ class ConfigFile 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); } /** @@ -172,7 +172,7 @@ class ConfigFile */ public function setCfgUpdateReadMapping(array $mapping) { - $this->cfgUpdateReadMapping = $mapping; + $this->_cfgUpdateReadMapping = $mapping; } /** @@ -180,7 +180,7 @@ class ConfigFile */ public function resetConfigData() { - $_SESSION[$this->id] = array(); + $_SESSION[$this->_id] = array(); } /** @@ -190,7 +190,7 @@ class ConfigFile */ public function setConfigData(array $cfg) { - $_SESSION[$this->id] = $cfg; + $_SESSION[$this->_id] = $cfg; } /** @@ -206,30 +206,30 @@ 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); } /** @@ -260,7 +260,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; @@ -284,8 +284,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 +301,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 +316,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 +330,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 +360,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 +370,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,8 +382,8 @@ class ConfigFile */ public function getServers() { - return isset($_SESSION[$this->id]['Servers']) - ? $_SESSION[$this->id]['Servers'] + return isset($_SESSION[$this->_id]['Servers']) + ? $_SESSION[$this->_id]['Servers'] : null; } @@ -396,7 +396,7 @@ class ConfigFile */ function getServerDSN($server) { - if (!isset($_SESSION[$this->id]['Servers'][$server])) { + if (!isset($_SESSION[$this->_id]['Servers'][$server])) { return ''; } @@ -430,7 +430,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"); @@ -448,21 +448,21 @@ class ConfigFile */ 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 +488,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 +504,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; } From 9dab21d83583c351b3787f6d813ca72bab57f6c3 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 21:51:21 +0530 Subject: [PATCH 3/9] Add missing @return tags --- libraries/config/ConfigFile.class.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index 50809fcf1c..e1245f28c8 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -129,6 +129,8 @@ class ConfigFile * they are set to their default values (use only full paths) * * @param array $keys + * + * @return void */ public function setPersistKeys($keys) { @@ -152,6 +154,8 @@ 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) { @@ -168,7 +172,10 @@ class ConfigFile * Sets path mapping for updating config in * {@link updateWithGlobalConfig()} or reading * by {@link getConfig()} or {@link getConfigArray()} - * @var array + * + * @param array + * + * @return void */ public function setCfgUpdateReadMapping(array $mapping) { @@ -177,6 +184,8 @@ class ConfigFile /** * Resets configuration data + * + * @return void */ public function resetConfigData() { @@ -187,6 +196,8 @@ class ConfigFile * Sets configuration data (overrides old data) * * @param array $cfg + * + * @return void */ public function setConfigData(array $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) { @@ -240,6 +253,8 @@ class ConfigFile * @param mixed $value * @param mixed $key * @param mixed $prefix + * + * @return void */ private function _flattenArray($value, $key, $prefix) { @@ -271,6 +286,8 @@ class ConfigFile * (config will contain differences to defaults from config.defaults.php). * * @param array $cfg + * + * @return void */ public function updateWithGlobalConfig(array $cfg) { @@ -445,6 +462,8 @@ class ConfigFile * Removes server * * @param int $server + * + * @return void */ public function removeServer($server) { From 42f8613c0c4680976909de3b25192643b5072322 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 21:52:52 +0530 Subject: [PATCH 4/9] Wrap a long line --- libraries/config/ConfigFile.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index e1245f28c8..d3b2eeadbe 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -219,7 +219,9 @@ 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 From 3b7de22bdd7657908d0dd71fd488caed583305df Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 21:54:25 +0530 Subject: [PATCH 5/9] Fix indentation --- libraries/config/ConfigFile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index d3b2eeadbe..887440b455 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -401,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; } /** From 9341f92d33e246ea5f9561cbc43c0b1399c080ba Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 21:56:36 +0530 Subject: [PATCH 6/9] Add param name in docs --- libraries/config/ConfigFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index 887440b455..ea19fbd5b0 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -173,7 +173,7 @@ class ConfigFile * {@link updateWithGlobalConfig()} or reading * by {@link getConfig()} or {@link getConfigArray()} * - * @param array + * @param array $mapping * * @return void */ From 3957c093a4b83730491177b6c7f94af4cb4fee05 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 21:59:28 +0530 Subject: [PATCH 7/9] Prefix private instance variable with underscore --- libraries/config/Form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/config/Form.class.php b/libraries/config/Form.class.php index f17c747e30..d82e66b69e 100644 --- a/libraries/config/Form.class.php +++ b/libraries/config/Form.class.php @@ -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; } } From 8b7318f0dbeb2175eac06c6a40835ad04bdb2820 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 22:08:59 +0530 Subject: [PATCH 8/9] Prefix private instance variable with underscore - more --- libraries/config/FormDisplay.class.php | 122 ++++++++++++------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php index 6902dc235b..d61aab7e2b 100644 --- a/libraries/config/FormDisplay.class.php +++ b/libraries/config/FormDisplay.class.php @@ -29,7 +29,7 @@ class FormDisplay * Form list * @var Form[] */ - private $forms = array(); + private $_forms = array(); /** * Stores validation errors, indexed by paths @@ -37,49 +37,49 @@ 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; 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'), @@ -98,14 +98,14 @@ class FormDisplay */ 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 +125,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 +138,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 +161,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 +189,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 +204,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 +219,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 +234,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 +269,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 +324,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 +411,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 +434,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 +500,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 +514,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 +529,7 @@ class FormDisplay if ($type == 'boolean') { $_POST[$key] = false; } else { - $this->errors[$form->name][] = sprintf( + $this->_errors[$form->name][] = sprintf( __('Missing data for %s'), '' . PMA_lang_name($system_path) . '' ); @@ -539,13 +539,13 @@ 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 +574,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 +611,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 +637,7 @@ 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 +654,7 @@ class FormDisplay */ public function hasErrors() { - return count($this->errors) > 0; + return count($this->_errors) > 0; } @@ -722,13 +722,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); } } From ad3e021958d5a5f8a9c926e81a763f8c1d5f0b91 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 16 May 2012 22:13:37 +0530 Subject: [PATCH 9/9] Various CheckStyle fixes --- libraries/config/FormDisplay.class.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php index d61aab7e2b..09bfd753f0 100644 --- a/libraries/config/FormDisplay.class.php +++ b/libraries/config/FormDisplay.class.php @@ -22,6 +22,8 @@ require_once './libraries/js_escape.lib.php'; /** * Form management class, displays and processes forms + * + * @package PhpMyAdmin */ class FormDisplay { @@ -77,6 +79,9 @@ class FormDisplay */ private $_userprefs_disallow; + /** + * Constructor + */ public function __construct() { $this->_js_lang_strings = array( @@ -95,6 +100,8 @@ 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) { @@ -539,7 +546,9 @@ class FormDisplay } // user preferences allow/disallow - if ($is_setup_script && isset($this->_userprefs_keys[$system_path])) { + if ($is_setup_script + && isset($this->_userprefs_keys[$system_path]) + ) { if (isset($this->_userprefs_disallow[$system_path]) && isset($_POST[$key . '-userprefs-allow']) ) { @@ -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) + ); } }