Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 459 lines (420 sloc) 16.013 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 *
8 */
9
10 /**
11 * Gets some core libraries
12 */
13 require_once './libraries/common.inc.php';
14 require_once './libraries/mysql_charsets.lib.php';
91d372f @ammaryasir Added a library file for the table-search and zoom-search code
ammaryasir authored
15 require_once './libraries/tbl_select.lib.php';
eaea003 @ammaryasir Added some features
ammaryasir authored
16 require_once './libraries/relation.lib.php';
03a1a84 @ammaryasir Test
ammaryasir authored
17 require_once './libraries/tbl_info.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
18
eaea003 @ammaryasir Added some features
ammaryasir authored
19 $GLOBALS['js_include'][] = 'makegrid.js';
20 $GLOBALS['js_include'][] = 'sql.js';
543df4c @ammaryasir Added interface for browsing/editing points
ammaryasir authored
21 $GLOBALS['js_include'][] = 'functions.js';
1653fd3 @ammaryasir Plot functionality using Hihcharts
ammaryasir authored
22 $GLOBALS['js_include'][] = 'tbl_zoom_plot.js';
7a821c8 @ammaryasir Improved the panning feature
ammaryasir authored
23 $GLOBALS['js_include'][] = 'date.js';
ed98d7e @ammaryasir Added: Mousewheel zoom and panning feature
ammaryasir authored
24 $GLOBALS['js_include'][] = 'jquery/jquery.mousewheel.js';
1653fd3 @ammaryasir Plot functionality using Hihcharts
ammaryasir authored
25 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
26 /* Files required for chart exporting */
e09759b @ammaryasir Added support for ploting strings(char,varchar,enums)
ammaryasir authored
27 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
1653fd3 @ammaryasir Plot functionality using Hihcharts
ammaryasir authored
28 $GLOBALS['js_include'][] = 'canvg/canvg.js';
4a5cb00 @Crack Fix jQuery UI version number
Crack authored
29 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
30 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
31
c7cef3b @ammaryasir Refactored the tbl_select.php and tbl_zoom_select.php code in librari…
ammaryasir authored
32
6f619e4 @nijel Whitespace cleanup
nijel authored
33 /**
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
34 * Handle AJAX request for data row on point select
35 * @var post_params Object containing parameters for the POST request
36 */
37
38 if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
6f619e4 @nijel Whitespace cleanup
nijel authored
39 $extra_data = array();
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
40 $row_info_query = 'SELECT * FROM `' . $_REQUEST['db'] . '`.`'
41 . $_REQUEST['table'] . '` WHERE ' . $_REQUEST['where_clause'];
42 $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
43 $fields_meta = PMA_DBI_get_fields_meta($result);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
44 while ($row = PMA_DBI_fetch_assoc($result)) {
e71182b @madhuracj Convert bit values to printable form
madhuracj authored
45 // for bit fields we need to convert them to printable form
46 $i = 0;
47 foreach ($row as $col => $val) {
48 if ($fields_meta[$i]->type == 'bit') {
49 $row[$col] = PMA_printable_bit_value($val, $fields_meta[$i]->length);
50 }
51 $i++;
52 }
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
53 $extra_data['row_info'] = $row;
54 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
55 PMA_ajaxResponse(null, true, $extra_data);
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
56 }
57
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
58 /**
59 * Handle AJAX request for changing field information(value,collation,operators,field values)
60 * in input form
61 * @var post_params Object containing parameters for the POST request
62 */
63
64 if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
65 $extra_data = array();
66 $field = $_REQUEST['field'];
67 if($field == 'pma_null') {
68 $extra_data['field_type'] = '';
69 $extra_data['field_collation'] = '';
70 $extra_data['field_operators'] = '';
71 PMA_ajaxResponse(NULL, true, $extra_data);
72 }
73
74
75 // Gets the list and number of fields
76 list($fields_list, $fields_type, $fields_collation, $fields_null) = PMA_tbl_getFields($_REQUEST['db'],$_REQUEST['table']);
77
78 $foreigners = PMA_getForeigners($db, $table);
79 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
80 $key = array_search($field,$fields_list);
81 $extra_data['field_type'] = $fields_type[$key];
82 $extra_data['field_collation'] = $fields_collation[$key];
83
84 // HTML for operators
85 $html = '<select name="zoomFunc[]">';
86 if (strncasecmp($fields_type[$key], 'enum', 4) == 0) {
87 foreach ($GLOBALS['cfg']['EnumOperators'] as $fc) {
88 $html .= "\n" . ' '
89 . '<option value="' . htmlspecialchars($fc) . '">'
90 . htmlspecialchars($fc) . '</option>';
91 }
92 } elseif (preg_match('@char|blob|text|set@i', $fields_type[$key])) {
93 foreach ($GLOBALS['cfg']['TextOperators'] as $fc) {
94 $html .= "\n" . ' '
95 . '<option value="' . htmlspecialchars($fc) . '">'
96 . htmlspecialchars($fc) . '</option>';
97 }
98 } else {
99 foreach ($GLOBALS['cfg']['NumOperators'] as $fc) {
100 $html .= "\n" . ' '
101 . '<option value="' . htmlspecialchars($fc) . '">'
102 . htmlspecialchars($fc) . '</option>';
103 }
104 } // end if... else...
105
106 if ($fields_null[$key]) {
107 foreach ($GLOBALS['cfg']['NullOperators'] as $fc) {
108 $html .= "\n" . ' '
109 . '<option value="' . htmlspecialchars($fc) . '">'
110 . htmlspecialchars($fc) . '</option>';
111 }
112 }
113 $html .= '</select>';
114 $extra_data['field_operators'] = $html;
115
116 // retrieve keys into foreign fields, if any
117 // check also foreigners even if relwork is FALSE (to get
118 // foreign keys from innodb)
119 $foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
120
121 // HTML for field values
122 $html = PMA_getForeignFields_Values($foreigners, $foreignData, $field, array($_REQUEST['it'] => $fields_type[$key]), $_REQUEST['it'] ,$_REQUEST['db'], $_REQUEST['table'], $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '');
123 $extra_data['field_value'] = $html;
124 PMA_ajaxResponse(NULL, true, $extra_data);
125 }
126
effa795 @madhuracj Wrong message used in 8373e5feec2232e6a17b342eb0bf74930431bfcc
madhuracj authored
127 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
128 /**
129 * Not selection yet required -> displays the selection form
130 */
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
131
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
132 // Gets some core libraries
133 require_once './libraries/tbl_common.php';
134 $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
135
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
136 /**
137 * Gets tables informations
138 */
139 require_once './libraries/tbl_info.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
140
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
141 /**
142 * Displays top menu links
143 */
144 require_once './libraries/tbl_links.inc.php';
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
145
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
146 if (! isset($goto)) {
147 $goto = $GLOBALS['cfg']['DefaultTabTable'];
148 }
149 // Defines the url to return to in case of error in the next sql statement
150 $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
151
152 // Gets the list and number of fields
153
347fca5 @nijel Use same order of database and table params as elsewhere
nijel authored
154 list($fields_list, $fields_type, $fields_collation, $fields_null) = PMA_tbl_getFields($db, $table);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
155 $fields_cnt = count($fields_list);
156
157 // retrieve keys into foreign fields, if any
158 // check also foreigners even if relwork is FALSE (to get
159 // foreign keys from innodb)
160 $foreigners = PMA_getForeigners($db, $table);
161 $flag = 1;
162 $tbl_fields_type = $tbl_fields_collation = $tbl_fields_null = array();
163 if (! isset($zoom_submit) && ! isset($inputs)) {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
164 $dataLabel = PMA_getDisplayField($db, $table);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
165 }
166 ?>
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
167 <div id="sqlqueryresults"></div>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
168 <fieldset id="fieldset_subtab">
169 <?php
170 $url_params = array();
171 $url_params['db'] = $db;
172 $url_params['table'] = $table;
a06d689 @lem9 Avoid duplicate ids
lem9 authored
173 echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params, '', 'topmenu2');
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
174
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
175 /**
176 * Set the field name,type,collation and whether null on select of a coulmn
177 */
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
178 if (isset($inputs) && ($inputs[0] != 'pma_null' || $inputs[1] != 'pma_null')) {
70167fe @ammaryasir Made suggested change to tbl_select.php and tbl_zoom_select.php
ammaryasir authored
179 $flag = 2;
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
180 for ($i = 0 ; $i < 4 ; $i++) {
181 if ($inputs[$i] != 'pma_null') {
182 $key = array_search($inputs[$i], $fields_list);
183 $tbl_fields_type[$i] = $fields_type[$key];
184 $tbl_fields_collation[$i] = $fields_collation[$key];
185 $tbl_fields_null[$i] = $fields_null[$key];
186 }
70167fe @ammaryasir Made suggested change to tbl_select.php and tbl_zoom_select.php
ammaryasir authored
187 }
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
188 }
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
189
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
190 /*
191 * Form for input criteria
192 */
f939564 @ammaryasir Created the SVG based scatter-plot functionality
ammaryasir authored
193
18694f2 @ammaryasir Added generate plot feature using SVG ( only for numeric fields )
ammaryasir authored
194 ?>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
195 <form method="post" action="tbl_zoom_select.php" name="insertForm" id="zoom_search_form"
196 <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
197 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
198 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
199 <input type="hidden" name="back" value="tbl_zoom_select.php" />
471e10a @lem9 Fix some of the XHTML problems
lem9 authored
200 <input type="hidden" name="flag" id="id_flag" value="<?php echo $flag; ?>" />
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
201
543df4c @ammaryasir Added interface for browsing/editing points
ammaryasir authored
202 <fieldset id="inputSection">
18694f2 @ammaryasir Added generate plot feature using SVG ( only for numeric fields )
ammaryasir authored
203
d9486e2 @ammaryasir Validations for input form submit
ammaryasir authored
204 <legend><?php echo __('Do a "query by example" (wildcard: "%") for two different columns') ?></legend>
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
205 <table class="data" id="tabId">
eaea003 @ammaryasir Added some features
ammaryasir authored
206 <?php echo PMA_tbl_setTableHeader();?>
207 <tbody>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
208 <?php
209 $odd_row = true;
6f619e4 @nijel Whitespace cleanup
nijel authored
210
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
211 for ($i = 0; $i < 4; $i++) {
212 if ($i == 2) {
213 echo "<tr><td>";
eaea003 @ammaryasir Added some features
ammaryasir authored
214 echo __("Additional search criteria");
56a73a4 @lem9 XHTML problems
lem9 authored
215 echo "</td></tr>";
6f619e4 @nijel Whitespace cleanup
nijel authored
216 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
217 ?>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
218 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
471e10a @lem9 Fix some of the XHTML problems
lem9 authored
219 <th><select name="inputs[]" id="<?php echo 'tableid_' . $i; ?>" >
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
220 <option value="<?php echo 'pma_null'; ?>"><?php echo __('None'); ?></option>
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
221 <?php
222 for ($j = 0 ; $j < $fields_cnt ; $j++) {
223 if (isset($inputs[$i]) && $inputs[$i] == htmlspecialchars($fields_list[$j])) {?>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
224 <option value="<?php echo htmlspecialchars($fields_list[$j]);?>" selected="selected">
225 <?php echo htmlspecialchars($fields_list[$j]);?></option>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
226 <?php
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
227 } else { ?>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
228 <option value="<?php echo htmlspecialchars($fields_list[$j]);?>">
229 <?php echo htmlspecialchars($fields_list[$j]);?></option>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
230 <?php
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
231 }
232 } ?>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
233 </select></th>
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
234 <td></td>
235 <td></td>
236 <td></td>
237 <td></td>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
238 </tr>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
239 <tr><td>
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
240 <input type="hidden" name="types[<?php echo $i; ?>]" id="types_<?php echo $i; ?>" />
241 <input type="hidden" name="collations[<?php echo $i;?>]" id="collations_<?php echo $i; ?>" />
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
242 </td></tr>
243 <?php
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
244 }//end for
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
245 ?>
dc35ecf @lem9 XHTML problems
lem9 authored
246 </tbody>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
247 </table>
f939564 @ammaryasir Created the SVG based scatter-plot functionality
ammaryasir authored
248
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
249 <?php
250 /*
251 * Other inputs like data label and mode go after selection of column criteria
252 */
04e82bb @ammaryasir Default data label now taken from table display field
ammaryasir authored
253
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
254 //Set default datalabel if not selected
0bf475b @lem9 Coding style
lem9 authored
255 if (isset($zoom_submit) && $inputs[0] != 'pma_null' && $inputs[1] != 'pma_null') {
256 if ($dataLabel == '') {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
257 $dataLabel = PMA_getDisplayField($db, $table);
04e82bb @ammaryasir Default data label now taken from table display field
ammaryasir authored
258 }
0bf475b @lem9 Coding style
lem9 authored
259 }
260 ?>
7880782 @ammaryasir Added 'Max rows to plot' as input criteria
ammaryasir authored
261 <table class="data">
483ec3b @lem9 Improve dialog
lem9 authored
262 <tr><td><label for="dataLabel"><?php echo __("Use this column to label each point"); ?></label></td>
f939564 @ammaryasir Created the SVG based scatter-plot functionality
ammaryasir authored
263 <td><select name="dataLabel" id='dataLabel' >
264 <option value = ''> <?php echo __('None'); ?> </option>
0bf475b @lem9 Coding style
lem9 authored
265 <?php
266 for ($j = 0; $j < $fields_cnt; $j++) {
267 if (isset($dataLabel) && $dataLabel == htmlspecialchars($fields_list[$j])) {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
268 ?>
269 <option value="<?php echo htmlspecialchars($fields_list[$j]);?>" selected="selected">
270 <?php echo htmlspecialchars($fields_list[$j]);?></option>
271 <?php
0bf475b @lem9 Coding style
lem9 authored
272 } else {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
273 ?>
274 <option value="<?php echo htmlspecialchars($fields_list[$j]);?>" >
275 <?php echo htmlspecialchars($fields_list[$j]);?></option>
276 <?php
0bf475b @lem9 Coding style
lem9 authored
277 }
6e05e71 @nijel Whitespace cleanup
nijel authored
278 }
0bf475b @lem9 Coding style
lem9 authored
279 ?>
f939564 @ammaryasir Created the SVG based scatter-plot functionality
ammaryasir authored
280 </select>
281 </td></tr>
9e566cd @lem9 Other XHTML fixes
lem9 authored
282 <tr><td><label for="maxRowPlotLimit"><?php echo __("Maximum rows to plot"); ?></label></td>
7880782 @ammaryasir Added 'Max rows to plot' as input criteria
ammaryasir authored
283 <td>
6e05e71 @nijel Whitespace cleanup
nijel authored
284 <?php
9e566cd @lem9 Other XHTML fixes
lem9 authored
285 echo '<input type="text" name="maxPlotLimit" id="maxRowPlotLimit" value="';
6e05e71 @nijel Whitespace cleanup
nijel authored
286 if (! empty($maxPlotLimit)) {
d630321 @lem9 Missing HTML escape
lem9 authored
287 echo htmlspecialchars($maxPlotLimit);
9e566cd @lem9 Other XHTML fixes
lem9 authored
288 } else {
289 echo $GLOBALS['cfg']['maxRowPlotLimit'];
0bf475b @lem9 Coding style
lem9 authored
290 }
9e566cd @lem9 Other XHTML fixes
lem9 authored
291 echo '" /></td></tr>';
0bf475b @lem9 Coding style
lem9 authored
292 ?>
f939564 @ammaryasir Created the SVG based scatter-plot functionality
ammaryasir authored
293 </table>
64425cc @ammaryasir Fixed some issues and added support for plotting strings
ammaryasir authored
294
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
295 </fieldset>
296 <fieldset class="tblFooters">
297 <input type="hidden" name="max_number_of_fields"
298 value="<?php echo $fields_cnt; ?>" />
d9486e2 @ammaryasir Validations for input form submit
ammaryasir authored
299 <input type="submit" name="zoom_submit" id="inputFormSubmitId" value="<?php echo __('Go'); ?>" />
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
300 </fieldset>
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
301 </form>
dc35ecf @lem9 XHTML problems
lem9 authored
302 </fieldset>
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
303
6f619e4 @nijel Whitespace cleanup
nijel authored
304 <?php
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
305
306 /*
0bf475b @lem9 Coding style
lem9 authored
307 * Handle the input criteria and generate the query result
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
308 * Form for displaying query results
309 */
0bf475b @lem9 Coding style
lem9 authored
310 if (isset($zoom_submit) && $inputs[0] != 'pma_null' && $inputs[1] != 'pma_null' && $inputs[0] != $inputs[1]) {
543df4c @ammaryasir Added interface for browsing/editing points
ammaryasir authored
311
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
312 /*
313 * Query generation part
314 */
6f619e4 @nijel Whitespace cleanup
nijel authored
315 $w = $data = array();
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
316 $sql_query = 'SELECT *';
543df4c @ammaryasir Added interface for browsing/editing points
ammaryasir authored
317
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
318 //Add the table
319 $sql_query .= ' FROM ' . PMA_backquote($table);
0bf475b @lem9 Coding style
lem9 authored
320 for ($i = 0; $i < 4; $i++) {
321 if ($inputs[$i] == 'pma_null') {
322 continue;
323 }
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
324 $tmp = array();
325 // The where clause
326 $charsets = array();
327 $cnt_func = count($zoomFunc[$i]);
328 $func_type = $zoomFunc[$i];
329 list($charsets[$i]) = explode('_', $collations[$i]);
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
330 $unaryFlag = (isset($GLOBALS['cfg']['UnaryOperators'][$func_type])
331 && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1)
332 ? true
333 : false;
334 $whereClause = PMA_tbl_search_getWhereClause(
335 $fields[$i], $inputs[$i], $types[$i],
336 $collations[$i], $func_type, $unaryFlag
337 );
0bf475b @lem9 Coding style
lem9 authored
338 if ($whereClause) {
339 $w[] = $whereClause;
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
340 }
0bf475b @lem9 Coding style
lem9 authored
341 } // end for
342 if ($w) {
343 $sql_query .= ' WHERE ' . implode(' AND ', $w);
344 }
345 $sql_query .= ' LIMIT ' . $maxPlotLimit;
04e82bb @ammaryasir Default data label now taken from table display field
ammaryasir authored
346
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
347 /*
348 * Query execution part
349 */
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
350 $result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE);
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
351 $fields_meta = PMA_DBI_get_fields_meta($result);
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
352 while ($row = PMA_DBI_fetch_assoc($result)) {
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
353 //Need a row with indexes as 0,1,2 for the PMA_getUniqueCondition hence using a temporary array
0bf475b @lem9 Coding style
lem9 authored
354 $tmpRow = array();
355 foreach ($row as $val) {
356 $tmpRow[] = $val;
357 }
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
358 //Get unique conditon on each row (will be needed for row update)
0bf475b @lem9 Coding style
lem9 authored
359 $uniqueCondition = PMA_getUniqueCondition($result, $fields_cnt, $fields_meta, $tmpRow, true);
e3cb99d @ammaryasir Added better support for datetime fields
ammaryasir authored
360
0bf475b @lem9 Coding style
lem9 authored
361 //Append it to row array as where_clause
362 $row['where_clause'] = $uniqueCondition[0];
363 if ($dataLabel == $inputs[0] || $dataLabel == $inputs[1]) {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
364 $data[] = array(
365 $inputs[0] => $row[$inputs[0]],
366 $inputs[1] => $row[$inputs[1]],
367 'where_clause' => $uniqueCondition[0]
368 );
0bf475b @lem9 Coding style
lem9 authored
369 } elseif ($dataLabel) {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
370 $data[] = array(
371 $inputs[0] => $row[$inputs[0]],
372 $inputs[1] => $row[$inputs[1]],
373 $dataLabel => $row[$dataLabel],
374 'where_clause' => $uniqueCondition[0]
375 );
0bf475b @lem9 Coding style
lem9 authored
376 } else {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
377 $data[] = array(
378 $inputs[0] => $row[$inputs[0]],
379 $inputs[1] => $row[$inputs[1]],
380 $dataLabel => '',
381 'where_clause' => $uniqueCondition[0]
382 );
0bf475b @lem9 Coding style
lem9 authored
383 }
6f619e4 @nijel Whitespace cleanup
nijel authored
384 }
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
385 /*
386 * Form for displaying point data and also the scatter plot
387 */
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
388 ?>
389 <form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form"
390 <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
391 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
392 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
393 <input type="hidden" name="back" value="tbl_zoom_select.php" />
394
395 <fieldset id="displaySection">
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
396 <legend><?php echo __('Browse/Edit the points') ?></legend>
397 <center>
398 <?php
0bf475b @lem9 Coding style
lem9 authored
399 //JSON encode the data(query result)
400 if (isset($zoom_submit) && ! empty($data)) {
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
401 ?>
402 <div id='resizer' style="width:600px;height:400px">
13d741e @lem9 onClick should be onclick
lem9 authored
403 <center><a href="#" onclick="displayHelp();"><?php echo __('How to use'); ?></a></center>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
404 <div id="querydata" style="display:none">
405 <?php
6e05e71 @nijel Whitespace cleanup
nijel authored
406 echo json_encode($data);
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
407 ?>
408 </div>
409 <div id="querychart" style="float:right"></div>
410 </div>
411 <?php
6e05e71 @nijel Whitespace cleanup
nijel authored
412 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
413 ?>
414 </center>
b131ec7 @roccivic Improved layout for the data editor from the zoom search feature
roccivic authored
415 <div id='dataDisplay' style="display:none">
416 <table>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
417 <thead>
418 <tr>
419 <th> <?php echo __('Column'); ?> </th>
420 <th> <?php echo __('Null'); ?> </th>
421 <th> <?php echo __('Value'); ?> </th>
422 </tr>
423 </thead>
424 <tbody>
425 <?php
0bf475b @lem9 Coding style
lem9 authored
426 $odd_row = true;
427 for ($i = 4; $i < $fields_cnt + 4; $i++) {
428 $tbl_fields_type[$i] = $fields_type[$i - 4];
429 $fieldpopup = $fields_list[$i - 4];
430 $foreignData = PMA_getForeignData($foreigners, $fieldpopup, false, '', '');
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
431 ?>
432 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
433 <th><?php echo htmlspecialchars($fields_list[$i - 4]); ?></th>
20ca1e4 @madhuracj bug #3410999 - Zoom search, problems with data editor
madhuracj authored
434 <th><?php echo ($fields_null[$i - 4] == 'YES')
435 ? '<input type="checkbox" class="checkbox_null" name="fields_null[ '
436 . $i . ' ]" id="fields_null_id_' . $i . '" />'
437 : ''; ?>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
438 </th>
439 <th> <?php
440 echo PMA_getForeignFields_Values(
441 $foreigners, $foreignData, $fieldpopup, $tbl_fields_type,
20ca1e4 @madhuracj bug #3410999 - Zoom search, problems with data editor
madhuracj authored
442 $i, $db, $table, $titles,
443 $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', false, true
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
444 ); ?>
445 </th>
446 </tr>
447 <?php
6e05e71 @nijel Whitespace cleanup
nijel authored
448 }
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
449 ?>
450 </tbody>
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
451 </table>
b131ec7 @roccivic Improved layout for the data editor from the zoom search feature
roccivic authored
452 </div>
41715e5 @ammaryasir Removed mode feature, appended a missing configuration directive and …
ammaryasir authored
453 <input type="hidden" id="queryID" name="sql_query" />
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
454 </form>
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
455 <?php
41715e5 @ammaryasir Removed mode feature, appended a missing configuration directive and …
ammaryasir authored
456 }
0bf475b @lem9 Coding style
lem9 authored
457 require './libraries/footer.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
458 ?>
Something went wrong with that request. Please try again.