diff --git a/js/tbl_select.js b/js/tbl_select.js index 387aa518e3..a66920d1a3 100644 --- a/js/tbl_select.js +++ b/js/tbl_select.js @@ -22,16 +22,18 @@ $(document).ready(function() { cache: 'false' }); - /* - * Handle events from zoom-search page - * - */ + /*if($('#id_flag').val()==2) + { + $('#tbl_search_form').hide(); + $('#zoom_search_form').show(); - $('#tableid_1').change(function() { + }*/ + + $('#tableid_0').change(function() { $('#zoom_search_form').submit(); }) - $('#tableid_2').change(function() { + $('#tableid_1').change(function() { $('#zoom_search_form').submit(); }) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 59bdd6da11..6f301429bc 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -9,6 +9,54 @@ * @package phpMyAdmin */ +require_once 'url_generating.lib.php'; + + + + /** + * PMA_tbl_setTitle() sets the title for foreign keys display link + * + * @param $propertiesIconic Type of icon property + * @param $themeImage Icon Image + * @return string $str Value of the Title + * + */ + +function PMA_tbl_setTitle($propertiesIconic,$pmaThemeImage){ + if ($propertiesIconic == true) { + $str = '' . __('Browse foreign values') . ''; + + if ($propertiesIconic === 'both') { + $str .= __('Browse foreign values'); + return $str; + } + } else { + return __('Browse foreign values'); + } +} + + /** + * PMA_tbl_getFields() gets all the fields of a table along with their types,collations and whether null or not. + * + * @uses PMA_DBI_query() + * @uses PMA_backquote() + * @uses PMA_DBI_num_rows() + * @uses PMA_DBI_fetch_assoc() + * @uses PMA_DBI_free_result() + * @uses preg_replace() + * @uses str_replace() + * @uses strncasecmp() + * @uses empty() + * + * @param $db Selected database + * @param $table Selected table + * + * @return array($fields_list,$fields_type,$fields_collation,$fields_null) Array containing the field list, field types, collations and null constatint + * + */ + function PMA_tbl_getFields($table,$db) { // Gets the list and number of fields @@ -51,10 +99,179 @@ function PMA_tbl_getFields($table,$db) { } +/* PMA_tbl_setTableHeader() sets the table header for displaying a table in query-by-example format + * + * @return HTML content, the tags and content for table header + * + */ + +function PMA_tbl_setTableHeader(){ + +return ' + ' . __('Column') . ' + ' . __('Type') . ' + ' . __('Collation') . ' + ' . __('Operator') . ' + ' . __('Value') . ' + + '; + + +} + +/* PMA_tbl_getSubTabs() returns an array with necessary configrations to create sub-tabs(Table Search and Zoom Search) in the table_select page + * + * @return array $subtabs Array containing configuration (icon,text,link,id,args) of sub-tabs for Table Search and Zoom search + * + */ + +function PMA_tbl_getSubTabs(){ + + $subtabs = array(); + + $subtabs['search']['icon'] = 'b_search.png'; + $subtabs['search']['text'] = __('Table Search'); + $subtabs['search']['link'] = 'tbl_select.php'; + $subtabs['search']['id'] = 'tbl_search_id'; + $subtabs['search']['args']['pos'] = 0; + + $subtabs['zoom']['icon'] = 'b_props.png'; + $subtabs['zoom']['link'] = 'tbl_zoom_select.php'; + $subtabs['zoom']['text'] = __('Zoom Search'); + $subtabs['zoom']['id'] = 'zoom_search_id'; + + return $subtabs; + +} + + +/* PMA_tbl_getForeignFields_Values() creates the HTML content for: 1) Browsing foreign data for a field. 2) Creating elements for search criteria input on fields. + * + * @uses PMA_foreignDropdown + * @uses PMA_generate_common_url + * @uses isset() + * @uses is_array() + * @uses in_array() + * @uses urlencode() + * @uses str_replace() + * @uses stbstr() + * + * @param $foreigners Array of foreign keys + * @param $foreignData Foreign keys data + * @param $field Column name + * @param $tbl_fields_type Column type + * @param $i Column index + * @param $db Selected database + * @param $table Selected table + * @param $titles Selected title + * @param $foreignMaxLimit Max limit of displaying foreign elements + * @param $fields Array of search criteria inputs + * + * @return string $str HTML content for viewing foreing data and elements for search criteria input. + * + */ + +function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table,$titles,$foreignMaxLimit, $fields){ + + $str = ''; + + if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) { + + // f o r e i g n k e y s + $str .= ' ' . "\n"; + } elseif ($foreignData['foreign_link'] == true) { + + $str .= '' ; ?> + + '; + // ' . str_replace("'", "\'", $titles['Browse']) . '\');'; + // ]] + $str .= ''; + ?> + ' . "\n"; + for ($j = 0; $j < $cnt_enum_value; $j++) { + if(isset($fields[$i]) && is_array($fields[$i]) && in_array($enum_value[$j],$fields[$i])){ + $str .= ' '; + } + else{ + $str .= ' '; + } + } // end for + $str .= ' ' . "\n"; + } else { + // o t h e r c a s e s + $the_class = 'textfield'; + $type = $tbl_fields_type[$i]; + if ($type == 'date') { + $the_class .= ' datefield'; + } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') { + $the_class .= ' datetimefield'; + } + if(isset($fields[$i]) && is_string($fields[$i])){ + $str .= ' ' . "\n"; + } + else{ + $str .= ' ' . "\n"; + } + }; + return $str; + +} + + +/* PMA_tbl_search_getWhereClause() Return the where clause for query generation based on the inputs provided. + * + * @uses PMA_backquote + * @uses PMA_sqlAddslashes + * @uses preg_match + * @uses isset() + * @uses in_array() + * @uses str_replace() + * @uses strpos() + * @uses explode() + * @uses trim() + * + * @param $fields Search criteria input + * @param $names Name of the field(column) on which search criteria is submitted + * @param $types Type of the field + * @param $collations Field collation + * @param $func_type Search fucntion/operator + * @param $unaryFlag Whether operator unary or not + * + * @return string $str HTML content for viewing foreing data and elements for search criteria input. + * + */ + function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag){ - //Return the where clause for query generation based on the inputs provided in the tbl_select.php form - + + $w = ''; if($unaryFlag){ $fields = ''; $w = PMA_backquote($names) . ' ' . $func_type; @@ -128,24 +345,5 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu return $w; } - -function PMA_tbl_getSubTabs(){ - - $subtabs = array(); - - $subtabs['search']['icon'] = 'b_search.png'; - $subtabs['search']['text'] = __('Table Search'); - $subtabs['search']['link'] = 'tbl_select.php'; - $subtabs['search']['id'] = 'tbl_search_id'; - $subtabs['search']['args']['pos'] = 0; - - $subtabs['zoom']['icon'] = 'b_props.png'; - $subtabs['zoom']['link'] = 'tbl_zoom_select.php'; - $subtabs['zoom']['text'] = __('Zoom Search'); - $subtabs['zoom']['id'] = 'zoom_search_id'; - - return $subtabs; - -} ?> diff --git a/tbl_select.php b/tbl_select.php index a2fd6194f3..ee89c13c64 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -21,18 +21,8 @@ $GLOBALS['js_include'][] = 'sql.js'; $GLOBALS['js_include'][] = 'tbl_select.js'; $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; $GLOBALS['js_include'][] = 'jquery/timepicker.js'; -if ($GLOBALS['cfg']['PropertiesIconic'] == true) { - $titles['Browse'] = - '' . __('Browse foreign values') . ''; - if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { - $titles['Browse'] .= __('Browse foreign values'); - } -} else { - $titles['Browse'] = __('Browse foreign values'); -} +$titles['Browse'] = PMA_tbl_setTitle($GLOBALS['cfg']['PropertiesIconic'], $pmaThemeImage); /** * Not selection yet required -> displays the selection form @@ -72,7 +62,6 @@ if (! isset($param) || $param[0] == '') { // check also foreigners even if relwork is FALSE (to get // foreign keys from innodb) $foreigners = PMA_getForeigners($db, $table); - $flag = 1; ?>
@@ -95,14 +84,7 @@ echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params);
- - - - - - - - + ' . "\n"; - // go back to first row - - // here, the 4th parameter is empty because there is no current - // value of data for the dropdown (the search page initial values - // are displayed empty) - echo PMA_foreignDropdown($foreignData['disp_row'], - $foreignData['foreign_field'], - $foreignData['foreign_display'], - '', $GLOBALS['cfg']['ForeignKeyMaxLimit']); - echo ' ' . "\n"; - } elseif ($foreignData['foreign_link'] == true) { - ?> - - - ' . "\n"; - for ($j = 0; $j < $cnt_enum_value; $j++) { - echo ' '; - } // end for - echo ' ' . "\n"; - } else { - // o t h e r c a s e s - $the_class = 'textfield'; - $type = $fields_type[$i]; - if ($type == 'date') { - $the_class .= ' datefield'; - } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') { - $the_class .= ' datetimefield'; - } - echo ' ' . "\n"; - }; - ?> + echo PMA_getForeignFields_Values($foreigners, $foreignData, $field, $fields_type, $i, $db, $table, $titles,$GLOBALS['cfg']['ForeignKeyMaxLimit'], '' ); + + ?> '; - if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { - $titles['Browse'] .= __('Browse foreign values'); - } -} else { - $titles['Browse'] = __('Browse foreign values'); -} +$titles['Browse'] = PMA_tbl_setTitle($GLOBALS['cfg']['PropertiesIconic'], $pmaThemeImage); + /** * Not selection yet required -> displays the selection form */ @@ -114,26 +105,19 @@ if(isset($inputs) && ($inputs[0] != __('pma_null') || $inputs[1] != __('pma_null
- - - - - - - - - + + - - + +
- + ' . "\n"; - // go back to first row - - // here, the 4th parameter is empty because there is no current - // value of data for the dropdown (the search page initial values - // are displayed empty) - echo PMA_foreignDropdown($foreignData['disp_row'], - $foreignData['foreign_field'], - $foreignData['foreign_display'], - '', $GLOBALS['cfg']['ForeignKeyMaxLimit']); - echo ' ' . "\n"; - } elseif ($foreignData['foreign_link'] == true) { - ?> - - - ' . "\n"; - for ($j = 0; $j < $cnt_enum_value; $j++) { - if(isset($fields[$i-1]) && is_array($fields[$i-1]) && in_array($enum_value[$j],$fields[$i-1])){ - echo ' '; - } - else{ - echo ' '; - } - } // end for - echo ' ' . "\n"; - } else { - // o t h e r c a s e s - $the_class = 'textfield'; - $type = $tbl_fields_type[$i-1]; - if ($type == 'date') { - $the_class .= ' datefield'; - } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') { - $the_class .= ' datetimefield'; - } - if(isset($fields[$i-1]) && is_string($fields[$i-1])){ - echo ' ' . "\n"; - } - else{ - echo ' ' . "\n"; - } - }; - } + if (isset($fields)) + echo PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i ,$db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], $fields); + else + echo PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i ,$db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], ''); + + } ?> - + + value="" />