new query window behavior

This commit is contained in:
Marc Delisle
2005-11-16 18:56:24 +00:00
parent 7e90f85a45
commit 9889178b87
9 changed files with 132 additions and 153 deletions

View File

@@ -7,6 +7,10 @@ $Source$
2005-11-16 Marc Delisle <lem9@users.sourceforge.net> 2005-11-16 Marc Delisle <lem9@users.sourceforge.net>
* tbl_properties_links.php: missing menu tabs * tbl_properties_links.php: missing menu tabs
* Documentation.html, config.default.php, footer.inc.php,
querywindow.php, tbl_query_box.php, libraries/common.lib.php,
libraries/left_header.inc.php, libraries/sql_query_form.lib.php:
new Query Window behavior
2005-11-16 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2005-11-16 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* added missing themes/darkblue_orange/img/error.ico * added missing themes/darkblue_orange/img/error.ico

View File

@@ -838,8 +838,8 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON &lt;pma_db&gt;.* TO 'pma'@'localhost';
you want to have on hold. On every login, this list gets cut to the maximum amount. you want to have on hold. On every login, this list gets cut to the maximum amount.
<br /><br /> <br /><br />
The query history is only available if you use the JavaScript-based query window, The query history is only available if JavaScript is enabled in your
see <b>$cfg['QueryFrame']</b>. browser.
<br /><br /> <br /><br />
To allow the usage of this functionality: To allow the usage of this functionality:
@@ -1739,8 +1739,7 @@ Defaults to FALSE (drop-down). <br />
<br /><br /> <br /><br />
</dd> </dd>
<dt><b>$cfg['QueryFrame'] </b>boolean<br /> <dt><b>$cfg['EditInWindow'] </b>boolean<br />
<b>$cfg['QueryFrameJS'] </b>boolean<br />
<b>$cfg['QueryWindowWidth'] </b>integer<br /> <b>$cfg['QueryWindowWidth'] </b>integer<br />
<b>$cfg['QueryWindowHeight'] </b>integer<br /> <b>$cfg['QueryWindowHeight'] </b>integer<br />
<b>$cfg['QueryHistoryDB'] </b>boolean<br /> <b>$cfg['QueryHistoryDB'] </b>boolean<br />
@@ -1748,19 +1747,23 @@ Defaults to FALSE (drop-down). <br />
<b>$cfg['QueryHistoryMax'] </b>integer <b>$cfg['QueryHistoryMax'] </b>integer
</dt> </dt>
<dd> <dd>
All those variables affect the query box feature. When All those variables affect the query window feature. A <tt>SQL</tt> link
$cfg['QueryFrame'] is set to true, a link or icon is displayed or icon is always displayed on the left panel. If JavaScript is enabled in
on the left panel. Clicking on it opens the query box, a direct your browser, a click on this opens a distinct query window, which is
interface to enter SQL queries. a direct interface to enter SQL queries. Otherwise, the right panel
changes to display a query box.
<br /><br /> <br /><br />
When $cfg['QueryFrameJS'] is set to true, clicking on that link opens The size of this query window can be customized with
the query box, a new custom sized browser window <tt>$cfg['QueryWindowWidth']</tt> and <tt>$cfg['QueryWindowWidth']</tt>
($cfg['QueryWindowWidth'], $cfg['QueryWindowWidth'] - both integers - both integers for the size in pixels. Note that normally, those
for the size in pixels). parameters will be modified in <tt>layout.inc.php</tt> for the
Also, a click on [Edit] from the results page (in the &quot;Showing theme you are using.
Rows&quot; section) opens the query box and puts the current query <br /><br />
inside it. If set to false, clicking on the link only opens the SQL If <tt>$cfg['EditInWindow']</tt> is set to true, a click on [Edit]
input in the main frame. from the results page (in the &quot;Showing Rows&quot; section)
opens the query window and puts the current query
inside it. If set to false, clicking on the link puts the SQL
query in the right panel's query box.
<br /><br /> <br /><br />
The usage of the JavaScript query window is recommended if you have a The usage of the JavaScript query window is recommended if you have a
JavaScript enabled browser. Basic functions are used to exchange quite JavaScript enabled browser. Basic functions are used to exchange quite

View File

@@ -480,9 +480,7 @@ $cfg['ShowBrowseComments'] = TRUE; // shows stored relation-comments in
$cfg['ShowPropertyComments']= TRUE; // shows stored relation-comments in 'table property' mode. $cfg['ShowPropertyComments']= TRUE; // shows stored relation-comments in 'table property' mode.
$cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate) $cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate)
$cfg['QueryFrame'] = TRUE; // displays a link or icon in the left frame to open the querybox, and activates the querybox when clicking on [Edit] on the results page. $cfg['EditInWindow'] = TRUE; // Set to TRUE if Edit link should open the query to edit in the query window (assuming Javascript is enabled), and to FALSE if we should edit in the right panel
$cfg['QueryFrameJS'] = TRUE; // whether to use JavaScript functions for opening a new window for SQL commands.
// if set to 'false', the target of the querybox is always the right frame.
$cfg['QueryWindowWidth'] = 550; // Width of Query window $cfg['QueryWindowWidth'] = 550; // Width of Query window
$cfg['QueryWindowHeight'] = 310; // Height of Query window $cfg['QueryWindowHeight'] = 310; // Height of Query window
$cfg['QueryHistoryDB'] = FALSE; // Set to TRUE if you want DB-based query history. $cfg['QueryHistoryDB'] = FALSE; // Set to TRUE if you want DB-based query history.

View File

@@ -16,8 +16,7 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
* Query window * Query window
*/ */
// If query window is wanted and open, update with latest selected db/table. // If query window is open, update with latest selected db/table.
if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
@@ -67,7 +66,6 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
//]]> //]]>
</script> </script>
<?php <?php
}
/** /**

View File

@@ -2045,9 +2045,10 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
&& ($cfg['SQLQuery']['Edit'] == TRUE ) && ($cfg['SQLQuery']['Edit'] == TRUE )
&& (!empty($edit_target))) { && (!empty($edit_target))) {
$onclick = ''; if ($cfg['EditInWindow'] == TRUE) {
if ($cfg['QueryFrameJS'] && $cfg['QueryFrame']) {
$onclick = 'window.parent.focus_querywindow(\'' . urlencode($local_query) . '\'); return false;'; $onclick = 'window.parent.focus_querywindow(\'' . urlencode($local_query) . '\'); return false;';
} else {
$onclick = '';
} }
$edit_link = $edit_target $edit_link = $edit_target

View File

@@ -54,7 +54,6 @@ if ( $GLOBALS['cfg']['LeftDisplayLogo'] ) {
.'</a>' . "\n"; .'</a>' . "\n";
} // end if ($GLOBALS['cfg']['Server']['auth_type'] != 'config' } // end if ($GLOBALS['cfg']['Server']['auth_type'] != 'config'
if ( $GLOBALS['cfg']['QueryFrame'] ) {
$anchor = 'querywindow.php?' . PMA_generate_common_url( $db, $table ); $anchor = 'querywindow.php?' . PMA_generate_common_url( $db, $table );
if ($GLOBALS['cfg']['MainPageIconic']) { if ($GLOBALS['cfg']['MainPageIconic']) {
@@ -67,12 +66,9 @@ if ( $GLOBALS['cfg']['LeftDisplayLogo'] ) {
} }
echo '<a href="' . $anchor . '&amp;no_js=true"' echo '<a href="' . $anchor . '&amp;no_js=true"'
.' title="' . $strQueryFrame . '"'; .' title="' . $strQueryFrame . '"';
if ( $GLOBALS['cfg']['QueryFrameJS'] ) {
echo ' onclick="javascript:window.parent.open_querywindow();' echo ' onclick="javascript:window.parent.open_querywindow();'
.' return false;"'; .' return false;"';
}
echo '>' . $query_frame_link_text . '</a>' . "\n"; echo '>' . $query_frame_link_text . '</a>' . "\n";
} // end if ($GLOBALS['cfg']['QueryFrame'])
} // end if ($server != 0) } // end if ($server != 0)
if ($GLOBALS['cfg']['MainPageIconic']) { if ($GLOBALS['cfg']['MainPageIconic']) {

View File

@@ -29,8 +29,6 @@ require_once('./libraries/file_listing.php'); // used for file listing
* @uses $GLOBALS['sql_query'] from grab_globals.lib.php * @uses $GLOBALS['sql_query'] from grab_globals.lib.php
* @uses $GLOBALS['cfg']['DefaultQueryTable'] * @uses $GLOBALS['cfg']['DefaultQueryTable']
* @uses $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses $GLOBALS['cfg']['DefaultQueryDatabase']
* @uses $GLOBALS['cfg']['QueryFrame']
* @uses $GLOBALS['cfg']['QueryFrameJS']
* @uses $GLOBALS['cfg']['Servers'] * @uses $GLOBALS['cfg']['Servers']
* @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['cfg']['DefaultTabDatabase']
* @uses $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses $GLOBALS['cfg']['DefaultQueryDatabase']
@@ -73,11 +71,6 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
$query = empty( $GLOBALS['sql_query'] ) ? '' : $GLOBALS['sql_query']; $query = empty( $GLOBALS['sql_query'] ) ? '' : $GLOBALS['sql_query'];
} }
// we dont need to check booth variables each time
if ( false == $GLOBALS['cfg']['QueryFrame'] ) {
$GLOBALS['cfg']['QueryFrameJS'] = false;
}
// set enctype to multipart for file uploads // set enctype to multipart for file uploads
if ( $GLOBALS['is_upload'] ) { if ( $GLOBALS['is_upload'] ) {
$enctype = ' enctype="multipart/form-data"'; $enctype = ' enctype="multipart/form-data"';
@@ -106,7 +99,7 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
// start output // start output
if ( $GLOBALS['cfg']['QueryFrameJS'] && $is_querywindow ) { if ( $is_querywindow ) {
?> ?>
<form method="post" id="sqlqueryform" <form method="post" id="sqlqueryform"
target="phpmain<?php echo md5( $GLOBALS['cfg']['PmaAbsoluteUri'] ); ?>" target="phpmain<?php echo md5( $GLOBALS['cfg']['PmaAbsoluteUri'] ); ?>"
@@ -169,7 +162,6 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
* *
* @usedby PMA_sqlQueryForm() * @usedby PMA_sqlQueryForm()
* @uses $GLOBALS['text_dir'] * @uses $GLOBALS['text_dir']
* @uses $GLOBALS['cfg']['QueryFrameJS']
* @uses $GLOBALS['cfg']['TextareaAutoSelect'] * @uses $GLOBALS['cfg']['TextareaAutoSelect']
* @uses $GLOBALS['cfg']['TextareaCols'] * @uses $GLOBALS['cfg']['TextareaCols']
* @uses $GLOBALS['cfg']['TextareaRows'] * @uses $GLOBALS['cfg']['TextareaRows']
@@ -194,7 +186,7 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
} }
// enable locking if inside query window // enable locking if inside query window
if ( $GLOBALS['cfg']['QueryFrameJS'] && $is_querywindow ) { if ( $is_querywindow ) {
$locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].' $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].'
.'checked = true;"'; .'checked = true;"';
} else { } else {

View File

@@ -30,7 +30,7 @@ require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
// initilize some variables // initialize some variables
$_sql_history = array(); $_sql_history = array();
$_input_query_history = array(); $_input_query_history = array();
@@ -114,10 +114,10 @@ function resize() {
</head> </head>
<body id="bodyquerywindow" <?php echo $onload; ?> <body id="bodyquerywindow" <?php echo $onload; ?>
bgcolor="<?php echo ($GLOBALS['cfg']['QueryFrameJS'] ? $GLOBALS['cfg']['LeftBgColor'] : $GLOBALS['cfg']['RightBgColor']); ?>"> bgcolor="<?php echo $GLOBALS['cfg']['LeftBgColor']; ?>">
<div id="querywindowcontainer"> <div id="querywindowcontainer">
<?php <?php
if ( $GLOBALS['cfg']['QueryFrameJS'] && !isset($no_js) ) { if ( !isset($no_js) ) {
$querydisplay_tab = (isset($querydisplay_tab) ? $querydisplay_tab : $GLOBALS['cfg']['QueryWindowDefTab']); $querydisplay_tab = (isset($querydisplay_tab) ? $querydisplay_tab : $GLOBALS['cfg']['QueryWindowDefTab']);
$tabs = array(); $tabs = array();
@@ -164,9 +164,8 @@ if ( true == $GLOBALS['cfg']['PropertiesIconic'] ) {
} }
// Hidden forms and query frame interaction stuff // Hidden forms and query frame interaction stuff
if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
if ( ! empty( $query_history_latest ) && ! empty( $query_history_latest_db ) ) { if ( ! empty( $query_history_latest ) && ! empty( $query_history_latest_db ) ) {
if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) { if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''), PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''),
(isset($query_history_latest_table) ? $query_history_latest_table : ''), (isset($query_history_latest_table) ? $query_history_latest_table : ''),
@@ -187,15 +186,15 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
$sql_query = urldecode($query_history_latest); $sql_query = urldecode($query_history_latest);
$db = $query_history_latest_db; $db = $query_history_latest_db;
$table = $query_history_latest_table; $table = $query_history_latest_table;
} elseif ( ! empty( $query_history_latest ) ) { } elseif ( ! empty( $query_history_latest ) ) {
$sql_query = urldecode($query_history_latest); $sql_query = urldecode($query_history_latest);
} }
if (isset($sql_query)) { if (isset($sql_query)) {
$show_query = 1; $show_query = 1;
} }
if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) { if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
$temp_history = PMA_getHistory( $GLOBALS['cfg']['Server']['user'] ); $temp_history = PMA_getHistory( $GLOBALS['cfg']['Server']['user'] );
if (is_array($temp_history) && count($temp_history) > 0) { if (is_array($temp_history) && count($temp_history) > 0) {
@@ -209,7 +208,7 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
} }
} }
} else { } else {
if (isset($query_history) && is_array($query_history)) { if (isset($query_history) && is_array($query_history)) {
$current_index = count($query_history); $current_index = count($query_history);
@@ -226,9 +225,7 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
} // end if check if this item exists } // end if check if this item exists
} // end while print history } // end while print history
} // end if history exists } // end if history exists
} // end if DB-based history
} // end if DB-based history
}
$url_query = PMA_generate_common_url(isset($db) ? $db : '', isset($table) ? $table : ''); $url_query = PMA_generate_common_url(isset($db) ? $db : '', isset($table) ? $table : '');
if (!isset($goto)) { if (!isset($goto)) {
@@ -237,8 +234,7 @@ if (!isset($goto)) {
require_once './libraries/bookmark.lib.php'; require_once './libraries/bookmark.lib.php';
// in case of javascript disabled in queryframe ... if (isset($no_js) && $no_js) {
if ( $GLOBALS['cfg']['QueryFrame'] && ! $GLOBALS['cfg']['QueryFrameJS'] ) {
// ... we redirect to appropriate query sql page // ... we redirect to appropriate query sql page
// works only full if $db and $table is also stored/grabbed from $_COOKIE // works only full if $db and $table is also stored/grabbed from $_COOKIE
if ( ! empty( $table ) ) { if ( ! empty( $table ) ) {
@@ -266,18 +262,17 @@ unset( $sql_query );
PMA_sqlQueryForm( $query_to_display, $querydisplay_tab ); PMA_sqlQueryForm( $query_to_display, $querydisplay_tab );
// Hidden forms and query frame interaction stuff // Hidden forms and query frame interaction stuff
if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) { if (isset($auto_commit) && $auto_commit == 'true') {
if (isset($auto_commit) && $auto_commit == 'true') { ?>
?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
//<![CDATA[ //<![CDATA[
query_auto_commit(); query_auto_commit();
//]]> //]]>
</script> </script>
<?php <?php
} }
if ( count( $_sql_history ) > 0 if ( count( $_sql_history ) > 0
&& ( $querydisplay_tab == 'history' || $querydisplay_tab == 'full' ) ) { && ( $querydisplay_tab == 'history' || $querydisplay_tab == 'full' ) ) {
$tab = isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full'; $tab = isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full';
echo $strQuerySQLHistory . ':<br />' . "\n" echo $strQuerySQLHistory . ':<br />' . "\n"
@@ -334,21 +329,21 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
} }
unset( $tab, $_sql_history, $sql, $query ); unset( $tab, $_sql_history, $sql, $query );
echo '</ul>' . "\n"; echo '</ul>' . "\n";
} }
?> ?>
<form action="querywindow.php" method="post" name="querywindow" id="hiddenqueryform"> <form action="querywindow.php" method="post" name="querywindow" id="hiddenqueryform">
<?php <?php
echo PMA_generate_common_hidden_inputs('', '') . "\n"; echo PMA_generate_common_hidden_inputs('', '') . "\n";
foreach ( $_input_query_history as $sql => $history ) { foreach ( $_input_query_history as $sql => $history ) {
echo '<input type="hidden" name="query_history[]" value="' echo '<input type="hidden" name="query_history[]" value="'
. $sql . '" />' . "\n"; . $sql . '" />' . "\n";
echo '<input type="hidden" name="query_history_db[]" value="' echo '<input type="hidden" name="query_history_db[]" value="'
. htmlspecialchars( $history['db'] ) . '" />' . "\n"; . htmlspecialchars( $history['db'] ) . '" />' . "\n";
echo '<input type="hidden" name="query_history_table[]" value="' echo '<input type="hidden" name="query_history_table[]" value="'
. htmlspecialchars( $history['table'] ) . '" />' . "\n"; . htmlspecialchars( $history['table'] ) . '" />' . "\n";
} }
unset( $_input_query_history, $sql, $history ); unset( $_input_query_history, $sql, $history );
?> ?>
<input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" /> <input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" />
<input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" /> <input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" />
@@ -362,7 +357,6 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
<input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" /> <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
</form> </form>
<?php <?php
}
?> ?>
</div> </div>
</body> </body>

View File

@@ -15,18 +15,11 @@ require_once('./libraries/common.lib.php');
require_once('./libraries/bookmark.lib.php'); require_once('./libraries/bookmark.lib.php');
require_once './libraries/sql_query_form.lib.php'; require_once './libraries/sql_query_form.lib.php';
// we dont need to check booth variables each time
if ( false == $cfg['QueryFrame'] ) {
$cfg['QueryFrameJS'] = false;
}
if ( empty( $querydisplay_tab ) ) { if ( empty( $querydisplay_tab ) ) {
$querydisplay_tab = ''; $querydisplay_tab = '';
} }
// in case of javascript disabled in queryframe ... if ( $is_inside_querywindow ) {
if ( $GLOBALS['cfg']['QueryFrame'] && ! $GLOBALS['cfg']['QueryFrameJS']
&& $is_inside_querywindow ) {
// ... we redirect to appropriate query sql page // ... we redirect to appropriate query sql page
// works only full if $db and $table is also stored/grabbed from $_COOKIE // works only full if $db and $table is also stored/grabbed from $_COOKIE
if ( ! empty( $table ) ) { if ( ! empty( $table ) ) {