Minor coding style modifications.

Fix typos.
PHPDoc and JSDoc updates.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
Hugues Peccatte 2014-11-02 14:04:31 +01:00
parent 4139575bbc
commit 037a034b43
21 changed files with 123 additions and 98 deletions

View File

@ -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
);
}
}

View File

@ -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!'));
}

View File

@ -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') {

View File

@ -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()

View File

@ -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();

View File

@ -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)
{

View File

@ -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

View File

@ -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) {

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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[]
*
**/

View File

@ -136,7 +136,8 @@ class PMA_Console
. $val['id'] . '" targetdb="' . htmlspecialchars($val['db'])
. '"><div class="action_content">'
. sprintf($tpl_bookmark_actions, htmlspecialchars($val['db']))
. '</div><span class="bookmark_label ' . ($val['shared'] ? 'shared' : '') . '">'
. '</div><span class="bookmark_label '
. ($val['shared'] ? 'shared' : '') . '">'
. htmlspecialchars($val['label'])
. '</span> <span class="query">'
. htmlspecialchars($val['query'])

View File

@ -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';
}

View File

@ -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 {

View File

@ -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 .= '<table id="' . $t_n_url . '" cellpadding="0" cellspacing="0" ';
$html .= 'class="pmd_tab" style="position:absolute;';
$html .= 'left:';
$html .= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["X"] : rand(20, 700)) . 'px;';
$html .= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["X"] : rand(20, 700))
. 'px;';
$html .= 'top:';
$html .= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["Y"] : rand(20, 550)) . 'px;';
$html .= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["Y"] : rand(20, 550))
. 'px;';
$html .= 'display:';
$html .= (isset($tab_pos[$t_n]) || $display_page == -1) ? 'block;' : 'none;';
$html .= 'z-index: 1;">';
@ -666,7 +668,8 @@ function PMA_getDatabaseTables(
$tmpColumn = $t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j];
if (!PMA_Util::isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])) {
if (!PMA_Util::isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])
) {
$html .= (isset($tables_pk_or_unique_keys[$tmpColumn]) ? 1 : 0);
} else {
// if foreign keys are supported, it's not necessary that the

View File

@ -361,7 +361,8 @@ function PMA_importGetNextChunk($size = 32768)
} else {
$r = /*overload*/mb_substr($GLOBALS['import_text'], 0, $size);
$GLOBALS['offset'] += $size;
$GLOBALS['import_text'] = /*overload*/mb_substr($GLOBALS['import_text'], $size);
$GLOBALS['import_text'] = /*overload*/
mb_substr($GLOBALS['import_text'], $size);
return $r;
}
}

View File

@ -159,21 +159,24 @@ class Node_Table extends Node_DatabaseChild
$query .= "ORDER BY `COLUMN_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->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:

View File

@ -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;
}

View File

@ -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

View File

@ -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` = "

View File

@ -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(