From 037a034b437b493b05d98231aff3dc0eb17d459a Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 2 Nov 2014 14:04:31 +0100 Subject: [PATCH] Minor coding style modifications. Fix typos. PHPDoc and JSDoc updates. Signed-off-by: Hugues Peccatte --- db_sql_autocomplete.php | 4 +- export.php | 8 +- import.php | 8 +- js/ajax.js | 10 +-- js/common.js | 8 +- js/config.js | 4 +- js/console.js | 4 +- js/db_structure.js | 6 +- js/functions.js | 35 +++++---- js/pmd/history.js | 11 ++- js/pmd/move.js | 2 +- libraries/Console.class.php | 3 +- libraries/config/Validator.class.php | 4 +- libraries/core.lib.php | 4 +- libraries/db_designer.lib.php | 11 ++- libraries/import.lib.php | 3 +- .../navigation/Nodes/Node_Table.class.php | 76 ++++++++++--------- libraries/sqlparser.lib.php | 5 +- tbl_addfield.php | 8 +- test/classes/PMA_TableSearch_test.php | 4 +- test/libraries/PMA_generateCommonUrl_test.php | 3 +- 21 files changed, 123 insertions(+), 98 deletions(-) diff --git a/db_sql_autocomplete.php b/db_sql_autocomplete.php index 48cf3d884c..3701627e0b 100644 --- a/db_sql_autocomplete.php +++ b/db_sql_autocomplete.php @@ -14,7 +14,9 @@ $sql_autocomplete = array(); if ($db) { $tableNames = $GLOBALS['dbi']->getTables($db); foreach ($tableNames as $tableName) { - $sql_autocomplete[$tableName] = $GLOBALS['dbi']->getColumnNames($db, $tableName); + $sql_autocomplete[$tableName] = $GLOBALS['dbi']->getColumnNames( + $db, $tableName + ); } } diff --git a/export.php b/export.php index ff84141209..ff709956ff 100644 --- a/export.php +++ b/export.php @@ -255,9 +255,11 @@ if (!defined('TESTSUITE')) { } elseif ($export_type == 'table' && /*overload*/mb_strlen($db) && /*overload*/mb_strlen($table) ) { - $err_url = 'tbl_export.php' . PMA_URL_getCommon(array( - 'db' => $db, 'table' => $table - )); + $err_url = 'tbl_export.php' . PMA_URL_getCommon( + array( + 'db' => $db, 'table' => $table + ) + ); } else { PMA_fatalError(__('Bad parameters!')); } diff --git a/import.php b/import.php index 78dbc3550b..73e276ad98 100644 --- a/import.php +++ b/import.php @@ -222,9 +222,11 @@ $pmaString = $GLOBALS['PMA_String']; // Create error and goto url if ($import_type == 'table') { - $err_url = 'tbl_import.php' . PMA_URL_getCommon(array( - 'db' => $db, 'table' => $table - )); + $err_url = 'tbl_import.php' . PMA_URL_getCommon( + array( + 'db' => $db, 'table' => $table + ) + ); $_SESSION['Import_message']['go_back_url'] = $err_url; $goto = 'tbl_import.php'; } elseif ($import_type == 'database') { diff --git a/js/ajax.js b/js/ajax.js index cd2bf92307..d0146a7553 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -38,7 +38,7 @@ var AJAX = { * Given the filename of a script, returns a hash to be * used to refer to all the events registered for the file * - * @param string key The filename for which to get the event name + * @param key string key The filename for which to get the event name * * @return int */ @@ -59,8 +59,8 @@ var AJAX = { /** * Registers an onload event for a file * - * @param string file The filename for which to register the event - * @param function func The function to execute when the page is ready + * @param file string file The filename for which to register the event + * @param func function func The function to execute when the page is ready * * @return self For chaining */ @@ -406,7 +406,7 @@ var AJAX = { } else if (data._promptPhpErrors) { // otherwise just prompt user if it is set so. msg = msg + PMA_messages.phpErrorsFound; - // scroll to bottom where all the erros are displayed. + // scroll to bottom where all the errors are displayed. $('html, body').animate({scrollTop:$(document).height()}, 'slow'); } } @@ -652,7 +652,7 @@ AJAX.cache = { * Saves a new page in the cache * * @param string hash The hash part of the url that is being loaded - * @param array scripts A list of scripts that is requured for the page + * @param array scripts A list of scripts that is required for the page * @param string menu A hash that links to a menu stored * in a dedicated menu cache * @param array params A list of parameters used by PMA_commonParams() diff --git a/js/common.js b/js/common.js index daf1f04385..8c4e8b8c65 100644 --- a/js/common.js +++ b/js/common.js @@ -212,7 +212,7 @@ PMA_DROP_IMPORT = { .children('progress').val(percent); }, /** - * Function to upload the file asyncronously + * Function to upload the file asynchronously * * @param formData FormData object for a specific file * @param hash hash of the current file upload @@ -355,7 +355,7 @@ PMA_DROP_IMPORT = { /** * Called when upload has finished * - * @param string, uniques hash for a certain upload + * @param string, unique hash for a certain upload * @param bool, true if upload was aborted * @param bool, status of sql upload, as sent by server * @@ -398,7 +398,7 @@ PMA_DROP_IMPORT = { }, /** * Triggered when dragged objects are dropped to UI - * From this function, the AJAX Upload operation is initated + * From this function, the AJAX Upload operation is initiated * * @param event object * @@ -410,7 +410,7 @@ PMA_DROP_IMPORT = { if (dbname !== '') { var files = event.originalEvent.dataTransfer.files; if (!files || files.length === 0) { - // No files actually transfered + // No files actually transferred $(".pma_drop_handler").fadeOut(); event.stopPropagation(); event.preventDefault(); diff --git a/js/config.js b/js/config.js index 149e3d2091..63147b7e90 100644 --- a/js/config.js +++ b/js/config.js @@ -291,12 +291,12 @@ function validateField(id, type, onKeyUp, params) } /** - * Returns valdiation functions associated with form field + * Returns validation functions associated with form field * * @param {String} field_id form field id * @param {boolean} onKeyUpOnly see validateField * @type Array - * @return array of [function, paramseters to be passed to function] + * @return array of [function, parameters to be passed to function] */ function getFieldValidators(field_id, onKeyUpOnly) { diff --git a/js/console.js b/js/console.js index 56259fc5bf..d832297001 100644 --- a/js/console.js +++ b/js/console.js @@ -187,7 +187,7 @@ var PMA_console = { } }, /** - * Excute query and show results in console + * Execute query and show results in console * * @return void */ @@ -294,7 +294,7 @@ var PMA_console = { PMA_console.collapse(); }, /** - * Toggle console mode between collsapse/show + * Toggle console mode between collapse/show * Used for toggle buttons and shortcuts * * @return void diff --git a/js/db_structure.js b/js/db_structure.js index 807b8cb898..7eee8d6db2 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -101,7 +101,7 @@ function PMA_adjustTotals() { sizeSum += valSize; overheadSum += valOverhead; }); - // Add some commas for readablility: + // Add some commas for readability: // 1000000 becomes 1,000,000 var strRowSum = rowsSum + ""; var regex = /(\d+)(\d{3})/; @@ -209,7 +209,7 @@ AJAX.registerOnload('db_structure.js', function () { /** * function to open the confirmation dialog for making table consistent with central list * - * @param string msg message text to be displayedd to user + * @param string msg message text to be displayed to user * @param function success function to be called on success * */ @@ -455,7 +455,7 @@ AJAX.registerOnload('db_structure.js', function () { //Calculate Real End for InnoDB /** - * Ajax Event handler for calculatig the real end for a InnoDB table + * Ajax Event handler for calculating the real end for a InnoDB table * */ $('#real_end_input').live('click', function (event) { diff --git a/js/functions.js b/js/functions.js index 704cd94ba8..24604c05cc 100644 --- a/js/functions.js +++ b/js/functions.js @@ -55,12 +55,12 @@ var chart_activeTimeouts = {}; var central_column_list = []; /** - * @var primary_indexes array to hold 'Primary' indexe columns. + * @var primary_indexes array to hold 'Primary' index columns. */ var primary_indexes = []; /** - * @var unique_indexes array to hold 'Unique' indexe columns. + * @var unique_indexes array to hold 'Unique' index columns. */ var unique_indexes = []; @@ -421,7 +421,7 @@ function confirmLink(theLink, theSqlQuery) /** * Displays an error message if a "DROP DATABASE" statement is submitted * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before - * sumitting it if required. + * submitting it if required. * This function is called by the 'checkSqlQuery()' js function. * * @param theForm1 object the form @@ -565,14 +565,13 @@ function emptyCheckTheField(theForm, theFieldName) * @param string the name of the form field to put the focus on * * @return boolean whether the form field is empty or not + * + * @deprecated + * @see emptyCheckTheField(theForm, theFieldName) */ function emptyFormElements(theForm, theFieldName) { - var theField = theForm.elements[theFieldName]; - var isEmpty = emptyCheckTheField(theForm, theFieldName); - - - return isEmpty; + return emptyCheckTheField(theForm, theFieldName); } // end of the 'emptyFormElements()' function @@ -729,7 +728,7 @@ AJAX.registerOnload('functions.js', function () { } else { updateInterval = window.setInterval(UpdateIdleTime, 2000); } - } else { //timeout occured + } else { //timeout occurred window.location.reload(true); clearInterval(IncInterval); } @@ -859,7 +858,7 @@ var marked_row = []; /** * marks all rows and selects its first checkbox inside the given element - * the given element is usaly a table or a div containing the table or tables + * the given element is usually a table or a div containing the table or tables * * @param container DOM element */ @@ -874,7 +873,7 @@ function markAllRows(container_id) /** * marks all rows and selects its first checkbox inside the given element - * the given element is usaly a table or a div containing the table or tables + * the given element is usually a table or a div containing the table or tables * * @param container DOM element */ @@ -888,7 +887,7 @@ function unMarkAllRows(container_id) } /** - * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div) + * Checks/unchecks all checkbox in given container (f.e. a form, fieldset or div) * * @param string container_id the container id * @param boolean state new value for checkbox (true or false) @@ -2291,7 +2290,7 @@ function PMA_SQLPrettyPrint(string) output += "\n" + tabs(indentLevel + 1); lastStatementPart = tokens[i][1]; } - // Normal indentatin and spaces for everything else + // Normal indentation and spaces for everything else else { if (! spaceExceptionsBefore[tokens[i][1]] && ! (i > 0 && spaceExceptionsAfter[tokens[i - 1][1]]) && @@ -2319,7 +2318,7 @@ function PMA_SQLPrettyPrint(string) if (blockStack[0] == 'statement') { output += "\n" + tabs(indentLevel + 1); } - // Todo: Also split and or blocks in newlines & identation++ + // Todo: Also split and or blocks in newlines & indentation++ //if (blockStack[0] == 'generic') // output += ... } @@ -2737,7 +2736,7 @@ AJAX.registerOnload('functions.js', function () { PMA_ajaxShowMessage($error, false); } }); // end $.post() - });//end of table maintanance ajax click + });//end of table maintenance ajax click }); //end $(document).ready for 'Table operations' /** @@ -3553,7 +3552,7 @@ function PMA_mainMenuResizerCallback() { // 5 px margin for jumping menu in Chrome return $(document.body).width() - 5; } -// This must be fired only once after the inital page load +// This must be fired only once after the initial page load $(function () { // Initialise the menu resize plugin $('#topmenu').menuResizer(PMA_mainMenuResizerCallback); @@ -3784,7 +3783,7 @@ AJAX.registerOnload('functions.js', function () { $('.vmarker').filter('.row_' + row_num).removeClass('marked'); } } else { - // normaln data table, just toggle class + // normal data table, just toggle class $('.vmarker').filter('.row_' + row_num).toggleClass('marked'); } }); @@ -4639,7 +4638,7 @@ function PMA_ignorePhpErrors(clearPrevErrors){ $('#pma_report_errors_form').submit(); } - // remove dislayed errors + // remove displayed errors $('#pma_errors').fadeOut( "slow"); $('#pma_errors').remove(); } diff --git a/js/pmd/history.js b/js/pmd/history.js index 8837ae0617..1577f4e338 100644 --- a/js/pmd/history.js +++ b/js/pmd/history.js @@ -28,7 +28,7 @@ function panel(index) } /** - * To display details of obects(where,rename,Having,aggregate,groupby,orderby,having) + * To display details of objects(where,rename,Having,aggregate,groupby,orderby,having) * * @param index index of history_array where change is to be made * @@ -359,7 +359,7 @@ var where = function (nrelation_operator, nquery) { * * @param nrelation_operator type of relation operator to be applied * @param nquery stores value of value/sub-query - * + * @param noperator operator **/ var having = function (nrelation_operator, nquery, noperator) { @@ -428,7 +428,7 @@ var aggregate = function (noperator) { /** * This function returns unique element from an array * - * @param arraName array from which duplicate elem are to be removed. + * @param arrayName array from which duplicate elem are to be removed. * @return unique array */ @@ -469,7 +469,7 @@ function found(arrayName, value) * This function concatenates two array * * @params add array elements of which are pushed in - * @params arr array in which elemnets are added + * @params arr array in which elements are added */ function add_array(add, arr) { @@ -479,7 +479,7 @@ function add_array(add, arr) return arr; } -/* This fucntion removes all elements present in one array from the other. +/* This function removes all elements present in one array from the other. * * @params rem array from which each element is removed from other array. * @params arr array from which elements are removed. @@ -629,7 +629,6 @@ function gradient(id, level) box.style.KhtmlOpacity = level; box.style.filter = "alpha(opacity=" + level * 100 + ")"; box.style.display = "block"; - return; } diff --git a/js/pmd/move.js b/js/pmd/move.js index 5e24b7001f..b65d2d3b75 100644 --- a/js/pmd/move.js +++ b/js/pmd/move.js @@ -1683,7 +1683,7 @@ function store_column(id_this, owner, col) /** * This function builds object and adds them to history_array * first it does a few checks on each object, then makes an object(where,rename,groupby,aggregate,orderby) - * then a new history object is made and finally all these history objects are addded to history_array[] + * then a new history object is made and finally all these history objects are added to history_array[] * **/ diff --git a/libraries/Console.class.php b/libraries/Console.class.php index 0dbb192218..19aab62c8e 100644 --- a/libraries/Console.class.php +++ b/libraries/Console.class.php @@ -136,7 +136,8 @@ class PMA_Console . $val['id'] . '" targetdb="' . htmlspecialchars($val['db']) . '">
' . sprintf($tpl_bookmark_actions, htmlspecialchars($val['db'])) - . '
' + . '' . htmlspecialchars($val['label']) . ' ' . htmlspecialchars($val['query']) diff --git a/libraries/config/Validator.class.php b/libraries/config/Validator.class.php index 2f5859e48a..86d7e7855e 100644 --- a/libraries/config/Validator.class.php +++ b/libraries/config/Validator.class.php @@ -234,7 +234,9 @@ class PMA_Validator $port = empty($port) || $connect_type == 'socket' ? null : $port; $extension = 'mysqli'; } else { - $socket = empty($socket) || $connect_type == 'tcp' ? null : ':' . ($socket[0] == '/' ? '' : '/') . $socket; + $socket = empty($socket) || $connect_type == 'tcp' + ? null + : ':' . ($socket[0] == '/' ? '' : '/') . $socket; $port = empty($port) || $connect_type == 'socket' ? null : ':' . $port; $extension = 'mysql'; } diff --git a/libraries/core.lib.php b/libraries/core.lib.php index 26c5e34576..8e92c5a6d4 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -229,8 +229,8 @@ function PMA_fatalError( /* Load gettext for fatal errors */ if (!function_exists('__')) { - // It is possible that PMA_fatalError() is called before including vendor_config.php - // which defines GETTEXT_INC. See bug #4557 + // It is possible that PMA_fatalError() is called before including + // vendor_config.php which defines GETTEXT_INC. See bug #4557 if (defined(GETTEXT_INC)) { include_once GETTEXT_INC; } else { diff --git a/libraries/db_designer.lib.php b/libraries/db_designer.lib.php index f626a57267..2c60c7528a 100644 --- a/libraries/db_designer.lib.php +++ b/libraries/db_designer.lib.php @@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) { require_once 'libraries/relation.lib.php'; /** - * Function to get html to display a page selector + * Function to get html to display a page selector * * @param array $cfgRelation information about the configuration storage * @param string $db database name @@ -557,9 +557,11 @@ function PMA_getDatabaseTables( $html .= 'fetchResult($query); - } else { - $db = PMA_Util::backquote($db); - $table = PMA_Util::backquote($table); - $query = "SHOW COLUMNS FROM $table FROM $db"; - $handle = $GLOBALS['dbi']->tryQuery($query); - if ($handle !== false) { - $count = 0; - while ($arr = $GLOBALS['dbi']->fetchArray($handle)) { - if ($pos <= 0 && $count < $maxItems) { - $retval[] = $arr['Field']; - $count++; - } - $pos--; - } + break; + } + + $db = PMA_Util::backquote($db); + $table = PMA_Util::backquote($table); + $query = "SHOW COLUMNS FROM $table FROM $db"; + $handle = $GLOBALS['dbi']->tryQuery($query); + if ($handle === false) { + break; + } + + $count = 0; + while ($arr = $GLOBALS['dbi']->fetchArray($handle)) { + if ($pos <= 0 && $count < $maxItems) { + $retval[] = $arr['Field']; + $count++; } + $pos--; } break; case 'indexes': @@ -184,15 +187,17 @@ class Node_Table extends Node_DatabaseChild if ($handle === false) { break; } + $count = 0; while ($arr = $GLOBALS['dbi']->fetchArray($handle)) { - if (! in_array($arr['Key_name'], $retval)) { - if ($pos <= 0 && $count < $maxItems) { - $retval[] = $arr['Key_name']; - $count++; - } - $pos--; + if (in_array($arr['Key_name'], $retval)) { + continue; } + if ($pos <= 0 && $count < $maxItems) { + $retval[] = $arr['Key_name']; + $count++; + } + $pos--; } break; case 'triggers': @@ -208,21 +213,24 @@ class Node_Table extends Node_DatabaseChild $query .= "ORDER BY `TRIGGER_NAME` ASC "; $query .= "LIMIT " . intval($pos) . ", $maxItems"; $retval = $GLOBALS['dbi']->fetchResult($query); - } else { - $db = PMA_Util::backquote($db); - $table = PMA_Util::sqlAddSlashes($table); - $query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'"; - $handle = $GLOBALS['dbi']->tryQuery($query); - if ($handle !== false) { - $count = 0; - while ($arr = $GLOBALS['dbi']->fetchArray($handle)) { - if ($pos <= 0 && $count < $maxItems) { - $retval[] = $arr['Trigger']; - $count++; - } - $pos--; - } + break; + } + + $db = PMA_Util::backquote($db); + $table = PMA_Util::sqlAddSlashes($table); + $query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'"; + $handle = $GLOBALS['dbi']->tryQuery($query); + if ($handle === false) { + break; + } + + $count = 0; + while ($arr = $GLOBALS['dbi']->fetchArray($handle)) { + if ($pos <= 0 && $count < $maxItems) { + $retval[] = $arr['Trigger']; + $count++; } + $pos--; } break; default: diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index 3a498f3633..958ed41577 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -2093,7 +2093,8 @@ function PMA_SQP_analyze($arr) if ($upper_data == 'CURRENT_TIMESTAMP') { if ($in_timestamp_options) { if ($seen_default) { - $create_table_fields[$current_identifier]['default_current_timestamp'] = true; + $create_table_fields[$current_identifier] + ['default_current_timestamp'] = true; } } } @@ -2167,7 +2168,7 @@ function PMA_SQP_analyze($arr) ) { $create_table_fields[$current_identifier] ['on_update_current_timestamp'] - = true; + = true; $seen_default = false; } diff --git a/tbl_addfield.php b/tbl_addfield.php index 01b104c656..209f07bf2e 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -23,9 +23,11 @@ PMA_Util::checkParameters(array('db', 'table')); /** * Defines the url to return to in case of error in a sql statement */ -$err_url = 'tbl_sql.php' . PMA_URL_getCommon(array( - 'db' => $db, 'table' => $table -)); +$err_url = 'tbl_sql.php' . PMA_URL_getCommon( + array( + 'db' => $db, 'table' => $table + ) +); /** * The form used to define the field to add has been submitted diff --git a/test/classes/PMA_TableSearch_test.php b/test/classes/PMA_TableSearch_test.php index 7be77b5746..8519c153d8 100644 --- a/test/classes/PMA_TableSearch_test.php +++ b/test/classes/PMA_TableSearch_test.php @@ -242,7 +242,9 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase $replaceWith = "Column"; $useRegex = false; $charSet = "UTF-8"; - $tableSearch->replace($columnIndex, $find, $replaceWith, $useRegex, $charSet); + $tableSearch->replace( + $columnIndex, $find, $replaceWith, $useRegex, $charSet + ); $sql_query = $GLOBALS['sql_query']; $result = "UPDATE `PMA`.`PMA_BookMark` SET `Field1` = " diff --git a/test/libraries/PMA_generateCommonUrl_test.php b/test/libraries/PMA_generateCommonUrl_test.php index f2b3700cb3..fd58d88ef1 100644 --- a/test/libraries/PMA_generateCommonUrl_test.php +++ b/test/libraries/PMA_generateCommonUrl_test.php @@ -99,7 +99,8 @@ class PMA_GenerateCommonURL_Test extends PHPUnit_Framework_TestCase . 'token=token' ; - $expected = '#ABC#db=db' . $separator . 'table=table' . $separator . $expected; + $expected = '#ABC#db=db' . $separator . 'table=table' . $separator + . $expected; $this->assertEquals( $expected, PMA_URL_getCommon(