Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 208 lines (182 sloc) 6.169 kb
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
1 <?php
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
f8f4754 @lem9 gettext conversion
lem9 authored
4 * this file is register_globals safe
e8f3519 documentation;
Sebastian Mendel authored
5 *
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
6 * @todo move JavaScript out of here into .js files
e56949f @nijel Use package name PhpMyAdmin
nijel authored
7 * @package PhpMyAdmin
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
8 */
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
9
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
10 /**
11 *
12 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
13 require_once 'libraries/common.inc.php';
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
14
c8eaea4 @lem9 is_superuser not defined
lem9 authored
15 $is_superuser = PMA_isSuperuser();
16
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
17 /**
e8f3519 documentation;
Sebastian Mendel authored
18 * Gets a core script and starts output buffering work
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
19 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
20 require_once 'libraries/sql_query_form.lib.php';
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
21
22 /**
ee767e2 @nijel No need to explicitely include relation.lib its anyway included in commo...
nijel authored
23 * load relation params
e8f3519 documentation;
Sebastian Mendel authored
24 */
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
25 $cfgRelation = PMA_getRelationsParam();
26
e8f3519 documentation;
Sebastian Mendel authored
27 /**
28 * load bookmark support
29 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
30 require_once 'libraries/bookmark.lib.php';
071a068 wrong handling of linebreaks in query: bug #1243888
Sebastian Mendel authored
31
e8f3519 documentation;
Sebastian Mendel authored
32 $querydisplay_tabs = array(
33 'sql',
34 'files',
35 'history',
36 'full',
37 );
8fc4a4c moved styles into css
Sebastian Mendel authored
38
e8f3519 documentation;
Sebastian Mendel authored
39 if (isset($_REQUEST['querydisplay_tab'])
4b8d52d @madhuracj Fix CheckStyle warnings, Type:CloseBracketNewLine (Closing parenthesis o...
madhuracj authored
40 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)
41 ) {
e8f3519 documentation;
Sebastian Mendel authored
42 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
3143135 XHTML 1.0 trans. compliance and more semantic XHTML output
Sebastian Mendel authored
43 } else {
e8f3519 documentation;
Sebastian Mendel authored
44 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored
45 }
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
46
e8f3519 documentation;
Sebastian Mendel authored
47 /**
48 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
49 * so this page is loaded in main frame
50 */
51 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
37d50c1 @derrabus Huge set of optimizations, please test!
derrabus authored
52
e8f3519 documentation;
Sebastian Mendel authored
53 if ($no_js) {
54 $querydisplay_tab = 'full';
55 $tabs = false;
56 } else {
5de17e7 @lem9 patch #1252031, CSS for navigation tabs
lem9 authored
57 $tabs = array();
2d9dc11 @nijel Wrap long lines, replace inline html
nijel authored
58 $tabs['sql']['icon'] = 'b_sql.png';
59 $tabs['sql']['text'] = __('SQL');
60 $tabs['sql']['fragment'] = '#';
61 $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
62 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
2d9dc11 @nijel Wrap long lines, replace inline html
nijel authored
63 $tabs['import']['icon'] = 'b_import.png';
64 $tabs['import']['text'] = __('Import files');
65 $tabs['import']['fragment'] = '#';
66 $tabs['import']['attr']
67 = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
68 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
2d9dc11 @nijel Wrap long lines, replace inline html
nijel authored
69 $tabs['history']['icon'] = 'b_bookmark.png';
70 $tabs['history']['text'] = __('SQL history');
71 $tabs['history']['fragment'] = '#';
72 $tabs['history']['attr']
73 = 'onclick="PMA_querywindowCommit(\'history\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
74 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
4d878ae See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywindo...
Garvin Hicking authored
75
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
76 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
2d9dc11 @nijel Wrap long lines, replace inline html
nijel authored
77 $tabs['all']['text'] = __('All');
78 $tabs['all']['fragment'] = '#';
79 $tabs['all']['attr']
80 = 'onclick="PMA_querywindowCommit(\'full\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
81 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
210576b Fixed Bug #723955, 723736, 723713 (Query Frame)
Garvin Hicking authored
82 }
4d878ae See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywindo...
Garvin Hicking authored
83 }
84
e6894be @Chanaka Renamed ->method() with PMA_Util::method()
Chanaka authored
85 $titles['Change'] = PMA_Util::getIcon('b_edit.png', __('Change'));
e8f3519 documentation;
Sebastian Mendel authored
86 $url_query = PMA_generate_common_url($db, $table);
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
87
b2f3ae5 make $sql_query persistent (init it, never unset it, always assume it is...
Sebastian Mendel authored
88 if (! empty($sql_query)) {
e8f3519 documentation;
Sebastian Mendel authored
89 $show_query = 1;
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
90 }
91
e8f3519 documentation;
Sebastian Mendel authored
92 if ($no_js) {
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, rep...
Sebastian Mendel authored
93 // ... we redirect to appropriate query sql page
94 // works only full if $db and $table is also stored/grabbed from $_COOKIE
e8f3519 documentation;
Sebastian Mendel authored
95 if (strlen($table)) {
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
96 include 'tbl_sql.php';
e8f3519 documentation;
Sebastian Mendel authored
97 } elseif (strlen($db)) {
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
98 include 'db_sql.php';
7358f5a allow 0 as name for database, table collumn, alias and index
Sebastian Mendel authored
99 } else {
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
100 include 'server_sql.php';
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, rep...
Sebastian Mendel authored
101 }
102 exit;
103 }
104
105 /**
106 * Defines the query to be displayed in the query textarea
107 */
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored
108 if (! empty($show_query)) {
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, rep...
Sebastian Mendel authored
109 $query_to_display = $sql_query;
110 } else {
111 $query_to_display = '';
112 }
b2f3ae5 make $sql_query persistent (init it, never unset it, always assume it is...
Sebastian Mendel authored
113 $sql_query = '';
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, rep...
Sebastian Mendel authored
114
e8f3519 documentation;
Sebastian Mendel authored
115 /**
98c8a77 refactored JavaScript handling
Sebastian Mendel authored
116 * prepare JavaScript functionality
e8f3519 documentation;
Sebastian Mendel authored
117 */
a054562 @roccivic PMA_Footer and PMA_Header no longer need to be singletons
roccivic authored
118 $response = PMA_Response::getInstance();
d9bedbd @roccivic Finished integrating the PMA_Footer class
roccivic authored
119 $response->getFooter()->setMinimal();
2d9dc11 @nijel Wrap long lines, replace inline html
nijel authored
120 $header = $response->getHeader();
0aee714 @roccivic Drop old header_*.inc.php scripts from querywindow.php
roccivic authored
121 $header->disableMenu();
122 $header->setBodyId('bodyquerywindow');
123 $scripts = $header->getScripts();
4a74037 @roccivic Dropped header.inc.php in favor of the PMA_Header class
roccivic authored
124 $scripts->addFile('common.js');
125 $scripts->addFile('querywindow.js');
8744f8c + rfe #3517354 [interface] Allow disabling CodeMirror with $cfg['Codemir...
Jo Michael authored
126
e8f3519 documentation;
Sebastian Mendel authored
127 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
9a47688 @madhuracj Various coding style improvements
madhuracj authored
128 $scripts->addEvent('load', 'PMA_queryAutoCommit');
e8f3519 documentation;
Sebastian Mendel authored
129 }
130 if (PMA_isValid($_REQUEST['init'])) {
9a47688 @madhuracj Various coding style improvements
madhuracj authored
131 $scripts->addEvent('load', 'PMA_querywindowResize');
e8f3519 documentation;
Sebastian Mendel authored
132 }
ad8dc8e @lem9 bug #1805102, TextareaAutoSelect issues
lem9 authored
133 // always set focus to the textarea
7bb8edd @lem9 patch #1837691 [query window] js errors, thanks to Victor Volkov
lem9 authored
134 if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
9a47688 @madhuracj Various coding style improvements
madhuracj authored
135 $scripts->addEvent('load', 'PMA_querywindowSetFocus');
7bb8edd @lem9 patch #1837691 [query window] js errors, thanks to Victor Volkov
lem9 authored
136 }
e8f3519 documentation;
Sebastian Mendel authored
137
0aee714 @roccivic Drop old header_*.inc.php scripts from querywindow.php
roccivic authored
138 echo '<div id="querywindowcontainer">';
e8f3519 documentation;
Sebastian Mendel authored
139
140 if ($tabs) {
e6894be @Chanaka Renamed ->method() with PMA_Util::method()
Chanaka authored
141 echo PMA_Util::getHtmlTabs($tabs, array());
e8f3519 documentation;
Sebastian Mendel authored
142 unset($tabs);
9889178 @lem9 new query window behavior
lem9 authored
143 }
37d50c1 @derrabus Huge set of optimizations, please test!
derrabus authored
144
e8f3519 documentation;
Sebastian Mendel authored
145 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
146
147 // Hidden forms and query frame interaction stuff
148
149 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
150 if (! empty($_sql_history)
4b8d52d @madhuracj Fix CheckStyle warnings, Type:CloseBracketNewLine (Closing parenthesis o...
madhuracj authored
151 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')
152 ) {
e8f3519 documentation;
Sebastian Mendel authored
153 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
f8f4754 @lem9 gettext conversion
lem9 authored
154 echo __('SQL history') . ':<br />'
155 . '<ul>';
e8f3519 documentation;
Sebastian Mendel authored
156 foreach ($_sql_history as $query) {
9889178 @lem9 new query window behavior
lem9 authored
157 echo '<li>' . "\n";
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored
158
9889178 @lem9 new query window behavior
lem9 authored
159 // edit link
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored
160 $url_params = array(
161 'querydisplay_tab' => $tab,
162 'sql_query' => $query['sqlquery'],
163 'db' => $query['db'],
164 'table' => $query['table'],
165 );
166 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
167 . '">' . $titles['Change'] . '</a>';
168
e8f3519 documentation;
Sebastian Mendel authored
169 // execute link
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored
170 $url_params['auto_commit'] = 'true';
171 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
172 . ' target="frame_content">';
173
e8f3519 documentation;
Sebastian Mendel authored
174 if (! empty($query['db'])) {
175 echo '[';
e6894be @Chanaka Renamed ->method() with PMA_Util::method()
Chanaka authored
176 echo htmlspecialchars(PMA_Util::backquote($query['db']));
e8f3519 documentation;
Sebastian Mendel authored
177 if (! empty($query['table'])) {
e6894be @Chanaka Renamed ->method() with PMA_Util::method()
Chanaka authored
178 echo '.' . htmlspecialchars(PMA_Util::backquote($query['table']));
e8f3519 documentation;
Sebastian Mendel authored
179 }
180 echo '] ';
181 }
182 if (strlen($query['sqlquery']) > 120) {
183 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
184 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
185 echo htmlspecialchars(substr($query['sqlquery'], -50));
186 echo '</span>';
187 } else {
188 echo htmlspecialchars($query['sqlquery']);
189 }
190 echo '</a>' . "\n";
9889178 @lem9 new query window behavior
lem9 authored
191 echo '</li>' . "\n";
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored
192 }
e8f3519 documentation;
Sebastian Mendel authored
193 unset($tab, $_sql_history, $query);
9889178 @lem9 new query window behavior
lem9 authored
194 echo '</ul>' . "\n";
195 }
2d9dc11 @nijel Wrap long lines, replace inline html
nijel authored
196
197 echo '<form action="querywindow.php" method="post" name="hiddenqueryform"';
198 echo ' id="hiddenqueryform">';
199 echo PMA_generate_common_hidden_inputs('', '');
200 echo '<input type="hidden" name="db" value="' . htmlspecialchars($db) . '" />';
201 echo '<input type="hidden" name="table" value="'
202 . htmlspecialchars($table) . '" />';
203 echo '<input type="hidden" name="sql_query" value="" />';
204 echo '<input type="hidden" name="querydisplay_tab" value="'
205 . $querydisplay_tab . '" />';
206 echo '</form>';
207 echo '</div>';
Something went wrong with that request. Please try again.