Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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