Browse files

new query window behavior

  • Loading branch information...
1 parent 7e90f85 commit 9889178b874cb8b613079421a11e2fed8d127f09 @lem9 lem9 committed Nov 16, 2005
Showing with 131 additions and 152 deletions.
  1. +4 −0 ChangeLog
  2. +20 −17 Documentation.html
  3. +1 −3 config.default.php
  4. +1 −3 footer.inc.php
  5. +3 −2 libraries/common.lib.php
  6. +11 −15 libraries/left_header.inc.php
  7. +2 −10 libraries/sql_query_form.lib.php
  8. +88 −94 querywindow.php
  9. +1 −8 tbl_query_box.php
View
4 ChangeLog
@@ -7,6 +7,10 @@ $Source$
2005-11-16 Marc Delisle <lem9@users.sourceforge.net>
* 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>
* added missing themes/darkblue_orange/img/error.ico
View
37 Documentation.html
@@ -838,8 +838,8 @@
you want to have on hold. On every login, this list gets cut to the maximum amount.
<br /><br />
- The query history is only available if you use the JavaScript-based query window,
- see <b>$cfg['QueryFrame']</b>.
+ The query history is only available if JavaScript is enabled in your
+ browser.
<br /><br />
To allow the usage of this functionality:
@@ -1739,28 +1739,31 @@
<br /><br />
</dd>
- <dt><b>$cfg['QueryFrame'] </b>boolean<br />
- <b>$cfg['QueryFrameJS'] </b>boolean<br />
+ <dt><b>$cfg['EditInWindow'] </b>boolean<br />
<b>$cfg['QueryWindowWidth'] </b>integer<br />
<b>$cfg['QueryWindowHeight'] </b>integer<br />
<b>$cfg['QueryHistoryDB'] </b>boolean<br />
<b>$cfg['QueryWindowDefTab'] </b>string<br />
<b>$cfg['QueryHistoryMax'] </b>integer
</dt>
<dd>
- All those variables affect the query box feature. When
- $cfg['QueryFrame'] is set to true, a link or icon is displayed
- on the left panel. Clicking on it opens the query box, a direct
- interface to enter SQL queries.
- <br /><br />
- When $cfg['QueryFrameJS'] is set to true, clicking on that link opens
- the query box, a new custom sized browser window
- ($cfg['QueryWindowWidth'], $cfg['QueryWindowWidth'] - both integers
- for the size in pixels).
- Also, a click on [Edit] from the results page (in the &quot;Showing
- Rows&quot; section) opens the query box and puts the current query
- inside it. If set to false, clicking on the link only opens the SQL
- input in the main frame.
+ All those variables affect the query window feature. A <tt>SQL</tt> link
+ or icon is always displayed on the left panel. If JavaScript is enabled in
+ your browser, a click on this opens a distinct query window, which is
+ a direct interface to enter SQL queries. Otherwise, the right panel
+ changes to display a query box.
+ <br /><br />
+ The size of this query window can be customized with
+ <tt>$cfg['QueryWindowWidth']</tt> and <tt>$cfg['QueryWindowWidth']</tt>
+ - both integers for the size in pixels. Note that normally, those
+ parameters will be modified in <tt>layout.inc.php</tt> for the
+ theme you are using.
+ <br /><br />
+ If <tt>$cfg['EditInWindow']</tt> is set to true, a click on [Edit]
+ 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 />
The usage of the JavaScript query window is recommended if you have a
JavaScript enabled browser. Basic functions are used to exchange quite
View
4 config.default.php
@@ -480,9 +480,7 @@
$cfg['ShowPropertyComments']= TRUE; // shows stored relation-comments in 'table property' mode.
$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['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['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['QueryWindowWidth'] = 550; // Width of Query window
$cfg['QueryWindowHeight'] = 310; // Height of Query window
$cfg['QueryHistoryDB'] = FALSE; // Set to TRUE if you want DB-based query history.
View
4 footer.inc.php
@@ -16,8 +16,7 @@
* Query window
*/
-// If query window is wanted and open, update with latest selected db/table.
-if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
+// If query window is open, update with latest selected db/table.
?>
<script type="text/javascript">
//<![CDATA[
@@ -67,7 +66,6 @@
//]]>
</script>
<?php
-}
/**
View
5 libraries/common.lib.php
@@ -2045,9 +2045,10 @@ function PMA_showMessage($message)
&& ($cfg['SQLQuery']['Edit'] == TRUE )
&& (!empty($edit_target))) {
- $onclick = '';
- if ($cfg['QueryFrameJS'] && $cfg['QueryFrame']) {
+ if ($cfg['EditInWindow'] == TRUE) {
$onclick = 'window.parent.focus_querywindow(\'' . urlencode($local_query) . '\'); return false;';
+ } else {
+ $onclick = '';
}
$edit_link = $edit_target
View
26 libraries/left_header.inc.php
@@ -54,25 +54,21 @@
.'</a>' . "\n";
} // 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']) {
- $query_frame_link_text =
- '<img class="icon" src="' . $pmaThemeImage . 'b_selboard.png"'
- .' width="16" height="16" alt="' . $strQueryFrame . '" />';
- } else {
- echo '<br />' . "\n";
- $query_frame_link_text = $strQueryFrame;
- }
+ if ($GLOBALS['cfg']['MainPageIconic']) {
+ $query_frame_link_text =
+ '<img class="icon" src="' . $pmaThemeImage . 'b_selboard.png"'
+ .' width="16" height="16" alt="' . $strQueryFrame . '" />';
+ } else {
+ echo '<br />' . "\n";
+ $query_frame_link_text = $strQueryFrame;
+ }
echo '<a href="' . $anchor . '&amp;no_js=true"'
.' title="' . $strQueryFrame . '"';
- if ( $GLOBALS['cfg']['QueryFrameJS'] ) {
- echo ' onclick="javascript:window.parent.open_querywindow();'
- .' return false;"';
- }
+ echo ' onclick="javascript:window.parent.open_querywindow();'
+ .' return false;"';
echo '>' . $query_frame_link_text . '</a>' . "\n";
- } // end if ($GLOBALS['cfg']['QueryFrame'])
} // end if ($server != 0)
if ($GLOBALS['cfg']['MainPageIconic']) {
View
12 libraries/sql_query_form.lib.php
@@ -29,8 +29,6 @@
* @uses $GLOBALS['sql_query'] from grab_globals.lib.php
* @uses $GLOBALS['cfg']['DefaultQueryTable']
* @uses $GLOBALS['cfg']['DefaultQueryDatabase']
- * @uses $GLOBALS['cfg']['QueryFrame']
- * @uses $GLOBALS['cfg']['QueryFrameJS']
* @uses $GLOBALS['cfg']['Servers']
* @uses $GLOBALS['cfg']['DefaultTabDatabase']
* @uses $GLOBALS['cfg']['DefaultQueryDatabase']
@@ -73,11 +71,6 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
$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
if ( $GLOBALS['is_upload'] ) {
$enctype = ' enctype="multipart/form-data"';
@@ -106,7 +99,7 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
// start output
- if ( $GLOBALS['cfg']['QueryFrameJS'] && $is_querywindow ) {
+ if ( $is_querywindow ) {
?>
<form method="post" id="sqlqueryform"
target="phpmain<?php echo md5( $GLOBALS['cfg']['PmaAbsoluteUri'] ); ?>"
@@ -169,7 +162,6 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
*
* @usedby PMA_sqlQueryForm()
* @uses $GLOBALS['text_dir']
- * @uses $GLOBALS['cfg']['QueryFrameJS']
* @uses $GLOBALS['cfg']['TextareaAutoSelect']
* @uses $GLOBALS['cfg']['TextareaCols']
* @uses $GLOBALS['cfg']['TextareaRows']
@@ -194,7 +186,7 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
}
// enable locking if inside query window
- if ( $GLOBALS['cfg']['QueryFrameJS'] && $is_querywindow ) {
+ if ( $is_querywindow ) {
$locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].'
.'checked = true;"';
} else {
View
182 querywindow.php
@@ -30,7 +30,7 @@
$cfgRelation = PMA_getRelationsParam();
-// initilize some variables
+// initialize some variables
$_sql_history = array();
$_input_query_history = array();
@@ -114,10 +114,10 @@ function resize() {
</head>
<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">
<?php
-if ( $GLOBALS['cfg']['QueryFrameJS'] && !isset($no_js) ) {
+if ( !isset($no_js) ) {
$querydisplay_tab = (isset($querydisplay_tab) ? $querydisplay_tab : $GLOBALS['cfg']['QueryWindowDefTab']);
$tabs = array();
@@ -164,71 +164,68 @@ function resize() {
}
// 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 ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
- PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''),
- (isset($query_history_latest_table) ? $query_history_latest_table : ''),
- $GLOBALS['cfg']['Server']['user'],
- $query_history_latest );
- }
- $_input_query_history[$query_history_latest] = array(
- 'db' => $query_history_latest_db,
- 'table' => isset($query_history_latest_table) ? $query_history_latest_table : '',
- );
+if ( ! empty( $query_history_latest ) && ! empty( $query_history_latest_db ) ) {
+ if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
+ PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''),
+ (isset($query_history_latest_table) ? $query_history_latest_table : ''),
+ $GLOBALS['cfg']['Server']['user'],
+ $query_history_latest );
+ }
+
+ $_input_query_history[$query_history_latest] = array(
+ 'db' => $query_history_latest_db,
+ 'table' => isset($query_history_latest_table) ? $query_history_latest_table : '',
+ );
- $_sql_history[$query_history_latest] = array(
- 'db' => $query_history_latest_db,
- 'table' => isset( $query_history_latest_table ) ? $query_history_latest_table : '',
- );
+ $_sql_history[$query_history_latest] = array(
+ 'db' => $query_history_latest_db,
+ 'table' => isset( $query_history_latest_table ) ? $query_history_latest_table : '',
+ );
- $sql_query = urldecode($query_history_latest);
- $db = $query_history_latest_db;
- $table = $query_history_latest_table;
- } elseif ( ! empty( $query_history_latest ) ) {
- $sql_query = urldecode($query_history_latest);
- }
+ $sql_query = urldecode($query_history_latest);
+ $db = $query_history_latest_db;
+ $table = $query_history_latest_table;
+} elseif ( ! empty( $query_history_latest ) ) {
+ $sql_query = urldecode($query_history_latest);
+}
- if (isset($sql_query)) {
- $show_query = 1;
- }
+if (isset($sql_query)) {
+ $show_query = 1;
+}
- if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
+if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
- $temp_history = PMA_getHistory( $GLOBALS['cfg']['Server']['user'] );
- if (is_array($temp_history) && count($temp_history) > 0) {
- foreach ($temp_history AS $history_nr => $history_array) {
- if ( ! isset( $_sql_history[$history_array['sqlquery']] ) ) {
- $_sql_history[$history_array['sqlquery']] = array(
- 'db' => $history_array['db'],
- 'table' => isset( $history_array['table'] ) ? $history_array['table'] : '',
- );
- }
+ $temp_history = PMA_getHistory( $GLOBALS['cfg']['Server']['user'] );
+ if (is_array($temp_history) && count($temp_history) > 0) {
+ foreach ($temp_history AS $history_nr => $history_array) {
+ if ( ! isset( $_sql_history[$history_array['sqlquery']] ) ) {
+ $_sql_history[$history_array['sqlquery']] = array(
+ 'db' => $history_array['db'],
+ 'table' => isset( $history_array['table'] ) ? $history_array['table'] : '',
+ );
}
}
+ }
- } else {
-
- if (isset($query_history) && is_array($query_history)) {
- $current_index = count($query_history);
- foreach ($query_history AS $query_no => $query_sql) {
- if ( ! isset( $_input_query_history[$query_sql] ) ) {
- $_input_query_history[$query_sql] = array(
- 'db' => $query_history_db,
- 'table' => isset($query_history_table) ? $query_history_table : '',
- );
- $_sql_history[$query_sql] = array(
- 'db' => $query_history_db[$query_no],
- 'table' => isset( $query_history_table[$query_no] ) ? $query_history_table[$query_no] : '',
- );
- } // end if check if this item exists
- } // end while print history
- } // end if history exists
-
- } // end if DB-based history
-}
+} else {
+
+ if (isset($query_history) && is_array($query_history)) {
+ $current_index = count($query_history);
+ foreach ($query_history AS $query_no => $query_sql) {
+ if ( ! isset( $_input_query_history[$query_sql] ) ) {
+ $_input_query_history[$query_sql] = array(
+ 'db' => $query_history_db,
+ 'table' => isset($query_history_table) ? $query_history_table : '',
+ );
+ $_sql_history[$query_sql] = array(
+ 'db' => $query_history_db[$query_no],
+ 'table' => isset( $query_history_table[$query_no] ) ? $query_history_table[$query_no] : '',
+ );
+ } // end if check if this item exists
+ } // end while print history
+ } // end if history exists
+} // end if DB-based history
$url_query = PMA_generate_common_url(isset($db) ? $db : '', isset($table) ? $table : '');
if (!isset($goto)) {
@@ -237,8 +234,7 @@ function resize() {
require_once './libraries/bookmark.lib.php';
-// in case of javascript disabled in queryframe ...
-if ( $GLOBALS['cfg']['QueryFrame'] && ! $GLOBALS['cfg']['QueryFrameJS'] ) {
+if (isset($no_js) && $no_js) {
// ... we redirect to appropriate query sql page
// works only full if $db and $table is also stored/grabbed from $_COOKIE
if ( ! empty( $table ) ) {
@@ -266,26 +262,25 @@ function resize() {
PMA_sqlQueryForm( $query_to_display, $querydisplay_tab );
// 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">
//<![CDATA[
query_auto_commit();
//]]>
</script>
- <?php
- }
+<?php
+}
- if ( count( $_sql_history ) > 0
- && ( $querydisplay_tab == 'history' || $querydisplay_tab == 'full' ) ) {
- $tab = isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full';
- echo $strQuerySQLHistory . ':<br />' . "\n"
- .'<ul>';
- foreach ( $_sql_history as $sql => $query ) {
- echo '<li>' . "\n";
- // edit link
- echo '<a href="#" onclick="'
+if ( count( $_sql_history ) > 0
+ && ( $querydisplay_tab == 'history' || $querydisplay_tab == 'full' ) ) {
+ $tab = isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full';
+ echo $strQuerySQLHistory . ':<br />' . "\n"
+ .'<ul>';
+ foreach ( $_sql_history as $sql => $query ) {
+ echo '<li>' . "\n";
+ // edit link
+ echo '<a href="#" onclick="'
.' document.getElementById(\'hiddenqueryform\').'
.'querydisplay_tab.value = \'' . $tab . '\';'
.' document.getElementById(\'hiddenqueryform\').'
@@ -307,7 +302,7 @@ function resize() {
.' document.getElementById(\'hiddenqueryform\').submit();'
.' return false;">' . $titles['Change'] . '</a>';
// execute link
- echo '<a href="#" onclick="'
+ echo '<a href="#" onclick="'
.' document.getElementById(\'hiddenqueryform\').'
.'querydisplay_tab.value = \'' . $tab . '\';'
.' document.getElementById(\'hiddenqueryform\').'
@@ -330,25 +325,25 @@ function resize() {
.' return false;">[' . htmlspecialchars( $query['db'] ) . '] '
. urldecode( $sql ) . '</a>' . "\n";
- echo '</li>' . "\n";
- }
- unset( $tab, $_sql_history, $sql, $query );
- echo '</ul>' . "\n";
+ echo '</li>' . "\n";
}
- ?>
+ unset( $tab, $_sql_history, $sql, $query );
+ echo '</ul>' . "\n";
+}
+?>
<form action="querywindow.php" method="post" name="querywindow" id="hiddenqueryform">
- <?php
- echo PMA_generate_common_hidden_inputs('', '') . "\n";
- foreach ( $_input_query_history as $sql => $history ) {
- echo '<input type="hidden" name="query_history[]" value="'
- . $sql . '" />' . "\n";
- echo '<input type="hidden" name="query_history_db[]" value="'
- . htmlspecialchars( $history['db'] ) . '" />' . "\n";
- echo '<input type="hidden" name="query_history_table[]" value="'
- . htmlspecialchars( $history['table'] ) . '" />' . "\n";
- }
- unset( $_input_query_history, $sql, $history );
- ?>
+<?php
+echo PMA_generate_common_hidden_inputs('', '') . "\n";
+foreach ( $_input_query_history as $sql => $history ) {
+ echo '<input type="hidden" name="query_history[]" value="'
+ . $sql . '" />' . "\n";
+ echo '<input type="hidden" name="query_history_db[]" value="'
+ . htmlspecialchars( $history['db'] ) . '" />' . "\n";
+ echo '<input type="hidden" name="query_history_table[]" value="'
+ . htmlspecialchars( $history['table'] ) . '" />' . "\n";
+}
+unset( $_input_query_history, $sql, $history );
+?>
<input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" />
<input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" />
@@ -362,7 +357,6 @@ function resize() {
<input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
</form>
<?php
-}
?>
</div>
</body>
View
9 tbl_query_box.php
@@ -15,18 +15,11 @@
require_once('./libraries/bookmark.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 ) ) {
$querydisplay_tab = '';
}
-// in case of javascript disabled in queryframe ...
-if ( $GLOBALS['cfg']['QueryFrame'] && ! $GLOBALS['cfg']['QueryFrameJS']
- && $is_inside_querywindow ) {
+if ( $is_inside_querywindow ) {
// ... we redirect to appropriate query sql page
// works only full if $db and $table is also stored/grabbed from $_COOKIE
if ( ! empty( $table ) ) {

0 comments on commit 9889178

Please sign in to comment.