From ed1519ee76a572306bfa668e0cb72ce8e2d1bf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:33:10 +0200 Subject: [PATCH 01/14] Fix indentation of some code blocks --- libraries/sqlparser.lib.php | 289 ++++++++++++++++++------------------ 1 file changed, 144 insertions(+), 145 deletions(-) diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index 9a6df66f59..10c7547671 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -645,13 +645,12 @@ if (! defined('PMA_MINIMUM_COMMON')) { } elseif (($last == '-') || ($last == '+') || ($last == '!')) { $count2--; $punct_data = PMA_substr($sql, $count1, $count2 - $count1); - /** - * @todo for negation operator, split in 2 tokens ? - * "select x&~1 from t" - * becomes "select x & ~ 1 from t" ? - */ - } elseif ($last != '~') { + /** + * @todo for negation operator, split in 2 tokens ? + * "select x&~1 from t" + * becomes "select x & ~ 1 from t" ? + */ $debugstr = __('Unknown Punctuation String') . ' @ ' . ($count1+1) . "\n" . 'STR: ' . htmlspecialchars($punct_data); PMA_SQP_throwError($debugstr, $sql); @@ -812,16 +811,16 @@ if (! defined('PMA_MINIMUM_COMMON')) { return $sql_array; } // end of the "PMA_SQP_parse()" function - /** - * Checks for token types being what we want... - * - * @param string String of type that we have - * @param string String of type that we want - * - * @return boolean result of check - * - * @access private - */ + /** + * Checks for token types being what we want... + * + * @param string String of type that we have + * @param string String of type that we want + * + * @return boolean result of check + * + * @access private + */ function PMA_SQP_typeCheck($toCheck, $whatWeWant) { $typeSeperator = '_'; @@ -890,122 +889,122 @@ if (! defined('PMA_MINIMUM_COMMON')) { // for GROUP_CONCAT(...) $in_group_concat = false; -/* Description of analyzer results - * - * db, table, column, alias - * ------------------------ - * - * Inside the $subresult array, we create ['select_expr'] and ['table_ref'] arrays. - * - * The SELECT syntax (simplified) is - * - * SELECT - * select_expression,... - * [FROM [table_references] - * - * - * ['select_expr'] is filled with each expression, the key represents the - * expression position in the list (0-based) (so we don't lose track of - * multiple occurences of the same column). - * - * ['table_ref'] is filled with each table ref, same thing for the key. - * - * I create all sub-values empty, even if they are - * not present (for example no select_expression alias). - * - * There is a debug section at the end of loop #1, if you want to - * see the exact contents of select_expr and table_ref - * - * queryflags - * ---------- - * - * In $subresult, array 'queryflags' is filled, according to what we - * find in the query. - * - * Currently, those are generated: - * - * ['queryflags']['need_confirm'] = 1; if the query needs confirmation - * ['queryflags']['select_from'] = 1; if this is a real SELECT...FROM - * ['queryflags']['distinct'] = 1; for a DISTINCT - * ['queryflags']['union'] = 1; for a UNION - * ['queryflags']['join'] = 1; for a JOIN - * ['queryflags']['offset'] = 1; for the presence of OFFSET - * ['queryflags']['procedure'] = 1; for the presence of PROCEDURE - * - * query clauses - * ------------- - * - * The select is splitted in those clauses: - * ['select_expr_clause'] - * ['from_clause'] - * ['group_by_clause'] - * ['order_by_clause'] - * ['having_clause'] - * ['limit_clause'] - * ['where_clause'] - * - * The identifiers of the WHERE clause are put into the array - * ['where_clause_identifier'] - * - * For a SELECT, the whole query without the ORDER BY clause is put into - * ['unsorted_query'] - * - * foreign keys - * ------------ - * The CREATE TABLE may contain FOREIGN KEY clauses, so they get - * analyzed and ['foreign_keys'] is an array filled with - * the constraint name, the index list, - * the REFERENCES table name and REFERENCES index list, - * and ON UPDATE | ON DELETE clauses - * - * position_of_first_select - * ------------------------ - * - * The array index of the first SELECT we find. Will be used to - * insert a SQL_CALC_FOUND_ROWS. - * - * create_table_fields - * ------------------- - * - * Used to detect the DEFAULT CURRENT_TIMESTAMP and - * ON UPDATE CURRENT_TIMESTAMP clauses of the CREATE TABLE query. - * Also used to store the default value of the field. - * An array, each element is the identifier name. - * Note that for now, the timestamp_not_null element is created - * even for non-TIMESTAMP fields. - * - * Sub-elements: ['type'] which contains the column type - * optional (currently they are never false but can be absent): - * ['default_current_timestamp'] boolean - * ['on_update_current_timestamp'] boolean - * ['timestamp_not_null'] boolean - * - * section_before_limit, section_after_limit - * ----------------------------------------- - * - * Marks the point of the query where we can insert a LIMIT clause; - * so the section_before_limit will contain the left part before - * a possible LIMIT clause - * - * - * End of description of analyzer results - */ + /* Description of analyzer results + * + * db, table, column, alias + * ------------------------ + * + * Inside the $subresult array, we create ['select_expr'] and ['table_ref'] arrays. + * + * The SELECT syntax (simplified) is + * + * SELECT + * select_expression,... + * [FROM [table_references] + * + * + * ['select_expr'] is filled with each expression, the key represents the + * expression position in the list (0-based) (so we don't lose track of + * multiple occurences of the same column). + * + * ['table_ref'] is filled with each table ref, same thing for the key. + * + * I create all sub-values empty, even if they are + * not present (for example no select_expression alias). + * + * There is a debug section at the end of loop #1, if you want to + * see the exact contents of select_expr and table_ref + * + * queryflags + * ---------- + * + * In $subresult, array 'queryflags' is filled, according to what we + * find in the query. + * + * Currently, those are generated: + * + * ['queryflags']['need_confirm'] = 1; if the query needs confirmation + * ['queryflags']['select_from'] = 1; if this is a real SELECT...FROM + * ['queryflags']['distinct'] = 1; for a DISTINCT + * ['queryflags']['union'] = 1; for a UNION + * ['queryflags']['join'] = 1; for a JOIN + * ['queryflags']['offset'] = 1; for the presence of OFFSET + * ['queryflags']['procedure'] = 1; for the presence of PROCEDURE + * + * query clauses + * ------------- + * + * The select is splitted in those clauses: + * ['select_expr_clause'] + * ['from_clause'] + * ['group_by_clause'] + * ['order_by_clause'] + * ['having_clause'] + * ['limit_clause'] + * ['where_clause'] + * + * The identifiers of the WHERE clause are put into the array + * ['where_clause_identifier'] + * + * For a SELECT, the whole query without the ORDER BY clause is put into + * ['unsorted_query'] + * + * foreign keys + * ------------ + * The CREATE TABLE may contain FOREIGN KEY clauses, so they get + * analyzed and ['foreign_keys'] is an array filled with + * the constraint name, the index list, + * the REFERENCES table name and REFERENCES index list, + * and ON UPDATE | ON DELETE clauses + * + * position_of_first_select + * ------------------------ + * + * The array index of the first SELECT we find. Will be used to + * insert a SQL_CALC_FOUND_ROWS. + * + * create_table_fields + * ------------------- + * + * Used to detect the DEFAULT CURRENT_TIMESTAMP and + * ON UPDATE CURRENT_TIMESTAMP clauses of the CREATE TABLE query. + * Also used to store the default value of the field. + * An array, each element is the identifier name. + * Note that for now, the timestamp_not_null element is created + * even for non-TIMESTAMP fields. + * + * Sub-elements: ['type'] which contains the column type + * optional (currently they are never false but can be absent): + * ['default_current_timestamp'] boolean + * ['on_update_current_timestamp'] boolean + * ['timestamp_not_null'] boolean + * + * section_before_limit, section_after_limit + * ----------------------------------------- + * + * Marks the point of the query where we can insert a LIMIT clause; + * so the section_before_limit will contain the left part before + * a possible LIMIT clause + * + * + * End of description of analyzer results + */ // must be sorted // TODO: current logic checks for only one word, so I put only the // first word of the reserved expressions that end a table ref; // maybe this is not ok (the first word might mean something else) -// $words_ending_table_ref = array( -// 'FOR UPDATE', -// 'GROUP BY', -// 'HAVING', -// 'LIMIT', -// 'LOCK IN SHARE MODE', -// 'ORDER BY', -// 'PROCEDURE', -// 'UNION', -// 'WHERE' -// ); + // $words_ending_table_ref = array( + // 'FOR UPDATE', + // 'GROUP BY', + // 'HAVING', + // 'LIMIT', + // 'LOCK IN SHARE MODE', + // 'ORDER BY', + // 'PROCEDURE', + // 'UNION', + // 'WHERE' + // ); $words_ending_table_ref = array( 'FOR' => 1, 'GROUP' => 1, @@ -1047,7 +1046,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { // loop #1 for each token: select_expr, table_ref for SELECT for ($i = 0; $i < $size; $i++) { -//DEBUG echo "Loop1 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; + //DEBUG echo "Loop1 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; // High speed seek for locating the end of the current query if ($seek_queryend == true) { @@ -1068,7 +1067,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { continue; } // end if (type == punct_queryend) -// ============================================================== + // ============================================================== if ($arr[$i]['type'] == 'punct_bracket_open_round') { $number_of_brackets++; if ($in_extract) { @@ -1078,7 +1077,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { $number_of_brackets_in_group_concat++; } } -// ============================================================== + // ============================================================== if ($arr[$i]['type'] == 'punct_bracket_close_round') { $number_of_brackets--; if ($number_of_brackets == 0) { @@ -1109,7 +1108,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { */ continue; } -// ============================================================== + // ============================================================== if ($arr[$i]['type'] == 'alpha_functionName') { $upper_data = strtoupper($arr[$i]['data']); if ($upper_data =='EXTRACT') { @@ -1122,10 +1121,10 @@ if (! defined('PMA_MINIMUM_COMMON')) { } } -// ============================================================== + // ============================================================== if ($arr[$i]['type'] == 'alpha_reservedWord' -// && $arr[$i]['forbidden'] == false) { - ) { + //&& $arr[$i]['forbidden'] == false) { + ) { // We don't know what type of query yet, so run this if ($subresult['querytype'] == '') { $subresult['querytype'] = strtoupper($arr[$i]['data']); @@ -1168,7 +1167,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { // reserved words below } // end if (type == alpha_reservedWord) -// ============================== + // ============================== if ($arr[$i]['type'] == 'quote_backtick' || $arr[$i]['type'] == 'quote_double' || $arr[$i]['type'] == 'quote_single' @@ -1229,7 +1228,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { } // end if (querytype SELECT) } // end if (quote_backtick or double quote or alpha_identifier) -// =================================== + // =================================== if ($arr[$i]['type'] == 'punct_qualifier') { // to be able to detect an identifier following another $previous_was_identifier = false; @@ -1498,7 +1497,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { $in_subquery = false; for ($i = 0; $i < $size; $i++) { -//DEBUG echo "Loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; + //DEBUG echo "Loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; // need_confirm // @@ -1988,10 +1987,10 @@ if (! defined('PMA_MINIMUM_COMMON')) { if ($seen_references) { if ($seen_alter && $brackets_level > 0) { $foreign[$foreign_key_number]['ref_index_list'][] = $identifier; - // here, the first bracket level corresponds to the - // bracket of CREATE TABLE - // so if we are on level 2, it must be the index list - // of the foreign key REFERENCES + // here, the first bracket level corresponds to the + // bracket of CREATE TABLE + // so if we are on level 2, it must be the index list + // of the foreign key REFERENCES } elseif ($brackets_level > 1) { $foreign[$foreign_key_number]['ref_index_list'][] = $identifier; } elseif ($arr[$i+1]['type'] == 'punct_qualifier') { @@ -2200,7 +2199,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { $in_priv_list = false; for ($i = $start_token; $i < $number_of_tokens; $i++) { -// DEBUG echo "Loop format " . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; + // DEBUG echo "Loop format " . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; $before = ''; $after = ''; // array_shift($typearr); @@ -2307,7 +2306,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { // select 20 -9 // ) if ($typearr[3] != 'digit_integer') { - $after .= ' '; + $after .= ' '; } break; case 'punct_bracket_close_round': @@ -2453,8 +2452,8 @@ if (! defined('PMA_MINIMUM_COMMON')) { $before .= $space_alpha_reserved_word; } } else { - // on first keyword, check if it introduces a - // privilege list + // on first keyword, check if it introduces a + // privilege list if (isset($keywords_priv_list[$arr[$i]['data']])) { $in_priv_list = true; } From fae95bd225f63551445f51bb4645bd8c1ea6d065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:33:54 +0200 Subject: [PATCH 02/14] Fix indentation of some code blocks --- tbl_printview.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tbl_printview.php b/tbl_printview.php index 068cfbc743..a8eb5d623b 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -101,10 +101,10 @@ foreach ($the_tables as $key => $table) { $columns = PMA_DBI_get_columns($db, $table); -// We need this to correctly learn if a TIMESTAMP is NOT NULL, since -// SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL -// and SHOW CREATE TABLE says NOT NULL (tested -// in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). + // We need this to correctly learn if a TIMESTAMP is NOT NULL, since + // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL + // and SHOW CREATE TABLE says NOT NULL (tested + // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). $show_create_table = PMA_DBI_fetch_value( 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), From 747ab57391145c855f81efb89cd98d1c0e5b3c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:35:03 +0200 Subject: [PATCH 03/14] Adjust switch blocks to PEAR coding standards --- libraries/mysql_charsets.lib.php | 382 +++++++++++++++---------------- 1 file changed, 191 insertions(+), 191 deletions(-) diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index 45f9255bcf..05a5c3b83c 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -210,200 +210,200 @@ function PMA_getCollationDescr($collation) } $descr = ''; switch ($parts[1]) { - case 'bulgarian': - $descr = __('Bulgarian'); - break; - case 'chinese': - if ($parts[0] == 'gb2312' || $parts[0] == 'gbk') { - $descr = __('Simplified Chinese'); - } elseif ($parts[0] == 'big5') { - $descr = __('Traditional Chinese'); - } - break; - case 'ci': - $descr = __('case-insensitive'); - break; - case 'cs': - $descr = __('case-sensitive'); - break; - case 'croatian': - $descr = __('Croatian'); - break; - case 'czech': - $descr = __('Czech'); - break; - case 'danish': - $descr = __('Danish'); - break; - case 'english': - $descr = __('English'); - break; - case 'esperanto': - $descr = __('Esperanto'); - break; - case 'estonian': - $descr = __('Estonian'); - break; - case 'german1': - $descr = __('German') . ' (' . __('dictionary') . ')'; - break; - case 'german2': - $descr = __('German') . ' (' . __('phone book') . ')'; - break; - case 'hungarian': - $descr = __('Hungarian'); - break; - case 'icelandic': - $descr = __('Icelandic'); - break; - case 'japanese': - $descr = __('Japanese'); - break; - case 'latvian': - $descr = __('Latvian'); - break; - case 'lithuanian': - $descr = __('Lithuanian'); - break; - case 'korean': - $descr = __('Korean'); - break; - case 'persian': - $descr = __('Persian'); - break; - case 'polish': - $descr = __('Polish'); - break; - case 'roman': - $descr = __('West European'); - break; - case 'romanian': - $descr = __('Romanian'); - break; - case 'slovak': - $descr = __('Slovak'); - break; - case 'slovenian': - $descr = __('Slovenian'); - break; - case 'spanish': - $descr = __('Spanish'); - break; - case 'spanish2': - $descr = __('Traditional Spanish'); - break; - case 'swedish': - $descr = __('Swedish'); - break; - case 'thai': - $descr = __('Thai'); - break; - case 'turkish': - $descr = __('Turkish'); - break; - case 'ukrainian': - $descr = __('Ukrainian'); - break; - case 'unicode': + case 'bulgarian': + $descr = __('Bulgarian'); + break; + case 'chinese': + if ($parts[0] == 'gb2312' || $parts[0] == 'gbk') { + $descr = __('Simplified Chinese'); + } elseif ($parts[0] == 'big5') { + $descr = __('Traditional Chinese'); + } + break; + case 'ci': + $descr = __('case-insensitive'); + break; + case 'cs': + $descr = __('case-sensitive'); + break; + case 'croatian': + $descr = __('Croatian'); + break; + case 'czech': + $descr = __('Czech'); + break; + case 'danish': + $descr = __('Danish'); + break; + case 'english': + $descr = __('English'); + break; + case 'esperanto': + $descr = __('Esperanto'); + break; + case 'estonian': + $descr = __('Estonian'); + break; + case 'german1': + $descr = __('German') . ' (' . __('dictionary') . ')'; + break; + case 'german2': + $descr = __('German') . ' (' . __('phone book') . ')'; + break; + case 'hungarian': + $descr = __('Hungarian'); + break; + case 'icelandic': + $descr = __('Icelandic'); + break; + case 'japanese': + $descr = __('Japanese'); + break; + case 'latvian': + $descr = __('Latvian'); + break; + case 'lithuanian': + $descr = __('Lithuanian'); + break; + case 'korean': + $descr = __('Korean'); + break; + case 'persian': + $descr = __('Persian'); + break; + case 'polish': + $descr = __('Polish'); + break; + case 'roman': + $descr = __('West European'); + break; + case 'romanian': + $descr = __('Romanian'); + break; + case 'slovak': + $descr = __('Slovak'); + break; + case 'slovenian': + $descr = __('Slovenian'); + break; + case 'spanish': + $descr = __('Spanish'); + break; + case 'spanish2': + $descr = __('Traditional Spanish'); + break; + case 'swedish': + $descr = __('Swedish'); + break; + case 'thai': + $descr = __('Thai'); + break; + case 'turkish': + $descr = __('Turkish'); + break; + case 'ukrainian': + $descr = __('Ukrainian'); + break; + case 'unicode': + $descr = __('Unicode') . ' (' . __('multilingual') . ')'; + break; + case 'bin': + $is_bin = true; + case 'general': + switch ($parts[0]) { + // Unicode charsets + case 'ucs2': + case 'utf8': $descr = __('Unicode') . ' (' . __('multilingual') . ')'; break; - case 'bin': - $is_bin = true; - case 'general': - switch ($parts[0]) { - // Unicode charsets - case 'ucs2': - case 'utf8': - $descr = __('Unicode') . ' (' . __('multilingual') . ')'; - break; - // West European charsets - case 'ascii': - case 'cp850': - case 'dec8': - case 'hp8': - case 'latin1': - case 'macroman': - $descr = __('West European') . ' (' . __('multilingual') . ')'; - break; - // Central European charsets - case 'cp1250': - case 'cp852': - case 'latin2': - case 'macce': - $descr = __('Central European') . ' (' . __('multilingual') . ')'; - break; - // Russian charsets - case 'cp866': - case 'koi8r': - $descr = __('Russian'); - break; - // Simplified Chinese charsets - case 'gb2312': - case 'gbk': - $descr = __('Simplified Chinese'); - break; - // Japanese charsets - case 'sjis': - case 'ujis': - case 'cp932': - case 'eucjpms': - $descr = __('Japanese'); - break; - // Baltic charsets - case 'cp1257': - case 'latin7': - $descr = __('Baltic') . ' (' . __('multilingual') . ')'; - break; - // Other - case 'armscii8': - case 'armscii': - $descr = __('Armenian'); - break; - case 'big5': - $descr = __('Traditional Chinese'); - break; - case 'cp1251': - $descr = __('Cyrillic') . ' (' . __('multilingual') . ')'; - break; - case 'cp1256': - $descr = __('Arabic'); - break; - case 'euckr': - $descr = __('Korean'); - break; - case 'hebrew': - $descr = __('Hebrew'); - break; - case 'geostd8': - $descr = __('Georgian'); - break; - case 'greek': - $descr = __('Greek'); - break; - case 'keybcs2': - $descr = __('Czech-Slovak'); - break; - case 'koi8u': - $descr = __('Ukrainian'); - break; - case 'latin5': - $descr = __('Turkish'); - break; - case 'swe7': - $descr = __('Swedish'); - break; - case 'tis620': - $descr = __('Thai'); - break; - default: - $descr = __('unknown'); - break; - } - if (!empty($is_bin)) { - $descr .= ', ' . __('Binary'); - } + // West European charsets + case 'ascii': + case 'cp850': + case 'dec8': + case 'hp8': + case 'latin1': + case 'macroman': + $descr = __('West European') . ' (' . __('multilingual') . ')'; break; - default: $descr = __('unknown'); + // Central European charsets + case 'cp1250': + case 'cp852': + case 'latin2': + case 'macce': + $descr = __('Central European') . ' (' . __('multilingual') . ')'; + break; + // Russian charsets + case 'cp866': + case 'koi8r': + $descr = __('Russian'); + break; + // Simplified Chinese charsets + case 'gb2312': + case 'gbk': + $descr = __('Simplified Chinese'); + break; + // Japanese charsets + case 'sjis': + case 'ujis': + case 'cp932': + case 'eucjpms': + $descr = __('Japanese'); + break; + // Baltic charsets + case 'cp1257': + case 'latin7': + $descr = __('Baltic') . ' (' . __('multilingual') . ')'; + break; + // Other + case 'armscii8': + case 'armscii': + $descr = __('Armenian'); + break; + case 'big5': + $descr = __('Traditional Chinese'); + break; + case 'cp1251': + $descr = __('Cyrillic') . ' (' . __('multilingual') . ')'; + break; + case 'cp1256': + $descr = __('Arabic'); + break; + case 'euckr': + $descr = __('Korean'); + break; + case 'hebrew': + $descr = __('Hebrew'); + break; + case 'geostd8': + $descr = __('Georgian'); + break; + case 'greek': + $descr = __('Greek'); + break; + case 'keybcs2': + $descr = __('Czech-Slovak'); + break; + case 'koi8u': + $descr = __('Ukrainian'); + break; + case 'latin5': + $descr = __('Turkish'); + break; + case 'swe7': + $descr = __('Swedish'); + break; + case 'tis620': + $descr = __('Thai'); + break; + default: + $descr = __('unknown'); + break; + } + if (!empty($is_bin)) { + $descr .= ', ' . __('Binary'); + } + break; + default: $descr = __('unknown'); } if (!empty($parts[2])) { if ($parts[2] == 'ci') { From 617f6f5c241470a16a102eafdcb7de0bdbc39330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:36:16 +0200 Subject: [PATCH 04/14] Adjust switch blocks to PEAR coding standards --- libraries/common.lib.php | 164 +++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index b03e5dc855..dfa69df834 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -50,21 +50,21 @@ function PMA_pow($base, $exp, $use_function = false) return false; } switch ($use_function) { - case 'bcpow' : - // bcscale() needed for testing PMA_pow() with base values < 1 - bcscale(10); - $pow = bcpow($base, $exp); - break; - case 'gmp_pow' : - $pow = gmp_strval(gmp_pow($base, $exp)); - break; - case 'pow' : - $base = (float) $base; - $exp = (int) $exp; - $pow = pow($base, $exp); - break; - default: - $pow = $use_function($base, $exp); + case 'bcpow' : + // bcscale() needed for testing PMA_pow() with base values < 1 + bcscale(10); + $pow = bcpow($base, $exp); + break; + case 'gmp_pow' : + $pow = gmp_strval(gmp_pow($base, $exp)); + break; + case 'pow' : + $base = (float) $base; + $exp = (int) $exp; + $pow = pow($base, $exp); + break; + default: + $pow = $use_function($base, $exp); } return $pow; @@ -301,23 +301,23 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '') $formatted_sql = ''; switch ($cfg['SQP']['fmtType']) { - case 'none': - if ($unparsed_sql != '') { - $formatted_sql = '
' . "\n"
-                    . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n"
-                    . '
'; - } else { - $formatted_sql = PMA_SQP_formatNone($parsed_sql); - } - break; - case 'html': - $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color'); - break; - case 'text': - $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text'); - break; - default: - break; + case 'none': + if ($unparsed_sql != '') { + $formatted_sql = '
' . "\n"
+                . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n"
+                . '
'; + } else { + $formatted_sql = PMA_SQP_formatNone($parsed_sql); + } + break; + case 'html': + $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color'); + break; + case 'text': + $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text'); + break; + default: + break; } // end switch return $formatted_sql; @@ -350,57 +350,57 @@ function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', $ju $link = str_replace('_', '-', strtolower($link)); switch ($cfg['MySQLManualType']) { - case 'chapters': - if (empty($chapter)) { - $chapter = 'index'; + case 'chapters': + if (empty($chapter)) { + $chapter = 'index'; + } + if (empty($anchor)) { + $anchor = $link; + } + $url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $anchor; + break; + case 'big': + if (empty($anchor)) { + $anchor = $link; + } + $url = $cfg['MySQLManualBase'] . '#' . $anchor; + break; + case 'searchable': + if (empty($link)) { + $link = 'index'; + } + $url = $cfg['MySQLManualBase'] . '/' . $link . '.html'; + if (!empty($anchor)) { + $url .= '#' . $anchor; + } + break; + case 'viewable': + default: + if (empty($link)) { + $link = 'index'; + } + $mysql = '5.0'; + $lang = 'en'; + if (defined('PMA_MYSQL_INT_VERSION')) { + if (PMA_MYSQL_INT_VERSION >= 50500) { + $mysql = '5.5'; + /* l10n: Language to use for MySQL 5.5 documentation, please use only languages which do exist in official documentation. */ + $lang = _pgettext('MySQL 5.5 documentation language', 'en'); + } else if (PMA_MYSQL_INT_VERSION >= 50100) { + $mysql = '5.1'; + /* l10n: Language to use for MySQL 5.1 documentation, please use only languages which do exist in official documentation. */ + $lang = _pgettext('MySQL 5.1 documentation language', 'en'); + } else { + $mysql = '5.0'; + /* l10n: Language to use for MySQL 5.0 documentation, please use only languages which do exist in official documentation. */ + $lang = _pgettext('MySQL 5.0 documentation language', 'en'); } - if (empty($anchor)) { - $anchor = $link; - } - $url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $anchor; - break; - case 'big': - if (empty($anchor)) { - $anchor = $link; - } - $url = $cfg['MySQLManualBase'] . '#' . $anchor; - break; - case 'searchable': - if (empty($link)) { - $link = 'index'; - } - $url = $cfg['MySQLManualBase'] . '/' . $link . '.html'; - if (!empty($anchor)) { - $url .= '#' . $anchor; - } - break; - case 'viewable': - default: - if (empty($link)) { - $link = 'index'; - } - $mysql = '5.0'; - $lang = 'en'; - if (defined('PMA_MYSQL_INT_VERSION')) { - if (PMA_MYSQL_INT_VERSION >= 50500) { - $mysql = '5.5'; - /* l10n: Language to use for MySQL 5.5 documentation, please use only languages which do exist in official documentation. */ - $lang = _pgettext('MySQL 5.5 documentation language', 'en'); - } else if (PMA_MYSQL_INT_VERSION >= 50100) { - $mysql = '5.1'; - /* l10n: Language to use for MySQL 5.1 documentation, please use only languages which do exist in official documentation. */ - $lang = _pgettext('MySQL 5.1 documentation language', 'en'); - } else { - $mysql = '5.0'; - /* l10n: Language to use for MySQL 5.0 documentation, please use only languages which do exist in official documentation. */ - $lang = _pgettext('MySQL 5.0 documentation language', 'en'); - } - } - $url = $cfg['MySQLManualBase'] . '/' . $mysql . '/' . $lang . '/' . $link . '.html'; - if (!empty($anchor)) { - $url .= '#' . $anchor; - } - break; + } + $url = $cfg['MySQLManualBase'] . '/' . $mysql . '/' . $lang . '/' . $link . '.html'; + if (!empty($anchor)) { + $url .= '#' . $anchor; + } + break; } $open_link = ''; From bc17e5eeddcfeb08b2b8e534fe8a43280771175e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:36:31 +0200 Subject: [PATCH 05/14] Fix indentation --- libraries/common.lib.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index dfa69df834..c114d9d3eb 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -615,14 +615,14 @@ function PMA_mysqlDie($error_message = '', $the_query = '', $_SESSION['Import_message']['message'] = $error_msg_output; if ($exit) { - /** - * If in an Ajax request - * - avoid displaying a Back link - * - use PMA_ajaxResponse() to transmit the message and exit - */ - if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($error_msg_output, false); - } + /** + * If in an Ajax request + * - avoid displaying a Back link + * - use PMA_ajaxResponse() to transmit the message and exit + */ + if ($GLOBALS['is_ajax_request'] == true) { + PMA_ajaxResponse($error_msg_output, false); + } if (! empty($back_url)) { if (strstr($back_url, '?')) { $back_url .= '&no_history=true'; @@ -635,13 +635,13 @@ function PMA_mysqlDie($error_message = '', $the_query = '', $error_msg_output .= '
'; $error_msg_output .= '[ ' . __('Back') . ' ]'; $error_msg_output .= '
' . "\n\n"; - } + } - echo $error_msg_output; - /** - * display footer and exit - */ - require './libraries/footer.inc.php'; + echo $error_msg_output; + /** + * display footer and exit + */ + require './libraries/footer.inc.php'; } else { echo $error_msg_output; } @@ -866,8 +866,8 @@ if (typeof(window.parent) != 'undefined' } //]]> ' . PHP_EOL; + if (!$jsonly) + echo '' . PHP_EOL; unset($GLOBALS['reload']); } From f7d85630ed4f0ee01a77c1ec1ca34c8cc46afca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:38:26 +0200 Subject: [PATCH 06/14] Improve coding style --- libraries/common.lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index c114d9d3eb..b4b0469bb4 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -855,8 +855,9 @@ function PMA_reloadNavigation($jsonly=false) unset($_SESSION['tmp_user_values']['table_limit_offset']); echo "\n"; $reload_url = './navigation.php?' . PMA_generate_common_url($GLOBALS['db'], '', '&'); - if (!$jsonly) - echo '' . PHP_EOL; + if (!$jsonly) { + echo '' . PHP_EOL; + } unset($GLOBALS['reload']); } From 9317162dcc44a392a4528fcb3567ae9f801a6787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 17:39:19 +0200 Subject: [PATCH 07/14] Fix indentation --- libraries/common.lib.php | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index b4b0469bb4..b87e00aca0 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1206,8 +1206,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view // mode because 1) it currently does not work and 2) we would // have two similar mechanisms on the page for the same goal if ($is_select || $GLOBALS['is_ajax_request'] === false && ! $query_too_big) { - // see in js/functions.js the jQuery code attached to id inline_edit - // document.write conflicts with jQuery, hence used $().append() + // see in js/functions.js the jQuery code attached to id inline_edit + // document.write conflicts with jQuery, hence used $().append() echo "