Skip to content

Commit

Permalink
phpcs warnings and errors corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
scnakandala committed Jul 9, 2013
1 parent e96b7d6 commit 1851790
Showing 1 changed file with 59 additions and 46 deletions.
105 changes: 59 additions & 46 deletions libraries/sql.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,22 @@ function PMA_getHtmlForPrintViewHeader($db, $sql_query, $num_rows)
$print_view_header = '';
$print_view_header .= "<h1>" . __('SQL result') . "</h1>";
$print_view_header .= "<p>";
$print_view_header .= "<strong>" . __('Host:') . "</strong> $hostname<br />";
$print_view_header .= "<strong>" . __('Host:')
. "</strong> $hostname<br />";
$print_view_header .= "<strong>" . __('Database:') . "</strong> "
. htmlspecialchars($db) . "<br />";
$print_view_header .= "<strong>" . __('Generation Time:') . "</strong> "
. PMA_Util::localisedDate() . "<br />";
$print_view_header .= "<strong>" . __('Generated by:') . "</strong> $versions<br />";
$print_view_header .= "<strong>" . __('Generated by:')
. "</strong> $versions<br />";
$print_view_header .= "<strong>" . __('SQL query:') . "</strong> "
. htmlspecialchars($sql_query) . ";";
if (isset($num_rows)) {
$print_view_header .= "<br />";
$print_view_header .= "<strong>" . __('Rows:') . "</strong> $num_rows";
}
$print_view_header .= "</p>";
}else{
} else {
$print_view_header = null;
}

Expand Down Expand Up @@ -456,7 +458,8 @@ function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
);
$profiling_table = '';

$profiling_table .= '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n";
$profiling_table .= '<fieldset><legend>' . __('Profiling')
. '</legend>' . "\n";
$profiling_table .= '<div style="float: left;">';
$profiling_table .= '<h3>' . __('Detailed profile') . '</h3>';
$profiling_table .= '<table id="profiletable"><thead>' . "\n";
Expand All @@ -476,9 +479,10 @@ function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
$i = 1;
foreach ($profiling_results as $one_result) {
if (isset($profiling_stats['states'][ucwords($one_result['Status'])])) {
$profiling_stats['states'][ucwords($one_result['Status'])]['time']
$states = $profiling_stats['states'];
$states[ucwords($one_result['Status'])]['time']
+= $one_result['Duration'];
$profiling_stats['states'][ucwords($one_result['Status'])]['calls']++;
$states[ucwords($one_result['Status'])]['calls']++;
} else {
$profiling_stats['states'][ucwords($one_result['Status'])] = array(
'total_time' => $one_result['Duration'],
Expand All @@ -489,7 +493,8 @@ function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)

$profiling_table .= ' <tr>' . "\n";
$profiling_table .= '<td>' . $i++ . '</td>' . "\n";
$profiling_table .= '<td>' . ucwords($one_result['Status']) . '</td>' . "\n";
$profiling_table .= '<td>' . ucwords($one_result['Status'])
. '</td>' . "\n";
$profiling_table .= '<td class="right">'
. (PMA_Util::formatNumber($one_result['Duration'], 3, 1))
. 's<span style="display:none;" class="rawvalue">'
Expand Down Expand Up @@ -533,12 +538,16 @@ function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
. $stats['total_time'] . '</span></td>' . "\n";
$profiling_table .= '<td align="right">'
. PMA_Util::formatNumber(
100 * ($stats['total_time'] / $profiling_stats['total_time']), 0, 2
100 * ($stats['total_time'] / $profiling_stats['total_time']),
0, 2
)
. '%</td>' . "\n";
$profiling_table .= '<td align="right">' . $stats['calls'] . '</td>' . "\n";
$profiling_table .= '<td align="right">' . $stats['calls'] . '</td>'
. "\n";
$profiling_table .= '<td align="right">'
. PMA_Util::formatNumber($stats['total_time'] / $stats['calls'], 3, 1)
. PMA_Util::formatNumber(
$stats['total_time'] / $stats['calls'], 3, 1
)
. 's<span style="display:none;" class="rawvalue">'
. number_format($stats['total_time'] / $stats['calls'], 8, '.', '')
. '</span></td>' . "\n";
Expand Down Expand Up @@ -673,7 +682,7 @@ function PMA_getHtmlForOptionsList($values, $selected_values)
* return null
*
* @param string $disp_mode display mode
* @param bool $cfgBookmark
* @param bool $cfgBookmark confguration setting for bookmarking
* @param string $sql_query sql query
* @param string $db current database
* @param string $table current table
Expand All @@ -695,18 +704,20 @@ function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $tabl
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;id_bookmark=1';
$bkm_sql_query = urlencode(
isset($complete_query) ? $complete_query : $sql_query
isset($complete_query) ? $complete_query : $sql_query
);
$html = '<form action="sql.php" method="post"'
. ' onsubmit="return ! emptyFormElements(this, \'bkm_fields[bkm_label]\');"'
. ' onsubmit="return ! emptyFormElements(this,'
. '\'bkm_fields[bkm_label]\');"'
. ' id="bookmarkQueryForm">';
$html .= PMA_generate_common_hidden_inputs();
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
. ' value="' . htmlspecialchars($db) . '" />';
$html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
. ' value="' . $bkm_user . '" />';
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="'
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"'
. ' value="'
. $bkm_sql_query
. '" />';
$html .= '<fieldset>';
Expand Down Expand Up @@ -1154,7 +1165,8 @@ function PMA_getDefaultSqlQueryForBrowse($db, $table)
*
* @return void
*/
function PMA_handleQueryExecuteError($is_gotofile, $error) {
function PMA_handleQueryExecuteError($is_gotofile, $error)
{
if ($is_gotofile) {
$message = PMA_Message::rawError($error);
$response = PMA_Response::getInstance();
Expand Down Expand Up @@ -1281,8 +1293,8 @@ function PMA_hasCurrentDbChanged($db)
* @param String $db current database
* @param String $table current table
* @param String $dropped_column dropped column if any
* @param bool $purge
* @param array $extra_data
* @param bool $purge whether purge set or not
* @param array $extra_data extra data
*
* @return array $extra_data
*/
Expand All @@ -1304,7 +1316,7 @@ function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
&& strlen($table)
) {
PMA_relationsCleanupColumn($db, $table, $dropped_column);
if(isset($extra_data)) {
if (isset($extra_data)) {
// to refresh the list of indexes (Ajax mode)
$extra_data['indexes_list'] = PMA_Index::getView($table, $db);
}
Expand All @@ -1331,8 +1343,7 @@ function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
function PMA_countQueryResults($num_rows, $is_select, $justBrowsing,
$db, $table, $parsed_sql, $analyzed_sql_results
) {
if (!PMA_isAppendLimitClause($analyzed_sql_results))
{
if (!PMA_isAppendLimitClause($analyzed_sql_results)) {
// if we did not append a limit, set this to get a correct
// "Showing rows..." message
// $_SESSION['tmp_user_values']['max_rows'] = 'all';
Expand Down Expand Up @@ -1423,14 +1434,15 @@ function PMA_countQueryResults($num_rows, $is_select, $justBrowsing,
/**
* Function to handle all aspects relating to executing the query
*
* @param array $analyzed_sql_results
* @param String $full_sql_query full sql query
* @param boolean $is_gotofile whether to go to a file
* @param String $db current database
* @param String $table current table
* @param boolean $find_real_end whether to find the real end
* @param String $import_text sql command
* @param String $bkm_user bookmarking user
* @param array $analyzed_sql_results analyzed sql results
* @param String $full_sql_query full sql query
* @param boolean $is_gotofile whether to go to a file
* @param String $db current database
* @param String $table current table
* @param boolean $find_real_end whether to find the real end
* @param String $import_text sql command
* @param String $bkm_user bookmarking user
* @param array $extra_data extra data
*
* @return mixed
*/
Expand Down Expand Up @@ -1458,8 +1470,8 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
// If there are no errors and bookmarklabel was given,
// store the query as a bookmark
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
PMA_storeTheQueryAsBookmark($db, $bkm_user,
$import_text, $_POST['bkm_label'],
PMA_storeTheQueryAsBookmark(
$db, $bkm_user, $import_text, $_POST['bkm_label'],
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
);
} // end store bookmarks
Expand All @@ -1478,11 +1490,11 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
}

$justBrowsing = PMA_isJustBrowsing(
$analyzed_sql_results,isset($find_real_end) ? $find_real_end : null
$analyzed_sql_results, isset($find_real_end) ? $find_real_end : null
);

$unlim_num_rows = PMA_countQueryResults($num_rows,
$analyzed_sql_results['is_select'], $justBrowsing, $db,
$unlim_num_rows = PMA_countQueryResults(
$num_rows, $analyzed_sql_results['is_select'], $justBrowsing, $db,
$table, $analyzed_sql_results['parsed_sql'], $analyzed_sql_results
);

Expand Down Expand Up @@ -1537,7 +1549,7 @@ function PMA_deleteTransformationInfo($db, $table, $analyzed_sql)
* @return string $message
*/
function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results,
$num_rows
$num_rows
) {
if ($analyzed_sql_results['is_delete']) {
$message = PMA_Message::getMessageForDeletedRows($num_rows);
Expand Down Expand Up @@ -1607,7 +1619,7 @@ function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results
* @return void
*/
function PMA_sendAjaxResponseForNoResultsReturned($message, $analyzed_sql,
$displayResultsObject, $showSql, $extra_data
$displayResultsObject, $showSql, $extra_data
) {
/**
* @todo find a better way to make getMessage() in Header.class.php
Expand Down Expand Up @@ -1679,8 +1691,8 @@ function PMA_sendResponseForNoResultsReturned($analyzed_sql_results, $db, $table
$num_rows
);
if ($GLOBALS['is_ajax_request'] == true) {
PMA_sendAjaxResponseForNoResultsReturned($message,
$analyzed_sql_results['analyzed_sql'],
PMA_sendAjaxResponseForNoResultsReturned(
$message, $analyzed_sql_results['analyzed_sql'],
$displayResultsObject, $cfg['ShowSQL'],
isset($extra_data) ? $extra_data : null
);
Expand Down Expand Up @@ -1766,17 +1778,18 @@ function PMA_getBookmarkCreatedMessage()
* @param string $db current database
* @param string $goto goto page url
* @param string $pmaThemeImage theme image uri
* @param string $text_dir
* @param string $text_dir text directory
* @param string $url_query url query
* @param string $disp_mode display mode
* @param string $sql_limit_to_append sql limit to append
* @param bool $editable whether the result table is editable or not
* @param int $unlim_num_rows unlimited number of rows
* @param bool $showtable
* @param int $num_rows number of rows
* @param bool $showtable whether to show table or not
* @param object $result result of the executed query
* @param int $querytime query execution time
* @param array $analyzed_sql_results analyzed sql results
* @param bool $is_procedure
* @param bool $is_procedure whether it is a procedure call or not
*
* @return type
*/
Expand Down Expand Up @@ -1805,7 +1818,7 @@ function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $d
$analyzed_sql_results['is_analyse'], $num_rows,
$fields_cnt, $querytime, $pmaThemeImage, $text_dir,
$analyzed_sql_results['is_maint'], $analyzed_sql_results['is_explain'],
$analyzed_sql_results['is_show'], $showtable,$printview, $url_query,
$analyzed_sql_results['is_show'], $showtable, $printview, $url_query,
$editable
);

Expand All @@ -1822,10 +1835,10 @@ function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $d
* Function to get html for the previous query if there is such. If not will return
* null
*
* @param type $disp_query
* @param type $showSql
* @param type $sql_data
* @param type $disp_message
* @param string $disp_query display query
* @param bool $showSql whether to show sql
* @param array $sql_data sql data
* @param string $disp_message display message
*
* @return string $previous_update_query_html
*/
Expand Down Expand Up @@ -1876,7 +1889,7 @@ function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $disp_mode)
* Function to get html to display problems in indexes
*
* @param string $query_type query type
* @param boolean $selected
* @param boolean $selected selected
*
* @return void
*/
Expand Down

0 comments on commit 1851790

Please sign in to comment.