Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 298 lines (270 sloc) 10.083 kB
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Handles table zoom search tab
5 *
6 * display table zoom search form, create SQL queries from form data
7 *
0335bba @madhuracj Add missing package tag
madhuracj authored
8 * @package PhpMyAdmin
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
9 */
10
11 /**
12 * Gets some core libraries
13 */
14 require_once './libraries/common.inc.php';
15 require_once './libraries/mysql_charsets.lib.php';
91d372f @ammaryasir Added a library file for the table-search and zoom-search code
ammaryasir authored
16 require_once './libraries/tbl_select.lib.php';
eaea003 @ammaryasir Added some features
ammaryasir authored
17 require_once './libraries/relation.lib.php';
03a1a84 @ammaryasir Test
ammaryasir authored
18 require_once './libraries/tbl_info.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
19
eaea003 @ammaryasir Added some features
ammaryasir authored
20 $GLOBALS['js_include'][] = 'makegrid.js';
21 $GLOBALS['js_include'][] = 'sql.js';
543df4c @ammaryasir Added interface for browsing/editing points
ammaryasir authored
22 $GLOBALS['js_include'][] = 'functions.js';
7a821c8 @ammaryasir Improved the panning feature
ammaryasir authored
23 $GLOBALS['js_include'][] = 'date.js';
7a295f9 @lem9 Problems under IE 8
lem9 authored
24 /* < IE 9 doesn't support canvas natively */
25 if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
26 $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
27 }
28
3d82362 @lem9 simple plot
lem9 authored
29 $GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js';
30 $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasTextRenderer.js';
f5ac325 @lem9 Parse numbers; axis labels
lem9 authored
31 $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js';
d584260 @lem9 Handling of dates
lem9 authored
32 $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.dateAxisRenderer.js';
d00d62e @lem9 Highlighter for data label
lem9 authored
33 $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.highlighter.js';
9f6dc05 @lem9 Zoom
lem9 authored
34 $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.cursor.js';
1653fd3 @ammaryasir Plot functionality using Hihcharts
ammaryasir authored
35 $GLOBALS['js_include'][] = 'canvg/canvg.js';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
36 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
3d82362 @lem9 simple plot
lem9 authored
37 $GLOBALS['js_include'][] = 'tbl_zoom_plot_jqplot.js';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
38
49b6e49 Don't rely on grab_globals in tbl_zoom_select
Jo Michael authored
39 /**
40 * Sets globals from $_POST
41 */
42 $post_params = array(
43 'dataLabel',
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
44 'criteriaColumnNullFlags',
45 'criteriaColumnNames',
49b6e49 Don't rely on grab_globals in tbl_zoom_select
Jo Michael authored
46 'maxPlotLimit',
47 'zoom_submit',
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
48 'criteriaColumnOperators'
49b6e49 Don't rely on grab_globals in tbl_zoom_select
Jo Michael authored
49 );
50 foreach ($post_params as $one_post_param) {
51 if (isset($_POST[$one_post_param])) {
52 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
53 }
54 }
c7cef3b @ammaryasir Refactored the tbl_select.php and tbl_zoom_select.php code in librari…
ammaryasir authored
55
6f619e4 @nijel Whitespace cleanup
nijel authored
56 /**
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
57 * Handle AJAX request for data row on point select
58 * @var post_params Object containing parameters for the POST request
59 */
60
61 if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
6f619e4 @nijel Whitespace cleanup
nijel authored
62 $extra_data = array();
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
63 $row_info_query = 'SELECT * FROM `' . $_REQUEST['db'] . '`.`'
64 . $_REQUEST['table'] . '` WHERE ' . $_REQUEST['where_clause'];
65 $result = PMA_DBI_query($row_info_query . ";", null, PMA_DBI_QUERY_STORE);
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
66 $fields_meta = PMA_DBI_get_fields_meta($result);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
67 while ($row = PMA_DBI_fetch_assoc($result)) {
e71182b @madhuracj Convert bit values to printable form
madhuracj authored
68 // for bit fields we need to convert them to printable form
69 $i = 0;
70 foreach ($row as $col => $val) {
71 if ($fields_meta[$i]->type == 'bit') {
3467896 @madhuracj These have been missed when functions were renamed
madhuracj authored
72 $row[$col] = PMA_printableBitValue($val, $fields_meta[$i]->length);
e71182b @madhuracj Convert bit values to printable form
madhuracj authored
73 }
74 $i++;
75 }
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
76 $extra_data['row_info'] = $row;
77 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
78 PMA_ajaxResponse(null, true, $extra_data);
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
79 }
80
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
81 /**
8243eac @madhuracj Wrap some long lines
madhuracj authored
82 * Handle AJAX request for changing field information
83 * (value,collation,operators,field values) in input form
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
84 * @var post_params Object containing parameters for the POST request
85 */
86
87 if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
88 $extra_data = array();
89 $field = $_REQUEST['field'];
e482a94 @ruleant improve coding style
ruleant authored
90 if ($field == 'pma_null') {
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
91 $extra_data['field_type'] = '';
92 $extra_data['field_collation'] = '';
93 $extra_data['field_operators'] = '';
e482a94 @ruleant improve coding style
ruleant authored
94 PMA_ajaxResponse(null, true, $extra_data);
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
95 }
96
97
98 // Gets the list and number of fields
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
99 list($columnNames, $columnTypes, $columnCollations, $columnNullFlags)
8243eac @madhuracj Wrap some long lines
madhuracj authored
100 = PMA_tbl_getFields($_REQUEST['db'], $_REQUEST['table']);
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
101
102 $foreigners = PMA_getForeigners($db, $table);
103 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
104 $key = array_search($field, $columnNames);
105 $extra_data['field_type'] = $columnTypes[$key];
106 $extra_data['field_collation'] = $columnCollations[$key];
ff66fdb @roccivic Remove stray trailing whitespaces
roccivic authored
107
108 // HTML for operators
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
109 $html = '<select name="criteriaColumnOperators[]">';
13bd089 @nijel Centralize generating of operators list
nijel authored
110 $html .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml(
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
111 preg_replace('@\(.*@s', '', $columnTypes[$key]),
112 $columnNullFlags[$key]
13bd089 @nijel Centralize generating of operators list
nijel authored
113 );
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
114 $html .= '</select>';
115 $extra_data['field_operators'] = $html;
116
117 // retrieve keys into foreign fields, if any
118 // check also foreigners even if relwork is FALSE (to get
119 // foreign keys from innodb)
120 $foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
121
122 // HTML for field values
e482a94 @ruleant improve coding style
ruleant authored
123 $html = PMA_getForeignFields_Values(
124 $foreigners,
125 $foreignData,
126 $field,
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
127 array($_REQUEST['it'] => $columnTypes[$key]),
e482a94 @ruleant improve coding style
ruleant authored
128 $_REQUEST['it'],
129 $_REQUEST['db'],
130 $_REQUEST['table'],
131 $titles,
132 $GLOBALS['cfg']['ForeignKeyMaxLimit'],
133 ''
134 );
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
135 $extra_data['field_value'] = $html;
e482a94 @ruleant improve coding style
ruleant authored
136 PMA_ajaxResponse(null, true, $extra_data);
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
137 }
138
effa795 @madhuracj Wrong message used in 8373e5feec2232e6a17b342eb0bf74930431bfcc
madhuracj authored
139 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
140 /**
141 * Not selection yet required -> displays the selection form
142 */
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
143
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
144 // Gets some core libraries
28923b4 @roccivic Renamed tbl_common.php to tbl_common.inc.php for better consistency
roccivic authored
145 require_once './libraries/tbl_common.inc.php';
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
146 $url_query .= '&amp;goto=tbl_select.php&amp;back=tbl_select.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
147
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
148 /**
149 * Gets tables informations
150 */
151 require_once './libraries/tbl_info.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
152
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
153 if (! isset($goto)) {
154 $goto = $GLOBALS['cfg']['DefaultTabTable'];
155 }
156 // Defines the url to return to in case of error in the next sql statement
157 $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
158
159 // Gets the list and number of fields
160
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
161 list($columnNames, $columnTypes, $columnCollations, $columnNullFlags)
8243eac @madhuracj Wrap some long lines
madhuracj authored
162 = PMA_tbl_getFields($db, $table);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
163
164 // retrieve keys into foreign fields, if any
165 // check also foreigners even if relwork is FALSE (to get
166 // foreign keys from innodb)
167 $foreigners = PMA_getForeigners($db, $table);
49b6e49 Don't rely on grab_globals in tbl_zoom_select
Jo Michael authored
168
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
169 //Set default datalabel if not selected
60ccfbe @zixtor Improve if statement that sets default datalabel
zixtor authored
170 if ( !isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
171 $dataLabel = PMA_getDisplayField($db, $table);
0bf475b @lem9 Coding style
lem9 authored
172 }
efbe149 @zixtor Use PMA_tblSearchGetSelectionForm to display zoom search form
zixtor authored
173 echo PMA_tblSearchGetSelectionForm(
174 $goto, $db, $table, $columnNames, $columnTypes, $columnCollations,
175 $columnNullFlags, false, $foreigners, "zoom", $dataLabel
176 );
0bf475b @lem9 Coding style
lem9 authored
177 ?>
64425cc @ammaryasir Fixed some issues and added support for plotting strings
ammaryasir authored
178
6f619e4 @nijel Whitespace cleanup
nijel authored
179 <?php
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
180 /*
0bf475b @lem9 Coding style
lem9 authored
181 * Handle the input criteria and generate the query result
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
182 * Form for displaying query results
183 */
8243eac @madhuracj Wrap some long lines
madhuracj authored
184 if (isset($zoom_submit)
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
185 && $criteriaColumnNames[0] != 'pma_null'
186 && $criteriaColumnNames[1] != 'pma_null'
187 && $criteriaColumnNames[0] != $criteriaColumnNames[1]
8243eac @madhuracj Wrap some long lines
madhuracj authored
188 ) {
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
189 /*
190 * Query generation part
191 */
6a85bdd @zixtor Use existing function to build SQL query
zixtor authored
192 $sql_query = PMA_tblSearchBuildSqlQuery();
0bf475b @lem9 Coding style
lem9 authored
193 $sql_query .= ' LIMIT ' . $maxPlotLimit;
04e82bb @ammaryasir Default data label now taken from table display field
ammaryasir authored
194
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
195 /*
196 * Query execution part
197 */
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
198 $result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE);
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
199 $fields_meta = PMA_DBI_get_fields_meta($result);
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
200 while ($row = PMA_DBI_fetch_assoc($result)) {
8243eac @madhuracj Wrap some long lines
madhuracj authored
201 //Need a row with indexes as 0,1,2 for the PMA_getUniqueCondition
202 // hence using a temporary array
0bf475b @lem9 Coding style
lem9 authored
203 $tmpRow = array();
204 foreach ($row as $val) {
205 $tmpRow[] = $val;
206 }
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
207 //Get unique conditon on each row (will be needed for row update)
8243eac @madhuracj Wrap some long lines
madhuracj authored
208 $uniqueCondition = PMA_getUniqueCondition(
6719025 @zixtor Remove unnecessary variable columnCount
zixtor authored
209 $result, count($columnNames), $fields_meta, $tmpRow, true
8243eac @madhuracj Wrap some long lines
madhuracj authored
210 );
e3cb99d @ammaryasir Added better support for datetime fields
ammaryasir authored
211
0bf475b @lem9 Coding style
lem9 authored
212 //Append it to row array as where_clause
213 $row['where_clause'] = $uniqueCondition[0];
5d636a8 @zixtor Improve some repetitive code
zixtor authored
214 $tmpData = array(
215 $criteriaColumnNames[0] => $row[$criteriaColumnNames[0]],
216 $criteriaColumnNames[1] => $row[$criteriaColumnNames[1]],
217 'where_clause' => $uniqueCondition[0]
218 );
219 $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : '';
220
221 $data[] = $tmpData;
6f619e4 @nijel Whitespace cleanup
nijel authored
222 }
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
223 /*
224 * Form for displaying point data and also the scatter plot
225 */
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
226 ?>
227 <form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form"
228 <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
229 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
230 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
231 <input type="hidden" name="back" value="tbl_zoom_select.php" />
232
233 <fieldset id="displaySection">
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
234 <legend><?php echo __('Browse/Edit the points') ?></legend>
235 <center>
236 <?php
0bf475b @lem9 Coding style
lem9 authored
237 //JSON encode the data(query result)
238 if (isset($zoom_submit) && ! empty($data)) {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
239 ?>
4ffeb06 @lem9 Improve resizer
lem9 authored
240 <div id="resizer">
13d741e @lem9 onClick should be onclick
lem9 authored
241 <center><a href="#" onclick="displayHelp();"><?php echo __('How to use'); ?></a></center>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
242 <div id="querydata" style="display:none">
243 <?php
6e05e71 @nijel Whitespace cleanup
nijel authored
244 echo json_encode($data);
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
245 ?>
246 </div>
4ffeb06 @lem9 Improve resizer
lem9 authored
247 <div id="querychart"></div>
0264dee @lem9 Reset zoom
lem9 authored
248 <button class="button-reset"><?php echo __('Reset zoom'); ?></button>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
249 </div>
250 <?php
6e05e71 @nijel Whitespace cleanup
nijel authored
251 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
252 ?>
253 </center>
b131ec7 @roccivic Improved layout for the data editor from the zoom search feature
roccivic authored
254 <div id='dataDisplay' style="display:none">
255 <table>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
256 <thead>
257 <tr>
258 <th> <?php echo __('Column'); ?> </th>
259 <th> <?php echo __('Null'); ?> </th>
260 <th> <?php echo __('Value'); ?> </th>
261 </tr>
262 </thead>
263 <tbody>
264 <?php
0bf475b @lem9 Coding style
lem9 authored
265 $odd_row = true;
6719025 @zixtor Remove unnecessary variable columnCount
zixtor authored
266 for ($i = 4; $i < count($columnNames) + 4; $i++) {
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
267 $tbl_fields_type[$i] = $columnTypes[$i - 4];
268 $fieldpopup = $columnNames[$i - 4];
0bf475b @lem9 Coding style
lem9 authored
269 $foreignData = PMA_getForeignData($foreigners, $fieldpopup, false, '', '');
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
270 ?>
271 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
272 <th><?php echo htmlspecialchars($columnNames[$i - 4]); ?></th>
273 <th><?php echo ($columnNullFlags[$i - 4] == 'YES')
274 ? '<input type="checkbox" class="checkbox_null" name="criteriaColumnNullFlags[ '
20ca1e4 @madhuracj bug #3410999 - Zoom search, problems with data editor
madhuracj authored
275 . $i . ' ]" id="fields_null_id_' . $i . '" />'
276 : ''; ?>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
277 </th>
278 <th> <?php
279 echo PMA_getForeignFields_Values(
280 $foreigners, $foreignData, $fieldpopup, $tbl_fields_type,
20ca1e4 @madhuracj bug #3410999 - Zoom search, problems with data editor
madhuracj authored
281 $i, $db, $table, $titles,
282 $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', false, true
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
283 ); ?>
284 </th>
285 </tr>
286 <?php
6e05e71 @nijel Whitespace cleanup
nijel authored
287 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
288 ?>
289 </tbody>
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
290 </table>
b131ec7 @roccivic Improved layout for the data editor from the zoom search feature
roccivic authored
291 </div>
41715e5 @ammaryasir Removed mode feature, appended a missing configuration directive and …
ammaryasir authored
292 <input type="hidden" id="queryID" name="sql_query" />
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
293 </form>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
294 <?php
41715e5 @ammaryasir Removed mode feature, appended a missing configuration directive and …
ammaryasir authored
295 }
0bf475b @lem9 Coding style
lem9 authored
296 require './libraries/footer.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
297 ?>
Something went wrong with that request. Please try again.