Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / querywindow.php
blob76e2a3b05d90b2cf0a7a7e0bce92fbbfb18f8507
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * this file is register_globals safe
6 * @todo move JavaScript out of here into .js files
7 * @package phpMyAdmin
8 */
10 /**
13 require_once './libraries/common.inc.php';
15 $is_superuser = PMA_isSuperuser();
17 /**
18 * Gets a core script and starts output buffering work
20 require_once './libraries/sql_query_form.lib.php';
22 /**
23 * starts output buffering if requested and supported
25 require_once './libraries/ob.lib.php';
26 PMA_outBufferPre();
28 /**
29 * load relation params
31 $cfgRelation = PMA_getRelationsParam();
33 /**
34 * load bookmark support
36 require_once './libraries/bookmark.lib.php';
38 $querydisplay_tabs = array(
39 'sql',
40 'files',
41 'history',
42 'full',
45 if (isset($_REQUEST['querydisplay_tab'])
46 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)) {
47 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
48 } else {
49 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
52 /**
53 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
54 * so this page is loaded in main frame
56 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
58 if ($no_js) {
59 $querydisplay_tab = 'full';
60 $tabs = false;
61 } else {
62 $tabs = array();
63 $tabs['sql']['icon'] = 'ic_b_sql';
64 $tabs['sql']['text'] = __('SQL');
65 $tabs['sql']['fragment'] = '#';
66 $tabs['sql']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'sql\');return false;"';
67 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
68 $tabs['import']['icon'] = 'ic_b_import';
69 $tabs['import']['text'] = __('Import files');
70 $tabs['import']['fragment'] = '#';
71 $tabs['import']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'files\');return false;"';
72 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
73 $tabs['history']['icon'] = 'ic_b_bookmark';
74 $tabs['history']['text'] = __('SQL history');
75 $tabs['history']['fragment'] = '#';
76 $tabs['history']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'history\');return false;"';
77 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
79 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
80 $tabs['all']['text'] = __('All');
81 $tabs['all']['fragment'] = '#';
82 $tabs['all']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'full\');return false;"';
83 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
87 if ($GLOBALS['cfg']['PropertiesIconic']) {
88 $titles['Change'] =
89 '<img class="icon ic_b_edit" src="themes/dot.gif" alt="'
90 . __('Change') . '" title="' . __('Change')
91 . '" />';
93 if ('both' === $GLOBALS['cfg']['PropertiesIconic']) {
94 $titles['Change'] .= __('Change') . ' ';
96 } else {
97 $titles['Change'] = __('Change') . ' ';
100 $url_query = PMA_generate_common_url($db, $table);
102 if (! empty($sql_query)) {
103 $show_query = 1;
106 if ($no_js) {
107 // ... we redirect to appropriate query sql page
108 // works only full if $db and $table is also stored/grabbed from $_COOKIE
109 if (strlen($table)) {
110 require './tbl_sql.php';
111 } elseif (strlen($db)) {
112 require './db_sql.php';
113 } else {
114 require './server_sql.php';
116 exit;
120 * Defines the query to be displayed in the query textarea
122 if (! empty($show_query)) {
123 $query_to_display = $sql_query;
124 } else {
125 $query_to_display = '';
127 $sql_query = '';
130 * prepare JavaScript functionality
132 $js_include[] = 'common.js';
133 $js_include[] = 'querywindow.js';
135 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
136 $js_events[] = array(
137 'event' => 'load',
138 'function' => 'PMA_queryAutoCommit',
141 if (PMA_isValid($_REQUEST['init'])) {
142 $js_events[] = array(
143 'event' => 'load',
144 'function' => 'PMA_querywindowResize',
147 // always set focus to the textarea
148 if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
149 $js_events[] = array(
150 'event' => 'load',
151 'function' => 'PMA_querywindowSetFocus',
156 * start HTTP/HTML output
158 require_once './libraries/header_http.inc.php';
159 require_once './libraries/header_meta_style.inc.php';
160 require_once './libraries/header_scripts.inc.php';
162 </head>
164 <body id="bodyquerywindow">
165 <div id="querywindowcontainer">
166 <?php
168 if ($tabs) {
169 echo PMA_generate_html_tabs($tabs, array());
170 unset($tabs);
173 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
175 // Hidden forms and query frame interaction stuff
177 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
178 if (! empty($_sql_history)
179 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')) {
180 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
181 echo __('SQL history') . ':<br />'
182 . '<ul>';
183 foreach ($_sql_history as $query) {
184 echo '<li>' . "\n";
186 // edit link
187 $url_params = array(
188 'querydisplay_tab' => $tab,
189 'sql_query' => $query['sqlquery'],
190 'db' => $query['db'],
191 'table' => $query['table'],
193 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
194 . '">' . $titles['Change'] . '</a>';
196 // execute link
197 $url_params['auto_commit'] = 'true';
198 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
199 . ' target="frame_content">';
201 if (! empty($query['db'])) {
202 echo '[';
203 echo htmlspecialchars(PMA_backquote($query['db']));
204 if (! empty($query['table'])) {
205 echo '.' . htmlspecialchars(PMA_backquote($query['table']));
207 echo '] ';
209 if (strlen($query['sqlquery']) > 120) {
210 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
211 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
212 echo htmlspecialchars(substr($query['sqlquery'], -50));
213 echo '</span>';
214 } else {
215 echo htmlspecialchars($query['sqlquery']);
217 echo '</a>' . "\n";
218 echo '</li>' . "\n";
220 unset($tab, $_sql_history, $query);
221 echo '</ul>' . "\n";
224 <form action="querywindow.php" method="post" name="hiddenqueryform"
225 id="hiddenqueryform">
226 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
227 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
228 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
229 <input type="hidden" name="sql_query" value="" />
230 <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
231 </form>
232 </div>
233 </body>
234 </html>