Patch #705899 from Alexis Soulard

This commit is contained in:
Garvin Hicking
2003-04-06 19:14:36 +00:00
parent 0d39fbcb3f
commit 6d7e4ed82d
3 changed files with 71 additions and 26 deletions

View File

@@ -6,6 +6,9 @@ $Id$
$Source$
2003-04-06 Garvin Hicking <me@supergarv.de>
* tbl_query_box.php, libraries/functions.js: Patch #705899 included.
Now multiple fields can be inserted at cursor position (Mozilla/IE)
in the sql query textarea. Thanks to Alexis Soulard (alexis_soulard)
* header.inc.php3, footer.inc.php3, libraries/common.lib.php3,
libraries/relation.lib.php3: RFE #715914: Sort query history by
(autoincrement) key instead of timevalue. Only save queries in

View File

@@ -636,6 +636,46 @@ function onKeyDownArrowsHandler(e) {
e.returnValue = false;
}
/**
* Inserts multiple fields.
*
*/
function insertValueQuery() {
var myQuery = document.sqlform.sql_query;
var myListBox = document.sqlform.dummy;
if(myListBox.options.length > 0) {
var chaineAj = "";
var NbSelect = 0;
for(var i=0; i<myListBox.options.length; i++) {
if (myListBox.options[i].selected){
NbSelect++;
if (NbSelect > 1)
chaineAj += ", ";
chaineAj += myListBox.options[i].value;
}
}
//IE support
if (document.selection) {
myQuery.focus();
sel = document.selection.createRange();
sel.text = chaineAj;
document.sqlform.insert.focus();
}
//MOZILLA/NETSCAPE support
else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
var startPos = document.sqlform.sql_query.selectionStart;
var endPos = document.sqlform.sql_query.selectionEnd;
var chaineSql = document.sqlform.sql_query.value;
myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
} else {
myQuery.value += chaineAj;
}
}
}
/**
* listbox redirection
*/

View File

@@ -86,18 +86,23 @@ if ($cfg['QueryFrame'] && (!$cfg['QueryFrameJS'] || ($cfg['QueryFrameJS'] && !$d
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="zero_rows" value="<?php echo $strSuccess; ?>" />
<input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
<?php
if (!isset($is_inside_querywindow) ||
(isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full'))) {
?>
<!-- Query box and bookmark support -->
<li>
<a name="querybox"></a>
<?php echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . $queryframe_db_list . ' ' . PMA_showMySQLDocu('Reference', 'SELECT'); ?>
<table cellpadding="1" cellspacing="1">
<tr>
<td>
<?php echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . $queryframe_db_list . (isset($is_inside_querywindow) ? '<br />' : ' ') . PMA_showMySQLDocu('Reference', 'SELECT'); ?>
<br />
<textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? ceil($cfg['TextareaCols'] * 1.25) : $cfg['TextareaCols'] * 2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
<?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . htmlspecialchars(PMA_backquote($table)) . ' WHERE 1'); ?></textarea>
</td>
<?php if (isset($table) && $fields_cnt > 0) { ?>
&nbsp;&nbsp;&nbsp;<?php echo $strFields; ?>:
<select name="dummy" size="1">
<td align="center" valign="top"><?php echo (isset($is_inside_querywindow) ? '<br />' : '') . $strFields; ?>:<br />
<select name="dummy" size="4" multiple>
<?php
echo "\n";
for ($i = 0 ; $i < $fields_cnt; $i++) {
@@ -105,16 +110,14 @@ if (!isset($is_inside_querywindow) ||
. '<option value="' . PMA_backquote(htmlspecialchars($fields_list[$i])) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
}
?>
</select>
<input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="sqlform.sql_query.value = sqlform.sql_query.value + sqlform.dummy.value" />
</select><br /><br />
<input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="insertValueQuery()" />
</td>
<?php
}
?>
<br />
<div style="margin-bottom: 5px">
<textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? ceil($cfg['TextareaCols'] * 1.25) : $cfg['TextareaCols'] * 2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
<?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . htmlspecialchars(PMA_backquote($table)) . ' WHERE 1'); ?>
</textarea><br />
</tr>
</table>
<input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp;
<label for="checkbox_show_query"><?php echo $strShowThisQuery; ?></label><br />
</div>
@@ -245,7 +248,6 @@ if (!isset($is_inside_querywindow) ||
if (!isset($is_inside_querywindow) || (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'sql' || $querydisplay_tab == 'full' || ($querydisplay_tab == 'history' && $bookmark_go)))) {
?>
<input type="submit" name="SQL" value="<?php echo $strGo; ?>" />
</li>
<?php
}