From 3711b57df6e023d7a61457ab84b5cadf3a7a806e Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 1 Sep 2012 07:29:48 +0530 Subject: [PATCH 1/9] Fix coding style --- libraries/plugins/auth/swekey/swekey.auth.lib.php | 4 +++- libraries/plugins/export/ExportLatex.class.php | 10 +++++----- libraries/plugins/import/ImportSql.class.php | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/plugins/auth/swekey/swekey.auth.lib.php b/libraries/plugins/auth/swekey/swekey.auth.lib.php index def135d3ae..fd2b6c1b40 100644 --- a/libraries/plugins/auth/swekey/swekey.auth.lib.php +++ b/libraries/plugins/auth/swekey/swekey.auth.lib.php @@ -18,7 +18,9 @@ function Swekey_auth_check() $_SESSION['SWEKEY']['ENABLED'] = (! empty($confFile) && file_exists($confFile)); // Load the swekey.conf file the first time - if ($_SESSION['SWEKEY']['ENABLED'] && empty($_SESSION['SWEKEY']['CONF_LOADED'])) { + if ($_SESSION['SWEKEY']['ENABLED'] + && empty($_SESSION['SWEKEY']['CONF_LOADED']) + ) { $_SESSION['SWEKEY']['CONF_LOADED'] = true; $_SESSION['SWEKEY']['VALID_SWEKEYS'] = array(); $valid_swekeys = explode("\n", @file_get_contents($confFile)); diff --git a/libraries/plugins/export/ExportLatex.class.php b/libraries/plugins/export/ExportLatex.class.php index e5a52baaee..fa94e3c87f 100644 --- a/libraries/plugins/export/ExportLatex.class.php +++ b/libraries/plugins/export/ExportLatex.class.php @@ -347,11 +347,11 @@ class ExportLatex extends ExportPlugin '\\caption{' . $common_functions->expandUserString( $GLOBALS['latex_data_continued_caption'], - array( - 'texEscape', - get_class($this), - 'libraries/plugins/export/' . get_class($this) . ".class.php" - ), + array( + 'texEscape', + get_class($this), + 'libraries/plugins/export/' . get_class($this) . ".class.php" + ), array('table' => $table, 'database' => $db) ) . '} \\\\ ' diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.class.php index 5f0f1e0b48..0b705772dc 100644 --- a/libraries/plugins/import/ImportSql.class.php +++ b/libraries/plugins/import/ImportSql.class.php @@ -115,7 +115,7 @@ class ImportSql extends ImportPlugin /** * Handles the whole import logic * - * @param &$sql_data array 2-element array with sql data + * @param array &$sql_data 2-element array with sql data * * @return void */ From dec582c93c443db5817c56c714504b3d9598d7fd Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 2 Sep 2012 19:25:00 +0530 Subject: [PATCH 2/9] Do not prefix protected methods with underscore --- libraries/Config.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 648f4aab5e..dd86474a2d 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -1442,7 +1442,7 @@ class PMA_Config * * @static */ - static protected function _getFontsizeOptions($current_size = '82%') + static protected function getFontsizeOptions($current_size = '82%') { $unit = preg_replace('/[0-9.]*/', '', $current_size); $value = preg_replace('/[^0-9.]*/', '', $current_size); @@ -1503,7 +1503,7 @@ class PMA_Config * * @return string html selectbox */ - static protected function _getFontsizeSelection() + static protected function getFontsizeSelection() { $current_size = $GLOBALS['PMA_Config']->get('fontsize'); // for the case when there is no config file (this is supported) @@ -1514,7 +1514,7 @@ class PMA_Config $current_size = '82%'; } } - $options = PMA_Config::_getFontsizeOptions($current_size); + $options = PMA_Config::getFontsizeOptions($current_size); $return = '' . "\n"; $return .= ''; + $html_output .= ''; + $html_output .= ''; $html_output .= ''; // choices for types of search $html_output .= ''; @@ -422,17 +431,17 @@ class PMA_DbSearch __('Words are separated by a space character (" ").') ), '3' => __('the exact phrase'), - '4' => __('as regular expression') - . ' ' . $this->getCommonFunctions()->showMySQLDocu('Regexp', 'Regexp') + '4' => __('as regular expression') . ' ' + . $this->getCommonFunctions()->showMySQLDocu('Regexp', 'Regexp') ); // 4th parameter set to true to add line breaks - // 5th parameter set to false to avoid htmlspecialchars() escaping in the label - // since we have some HTML in some labels + // 5th parameter set to false to avoid htmlspecialchars() escaping + // in the label since we have some HTML in some labels $html_output .= $this->getCommonFunctions()->getRadioFields( 'criteriaSearchType', $choices, $this->_criteriaSearchType, true, false ); $html_output .= ''; - // displays table names as select options + // displays table names as select options $html_output .= ''; $html_output .= '' . __('Inside tables:') . ''; $html_output .= ''; @@ -480,7 +489,7 @@ class PMA_DbSearch $html_output .= ''; $html_output .= ''; $html_output .= $this->_getResultDivs(); - + return $html_output; } From 72bf04249b83010ab7587df61aa710e039e15559 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 2 Sep 2012 19:45:01 +0530 Subject: [PATCH 7/9] Fix indentation --- libraries/display_import.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/display_import.lib.php b/libraries/display_import.lib.php index ebf6758ffd..1e1e3244d4 100644 --- a/libraries/display_import.lib.php +++ b/libraries/display_import.lib.php @@ -226,13 +226,13 @@ if ($GLOBALS['is_upload'] && !empty($cfg['UploadDir'])) { ?>
  • getBrowseUploadFileBlock($max_upload_size); + echo $common_functions->getBrowseUploadFileBlock($max_upload_size); ?>
  • getSelectUploadFileBlock($import_list, $cfg['UploadDir']); + echo $common_functions->getSelectUploadFileBlock($import_list, $cfg['UploadDir']); ?>
  • From 2800659eaae6d7bb10fd784632205f56ba9ef633 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 2 Sep 2012 20:21:15 +0530 Subject: [PATCH 8/9] Improve documentation --- libraries/Index.class.php | 104 +++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/libraries/Index.class.php b/libraries/Index.class.php index 989b9d0556..078c7c5edd 100644 --- a/libraries/Index.class.php +++ b/libraries/Index.class.php @@ -96,6 +96,15 @@ class PMA_Index $this->set($params); } + /** + * Creates(if not already created) and returns the corresponding Index object + * + * @param string $schema database name + * @param string $table table name + * @param string $index_name index name + * + * @return object corresponding Index object + */ static public function singleton($schema, $table, $index_name = '') { PMA_Index::_loadIndexes($table, $schema); @@ -193,6 +202,13 @@ class PMA_Index } } + /** + * Adds a list of columns to the index + * + * @param array $columns array containing details about the columns + * + * @return void + */ public function addColumns($columns) { $_columns = array(); @@ -234,6 +250,13 @@ class PMA_Index return isset($this->_columns[$column]); } + /** + * Sets index details + * + * @param array $params index details + * + * @return void + */ public function set($params) { if (isset($params['columns'])) { @@ -276,21 +299,41 @@ class PMA_Index } } + /** + * Returns the number of columns of the index + * + * @return integer the number of the columns + */ public function getColumnCount() { return count($this->_columns); } + /** + * Returns the index comment + * + * @return string index comment + */ public function getComment() { return $this->_comment; } + /** + * Returns index remarks + * + * @return string index remarks + */ public function getRemarks() { return $this->_remarks; } + /** + * Returns concatenated remarks and comment + * + * @return string concatenated remarks and comment + */ public function getComments() { $comments = $this->getRemarks(); @@ -302,11 +345,21 @@ class PMA_Index return $comments; } + /** + * Returns index type ((BTREE, SPATIAL, FULLTEXT, HASH, RTREE) + * + * @return string index type + */ public function getType() { return $this->_type; } + /** + * Returns index choice (PRIMARY, UNIQUE, INDEX, SPATIAL, FULLTEXT) + * + * @return index choice + */ public function getChoice() { return $this->_choice; @@ -328,6 +381,11 @@ class PMA_Index ); } + /** + * Returns HTML for the index choice selector + * + * @return string HTML for the index choice selector + */ public function generateIndexSelector() { $html_options = ''; @@ -348,11 +406,24 @@ class PMA_Index return $html_options; } + /** + * Returns how the index is packed + * + * @return string how the index is packed + */ public function getPacked() { return $this->_packed; } + /** + * Returns 'No'/false if the index is not packed, + * how the index is packed if packed + * + * @param boolean $as_text whether to output should be in text + * + * @return mixed how index is paked + */ public function isPacked($as_text = false) { if ($as_text) { @@ -374,11 +445,23 @@ class PMA_Index return $this->_packed; } + /** + * Returns integer 0 if the index cannot contain duplicates, 1 if it can + * + * @return integer 0 if the index cannot contain duplicates, 1 if it can + */ public function getNonUnique() { return $this->_non_unique; } + /** + * Returns whether the index is a 'Unique' index + * + * @param boolean $as_text whether to output should be in text + * + * @return mixed whether the index is a 'Unique' index + */ public function isUnique($as_text = false) { if ($as_text) { @@ -396,16 +479,33 @@ class PMA_Index return $r[$this->_non_unique]; } + /** + * Returns the name of the index + * + * @return string the name of the index + */ public function getName() { return $this->_name; } + /** + * Sets the name of the index + * + * @param string $name index name + * + * @return void + */ public function setName($name) { $this->_name = (string) $name; } + /** + * Returns the columns of the index + * + * @return array the columns of the index + */ public function getColumns() { return $this->_columns; @@ -424,7 +524,7 @@ class PMA_Index */ static public function getView($table, $schema, $print_mode = false) { - + $common_functions = PMA_CommonFunctions::getInstance(); $indexes = PMA_Index::getFromTable($table, $schema); @@ -508,7 +608,7 @@ class PMA_Index $this_params['message_to_show'] = sprintf( __('Index %s has been dropped'), $index->getName() ); - + $js_msg = PMA_jsFormat( 'ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName() . ';' From 5fbb05628021e166a01439c7e54922f16ebadd4d Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 2 Sep 2012 20:25:44 +0530 Subject: [PATCH 9/9] Fix coding style. Remove trailing white spaces --- libraries/import.lib.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libraries/import.lib.php b/libraries/import.lib.php index 1bdcc1bd7d..1c8d7b1d20 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -77,12 +77,14 @@ function PMA_detectCompression($filepath) * @param string $sql query to run * @param string $full query to display, this might be commented * @param bool $controluser whether to use control user for queries + * @param array &$sql_data * * @return void * @access public */ -function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_data = array()) -{ +function PMA_importRunQuery($sql = '', $full = '', $controluser = false, + &$sql_data = array() +) { global $import_run_buffer, $go_sql, $complete_query, $display_query, $sql_query, $my_die, $error, $reload, $last_query_with_results, @@ -97,14 +99,14 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_d if (! empty($import_run_buffer['sql']) && trim($import_run_buffer['sql']) != '' ) { - + // USE query changes the database, son need to track // while running multiple queries $is_use_query = (stripos($import_run_buffer['sql'], "use ") !== false) ? true : false; - + $max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql'])); if (! $sql_query_disabled) { $sql_query .= $import_run_buffer['full']; @@ -116,9 +118,9 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_d $GLOBALS['message'] = PMA_Message::error(__('"DROP DATABASE" statements are disabled.')); $error = true; } else { - + $executed_queries++; - + if ($run_query && $GLOBALS['finished'] && empty($sql) @@ -138,7 +140,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_d $sql_query = $import_run_buffer['sql']; $sql_data['valid_sql'][] = $import_run_buffer['sql']; $sql_data['valid_queries']++; - + // If a 'USE ' SQL-clause was found, // set our current $db to the new one list($db, $reload) = PMA_lookForUse( @@ -147,7 +149,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_d $reload ); } elseif ($run_query) { - + if ($controluser) { $result = PMA_queryAsControlUser( $import_run_buffer['sql'] @@ -155,7 +157,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_d } else { $result = PMA_DBI_try_query($import_run_buffer['sql']); } - + $msg = '# '; if ($result === false) { // execution failed if (! isset($my_die)) { @@ -184,12 +186,12 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_d } else { $msg .= __('MySQL returned an empty result set (i.e. zero rows).'); } - + if (($a_num_rows > 0) || $is_use_query) { $sql_data['valid_sql'][] = $import_run_buffer['sql']; $sql_data['valid_queries']++; } - + } if (! $sql_query_disabled) { $sql_query .= $msg . "\n"; @@ -915,9 +917,9 @@ $import_notice = null; function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql = null, $options = null ) { - + $common_functions = PMA_CommonFunctions::getInstance(); - + /* Take care of the options */ if (isset($options['db_collation'])&& ! is_null($options['db_collation'])) { $collation = $options['db_collation'];