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>
* 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 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.
<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,8 +1739,7 @@ Defaults to FALSE (drop-down). <br />
<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 />
@@ -1748,19 +1747,23 @@ Defaults to FALSE (drop-down). <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.
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 />
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.
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 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['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 File

@@ -16,8 +16,7 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
* 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 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
//]]>
</script>
<?php
}
/**

View File

@@ -2045,9 +2045,10 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
&& ($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 File

@@ -54,25 +54,21 @@ if ( $GLOBALS['cfg']['LeftDisplayLogo'] ) {
.'</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 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['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 File

@@ -30,7 +30,7 @@ require_once('./libraries/relation.lib.php');
$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 @@ if ( true == $GLOBALS['cfg']['PropertiesIconic'] ) {
}
// 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 : '',
);
$_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);
}
if (isset($sql_query)) {
$show_query = 1;
}
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 );
}
$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'] : '',
);
}
$_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_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 ( $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'] : '',
);
}
}
}
} else {
} 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
}
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 @@ if (!isset($goto)) {
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 @@ unset( $sql_query );
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 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
.' 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 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
.' 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 @@ if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) {
<input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
</form>
<?php
}
?>
</div>
</body>

View File

@@ -15,18 +15,11 @@ require_once('./libraries/common.lib.php');
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 ) ) {