From ea1f6f37500b3db5917212fd9b07b4720f9218f0 Mon Sep 17 00:00:00 2001 From: xmujay Date: Tue, 20 Aug 2013 21:36:58 +0800 Subject: [PATCH] refactor PMA_getHtmlForSqlQueryForm and fix code style --- db_sql.php | 10 ++-- libraries/sql_query_form.lib.php | 36 ++++++------- querywindow.php | 2 +- server_sql.php | 2 +- tbl_sql.php | 10 ++-- tbl_tracking.php | 90 +++++++++++++++++++++++--------- 6 files changed, 98 insertions(+), 52 deletions(-) diff --git a/db_sql.php b/db_sql.php index c4418b4e7f..f5a17061f4 100644 --- a/db_sql.php +++ b/db_sql.php @@ -32,9 +32,13 @@ $back = 'db_sql.php'; /** * Query box, bookmark, insert data from textfile */ -PMA_sqlQueryForm( - true, false, - isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';' +$response->addHTML( + PMA_getHtmlForSqlQueryForm( + true, false, + isset($_REQUEST['delimiter']) + ? htmlspecialchars($_REQUEST['delimiter']) + : ';' + ) ); ?> diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php index 8bd1f9b48d..5f1b58ebb2 100644 --- a/libraries/sql_query_form.lib.php +++ b/libraries/sql_query_form.lib.php @@ -22,7 +22,7 @@ require_once './libraries/file_listing.lib.php'; // used for file listing require_once './libraries/bookmark.lib.php'; // used for bookmarks /** - * Prints the sql query boxes + * return HTML for the sql query boxes * * @param boolean|string $query query to display in the textarea * or true to display last executed @@ -31,7 +31,7 @@ require_once './libraries/bookmark.lib.php'; // used for bookmarks * false if not inside querywindow * @param string $delimiter delimeter * - * @return void + * @return string * * @usedby server_sql.php * @usedby db_sql.php @@ -40,8 +40,9 @@ require_once './libraries/bookmark.lib.php'; // used for bookmarks * @usedby tbl_tracking.php * @usedby querywindow.php */ -function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';') -{ +function PMA_getHtmlForSqlQueryForm( + $query = true, $display_tab = false, $delimiter = ';' +) { $html = ''; // check tab to display if inside querywindow if (! $display_tab) { @@ -81,18 +82,16 @@ function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';') 'tbl_sql.php' : $GLOBALS['goto']; } - // start output if ($is_querywindow) { - ?> -
name="sqlform" - onsubmit="var save_name = window.opener.parent.frame_content.name; - window.opener.parent.frame_content.name - = save_name + ''; - this.target = window.opener.parent.frame_content.name; - return checkSqlQuery(this)"> - '; } else { $html .= 'addHTML(PMA_getHtmlForSqlQueryForm()); ?> diff --git a/tbl_sql.php b/tbl_sql.php index 0d1006feb2..00927747bd 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -39,9 +39,13 @@ require_once 'libraries/tbl_info.inc.php'; /** * Query box, bookmark, insert data from textfile */ -PMA_sqlQueryForm( - true, false, - isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';' +$response->addHTML( + PMA_getHtmlForSqlQueryForm( + true, false, + isset($_REQUEST['delimiter']) + ? htmlspecialchars($_REQUEST['delimiter']) + : ';' + ) ); ?> diff --git a/tbl_tracking.php b/tbl_tracking.php index 19431dc69e..039fcf9694 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -72,7 +72,8 @@ if (isset($_REQUEST['report_export'])) { if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to - && (in_array('*', $filter_users) || in_array($entry['username'], $filter_users)) + && (in_array('*', $filter_users) + || in_array($entry['username'], $filter_users)) ) { $tmp_entries[] = array( 'id' => $id, @@ -258,7 +259,10 @@ if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution' // Export as SQL dump if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') { $new_query = "# " - . __('You can execute the dump by creating and using a temporary database. Please ensure that you have the privileges to do so.') + . __( + 'You can execute the dump by creating and using a temporary database. ' + . 'Please ensure that you have the privileges to do so.' + ) . "\n" . "# " . __('Comment out these two lines if you do not need them.') . "\n" . "\n" @@ -280,7 +284,7 @@ if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') $db = $table = ''; include_once './libraries/sql_query_form.lib.php'; - PMA_sqlQueryForm($new_query, 'sql'); + echo PMA_getHtmlForSqlQueryForm($new_query, 'sql'); $db = $db_temp; $table = $table_temp; @@ -497,7 +501,10 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { echo ''; @@ -566,12 +573,15 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to - && (in_array('*', $filter_users) || in_array($entry['username'], $filter_users)) + && (in_array('*', $filter_users) + || in_array($entry['username'], $filter_users)) ) { echo ''; echo '' . $i . ''; - echo '' . htmlspecialchars($entry['date']) . ''; - echo '' . htmlspecialchars($entry['username']) . ''; + echo '' . htmlspecialchars($entry['date']) + . ''; + echo '' . htmlspecialchars($entry['username']) + . ''; echo '' . $statement . ''; echo ''; echo '' . $i . ''; - echo '' . htmlspecialchars($entry['date']) . ''; - echo '' . htmlspecialchars($entry['username']) . ''; + echo '' . htmlspecialchars($entry['date']) + . ''; + echo '' . htmlspecialchars($entry['username']) + . ''; echo '' . $statement . ''; echo ''; printf( @@ -668,10 +684,13 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { ); $str_export1 = ''; $str_export2 = '' @@ -679,7 +698,10 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { echo ''; echo '
'; echo '' . htmlspecialchars($entries['db_name']) . ' . ' . htmlspecialchars($entries['table_name']) . $status . '' . "\n"; + echo '' . "\n"; } echo ''; echo ''; @@ -793,7 +818,10 @@ if ($last_version > 0) { echo '">' . __('Tracking report') . ''; echo '| ' . __('Structure snapshot') . ''; echo ''; @@ -859,18 +887,28 @@ echo ''; echo ''; echo '

' . __('Track these data definition statements:') . '

'; -echo ' ALTER TABLE
'; -echo ' RENAME TABLE
'; -echo ' CREATE TABLE
'; -echo ' DROP TABLE
'; +echo '' + . ' ALTER TABLE
'; +echo '' + . ' RENAME TABLE
'; +echo '' + . ' CREATE TABLE
'; +echo '' + . ' DROP TABLE
'; echo '
'; -echo ' CREATE INDEX
'; -echo ' DROP INDEX
'; +echo '' + . ' CREATE INDEX
'; +echo '' + . ' DROP INDEX
'; echo '

' . __('Track these data manipulation statements:') . '

'; -echo ' INSERT
'; -echo ' UPDATE
'; -echo ' DELETE
'; -echo ' TRUNCATE
'; +echo '' + . ' INSERT
'; +echo '' + . ' UPDATE
'; +echo '' + . ' DELETE
'; +echo '' + . ' TRUNCATE
'; echo ''; echo '
';