Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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