Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 217 lines (190 sloc) 6.329 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 */
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
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 */
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
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 */
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
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 */
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
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'])
4b8d52d9 »
2012-04-22 Fix CheckStyle warnings, Type:CloseBracketNewLine (Closing parenthesi…
46 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)
47 ) {
e8f3519a »
2007-03-22 documentation;
48 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
3143135a »
2005-10-11 XHTML 1.0 trans. compliance and more semantic XHTML output
49 } else {
e8f3519a »
2007-03-22 documentation;
50 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
64bd56df »
2005-09-26 Support for browsing selected columns (RFE #1275909).
51 }
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
52
e8f3519a »
2007-03-22 documentation;
53 /**
54 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
55 * so this page is loaded in main frame
56 */
57 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
37d50c18 »
2003-11-26 Huge set of optimizations, please test!
58
e8f3519a »
2007-03-22 documentation;
59 if ($no_js) {
60 $querydisplay_tab = 'full';
61 $tabs = false;
62 } else {
5de17e7c »
2005-08-16 patch #1252031, CSS for navigation tabs
63 $tabs = array();
d17814f4 »
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
64 $tabs['sql']['icon'] = 'b_sql.png';
f8f47541 »
2010-05-06 gettext conversion
65 $tabs['sql']['text'] = __('SQL');
e8f3519a »
2007-03-22 documentation;
66 $tabs['sql']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
67 $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
68 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
d17814f4 »
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
69 $tabs['import']['icon'] = 'b_import.png';
f8f47541 »
2010-05-06 gettext conversion
70 $tabs['import']['text'] = __('Import files');
e8f3519a »
2007-03-22 documentation;
71 $tabs['import']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
72 $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
73 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
d17814f4 »
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
74 $tabs['history']['icon'] = 'b_bookmark.png';
e42539a8 »
2011-09-21 Use PMA_getIcon()
75 $tabs['history']['text'] = __('SQL history');
e8f3519a »
2007-03-22 documentation;
76 $tabs['history']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
77 $tabs['history']['attr'] = 'onclick="PMA_querywindowCommit(\'history\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
78 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
4d878ae9 »
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
79
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
80 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
f8f47541 »
2010-05-06 gettext conversion
81 $tabs['all']['text'] = __('All');
e8f3519a »
2007-03-22 documentation;
82 $tabs['all']['fragment'] = '#';
29a41fc9 »
2011-09-25 "javascript:" is not needed here
83 $tabs['all']['attr'] = 'onclick="PMA_querywindowCommit(\'full\');return false;"';
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
84 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
210576b0 »
2003-04-20 Fixed Bug #723955, 723736, 723713 (Query Frame)
85 }
4d878ae9 »
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
86 }
87
e42539a8 »
2011-09-21 Use PMA_getIcon()
88 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'));
e8f3519a »
2007-03-22 documentation;
89 $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
90
b2f3ae5f »
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
91 if (! empty($sql_query)) {
e8f3519a »
2007-03-22 documentation;
92 $show_query = 1;
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
93 }
94
e8f3519a »
2007-03-22 documentation;
95 if ($no_js) {
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
96 // ... we redirect to appropriate query sql page
97 // works only full if $db and $table is also stored/grabbed from $_COOKIE
e8f3519a »
2007-03-22 documentation;
98 if (strlen($table)) {
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
99 include 'tbl_sql.php';
e8f3519a »
2007-03-22 documentation;
100 } elseif (strlen($db)) {
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
101 include 'db_sql.php';
7358f5a7 »
2006-01-14 allow 0 as name for database, table collumn, alias and index
102 } else {
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
103 include 'server_sql.php';
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
104 }
105 exit;
106 }
107
108 /**
109 * Defines the query to be displayed in the query textarea
110 */
03f22453 »
2007-03-19 bug #1664212 querywindow loses url encoded characters
111 if (! empty($show_query)) {
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
112 $query_to_display = $sql_query;
113 } else {
114 $query_to_display = '';
115 }
b2f3ae5f »
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
116 $sql_query = '';
b8741540 »
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
117
e8f3519a »
2007-03-22 documentation;
118 /**
98c8a771 »
2007-10-05 refactored JavaScript handling
119 * prepare JavaScript functionality
e8f3519a »
2007-03-22 documentation;
120 */
4a740376 »
2012-05-23 Dropped header.inc.php in favor of the PMA_Header class
121 $scripts = PMA_Header::getInstance()->getScripts();
122 $scripts->addFile('common.js');
123 $scripts->addFile('querywindow.js');
8744f8cf »
2012-04-13 + rfe #3517354 [interface] Allow disabling CodeMirror with $cfg['Code…
124
e8f3519a »
2007-03-22 documentation;
125 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
4a740376 »
2012-05-23 Dropped header.inc.php in favor of the PMA_Header class
126 $scripts->addEvent('load','PMA_queryAutoCommit');
e8f3519a »
2007-03-22 documentation;
127 }
128 if (PMA_isValid($_REQUEST['init'])) {
4a740376 »
2012-05-23 Dropped header.inc.php in favor of the PMA_Header class
129 $scripts->addEvent('load','PMA_querywindowResize');
e8f3519a »
2007-03-22 documentation;
130 }
ad8dc8e1 »
2007-10-20 bug #1805102, TextareaAutoSelect issues
131 // always set focus to the textarea
7bb8eddf »
2007-11-26 patch #1837691 [query window] js errors, thanks to Victor Volkov
132 if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
4a740376 »
2012-05-23 Dropped header.inc.php in favor of the PMA_Header class
133 $scripts->addEvent('load','PMA_querywindowSetFocus');
7bb8eddf »
2007-11-26 patch #1837691 [query window] js errors, thanks to Victor Volkov
134 }
e8f3519a »
2007-03-22 documentation;
135
98c8a771 »
2007-10-05 refactored JavaScript handling
136 /**
137 * start HTTP/HTML output
138 */
b2fd866d »
2012-03-16 Leading ./ paths for includes can be omitted, part 2
139 require_once 'libraries/header_http.inc.php';
140 require_once 'libraries/header_meta_style.inc.php';
141 require_once 'libraries/header_scripts.inc.php';
98c8a771 »
2007-10-05 refactored JavaScript handling
142 ?>
e8f3519a »
2007-03-22 documentation;
143 </head>
144
98c8a771 »
2007-10-05 refactored JavaScript handling
145 <body id="bodyquerywindow">
e8f3519a »
2007-03-22 documentation;
146 <div id="querywindowcontainer">
9889178b »
2005-11-16 new query window behavior
147 <?php
e8f3519a »
2007-03-22 documentation;
148
149 if ($tabs) {
60f84a04 »
2012-05-11 Fix function names: PMA_generate_html_tabs -> PMA_generateHtmlTabs
150 echo PMA_generateHtmlTabs($tabs, array());
e8f3519a »
2007-03-22 documentation;
151 unset($tabs);
9889178b »
2005-11-16 new query window behavior
152 }
37d50c18 »
2003-11-26 Huge set of optimizations, please test!
153
e8f3519a »
2007-03-22 documentation;
154 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
155
156 // Hidden forms and query frame interaction stuff
157
158 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
159 if (! empty($_sql_history)
4b8d52d9 »
2012-04-22 Fix CheckStyle warnings, Type:CloseBracketNewLine (Closing parenthesi…
160 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')
161 ) {
e8f3519a »
2007-03-22 documentation;
162 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
f8f47541 »
2010-05-06 gettext conversion
163 echo __('SQL history') . ':<br />'
164 . '<ul>';
e8f3519a »
2007-03-22 documentation;
165 foreach ($_sql_history as $query) {
9889178b »
2005-11-16 new query window behavior
166 echo '<li>' . "\n";
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
167
9889178b »
2005-11-16 new query window behavior
168 // edit link
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
169 $url_params = array(
170 'querydisplay_tab' => $tab,
171 'sql_query' => $query['sqlquery'],
172 'db' => $query['db'],
173 'table' => $query['table'],
174 );
175 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
176 . '">' . $titles['Change'] . '</a>';
177
e8f3519a »
2007-03-22 documentation;
178 // execute link
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
179 $url_params['auto_commit'] = 'true';
180 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
181 . ' target="frame_content">';
182
e8f3519a »
2007-03-22 documentation;
183 if (! empty($query['db'])) {
184 echo '[';
185 echo htmlspecialchars(PMA_backquote($query['db']));
186 if (! empty($query['table'])) {
187 echo '.' . htmlspecialchars(PMA_backquote($query['table']));
188 }
189 echo '] ';
190 }
191 if (strlen($query['sqlquery']) > 120) {
192 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
193 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
194 echo htmlspecialchars(substr($query['sqlquery'], -50));
195 echo '</span>';
196 } else {
197 echo htmlspecialchars($query['sqlquery']);
198 }
199 echo '</a>' . "\n";
9889178b »
2005-11-16 new query window behavior
200 echo '</li>' . "\n";
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
201 }
e8f3519a »
2007-03-22 documentation;
202 unset($tab, $_sql_history, $query);
9889178b »
2005-11-16 new query window behavior
203 echo '</ul>' . "\n";
204 }
205 ?>
e8f3519a »
2007-03-22 documentation;
206 <form action="querywindow.php" method="post" name="hiddenqueryform"
207 id="hiddenqueryform">
208 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
209 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
210 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
d27b8efa »
2007-03-26 removed unnecessary JavaScript code (due to session based history)
211 <input type="hidden" name="sql_query" value="" />
4d878ae9 »
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
212 <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
213 </form>
64bd56df »
2005-09-26 Support for browsing selected columns (RFE #1275909).
214 </div>
dd6345c9 »
2003-02-24 Display a (javascript) based query window as a new frame below the left
215 </body>
216 </html>
Something went wrong with that request. Please try again.