Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 173 lines (155 sloc) 6.065 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';
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
16 require_once './libraries/TableSearch.class.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
a054562 @roccivic PMA_Footer and PMA_Header no longer need to be singletons
roccivic authored
19 $response = PMA_Response::getInstance();
20 $header = $response->getHeader();
21 $scripts = $header->getScripts();
4a74037 @roccivic Dropped header.inc.php in favor of the PMA_Header class
roccivic authored
22 $scripts->addFile('makegrid.js');
23 $scripts->addFile('sql.js');
24 $scripts->addFile('date.js');
7a295f9 @lem9 Problems under IE 8
lem9 authored
25 /* < IE 9 doesn't support canvas natively */
26 if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
4a74037 @roccivic Dropped header.inc.php in favor of the PMA_Header class
roccivic authored
27 $scripts->addFile('canvg/flashcanvas.js');
7a295f9 @lem9 Problems under IE 8
lem9 authored
28 }
4a74037 @roccivic Dropped header.inc.php in favor of the PMA_Header class
roccivic authored
29 $scripts->addFile('jqplot/jquery.jqplot.js');
30 $scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js');
31 $scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
32 $scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js');
33 $scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
34 $scripts->addFile('jqplot/plugins/jqplot.cursor.js');
35 $scripts->addFile('canvg/canvg.js');
36 $scripts->addFile('jquery/timepicker.js');
37 $scripts->addFile('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 librari…
ammaryasir authored
52
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
53 $table_search = new PMA_TableSearch($db, $table, "zoom");
54
6f619e4 @nijel Whitespace cleanup
nijel authored
55 /**
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
56 * Handle AJAX request for data row on point select
57 * @var post_params Object containing parameters for the POST request
58 */
59
60 if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
6f619e4 @nijel Whitespace cleanup
nijel authored
61 $extra_data = array();
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
62 $row_info_query = 'SELECT * FROM `' . $_REQUEST['db'] . '`.`'
63 . $_REQUEST['table'] . '` WHERE ' . $_REQUEST['where_clause'];
64 $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
65 $fields_meta = PMA_DBI_get_fields_meta($result);
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
66 while ($row = PMA_DBI_fetch_assoc($result)) {
e71182b @madhuracj Convert bit values to printable form
madhuracj authored
67 // for bit fields we need to convert them to printable form
68 $i = 0;
69 foreach ($row as $col => $val) {
70 if ($fields_meta[$i]->type == 'bit') {
7664661 @Chanaka Implement class behavior of common.lib.php file
Chanaka authored
71 $row[$col] = PMA_CommonFunctions::getInstance()
72 ->printableBitValue($val, $fields_meta[$i]->length);
e71182b @madhuracj Convert bit values to printable form
madhuracj authored
73 }
74 $i++;
75 }
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
76 $extra_data['row_info'] = $row;
77 }
a16e723 @roccivic Dropped PMA_ajaxResponse()
roccivic authored
78 PMA_Response::getInstance()->addJSON($extra_data);
79 exit;
241caff @ammaryasir Used AJAX to get data row on point select, hence reducing the amount …
ammaryasir authored
80 }
81
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
82 /**
8243eac @madhuracj Wrap some long lines
madhuracj authored
83 * Handle AJAX request for changing field information
84 * (value,collation,operators,field values) in input form
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
85 * @var post_params Object containing parameters for the POST request
86 */
87
88 if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
a16e723 @roccivic Dropped PMA_ajaxResponse()
roccivic authored
89 $response = PMA_Response::getInstance();
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
90 $field = $_REQUEST['field'];
e482a94 @ruleant improve coding style
ruleant authored
91 if ($field == 'pma_null') {
a16e723 @roccivic Dropped PMA_ajaxResponse()
roccivic authored
92 $response->addJSON('field_type', '');
93 $response->addJSON('field_collation', '');
94 $response->addJSON('field_operators', '');
95 $response->addJSON('field_value', '');
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
96 exit;
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
97 }
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
98 $key = array_search($field, $table_search->getColumnNames());
99 $properties = $table_search->getColumnProperties($_REQUEST['it'], $key);
a16e723 @roccivic Dropped PMA_ajaxResponse()
roccivic authored
100 $response->addJSON('field_type', $properties['type']);
101 $response->addJSON('field_collation', $properties['collation']);
102 $response->addJSON('field_operators', $properties['func']);
103 $response->addJSON('field_value', $properties['value']);
104 exit;
9be5d8e @ammaryasir Used AJAX for updating field information(type,collation,operators,fie…
ammaryasir authored
105 }
106
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
107 // Gets some core libraries
28923b4 @roccivic Renamed tbl_common.php to tbl_common.inc.php for better consistency
roccivic authored
108 require_once './libraries/tbl_common.inc.php';
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
109 $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
110
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
111 // Gets tables informations
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
112 require_once './libraries/tbl_info.inc.php';
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
113
c2e7d4b @lem9 Remove tab characters; coding style (first part)
lem9 authored
114 if (! isset($goto)) {
115 $goto = $GLOBALS['cfg']['DefaultTabTable'];
116 }
117 // Defines the url to return to in case of error in the next sql statement
118 $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
119
120 //Set default datalabel if not selected
60ccfbe @zixtor Improve if statement that sets default datalabel
zixtor authored
121 if ( !isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
122 $dataLabel = PMA_getDisplayField($db, $table);
0bf475b @lem9 Coding style
lem9 authored
123 }
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
124
125 // Displays the zoom search form
126 $response->addHTML($table_search->getSelectionForm($goto, $dataLabel));
64425cc @ammaryasir Fixed some issues and added support for plotting strings
ammaryasir authored
127
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
128 /*
0bf475b @lem9 Coding style
lem9 authored
129 * Handle the input criteria and generate the query result
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
130 * Form for displaying query results
131 */
8243eac @madhuracj Wrap some long lines
madhuracj authored
132 if (isset($zoom_submit)
a812a89 @zixtor Remove variables left in 8a0d2d6766297b6168aae
zixtor authored
133 && $_POST['criteriaColumnNames'][0] != 'pma_null'
134 && $_POST['criteriaColumnNames'][1] != 'pma_null'
135 && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]
8243eac @madhuracj Wrap some long lines
madhuracj authored
136 ) {
4183cdb @zixtor Fix some spacing and coding styles in tbl_zoom_select.php
zixtor authored
137 //Query generation part
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
138 $sql_query = $table_search->buildSqlQuery();
0bf475b @lem9 Coding style
lem9 authored
139 $sql_query .= ' LIMIT ' . $maxPlotLimit;
04e82bb @ammaryasir Default data label now taken from table display field
ammaryasir authored
140
4183cdb @zixtor Fix some spacing and coding styles in tbl_zoom_select.php
zixtor authored
141 //Query execution part
7b4bb1c @madhuracj Coding style improvements
madhuracj authored
142 $result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE);
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
143 $fields_meta = PMA_DBI_get_fields_meta($result);
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
144 while ($row = PMA_DBI_fetch_assoc($result)) {
7664661 @Chanaka Implement class behavior of common.lib.php file
Chanaka authored
145 //Need a row with indexes as 0,1,2 for the getUniqueCondition
8243eac @madhuracj Wrap some long lines
madhuracj authored
146 // hence using a temporary array
0bf475b @lem9 Coding style
lem9 authored
147 $tmpRow = array();
148 foreach ($row as $val) {
149 $tmpRow[] = $val;
150 }
362a57f @ammaryasir Functionality for edit data points added (primitive)
ammaryasir authored
151 //Get unique conditon on each row (will be needed for row update)
7664661 @Chanaka Implement class behavior of common.lib.php file
Chanaka authored
152 $uniqueCondition = PMA_CommonFunctions::getInstance()->getUniqueCondition(
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
153 $result, count($table_search->getColumnNames()), $fields_meta, $tmpRow,
154 true
8243eac @madhuracj Wrap some long lines
madhuracj authored
155 );
0bf475b @lem9 Coding style
lem9 authored
156 //Append it to row array as where_clause
157 $row['where_clause'] = $uniqueCondition[0];
2da7a2e @zixtor Move zoom-search result form's html to function
zixtor authored
158
5d636a8 @zixtor Improve some repetitive code
zixtor authored
159 $tmpData = array(
a812a89 @zixtor Remove variables left in 8a0d2d6766297b6168aae
zixtor authored
160 $_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]],
161 $_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]],
5d636a8 @zixtor Improve some repetitive code
zixtor authored
162 'where_clause' => $uniqueCondition[0]
163 );
164 $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : '';
165 $data[] = $tmpData;
6f619e4 @nijel Whitespace cleanup
nijel authored
166 }
26d8848 @zixtor Unset temporary variable
zixtor authored
167 unset($tmpData);
602a64a @ammaryasir Added the Show/Hide search criteria feature
ammaryasir authored
168
2da7a2e @zixtor Move zoom-search result form's html to function
zixtor authored
169 //Displays form for point data and scatter plot
ef2123e @zixtor Use PMA_TableSearch in tbl_zoom_select.php
zixtor authored
170 $response->addHTML($table_search->getZoomResultsForm($goto, $data));
41715e5 @ammaryasir Removed mode feature, appended a missing configuration directive and …
ammaryasir authored
171 }
7396fa3 @ammaryasir Designed the zoom-search form(tbl_zoom_select.php)
ammaryasir authored
172 ?>
Something went wrong with that request. Please try again.