Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 202 lines (181 sloc) 6.979 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'] = '';
745598a @zixtor Fix AJAX response extra_data in zoom search
zixtor authored
91 $extra_data['field_value'] = '';
e482a94 @ruleant improve coding style
ruleant authored
92 PMA_ajaxResponse(null, true, $extra_data);
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,field ...
ammaryasir authored
93 }
94 // Gets the list and number of fields
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
95 list($columnNames, $columnTypes, $columnCollations, $columnNullFlags)
8243eac @madhuracj Wrap some long lines
madhuracj authored
96 = PMA_tbl_getFields($_REQUEST['db'], $_REQUEST['table']);
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,field ...
ammaryasir authored
97 $foreigners = PMA_getForeigners($db, $table);
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
98 $key = array_search($field, $columnNames);
052fd61 @zixtor Use PMA_tblSearchGetColumnProperties to change table row
zixtor authored
99 $properties = PMA_tblSearchGetColumnProperties(
100 $db, $table, $columnNames, $columnTypes, $columnCollations,
101 $columnNullFlags, $foreigners, $_REQUEST['it'], $key
e482a94 @ruleant improve coding style
ruleant authored
102 );
052fd61 @zixtor Use PMA_tblSearchGetColumnProperties to change table row
zixtor authored
103 $extra_data['field_type'] = $properties['type'];
104 $extra_data['field_collation'] = $properties['collation'];
105 $extra_data['field_operators'] = $properties['func'];
106 $extra_data['field_value'] = $properties['value'];
e482a94 @ruleant improve coding style
ruleant authored
107 PMA_ajaxResponse(null, true, $extra_data);
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,field ...
ammaryasir authored
108 }
109
effa795 @madhuracj Wrong message used in 8373e5feec2232e6a17b342eb0bf74930431bfcc
madhuracj authored
110 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
111 /**
112 * Not selection yet required -> displays the selection form
113 */
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
114
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
115 // Gets some core libraries
28923b4 @roccivic Renamed tbl_common.php to tbl_common.inc.php for better consistency
roccivic authored
116 require_once './libraries/tbl_common.inc.php';
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
117 $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
118
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
119 /**
120 * Gets tables informations
121 */
122 require_once './libraries/tbl_info.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
123
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
124 if (! isset($goto)) {
125 $goto = $GLOBALS['cfg']['DefaultTabTable'];
126 }
127 // Defines the url to return to in case of error in the next sql statement
128 $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
129
130 // Gets the list and number of fields
131
2d9217f @zixtor Make variable names uniform in search scripts
zixtor authored
132 list($columnNames, $columnTypes, $columnCollations, $columnNullFlags)
8243eac @madhuracj Wrap some long lines
madhuracj authored
133 = PMA_tbl_getFields($db, $table);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
134
135 // retrieve keys into foreign fields, if any
136 // check also foreigners even if relwork is FALSE (to get
137 // foreign keys from innodb)
138 $foreigners = PMA_getForeigners($db, $table);
49b6e49 Don't rely on grab_globals in tbl_zoom_select
Jo Michael authored
139
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
140 //Set default datalabel if not selected
60ccfbe @zixtor Improve if statement that sets default datalabel
zixtor authored
141 if ( !isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
142 $dataLabel = PMA_getDisplayField($db, $table);
0bf475b @lem9 Coding style
lem9 authored
143 }
efbe149 @zixtor Use PMA_tblSearchGetSelectionForm to display zoom search form
zixtor authored
144 echo PMA_tblSearchGetSelectionForm(
145 $goto, $db, $table, $columnNames, $columnTypes, $columnCollations,
146 $columnNullFlags, false, $foreigners, "zoom", $dataLabel
147 );
0bf475b @lem9 Coding style
lem9 authored
148 ?>
64425cc @ammaryasir Fixed some issues and added support for plotting strings
ammaryasir authored
149
6f619e4 @nijel Whitespace cleanup
nijel authored
150 <?php
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
151 /*
0bf475b @lem9 Coding style
lem9 authored
152 * Handle the input criteria and generate the query result
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
153 * Form for displaying query results
154 */
8243eac @madhuracj Wrap some long lines
madhuracj authored
155 if (isset($zoom_submit)
a812a89 @zixtor Remove variables left in 8a0d2d6766297b6168aae
zixtor authored
156 && $_POST['criteriaColumnNames'][0] != 'pma_null'
157 && $_POST['criteriaColumnNames'][1] != 'pma_null'
158 && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]
8243eac @madhuracj Wrap some long lines
madhuracj authored
159 ) {
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
160 /*
161 * Query generation part
162 */
6a85bdd @zixtor Use existing function to build SQL query
zixtor authored
163 $sql_query = PMA_tblSearchBuildSqlQuery();
0bf475b @lem9 Coding style
lem9 authored
164 $sql_query .= ' LIMIT ' . $maxPlotLimit;
04e82bb @ammaryasir Default data label now taken from table display field
ammaryasir authored
165
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
166 /*
167 * Query execution part
168 */
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
169 $result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE);
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
170 $fields_meta = PMA_DBI_get_fields_meta($result);
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
171 while ($row = PMA_DBI_fetch_assoc($result)) {
8243eac @madhuracj Wrap some long lines
madhuracj authored
172 //Need a row with indexes as 0,1,2 for the PMA_getUniqueCondition
173 // hence using a temporary array
0bf475b @lem9 Coding style
lem9 authored
174 $tmpRow = array();
175 foreach ($row as $val) {
176 $tmpRow[] = $val;
177 }
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
178 //Get unique conditon on each row (will be needed for row update)
8243eac @madhuracj Wrap some long lines
madhuracj authored
179 $uniqueCondition = PMA_getUniqueCondition(
6719025 @zixtor Remove unnecessary variable columnCount
zixtor authored
180 $result, count($columnNames), $fields_meta, $tmpRow, true
8243eac @madhuracj Wrap some long lines
madhuracj authored
181 );
0bf475b @lem9 Coding style
lem9 authored
182 //Append it to row array as where_clause
183 $row['where_clause'] = $uniqueCondition[0];
2da7a2e @zixtor Move zoom-search result form's html to function
zixtor authored
184
5d636a8 @zixtor Improve some repetitive code
zixtor authored
185 $tmpData = array(
a812a89 @zixtor Remove variables left in 8a0d2d6766297b6168aae
zixtor authored
186 $_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]],
187 $_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]],
5d636a8 @zixtor Improve some repetitive code
zixtor authored
188 'where_clause' => $uniqueCondition[0]
189 );
190 $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : '';
191 $data[] = $tmpData;
6f619e4 @nijel Whitespace cleanup
nijel authored
192 }
26d8848 @zixtor Unset temporary variable
zixtor authored
193 unset($tmpData);
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
194
2da7a2e @zixtor Move zoom-search result form's html to function
zixtor authored
195 //Displays form for point data and scatter plot
196 echo PMA_tblSearchGetZoomResultsForm($goto, $db, $table, $columnNames,
197 $columnTypes, $columnNullFlags, $foreigners, $data
198 );
41715e5 @ammaryasir Removed mode feature, appended a missing configuration directive and cha...
ammaryasir authored
199 }
0bf475b @lem9 Coding style
lem9 authored
200 require './libraries/footer.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
201 ?>
Something went wrong with that request. Please try again.