Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 223 lines (196 sloc) 6.453 kb
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
1 <?php
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
f8f47541 »
2010-05-06 gettext conversion
4 * this file is register_globals safe
e8f3519a »
2007-03-22 documentation;
5 *
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
6 * @todo move JavaScript out of here into .js files
e56949f1 »
2011-10-25 Use package name PhpMyAdmin
7 * @package PhpMyAdmin
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
8 */
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
9
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
10 /**
11 *
12 */
d0facc3d »
2007-03-20 splitted common.lib.php into common.inc.php, core.lib.php and common.…
13 require_once './libraries/common.inc.php';
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
14
c8eaea4e »
2006-05-30 is_superuser not defined
15 $is_superuser = PMA_isSuperuser();
16
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
17 /**
e8f3519a »
2007-03-22 documentation;
18 * Gets a core script and starts output buffering work
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
19 */
e8f3519a »
2007-03-22 documentation;
20 require_once './libraries/sql_query_form.lib.php';
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
21
22 /**
e8f3519a »
2007-03-22 documentation;
23 * starts output buffering if requested and supported
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
24 */
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
25 require_once './libraries/ob.lib.php';
e8f3519a »
2007-03-22 documentation;
26 PMA_outBufferPre();
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
27
e8f3519a »
2007-03-22 documentation;
28 /**
ee767e2d »
2010-07-26 No need to explicitely include relation.lib its anyway included in co…
29 * load relation params
e8f3519a »
2007-03-22 documentation;
30 */
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
31 $cfgRelation = PMA_getRelationsParam();
32
e8f3519a »
2007-03-22 documentation;
33 /**
34 * load bookmark support
35 */
36 require_once './libraries/bookmark.lib.php';
071a0684 »
2005-10-18 wrong handling of linebreaks in query: bug #1243888
37
e8f3519a »
2007-03-22 documentation;
38 $querydisplay_tabs = array(
39 'sql',
40 'files',
41 'history',
42 'full',
43 );
8fc4a4ce »
2005-11-23 moved styles into css
44
e8f3519a »
2007-03-22 documentation;
45 if (isset($_REQUEST['querydisplay_tab'])
46 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)) {
47 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
3143135a »
2005-10-11 XHTML 1.0 trans. compliance and more semantic XHTML output
48 } else {
e8f3519a »
2007-03-22 documentation;
49 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
64bd56df »
2005-09-26 Support for browsing selected columns (RFE #1275909).
50 }
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
51
e8f3519a »
2007-03-22 documentation;
52 /**
53 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
54 * so this page is loaded in main frame
55 */
56 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
37d50c18 »
2003-11-26 Huge set of optimizations, please test!
57
e8f3519a »
2007-03-22 documentation;
58 if ($no_js) {
59 $querydisplay_tab = 'full';
60 $tabs = false;
61 } else {
5de17e7c »
2005-08-16 patch #1252031, CSS for navigation tabs
62 $tabs = array();
d17814f4 »
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
63 $tabs['sql']['icon'] = 'b_sql.png';
f8f47541 »
2010-05-06 gettext conversion
64 $tabs['sql']['text'] = __('SQL');
e8f3519a »
2007-03-22 documentation;
65 $tabs['sql']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
66 $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
67 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
d17814f4 »
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
68 $tabs['import']['icon'] = 'b_import.png';
f8f47541 »
2010-05-06 gettext conversion
69 $tabs['import']['text'] = __('Import files');
e8f3519a »
2007-03-22 documentation;
70 $tabs['import']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
71 $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
72 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
d17814f4 »
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
73 $tabs['history']['icon'] = 'b_bookmark.png';
e42539a8 »
2011-09-21 Use PMA_getIcon()
74 $tabs['history']['text'] = __('SQL history');
e8f3519a »
2007-03-22 documentation;
75 $tabs['history']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
76 $tabs['history']['attr'] = 'onclick="PMA_querywindowCommit(\'history\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
77 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
4d878ae9 »
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
78
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
79 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
f8f47541 »
2010-05-06 gettext conversion
80 $tabs['all']['text'] = __('All');
e8f3519a »
2007-03-22 documentation;
81 $tabs['all']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
82 $tabs['all']['attr'] = 'onclick="PMA_querywindowCommit(\'full\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
83 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
210576b0 »
2003-04-20 Fixed Bug #723955, 723736, 723713 (Query Frame)
84 }
4d878ae9 »
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
85 }
86
e42539a8 »
2011-09-21 Use PMA_getIcon()
87 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'));
e8f3519a »
2007-03-22 documentation;
88 $url_query = PMA_generate_common_url($db, $table);
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
89
b2f3ae5f »
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
90 if (! empty($sql_query)) {
e8f3519a »
2007-03-22 documentation;
91 $show_query = 1;
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
92 }
93
e8f3519a »
2007-03-22 documentation;
94 if ($no_js) {
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
95 // ... we redirect to appropriate query sql page
96 // works only full if $db and $table is also stored/grabbed from $_COOKIE
e8f3519a »
2007-03-22 documentation;
97 if (strlen($table)) {
9bcb83af »
2011-09-23 File is being conditionally included; use "include" instead
98 include './tbl_sql.php';
e8f3519a »
2007-03-22 documentation;
99 } elseif (strlen($db)) {
9bcb83af »
2011-09-23 File is being conditionally included; use "include" instead
100 include './db_sql.php';
7358f5a7 »
2006-01-14 allow 0 as name for database, table collumn, alias and index
101 } else {
9bcb83af »
2011-09-23 File is being conditionally included; use "include" instead
102 include './server_sql.php';
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
103 }
104 exit;
105 }
106
107 /**
108 * Defines the query to be displayed in the query textarea
109 */
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
110 if (! empty($show_query)) {
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
111 $query_to_display = $sql_query;
112 } else {
113 $query_to_display = '';
114 }
b2f3ae5f »
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
115 $sql_query = '';
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
116
e8f3519a »
2007-03-22 documentation;
117 /**
98c8a771 »
2007-10-05 refactored JavaScript handling
118 * prepare JavaScript functionality
e8f3519a »
2007-03-22 documentation;
119 */
98c8a771 »
2007-10-05 refactored JavaScript handling
120 $js_include[] = 'common.js';
121 $js_include[] = 'querywindow.js';
e8f3519a »
2007-03-22 documentation;
122
123 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
98c8a771 »
2007-10-05 refactored JavaScript handling
124 $js_events[] = array(
125 'event' => 'load',
126 'function' => 'PMA_queryAutoCommit',
127 );
e8f3519a »
2007-03-22 documentation;
128 }
129 if (PMA_isValid($_REQUEST['init'])) {
98c8a771 »
2007-10-05 refactored JavaScript handling
130 $js_events[] = array(
131 'event' => 'load',
132 'function' => 'PMA_querywindowResize',
133 );
e8f3519a »
2007-03-22 documentation;
134 }
ad8dc8e1 »
2007-10-20 bug #1805102, TextareaAutoSelect issues
135 // always set focus to the textarea
7bb8eddf »
2007-11-26 patch #1837691 [query window] js errors, thanks to Victor Volkov
136 if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
137 $js_events[] = array(
138 'event' => 'load',
139 'function' => 'PMA_querywindowSetFocus',
140 );
141 }
e8f3519a »
2007-03-22 documentation;
142
98c8a771 »
2007-10-05 refactored JavaScript handling
143 /**
144 * start HTTP/HTML output
145 */
146 require_once './libraries/header_http.inc.php';
147 require_once './libraries/header_meta_style.inc.php';
148 require_once './libraries/header_scripts.inc.php';
149 ?>
e8f3519a »
2007-03-22 documentation;
150 </head>
151
98c8a771 »
2007-10-05 refactored JavaScript handling
152 <body id="bodyquerywindow">
e8f3519a »
2007-03-22 documentation;
153 <div id="querywindowcontainer">
9889178b »
2005-11-16 new query window behavior
154 <?php
e8f3519a »
2007-03-22 documentation;
155
156 if ($tabs) {
8480ffb6 »
2009-06-07 improve function names
157 echo PMA_generate_html_tabs($tabs, array());
e8f3519a »
2007-03-22 documentation;
158 unset($tabs);
9889178b »
2005-11-16 new query window behavior
159 }
37d50c18 »
2003-11-26 Huge set of optimizations, please test!
160
e8f3519a »
2007-03-22 documentation;
161 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
162
163 // Hidden forms and query frame interaction stuff
164
165 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
166 if (! empty($_sql_history)
167 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')) {
168 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
f8f47541 »
2010-05-06 gettext conversion
169 echo __('SQL history') . ':<br />'
170 . '<ul>';
e8f3519a »
2007-03-22 documentation;
171 foreach ($_sql_history as $query) {
9889178b »
2005-11-16 new query window behavior
172 echo '<li>' . "\n";
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
173
9889178b »
2005-11-16 new query window behavior
174 // edit link
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
175 $url_params = array(
176 'querydisplay_tab' => $tab,
177 'sql_query' => $query['sqlquery'],
178 'db' => $query['db'],
179 'table' => $query['table'],
180 );
181 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
182 . '">' . $titles['Change'] . '</a>';
183
e8f3519a »
2007-03-22 documentation;
184 // execute link
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
185 $url_params['auto_commit'] = 'true';
186 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
187 . ' target="frame_content">';
188
e8f3519a »
2007-03-22 documentation;
189 if (! empty($query['db'])) {
190 echo '[';
191 echo htmlspecialchars(PMA_backquote($query['db']));
192 if (! empty($query['table'])) {
193 echo '.' . htmlspecialchars(PMA_backquote($query['table']));
194 }
195 echo '] ';
196 }
197 if (strlen($query['sqlquery']) > 120) {
198 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
199 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
200 echo htmlspecialchars(substr($query['sqlquery'], -50));
201 echo '</span>';
202 } else {
203 echo htmlspecialchars($query['sqlquery']);
204 }
205 echo '</a>' . "\n";
9889178b »
2005-11-16 new query window behavior
206 echo '</li>' . "\n";
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
207 }
e8f3519a »
2007-03-22 documentation;
208 unset($tab, $_sql_history, $query);
9889178b »
2005-11-16 new query window behavior
209 echo '</ul>' . "\n";
210 }
211 ?>
e8f3519a »
2007-03-22 documentation;
212 <form action="querywindow.php" method="post" name="hiddenqueryform"
213 id="hiddenqueryform">
214 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
215 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
216 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
217 <input type="hidden" name="sql_query" value="" />
4d878ae9 »
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
218 <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
219 </form>
64bd56df »
2005-09-26 Support for browsing selected columns (RFE #1275909).
220 </div>
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
221 </body>
222 </html>
Something went wrong with that request. Please try again.