RFE #769219 - retain user formating for SQL

This commit is contained in:
Garvin Hicking
2003-07-28 18:51:14 +00:00
parent 3959ff5f5b
commit 116999909e
3 changed files with 18 additions and 9 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2003-07-28 Garvin Hicking <me@supergarv.de>
* sql.php3, libraries/common.lib.php3 - when $cfg['SQP']['fmtType']
is set to 'none', positively retain any user formatting for query
output. (RFE #769219)
2003-07-28 Marc Delisle <lem9@users.sourceforge.net> 2003-07-28 Marc Delisle <lem9@users.sourceforge.net>
* sql.php3: bug 778899, could not create a bookmark * sql.php3: bug 778899, could not create a bookmark
* ldi_table.php3: Users with register_global=off received some * ldi_table.php3: Users with register_global=off received some

View File

@@ -345,10 +345,10 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
* *
* @author Robin Johnson <robbat2@users.sourceforge.net> * @author Robin Johnson <robbat2@users.sourceforge.net>
*/ */
function PMA_formatSql($parsed_sql) function PMA_formatSql($parsed_sql, $unparsed_sql = '')
{ {
global $cfg; global $cfg;
// Check that we actually have a valid set of parsed data // Check that we actually have a valid set of parsed data
// well, not quite // well, not quite
// first check for the SQL parser having hit an error // first check for the SQL parser having hit an error
@@ -360,7 +360,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// We don't so just return the input directly // We don't so just return the input directly
// This is intended to be used for when the SQL Parser is turned off // This is intended to be used for when the SQL Parser is turned off
$formatted_sql = '<pre>' . "\n" $formatted_sql = '<pre>' . "\n"
. $parsed_sql . "\n" . (($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '') ? $unparsed_sql : $parsed_sql) . "\n"
. '</pre>'; . '</pre>';
return $formatted_sql; return $formatted_sql;
} }
@@ -369,7 +369,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
switch ($cfg['SQP']['fmtType']) { switch ($cfg['SQP']['fmtType']) {
case 'none': case 'none':
$formatted_sql = PMA_SQP_formatNone($parsed_sql); if ($unparsed_sql != '') {
$formatted_sql = "<pre>\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n</pre>";
} else {
$formatted_sql = PMA_SQP_formatNone($parsed_sql);
}
break; break;
case 'html': case 'html':
$formatted_sql = PMA_SQP_formatHtml($parsed_sql,'color'); $formatted_sql = PMA_SQP_formatHtml($parsed_sql,'color');
@@ -447,7 +451,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
} // end if } // end if
echo '</p>' . "\n" echo '</p>' . "\n"
. '<p>' . "\n" . '<p>' . "\n"
. ' ' . PMA_formatSql($parsed_sql) . "\n" . ' ' . PMA_formatSql($parsed_sql, $the_query) . "\n"
. '</p>' . "\n"; . '</p>' . "\n";
} // end if } // end if
if (!empty($error_message)) { if (!empty($error_message)) {
@@ -1317,7 +1321,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
</tr> </tr>
<?php <?php
if ($cfg['ShowSQL'] == TRUE && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) { if ($cfg['ShowSQL'] == TRUE && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) {
$local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : $GLOBALS['sql_query']; $local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : (($cfg['SQP']['fmtType'] == 'none' && $GLOBALS['unparsed_sql'] != '') ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']);
// Basic url query part // Basic url query part
$url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
echo "\n"; echo "\n";
@@ -1349,7 +1353,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
$query_base = PMA_validateSQL($query_base); $query_base = PMA_validateSQL($query_base);
} else { } else {
$parsed_sql = PMA_SQP_parse($query_base); $parsed_sql = PMA_SQP_parse($query_base);
$query_base = PMA_formatSql($parsed_sql); $query_base = PMA_formatSql($parsed_sql, $query_base);
} }
// Prepares links that may be displayed to edit/explain the query // Prepares links that may be displayed to edit/explain the query
@@ -1479,7 +1483,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
} else if (!empty($GLOBALS['validatequery'])) { } else if (!empty($GLOBALS['validatequery'])) {
// skip the extra bit here // skip the extra bit here
} else { } else {
echo '&nbsp;' . PMA_formatSql(PMA_SQP_parse($GLOBALS['sql_limit_to_append'])); echo '&nbsp;' . PMA_formatSql(PMA_SQP_parse($GLOBALS['sql_limit_to_append'], $GLOBALS['sql_limit_to_append']));
} }
} }

View File

@@ -90,6 +90,7 @@ if (isset($btnDrop) || isset($navig)) {
* Reformat the query * Reformat the query
*/ */
$GLOBALS['unparsed_sql'] = $sql_query;
$parsed_sql = PMA_SQP_parse($sql_query); $parsed_sql = PMA_SQP_parse($sql_query);
$analyzed_sql = PMA_SQP_analyze($parsed_sql); $analyzed_sql = PMA_SQP_analyze($parsed_sql);
// Bug #641765 - Robbat2 - 12 January 2003, 10:49PM // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
@@ -761,7 +762,6 @@ if (typeof(window.print) != 'undefined') {
} // end executes the query } // end executes the query
echo "\n\n"; echo "\n\n";
/** /**
* Displays the footer * Displays the footer
*/ */