diff --git a/ChangeLog b/ChangeLog index 39a3e64aac..c249cd17e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,6 +54,8 @@ VerboseMultiSubmit, ReplaceHelpImg - bug #3531584 [interface] No form validation in change password dialog - bug #3531585 [interface] Broken password validation in copy user form - bug #3531586 [unterface] Add user form prints JSON when user presses enter +- bug #3534121 [config] duplicate line in config.sample.inc.php +- bug #3534311 [interface] Grid editing incorrectly parses ENUM/SET values 3.5.1.0 (2012-05-03) - bug #3510784 [edit] Limit clause ignored when sort order is remembered diff --git a/config.sample.inc.php b/config.sample.inc.php index 69bc6242d5..7a16073bac 100644 --- a/config.sample.inc.php +++ b/config.sample.inc.php @@ -58,7 +58,6 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false; // $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; // $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig'; // $cfg['Servers'][$i]['recent'] = 'pma_recent'; -// $cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs'; /* Contrib / Swekey authentication */ // $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf'; diff --git a/js/server_status.js b/js/server_status.js index 6677d7b0dc..edd0c54658 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -130,10 +130,6 @@ $(function() { } }); - $.ajaxSetup({ - cache: false - }); - // Add tabs $('#serverStatusTabs').tabs({ // Tab persistence diff --git a/js/server_variables.js b/js/server_variables.js index 0eb2c2f60f..94ca6110da 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -174,7 +174,7 @@ function editVariable(link) $cell.html(''); // put edit field and save/cancel link $cell.prepend(''); + '
' + - '
'); $cell.find('table td:first').append(mySaveLink); $cell.find('table td:first').append(' '); $cell.find('table td:first').append(myCancelLink); diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 006e6cd15e..e7d60eeb8d 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -139,7 +139,7 @@ $(document).ready(function() { 'table' : window.parent.table, 'field' : $('#tableid_0').val(), 'it' : 0, - 'token' : window.parent.token, + 'token' : window.parent.token },function(data) { $('#tableFieldsId tr:eq(1) td:eq(0)').html(data.field_type); $('#tableFieldsId tr:eq(1) td:eq(1)').html(data.field_collation); @@ -163,7 +163,7 @@ $(document).ready(function() { 'table' : window.parent.table, 'field' : $('#tableid_1').val(), 'it' : 1, - 'token' : window.parent.token, + 'token' : window.parent.token },function(data) { $('#tableFieldsId tr:eq(3) td:eq(0)').html(data.field_type); $('#tableFieldsId tr:eq(3) td:eq(1)').html(data.field_collation); @@ -186,7 +186,7 @@ $(document).ready(function() { 'table' : window.parent.table, 'field' : $('#tableid_2').val(), 'it' : 2, - 'token' : window.parent.token, + 'token' : window.parent.token },function(data) { $('#tableFieldsId tr:eq(6) td:eq(0)').html(data.field_type); $('#tableFieldsId tr:eq(6) td:eq(1)').html(data.field_collation); @@ -207,7 +207,7 @@ $(document).ready(function() { 'table' : window.parent.table, 'field' : $('#tableid_3').val(), 'it' : 3, - 'token' : window.parent.token, + 'token' : window.parent.token },function(data) { $('#tableFieldsId tr:eq(8) td:eq(0)').html(data.field_type); $('#tableFieldsId tr:eq(8) td:eq(1)').html(data.field_collation); @@ -264,14 +264,14 @@ $(document).ready(function() { //Find changed values by comparing form values with selectedRow Object var newValues = new Object();//Stores the values changed from original var sqlTypes = new Object(); - var it = 4; + var it = 0; var xChange = false; var yChange = false; for (key in selectedRow) { var oldVal = selectedRow[key]; - var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val(); + var newVal = ($('#edit_fields_null_id_' + it).attr('checked')) ? null : $('#edit_fieldID_' + it).val(); if (newVal instanceof Array) { // when the column is of type SET - newVal = $('#fieldID_' + it).map(function(){ + newVal = $('#edit_fieldID_' + it).map(function(){ return $(this).val(); }).get().join(","); } @@ -286,7 +286,7 @@ $(document).ready(function() { searchedData[searchedDataKey][yLabel] = newVal; } } - var $input = $('#fieldID_' + it); + var $input = $('#edit_fieldID_' + it); if ($input.hasClass('bit')) { sqlTypes[key] = 'bit'; } @@ -534,6 +534,7 @@ $(document).ready(function() { // resizing, it's ok // under IE 9, everything is fine currentChart = $.jqplot('querychart', series, options); + currentChart.resetZoom(); $('button.button-reset').click(function(event) { event.preventDefault(); @@ -551,7 +552,7 @@ $(document).ready(function() { $('div#querychart').bind('jqplotDataClick', function(event, seriesIndex, pointIndex, data) { searchedDataKey = data[4]; // key from searchedData (global) - var field_id = 4; + var field_id = 0; var post_params = { 'ajax_request' : true, 'get_data_row' : true, @@ -565,8 +566,8 @@ $(document).ready(function() { // Row is contained in data.row_info, // now fill the displayResultForm with row values for (key in data.row_info) { - $field = $('#fieldID_' + field_id); - $field_null = $('#fields_null_id_' + field_id); + $field = $('#edit_fieldID_' + field_id); + $field_null = $('#edit_fields_null_id_' + field_id); if (data.row_info[key] == null) { $field_null.attr('checked', true); $field.val(''); diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e531feae7f..abcaaf6431 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3971,4 +3971,48 @@ function PMA_mimeDefaultFunction($buffer) return $buffer; } + +/* + * Parses ENUM/SET values + * + * @param string $definition The definition of the column + * for which to parse the values + * + * @return array + */ +function PMA_parseEnumSetValues($definition) +{ + $values_string = htmlentities($definition); + // There is a JS port of the below parser in functions.js + // If you are fixing something here, + // you need to also update the JS port. + $values = array(); + $in_string = false; + $buffer = ''; + for ($i=0; $i 0) { + // The leftovers in the buffer are the last value (if any) + $values[] = $buffer; + } + return $values; +} + ?> diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 757b94970c..e481e074b8 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -22,18 +22,18 @@ if (! defined('PHPMYADMIN')) { function PMA_tbl_getFields($db, $table) { // Gets the list and number of fields - $fields = PMA_DBI_get_columns($db, $table, null, true); - $fields_list = $fields_null = $fields_type = $fields_collation = array(); - $geom_column_present = false; + $columns = PMA_DBI_get_columns($db, $table, null, true); + $columnNames = $columnNullFlags = $columnTypes = $columnCollations = array(); + $geomColumnFlag = false; $geom_types = PMA_getGISDatatypes(); - foreach ($fields as $key => $row) { - $fields_list[] = $row['Field']; + foreach ($columns as $key => $row) { + $columnNames[] = $row['Field']; $type = $row['Type']; // check whether table contains geometric columns if (in_array($type, $geom_types)) { - $geom_column_present = true; + $geomColumnFlag = true; } // reformat mysql query output @@ -55,35 +55,35 @@ function PMA_tbl_getFields($db, $table) if (empty($type)) { $type = ' '; } - $fields_null[] = $row['Null']; - $fields_type[] = $type; - $fields_collation[] + $columnNullFlags[] = $row['Null']; + $columnTypes[] = $type; + $columnCollations[] = ! empty($row['Collation']) && $row['Collation'] != 'NULL' ? $row['Collation'] : ''; } // end while return array( - $fields_list, - $fields_type, - $fields_collation, - $fields_null, - $geom_column_present + $columnNames, + $columnTypes, + $columnCollations, + $columnNullFlags, + $geomColumnFlag ); } /** * Sets the table header for displaying a table in query-by-example format. * - * @param bool $geom_column_present whether a geometry column is present + * @param bool $geomColumnFlag whether a geometry column is present * * @return HTML content, the tags and content for table header */ -function PMA_tbl_setTableHeader($geom_column_present = false) +function PMA_tbl_getTableHeader($geomColumnFlag = false) { - // Display the Function column only if there is alteast one geomety colum + // Display the Function column only if there is at least one geometry column $func = ''; - if ($geom_column_present) { + if ($geomColumnFlag) { $func = '' . __('Function') . ''; } @@ -129,13 +129,13 @@ function PMA_tbl_getSubTabs() * @param array $foreigners Array of foreign keys * @param array $foreignData Foreign keys data * @param string $field Column name - * @param string $tbl_fields_type Column type - * @param int $i Column index + * @param string $field_type Column type + * @param int $column_index Column index * @param string $db Selected database * @param string $table Selected table * @param array $titles Selected title * @param int $foreignMaxLimit Max limit of displaying foreign elements - * @param array $fields Array of search criteria inputs + * @param array $criteriaValues Array of search criteria inputs * @param bool $in_fbs Whether we are in 'function based search' * @param bool $in_zoom_search_edit Whether we are in zoom search edit * @@ -143,16 +143,19 @@ function PMA_tbl_getSubTabs() * for search criteria input. */ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, - $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, - $in_fbs = false, $in_zoom_search_edit = false + $field_type, $column_index, $db, $table, $titles, $foreignMaxLimit, + $criteriaValues, $in_fbs = false, $in_zoom_search_edit = false ) { $str = ''; + $field_type = (string)$field_type; + $field_id = ($in_zoom_search_edit) ? 'edit_fieldID_' : 'fieldID_'; if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row']) ) { // f o r e i g n k e y s - $str .= ''; // 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 @@ -164,29 +167,34 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $str .= ''; } elseif ($foreignData['foreign_link'] == true) { - if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= ''; + if (isset($criteriaValues[$column_index]) + && is_string($criteriaValues[$column_index]) + ) { + $str .= ''; } else { - $str .= ''; + $str .= ''; } $str .= <<'; - } elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) { + } elseif (in_array($field_type, PMA_getGISDatatypes())) { // g e o m e t r y - $str .= ''; + $str .= ''; if ($in_fbs) { $edit_url = 'gis_data_editor.php?' . PMA_generate_common_url(); @@ -198,8 +206,8 @@ EOT; $str .= ''; } - } elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0 - || (strncasecmp($tbl_fields_type[$i], 'set', 3) == 0 && $in_zoom_search_edit) + } elseif (strncasecmp($field_type, 'enum', 4) == 0 + || (strncasecmp($field_type, 'set', 3) == 0 && $in_zoom_search_edit) ) { // e n u m s a n d s e t s @@ -211,23 +219,25 @@ EOT; $value = explode( ', ', - str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)) + str_replace("'", '', substr($field_type, 5, -1)) ); $cnt_value = count($value); - if ((strncasecmp($tbl_fields_type[$i], 'enum', 4) && ! $in_zoom_search_edit) - || (strncasecmp($tbl_fields_type[$i], 'set', 3) && $in_zoom_search_edit) + if ((strncasecmp($field_type, 'enum', 4) && ! $in_zoom_search_edit) + || (strncasecmp($field_type, 'set', 3) && $in_zoom_search_edit) ) { - $str .= ''; } else { - $str .= ''; } for ($j = 0; $j < $cnt_value; $j++) { - if (isset($fields[$i]) - && is_array($fields[$i]) - && in_array($value[$j], $fields[$i]) + if (isset($criteriaValues[$column_index]) + && is_array($criteriaValues[$column_index]) + && in_array($value[$j], $criteriaValues[$column_index]) ) { $str .= ''; @@ -241,24 +251,26 @@ EOT; } else { // o t h e r c a s e s $the_class = 'textfield'; - $type = $tbl_fields_type[$i]; - if ($type == 'date') { + if ($field_type == 'date') { $the_class .= ' datefield'; - } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') { + } elseif ($field_type == 'datetime' || substr($field_type, 0, 9) == 'timestamp') { $the_class .= ' datetimefield'; - } elseif (substr($type, 0, 3) == 'bit') { + } elseif (substr($field_type, 0, 3) == 'bit') { $the_class .= ' bit'; } - if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= ''; + if (isset($criteriaValues[$column_index]) + && is_string($criteriaValues[$column_index]) + ) { + $str .= ''; } else { - $str .= ''; + $str .= ''; } } return $str; @@ -267,18 +279,18 @@ EOT; /** * Return the where clause for query generation based on the inputs provided. * - * @param mixed $fields Search criteria input - * @param string $names Name of the column on which search is submitted - * @param string $types Type of the field - * @param string $collations Field collation - * @param string $func_type Search fucntion/operator - * @param bool $unaryFlag Whether operator unary or not - * @param bool $geom_func Whether geometry functions should be applied + * @param mixed $criteriaValues Search criteria input + * @param string $names Name of the column on which search is submitted + * @param string $types Type of the field + * @param string $collations Field collation + * @param string $func_type Search fucntion/operator + * @param bool $unaryFlag Whether operator unary or not + * @param bool $geom_func Whether geometry functions should be applied * * @return string HTML content for viewing foreing data and elements * for search criteria input. */ -function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, +function PMA_tbl_search_getWhereClause($criteriaValues, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null ) { /** @@ -303,7 +315,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, } else { // If the function takes two parameters // create gis data from the string - $gis_data = PMA_createGISData($fields); + $gis_data = PMA_createGISData($criteriaValues); $w = $geom_func . '(' . PMA_backquote($names) . ',' . $gis_data . ')'; return $w; @@ -313,7 +325,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $types = $geom_funcs[$geom_func]['type']; // If the where clause is something like 'IsEmpty(`spatial_col_name`)' - if (isset($geom_unary_functions[$geom_func]) && trim($fields) == '') { + if (isset($geom_unary_functions[$geom_func]) && trim($criteriaValues) == '') { $w = $backquoted_name; return $w; } @@ -322,20 +334,20 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, } if ($unaryFlag) { - $fields = ''; + $criteriaValues = ''; $w = $backquoted_name . ' ' . $func_type; - } elseif (in_array($types, PMA_getGISDatatypes()) && ! empty($fields)) { + } elseif (in_array($types, PMA_getGISDatatypes()) && ! empty($criteriaValues)) { // create gis data from the string - $gis_data = PMA_createGISData($fields); + $gis_data = PMA_createGISData($criteriaValues); $w = $backquoted_name . ' ' . $func_type . ' ' . $gis_data; } elseif (strncasecmp($types, 'enum', 4) == 0) { - if (! empty($fields)) { - if (! is_array($fields)) { - $fields = explode(',', $fields); + if (! empty($criteriaValues)) { + if (! is_array($criteriaValues)) { + $criteriaValues = explode(',', $criteriaValues); } - $enum_selected_count = count($fields); + $enum_selected_count = count($criteriaValues); if ($func_type == '=' && $enum_selected_count > 1) { $func_type = 'IN'; $parens_open = '('; @@ -350,16 +362,17 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $parens_open = ''; $parens_close = ''; } - $enum_where = '\'' . PMA_sqlAddslashes($fields[0]) . '\''; + $enum_where = '\'' . PMA_sqlAddslashes($criteriaValues[0]) . '\''; for ($e = 1; $e < $enum_selected_count; $e++) { - $enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\''; + $enum_where .= ', \'' . PMA_sqlAddslashes($criteriaValues[$e]) + . '\''; } $w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close; } - } elseif ($fields != '') { + } elseif ($criteriaValues != '') { // For these types we quote the value. Even if it's another type (like INT), // for a LIKE we always quote the value. MySQL converts strings to numbers // and numbers to strings as necessary during the comparison @@ -374,11 +387,11 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, // LIKE %...% if ($func_type == 'LIKE %...%') { $func_type = 'LIKE'; - $fields = '%' . $fields . '%'; + $criteriaValues = '%' . $criteriaValues . '%'; } if ($func_type == 'REGEXP ^...$') { $func_type = 'REGEXP'; - $fields = '^' . $fields . '$'; + $criteriaValues = '^' . $criteriaValues . '$'; } if ($func_type == 'IN (...)' @@ -389,7 +402,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type = str_replace(' (...)', '', $func_type); // quote values one by one - $values = explode(',', $fields); + $values = explode(',', $criteriaValues); foreach ($values as &$value) { $value = $quot . PMA_sqlAddslashes(trim($value)) . $quot; } @@ -404,7 +417,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, } } else { $w = $backquoted_name . ' ' . $func_type . ' ' - . $quot . PMA_sqlAddslashes($fields) . $quot;; + . $quot . PMA_sqlAddslashes($criteriaValues) . $quot;; } } // end if @@ -414,18 +427,10 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, /** * Builds the sql search query from the post parameters * - * @param string $table Selected table - * @param array $fields Entered values of the columns - * @param array $criteriaColumnNames Names of all columns - * @param array $criteriaColumnTypes Types of all columns - * @param array $criteriaColumnCollations Collations of all columns - * @param array $criteriaColumnOperators Operators for given column type - * * @return string the generated SQL query */ -function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames, - $criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators -) { +function PMA_tblSearchBuildSqlQuery() +{ $sql_query = 'SELECT '; // If only distinct values are needed @@ -437,21 +442,21 @@ function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames, // if all column names were selected to display, we do a 'SELECT *' // (more efficient and this helps prevent a problem in IE // if one of the rows is edited and we come back to the Select results) - if (count($_POST['columnsToDisplay']) == count($criteriaColumnNames)) { + if (isset($_POST['zoom_submit'])) { $sql_query .= '* '; } else { - $sql_query .= implode(', ', PMA_backquote($_POST['columnsToDisplay'])); + $sql_query .= (count($_POST['columnsToDisplay']) + == count($_POST['criteriaColumnNames']) + ? '* ' + : implode(', ', PMA_backquote($_POST['columnsToDisplay']))); } // end if - $sql_query .= ' FROM ' . PMA_backquote($table); - $whereClause = PMA_tblSearchGenerateWhereClause( - $fields, $criteriaColumnNames, $criteriaColumnTypes, - $criteriaColumnCollations, $criteriaColumnOperators - ); + $sql_query .= ' FROM ' . PMA_backquote($_POST['table']); + $whereClause = PMA_tblSearchGenerateWhereClause(); $sql_query .= $whereClause; - + // if the search results are to be ordered - if ($_POST['orderByColumn'] != '--nil--') { + if (isset($_POST['orderByColumn']) && $_POST['orderByColumn'] != '--nil--') { $sql_query .= ' ORDER BY ' . PMA_backquote($_POST['orderByColumn']) . ' ' . $_POST['order']; } // end if @@ -461,40 +466,39 @@ function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames, /** * Generates the where clause for the SQL search query to be executed * - * @param array $fields Entered values of the columns - * @param array $criteriaColumnNames Names of all columns - * @param array $criteriaColumnTypes Types of all columns - * @param array $criteriaColumnCollations Collations of all columns - * @param array $criteriaColumnOperators Operators for given column type - * * @return string the generated where clause */ -function PMA_tblSearchGenerateWhereClause($fields, $criteriaColumnNames, - $criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators -) { +function PMA_tblSearchGenerateWhereClause() +{ $fullWhereClause = ''; - if (trim($_POST['customWhereClause']) != '') { + if (isset($_POST['customWhereClause']) && trim($_POST['customWhereClause']) != '') { $fullWhereClause .= ' WHERE ' . $_POST['customWhereClause']; return $fullWhereClause; } - // If there are no search criterias set, return - if (! array_filter($fields)) { + // If there are no search criteria set, return + if (! array_filter($_POST['criteriaValues'])) { return $fullWhereClause; } // else continue to form the where clause from column criteria values $fullWhereClause = $charsets = array(); - reset($criteriaColumnOperators); - while (list($i, $operator) = each($criteriaColumnOperators)) { - list($charsets[$i]) = explode('_', $criteriaColumnCollations[$i]); + reset($_POST['criteriaColumnOperators']); + while (list($column_index, $operator) = each($_POST['criteriaColumnOperators'])) { + list($charsets[$column_index]) = explode( + '_', $_POST['criteriaColumnCollations'][$column_index] + ); $unaryFlag = $GLOBALS['PMA_Types']->isUnaryOperator($operator); - $tmp_geom_func = isset($geom_func[$i]) ? $geom_func[$i] : null; + $tmp_geom_func = isset($geom_func[$column_index]) + ? $geom_func[$column_index] : null; $whereClause = PMA_tbl_search_getWhereClause( - $fields[$i], $criteriaColumnNames[$i], $criteriaColumnTypes[$i], - $criteriaColumnCollations[$i], $operator, $unaryFlag, $tmp_geom_func + $_POST['criteriaValues'][$column_index], + $_POST['criteriaColumnNames'][$column_index], + $_POST['criteriaColumnTypes'][$column_index], + $_POST['criteriaColumnCollations'][$column_index], $operator, $unaryFlag, + $tmp_geom_func ); if ($whereClause) { @@ -519,8 +523,8 @@ function PMA_tblSearchGenerateWhereClause($fields, $criteriaColumnNames, * * @return string the generated HTML */ -function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes, - $geom_types, $column_index +function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes, $geom_types, + $column_index ) { $html_output = ''; // return if geometrical column is not present @@ -557,12 +561,11 @@ function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes, /** * Generates formatted HTML for extra search options in table search form * - * @param array $columnNames Array containing types of all columns in the table - * @param integer $columnCount Number of columns in the table + * @param array $columnNames Array containing types of all columns in the table * * @return string the generated HTML */ -function PMA_tblSearchGetOptions($columnNames, $columnCount) +function PMA_tblSearchGetOptions($columnNames) { $html_output = ''; $html_output .= PMA_getDivForSliderEffect('searchoptions', __('Options')); @@ -571,7 +574,7 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) */ $html_output .= '
' . '' . __('Select columns (at least one):') . '' - . '' - . '
'; + $html_output .= ''; + $html_output .= ''; /** * Displays option of changing default number of rows displayed per page @@ -629,99 +633,340 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) } /** - * Generates HTML for displaying fields table in search form + * Other search criteria like data label + * (for tbl_zoom_select.php) * + * @param array $columnNames Names of columns in the table + * @param array $dataLabel Label for points in zoom plot + * + * @return string the generated html + */ +function PMA_tblSearchGetOptionsZoom($columnNames, $dataLabel) +{ + $html_output = ''; + $html_output .= ''; + //Select options for datalabel + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + //Inputbox for changing default maximum rows to plot + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= '
'; + $html_output .= ''; + $html_output .= '
'; + return $html_output; +} + +/** + * Provides a column's type, collation, operators list, and crietria value + * to display in table search form + * + * @param string $db Selected Database + * @param string $table Selected Table + * @param array $columnNames Names of columns in the table + * @param array $columnTypes Types of columns in the table + * @param array $columnCollations Collation of all columns + * @param array $columnNullFlags Null information of columns + * @param array $foreigners Array of foreign keys + * @param integer $search_index Row number in table search form + * @param integer $column_index Column index in ColumnNames array + * + * @return array Array contaning column's properties + */ +function PMA_tblSearchGetColumnProperties($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $foreigners, $search_index, $column_index +) { + $selected_operator = (isset($_POST['criteriaColumnOperators']) + ? $_POST['criteriaColumnOperators'][$search_index] : ''); + $entered_value = (isset($_POST['criteriaValues']) + ? $_POST['criteriaValues'] : ''); + $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); + //Gets column's type and collation + $type = $columnTypes[$column_index]; + $collation = $columnCollations[$column_index]; + //Gets column's comparison operators depending on column type + $func = ''; + //Gets link to browse foreign data(if any) and criteria inputbox + $foreignData = PMA_getForeignData( + $foreigners, $columnNames[$column_index], false, '', '' + ); + $value = PMA_getForeignFields_Values( + $foreigners, $foreignData, $columnNames[$column_index], $type, $search_index, + $db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], $entered_value + ); + return array( + 'type' => $type, + 'collation' => $collation, + 'func' => $func, + 'value' => $value + ); +} + +/** + * Provides the search form's table row in case of Normal Search + * (for tbl_select.php) + * + * @param string $db Selected Database + * @param string $table Selected Table * @param array $columnNames Names of columns in the table * @param array $columnTypes Types of columns in the table * @param array $columnCollations Collation of all columns * @param array $columnNullFlags Null information of columns * @param boolean $geomColumnFlag Whether a geometry column is present - * @param integer $columnCount Number of columns in the table * @param array $foreigners Array of foreign keys - * @param string $db Selected database - * @param string $table Selected table + * + * @return string the generated table row + */ +function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $geomColumnFlag, $foreigners +) { + $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); + $geom_types = PMA_getGISDatatypes(); + $odd_row = true; + $html_output = ''; + // for every column present in table + for ($column_index = 0; $column_index < count($columnNames); $column_index++) { + $html_output .= ''; + $odd_row = !$odd_row; + //If 'Function' column is present + $html_output .= PMA_tblSearchGetGeomFuncHtml( + $geomColumnFlag, $columnTypes, $geom_types, $column_index + ); + //Displays column's name, type, collation and value + $html_output .= '' . htmlspecialchars($columnNames[$column_index]) + . ''; + $properties = PMA_tblSearchGetColumnProperties( + $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $foreigners, $column_index, $column_index + ); + $html_output .= '' . $properties['type'] . ''; + $html_output .= '' . $properties['collation'] . ''; + $html_output .= '' . $properties['func'] . ''; + $html_output .= '' . $properties['value'] . ''; + $html_output .= ''; + //Displays hidden fields + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + } // end for + + return $html_output; +} + +/** + * Provides the search form's table row in case of Zoom Search + * (for tbl_zoom_select.php) + * + * @param string $db Selected Database + * @param string $table Selected Table + * @param array $columnNames Names of columns in the table + * @param array $columnTypes Types of columns in the table + * @param array $columnCollations Collation of all columns + * @param array $columnNullFlags Null information of columns + * @param array $foreigners Array of foreign keys + * + * @return string the generated table row + */ +function PMA_tblSearchGetRowsZoom($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $foreigners +) { + $odd_row = true; + $html_output = ''; + /** + * Get already set search criteria (if any) + */ + + //Displays column rows for search criteria input + for ($i = 0; $i < 4; $i++) { + //After X-Axis and Y-Axis column rows, display additional criteria option + if ($i == 2) { + $html_output .= ''; + $html_output .= __("Additional search criteria"); + $html_output .= ''; + } + $html_output .= ''; + $odd_row = ! $odd_row; + //Select options for column names + $html_output .= ''; + if (isset($_POST['criteriaColumnNames']) + && $_POST['criteriaColumnNames'][$i] != 'pma_null' + ) { + $key = array_search($_POST['criteriaColumnNames'][$i], $columnNames); + $properties = PMA_tblSearchGetColumnProperties( + $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $foreigners, $i, $key + ); + $type[$i] = $properties['type']; + $collation[$i] = $properties['collation']; + $func[$i] = $properties['func']; + $value[$i] = $properties['value']; + } + //Column type + $html_output .= '' . (isset($type[$i]) ? $type[$i] : '') . ''; + //Column Collation + $html_output .= '' . (isset($collation[$i]) ? $collation[$i] : '') + . ''; + //Select options for column operators + $html_output .= '' . (isset($func[$i]) ? $func[$i] : '') . ''; + //Inputbox for search criteria value + $html_output .= '' . (isset($value[$i]) ? $value[$i] : '') . ''; + $html_output .= ''; + //Displays hidden fields + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + }//end for + return $html_output; +} + +/** + * Generates HTML for displaying fields table in search form + * + * @param string $db Selected Database + * @param string $table Selected Table + * @param array $columnNames Names of columns in the table + * @param array $columnTypes Types of columns in the table + * @param array $columnCollations Collation of all columns + * @param array $columnNullFlags Null information of columns + * @param boolean $geomColumnFlag Whether a geometry column is present + * @param array $foreigners Array of foreign keys + * @param string $searchType Whether normal search or zoom search * * @return string the generated HTML */ -function PMA_tblSearchGetFieldsTableHtml($columnNames, $columnTypes, - $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, - $foreigners, $db, $table +function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $geomColumnFlag, $foreigners, $searchType ) { $html_output = ''; - $html_output .= ''; - $html_output .= PMA_tbl_setTableHeader($geomColumnFlag) . ''; - $odd_row = true; - $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); - $geom_types = PMA_getGISDatatypes(); + $html_output .= '
'; + $html_output .= PMA_tbl_getTableHeader($geomColumnFlag); + $html_output .= ''; - // for every column present in table - for ($i = 0; $i < $columnCount; $i++) { - $html_output .= ''; - $odd_row = !$odd_row; - - /** - * If 'Function' column is present - */ - $html_output .= PMA_tblSearchGetGeomFuncHtml( - $geomColumnFlag, $columnTypes, $geom_types, $i + if ($searchType == 'zoom') { + $html_output .= PMA_tblSearchGetRowsZoom( + $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $foreigners ); - /** - * Displays column's name, type and collation - */ - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - /** - * Displays column's comparison operators depending on column type - */ - $html_output .= ''; - /** - * Displays column's foreign relations if any - */ - $html_output .= ''; - } // end for + } $html_output .= '
' . htmlspecialchars($columnNames[$i]) . '' . htmlspecialchars($columnTypes[$i]) . '' . $columnCollations[$i] . ''; - $field = $columnNames[$i]; - $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); - $html_output .= PMA_getForeignFields_Values( - $foreigners, $foreignData, $field, $columnTypes, $i, $db, $table, - $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true - ); - - $html_output .= '' - . '' - . '
'; return $html_output; } +/** + * Provides the form tag for table search form + * (normal search or zoom search) + * + * @param string $goto Goto URL + * @param string $db Selected Database + * @param string $table Selected Table + * @param string $searchType Whether normal search or zoom search + * + * @return string the HTML for form tag + */ +function PMA_tblSearchGetFormTag($goto, $db, $table, $searchType) +{ + $html_output = ''; + $scriptName = ($searchType == 'zoom' ? 'tbl_zoom_select.php' : 'tbl_select.php'); + $formId = ($searchType == 'zoom' ? 'zoom_search_form' : 'tbl_search_form'); + + $html_output .= '
'; + + $html_output .= PMA_generate_common_hidden_inputs($db, $table); + $html_output .= ''; + $html_output .= ''; + + return $html_output; +} + /** * Generates the table search form under table search tab * * @param string $goto Goto URL + * @param string $db Selected Database + * @param string $table Selected Table * @param array $columnNames Names of columns in the table * @param array $columnTypes Types of columns in the table * @param array $columnCollations Collation of all columns * @param array $columnNullFlags Null information of columns * @param boolean $geomColumnFlag Whether a geometry column is present - * @param integer $columnCount Number of columns in the table * @param array $foreigners Array of foreign keys - * @param string $db Selected database - * @param string $table Selected table + * @param string $searchType Whether normal search or zoom search + * @param string $dataLabel Label for points in zoom plot * * @return string the generated HTML for table search form */ -function PMA_tblSearchGetSelectionForm($goto, $columnNames, $columnTypes, - $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, - $foreigners, $db, $table +function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, + $columnTypes, $columnCollations, $columnNullFlags, $geomColumnFlag, $foreigners, + $searchType, $dataLabel = null ) { $html_output = ''; $html_output .= '
'; @@ -729,39 +974,62 @@ function PMA_tblSearchGetSelectionForm($goto, $columnNames, $columnTypes, $url_params['db'] = $db; $url_params['table'] = $table; - $html_output .= PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2'); - $html_output .= ''; - $html_output .= PMA_generate_common_hidden_inputs($db, $table); - $html_output .= ''; - $html_output .= '' - . ''; + } else { + $html_output .= '
'; + } return $html_output; } ?> diff --git a/sql.php b/sql.php index 1a03f04cb3..28a1e7d33d 100644 --- a/sql.php +++ b/sql.php @@ -153,13 +153,11 @@ if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) $field_info_result = PMA_DBI_fetch_result($field_info_query, null, null, null, PMA_DBI_QUERY_STORE); - $search = array('enum', '(', ')', "'"); - - $values = explode(',', str_replace($search, '', $field_info_result[0]['Type'])); + $values = PMA_parseEnumSetValues($field_info_result[0]['Type']); $dropdown = ''; foreach ($values as $value) { - $dropdown .= '