2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Handles table zoom search tab
6 * display table zoom search form, create SQL queries from form data
11 * Gets some core libraries
13 require_once './libraries/common.inc.php';
14 require_once './libraries/mysql_charsets.lib.php';
15 require_once './libraries/tbl_select.lib.php';
17 $GLOBALS['js_include'][] = 'tbl_select.js';
18 $GLOBALS['js_include'][] = 'tbl_zoom_plot.js';
19 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
20 /* Files required for chart exporting */
21 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
22 $GLOBALS['js_include'][] = 'canvg/canvg.js';
23 $GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
24 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
25 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
27 $titles['Browse'] = PMA_tbl_setTitle($GLOBALS['cfg']['PropertiesIconic'], $pmaThemeImage);
31 * Not selection yet required -> displays the selection form
34 // Gets some core libraries
35 require_once './libraries/tbl_common.php';
36 //$err_url = 'tbl_select.php' . $err_url;
37 $url_query .= '&goto=tbl_select.php&back=tbl_select.php';
40 * Gets tables informations
42 require_once './libraries/tbl_info.inc.php';
45 * Displays top menu links
47 require_once './libraries/tbl_links.inc.php';
50 $goto = $GLOBALS['cfg']['DefaultTabTable'];
52 // Defines the url to return to in case of error in the next sql statement
53 $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
55 // Gets the list and number of fields
57 list($fields_list, $fields_type, $fields_collation, $fields_null) = PMA_tbl_getFields($table,$db);
58 $fields_cnt = count($fields_list);
60 // retrieve keys into foreign fields, if any
61 // check also foreigners even if relwork is FALSE (to get
62 // foreign keys from innodb)
63 $foreigners = PMA_getForeigners($db, $table);
65 $tbl_fields_type = $tbl_fields_collation = $tbl_fields_null = array();
68 <fieldset id
="fieldset_subtab">
70 $url_params = array();
71 $url_params['db'] = $db;
72 $url_params['table'] = $table;
74 echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params);
77 <?php
/* Form for Zoom Search input */
79 if(isset($inputs) && ($inputs[0] != __('pma_null') ||
$inputs[1] != __('pma_null')))
82 for($i = 0 ; $i < 2 ; $i++
)
84 if($inputs[$i] != __('pma_null'))
86 $key = array_search($inputs[$i],$fields_list);
87 $tbl_fields_type[$i] = $fields_type[$key];
88 $tbl_fields_collation[$i] = $fields_collation[$key];
89 $tbl_fields_null[$i] = $fields_null[$key];
97 if(isset($zoom_submit)) {
101 $sql_query = 'SELECT *';
103 // Add the colums to be selected
104 //$columns = $inputs;
105 //$columns = PMA_backquote($columns);
106 //$sql_query .= implode(', ', $columns);
111 $sql_query .= ' FROM ' . PMA_backquote($table);
112 for($i = 0 ; $i < 2 ; $i++
){
117 $cnt_func = count($zoomFunc[$i]);
118 $func_type = $zoomFunc[$i];
119 list($charsets[$i]) = explode('_', $collations[$i]);
120 $unaryFlag = (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) ?
true : false;
121 $whereClause = PMA_tbl_search_getWhereClause($fields[$i],$inputs[$i], $types[$i], $collations[$i], $func_type, $unaryFlag);
128 $sql_query .= ' WHERE ' . implode(' AND ', $w);
131 $settings = array('xLabel' => $inputs[0], 'yLabel' => $inputs[1], 'dataLabel' => $dataLabel);
132 $result = PMA_DBI_query( $sql_query . ";" , null, PMA_DBI_QUERY_STORE
);
133 while ($row = PMA_DBI_fetch_assoc($result)) {
137 $scatter_plot = PMA_SVG_scatter_plot($data,$settings);
143 <form method
="post" action
="tbl_zoom_select.php" name
="zoomInputForm" id
="zoom_search_form" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : ''); ?
>>
144 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
145 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
146 <input type
="hidden" name
="back" value
="tbl_select.php" />
147 <input type
="hidden" name
="flag" id
="id_flag" value
=<?php
echo $flag; ?
> />
150 <fieldset id
="zoom_fieldset_table_qbe">
151 <?php
if(isset($zoom_submit) && !empty($scatter_plot)){ ?
>
152 <div id
='resizer' style
="width:600px; height:400px;float:right">
153 <legend
><?php
echo __('Display Plot'); ?
></legend
>
154 <div id
="querydata" style
="display:none;">
155 <?php
if(isset($data)) echo json_encode($data); ?
>
162 <legend
><?php
echo __('Do a "query by example" (wildcard: "%") for two columns') ?
></legend
>
164 <?php
echo PMA_tbl_setTableHeader();?
>
169 for($i = 0 ; $i < 2 ; $i++
){
171 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
172 <th
><select name
="inputs[]" id
=<?php
echo 'tableid_' . $i?
> >
173 <option value
= <?php
echo __('pma_null')?
>><?php
echo __('None'); ?
> </option
>
175 for ($j = 0 ; $j < $fields_cnt ; $j++
){
176 if(isset($inputs[$i]) && $inputs[$i] == htmlspecialchars($fields_list[$j])){?
>
177 <option value
=<?php
echo htmlspecialchars($fields_list[$j]);?
> Selected
> <?php
echo htmlspecialchars($fields_list[$j]);?
></option
>
181 <option value
=<?php
echo htmlspecialchars($fields_list[$j]);?
> > <?php
echo htmlspecialchars($fields_list[$j]);?
></option
>
186 <td
><?php
if(isset($tbl_fields_type[$i]))echo $tbl_fields_type[$i]; ?
></td
>
187 <td
><?php
if(isset($tbl_fields_collation[$i]))echo $tbl_fields_collation[$i]; ?
></td
>
190 <?php
if(isset($inputs) && $inputs[$i] != __('pma_null')){ ?
>
191 <select name
="zoomFunc[]">
194 if (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
195 foreach ($GLOBALS['cfg']['EnumOperators'] as $fc) {
196 if(isset($zoomFunc[$i]) && $zoomFunc[$i] == htmlspecialchars($fc)){
198 . '<option value="' . htmlspecialchars($fc) . '" Selected>'
199 . htmlspecialchars($fc) . '</option>';
203 . '<option value="' . htmlspecialchars($fc) . '">'
204 . htmlspecialchars($fc) . '</option>';
207 } elseif (preg_match('@char|blob|text|set@i', $tbl_fields_type[$i])) {
208 foreach ($GLOBALS['cfg']['TextOperators'] as $fc) {
209 if(isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc){
211 . '<option value="' . htmlspecialchars($fc) . '" Selected>'
212 . htmlspecialchars($fc) . '</option>';
216 . '<option value="' . htmlspecialchars($fc) . '">'
217 . htmlspecialchars($fc) . '</option>';
221 foreach ($GLOBALS['cfg']['NumOperators'] as $fc) {
222 if(isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc){
224 . '<option value="' . htmlspecialchars($fc) . '" Selected>'
225 . htmlspecialchars($fc) . '</option>';
229 . '<option value="' . htmlspecialchars($fc) . '">'
230 . htmlspecialchars($fc) . '</option>';
233 } // end if... else...
235 if ($tbl_fields_null[$i]) {
236 foreach ($GLOBALS['cfg']['NullOperators'] as $fc) {
237 if(isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc){
239 . '<option value="' . htmlspecialchars($fc) . '" Selected>'
240 . htmlspecialchars($fc) . '</option>';
244 . '<option value="' . htmlspecialchars($fc) . '">'
245 . htmlspecialchars($fc) . '</option>';
254 $field = $inputs[$i];
256 $foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
258 echo PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i ,$db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], $fields);
260 echo PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i ,$db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '');
272 <input type
="hidden" name
="types[<?php echo $i; ?>]"
273 value
="<?php if(isset($tbl_fields_type[$i]))echo $tbl_fields_type[$i]; ?>" />
274 <input type
="hidden" name
="collations[<?php echo $i; ?>]"
275 value
="<?php if(isset($tbl_fields_collation[$i]))echo $tbl_fields_collation[$i]; ?>" />
285 <tr
><td
><label
for="label"><?php
echo __("Data Label"); ?
></label
> 
 
 
 
 
 
 
 
</td
>
286 <td
><select name
="dataLabel" id
='dataLabel' >
287 <option value
= ''> <?php
echo __('None'); ?
> </option
>
289 for ($j = 0 ; $j < $fields_cnt ; $j++
){
290 if(isset($dataLabel) && $dataLabel == htmlspecialchars($fields_list[$j])){?
>
291 <option value
=<?php
echo htmlspecialchars($fields_list[$j]);?
> Selected
> <?php
echo htmlspecialchars($fields_list[$j]);?
></option
>
295 <option value
=<?php
echo htmlspecialchars($fields_list[$j]);?
> > <?php
echo htmlspecialchars($fields_list[$j]);?
></option
>
306 <fieldset
class="tblFooters">
307 <input type
="hidden" name
="max_number_of_fields"
308 value
="<?php echo $fields_cnt; ?>" />
309 <input type
="submit" name
="zoom_submit" value
="<?php echo __('Go'); ?>" />
315 <div id
="sqlqueryresults"></div
>
317 require './libraries/footer.inc.php';