From 9f14151c7ca8968210346ab1cacfda071fdf306e Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 1 Jun 2012 12:42:50 +0530 Subject: [PATCH 01/38] Remove more variables from post_params --- libraries/tbl_select.lib.php | 64 +++++++++++++----------------------- tbl_select.php | 18 +++------- 2 files changed, 26 insertions(+), 56 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index ae94346cde..f0c97ff912 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -414,17 +414,9 @@ 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 '; @@ -437,17 +429,14 @@ 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 (count($_POST['columnsToDisplay']) == count($_POST['criteriaColumnNames'])) { $sql_query .= '* '; } else { $sql_query .= 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 @@ -461,16 +450,9 @@ 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 = ''; @@ -480,21 +462,21 @@ function PMA_tblSearchGenerateWhereClause($fields, $criteriaColumnNames, } // If there are no search criterias set, return - if (! array_filter($fields)) { + if (! array_filter($_POST['fields'])) { 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($i, $operator) = each($_POST['criteriaColumnOperators'])) { + list($charsets[$i]) = explode('_', $_POST['criteriaColumnCollations'][$i]); $unaryFlag = $GLOBALS['PMA_Types']->isUnaryOperator($operator); $tmp_geom_func = isset($geom_func[$i]) ? $geom_func[$i] : null; $whereClause = PMA_tbl_search_getWhereClause( - $fields[$i], $criteriaColumnNames[$i], $criteriaColumnTypes[$i], - $criteriaColumnCollations[$i], $operator, $unaryFlag, $tmp_geom_func + $_POST['fields'][$i], $_POST['criteriaColumnNames'][$i], $_POST['criteriaColumnTypes'][$i], + $_POST['criteriaColumnCollations'][$i], $operator, $unaryFlag, $tmp_geom_func ); if ($whereClause) { @@ -629,6 +611,8 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) /** * 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 @@ -636,14 +620,11 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) * @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 HTML */ -function PMA_tblSearchGetFieldsTableHtml($columnNames, $columnTypes, -$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, -$foreigners, $db, $table) +function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners) { $html_output = ''; $html_output .= ''; @@ -704,7 +685,9 @@ $foreigners, $db, $table) /** * Generates the table search form under table search tab * - * @param string $goto Goto URL + * @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 @@ -712,14 +695,11 @@ $foreigners, $db, $table) * @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 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, $columnCount, $foreigners) { $html_output = ''; $html_output .= '
'; @@ -741,8 +721,8 @@ $foreigners, $db, $table) * Displays table fields */ $html_output .= PMA_tblSearchGetFieldsTableHtml( - $columnNames, $columnTypes, $columnCollations, $columnNullFlags, - $geomColumnFlag, $columnCount, $foreigners, $db, $table + $db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, + $geomColumnFlag, $columnCount, $foreigners ); $html_output .= '
' diff --git a/tbl_select.php b/tbl_select.php index dd3dd733ec..734b1f5938 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -25,14 +25,7 @@ $GLOBALS['js_include'][] = 'gis_data_editor.js'; $post_params = array( 'ajax_request', - 'criteriaColumnCollations', - 'db', - 'fields', - 'criteriaColumnOperators', - 'criteriaColumnNames', - 'session_max_rows', - 'table', - 'criteriaColumnTypes', + 'session_max_rows' ); foreach ($post_params as $one_post_param) { if (isset($_POST[$one_post_param])) { @@ -73,8 +66,8 @@ if (! isset($_POST['columnsToDisplay']) || $_POST['columnsToDisplay'][0] == '') // Displays the table search form echo PMA_tblSearchGetSelectionForm( - $goto, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, - $geomColumnFlag, $columnCount, $foreigners, $db, $table + $goto, $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners ); include 'libraries/footer.inc.php'; @@ -82,10 +75,7 @@ if (! isset($_POST['columnsToDisplay']) || $_POST['columnsToDisplay'][0] == '') /** * Selection criteria have been submitted -> do the work */ - $sql_query = PMA_tblSearchBuildSqlQuery( - $table, $fields, $criteriaColumnNames, $criteriaColumnTypes, - $criteriaColumnCollations, $criteriaColumnOperators - ); + $sql_query = PMA_tblSearchBuildSqlQuery(); include 'sql.php'; } ?> From 230cae24d418990507754605d0836b526602b5a4 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 1 Jun 2012 13:21:42 +0530 Subject: [PATCH 02/38] Replace variable i with column_index --- libraries/tbl_select.lib.php | 111 +++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 51 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index f0c97ff912..dfd4672c58 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -130,7 +130,7 @@ function PMA_tbl_getSubTabs() * @param array $foreignData Foreign keys data * @param string $field Column name * @param string $tbl_fields_type Column type - * @param int $i Column index + * @param int $column_index Column index * @param string $db Selected database * @param string $table Selected table * @param array $titles Selected title @@ -143,7 +143,7 @@ function PMA_tbl_getSubTabs() * for search criteria input. */ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, - $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, + $tbl_fields_type, $column_index, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false, $in_zoom_search_edit = false ) { $str = ''; @@ -152,7 +152,8 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $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 +165,30 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $str .= ''; } elseif ($foreignData['foreign_link'] == true) { - if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= ''; + if (isset($fields[$column_index]) && is_string($fields[$column_index])) { + $str .= ''; } else { - $str .= ''; + $str .= ''; } $str .= <<'; - } elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) { + } elseif (in_array($tbl_fields_type[$column_index], 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 +200,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($tbl_fields_type[$column_index], 'enum', 4) == 0 + || (strncasecmp($tbl_fields_type[$column_index], 'set', 3) == 0 && $in_zoom_search_edit) ) { // e n u m s a n d s e t s @@ -211,23 +213,25 @@ EOT; $value = explode( ', ', - str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)) + str_replace("'", '', substr($tbl_fields_type[$column_index], 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($tbl_fields_type[$column_index], 'enum', 4) && ! $in_zoom_search_edit) + || (strncasecmp($tbl_fields_type[$column_index], '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($fields[$column_index]) + && is_array($fields[$column_index]) + && in_array($value[$j], $fields[$column_index]) ) { $str .= ''; @@ -241,7 +245,7 @@ EOT; } else { // o t h e r c a s e s $the_class = 'textfield'; - $type = $tbl_fields_type[$i]; + $type = $tbl_fields_type[$column_index]; if ($type == 'date') { $the_class .= ' datefield'; @@ -251,14 +255,14 @@ EOT; $the_class .= ' bit'; } - if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= ''; + . $column_index .'" value = "' . $fields[$column_index] . '"/>'; } else { - $str .= ''; + . $column_index .'" />'; } } return $str; @@ -469,14 +473,19 @@ function PMA_tblSearchGenerateWhereClause() // else continue to form the where clause from column criteria values $fullWhereClause = $charsets = array(); reset($_POST['criteriaColumnOperators']); - while (list($i, $operator) = each($_POST['criteriaColumnOperators'])) { - list($charsets[$i]) = explode('_', $_POST['criteriaColumnCollations'][$i]); + 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( - $_POST['fields'][$i], $_POST['criteriaColumnNames'][$i], $_POST['criteriaColumnTypes'][$i], - $_POST['criteriaColumnCollations'][$i], $operator, $unaryFlag, $tmp_geom_func + $_POST['fields'][$column_index], + $_POST['criteriaColumnNames'][$column_index], + $_POST['criteriaColumnTypes'][$column_index], + $_POST['criteriaColumnCollations'][$column_index], $operator, $unaryFlag, + $tmp_geom_func ); if ($whereClause) { @@ -634,7 +643,7 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes $geom_types = PMA_getGISDatatypes(); // for every column present in table - for ($i = 0; $i < $columnCount; $i++) { + for ($column_index = 0; $column_index < $columnCount; $column_index++) { $html_output .= '
'; $odd_row = !$odd_row; @@ -642,40 +651,40 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes * If 'Function' column is present */ $html_output .= PMA_tblSearchGetGeomFuncHtml( - $geomColumnFlag, $columnTypes, $geom_types, $i + $geomColumnFlag, $columnTypes, $geom_types, $column_index ); /** * Displays column's name, type and collation */ - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; + $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 .= ''; + $html_output .= '' + . '' + . ''; } // end for $html_output .= '
' . htmlspecialchars($columnNames[$i]) . '' . htmlspecialchars($columnTypes[$i]) . '' . $columnCollations[$i] . '' . htmlspecialchars($columnNames[$column_index]) . '' . htmlspecialchars($columnTypes[$column_index]) . '' . $columnCollations[$column_index] . ''; - $field = $columnNames[$i]; + $field = $columnNames[$column_index]; $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); $html_output .= PMA_getForeignFields_Values( - $foreigners, $foreignData, $field, $columnTypes, $i, $db, $table, + $foreigners, $foreignData, $field, $columnTypes, $column_index, $db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true ); - $html_output .= '' - . '' - . '
'; From 2d9217f1da69ae60de7aa4f2b3570d94e21ef966 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 1 Jun 2012 20:57:20 +0530 Subject: [PATCH 03/38] Make variable names uniform in search scripts --- libraries/tbl_select.lib.php | 126 ++++++++++++++++--------------- tbl_zoom_select.php | 140 +++++++++++++++++------------------ 2 files changed, 135 insertions(+), 131 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index dfd4672c58..d132eaf1c8 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_setTableHeader($geomColumnFlag = false) { // Display the Function column only if there is alteast one geomety colum $func = ''; - if ($geom_column_present) { + if ($geomColumnFlag) { $func = '' . __('Function') . ''; } @@ -135,7 +135,7 @@ function PMA_tbl_getSubTabs() * @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,8 +143,8 @@ function PMA_tbl_getSubTabs() * for search criteria input. */ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, - $tbl_fields_type, $column_index, $db, $table, $titles, $foreignMaxLimit, $fields, - $in_fbs = false, $in_zoom_search_edit = false + $tbl_fields_type, $column_index, $db, $table, $titles, $foreignMaxLimit, + $criteriaValues, $in_fbs = false, $in_zoom_search_edit = false ) { $str = ''; if ($foreigners @@ -152,7 +152,7 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, && is_array($foreignData['disp_row']) ) { // f o r e i g n k e y s - $str .= ''; } elseif ($foreignData['foreign_link'] == true) { - if (isset($fields[$column_index]) && is_string($fields[$column_index])) { + if (isset($criteriaValues[$column_index]) + && is_string($criteriaValues[$column_index]) + ) { $str .= ''; } else { $str .= ''; } $str .= <<'; if ($in_fbs) { @@ -220,18 +222,18 @@ EOT; if ((strncasecmp($tbl_fields_type[$column_index], 'enum', 4) && ! $in_zoom_search_edit) || (strncasecmp($tbl_fields_type[$column_index], 'set', 3) && $in_zoom_search_edit) ) { - $str .= ''; } for ($j = 0; $j < $cnt_value; $j++) { - if (isset($fields[$column_index]) - && is_array($fields[$column_index]) - && in_array($value[$j], $fields[$column_index]) + if (isset($criteriaValues[$column_index]) + && is_array($criteriaValues[$column_index]) + && in_array($value[$j], $criteriaValues[$column_index]) ) { $str .= ''; @@ -255,12 +257,14 @@ EOT; $the_class .= ' bit'; } - if (isset($fields[$column_index]) && is_string($fields[$column_index])) { - $str .= ''; + . $column_index .'" value = "' . $criteriaValues[$column_index] . '"/>'; } else { - $str .= ''; } @@ -271,18 +275,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 ) { /** @@ -307,7 +311,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; @@ -317,7 +321,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; } @@ -326,20 +330,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 = '('; @@ -354,16 +358,16 @@ 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 @@ -378,11 +382,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 (...)' @@ -393,7 +397,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; } @@ -408,7 +412,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 @@ -466,7 +470,7 @@ function PMA_tblSearchGenerateWhereClause() } // If there are no search criterias set, return - if (! array_filter($_POST['fields'])) { + if (! array_filter($_POST['criteriaValues'])) { return $fullWhereClause; } @@ -481,7 +485,7 @@ function PMA_tblSearchGenerateWhereClause() $tmp_geom_func = isset($geom_func[$column_index]) ? $geom_func[$column_index] : null; $whereClause = PMA_tbl_search_getWhereClause( - $_POST['fields'][$column_index], + $_POST['criteriaValues'][$column_index], $_POST['criteriaColumnNames'][$column_index], $_POST['criteriaColumnTypes'][$column_index], $_POST['criteriaColumnCollations'][$column_index], $operator, $unaryFlag, diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 0e705ddf58..9f1ccd53bc 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -40,15 +40,15 @@ $GLOBALS['js_include'][] = 'tbl_zoom_plot_jqplot.js'; * Sets globals from $_POST */ $post_params = array( - 'collations', + 'criteriaColumnCollations', 'dataLabel', - 'fields', - 'fields_null', - 'inputs', + 'criteriaValues', + 'criteriaColumnNullFlags', + 'criteriaColumnNames', 'maxPlotLimit', - 'types', + 'criteriaColumnTypes', 'zoom_submit', - 'zoomFunc' + 'criteriaColumnOperators' ); foreach ($post_params as $one_post_param) { if (isset($_POST[$one_post_param])) { @@ -99,20 +99,20 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) // Gets the list and number of fields - list($fields_list, $fields_type, $fields_collation, $fields_null) + list($columnNames, $columnTypes, $columnCollations, $columnNullFlags) = PMA_tbl_getFields($_REQUEST['db'], $_REQUEST['table']); $foreigners = PMA_getForeigners($db, $table); $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); - $key = array_search($field, $fields_list); - $extra_data['field_type'] = $fields_type[$key]; - $extra_data['field_collation'] = $fields_collation[$key]; + $key = array_search($field, $columnNames); + $extra_data['field_type'] = $columnTypes[$key]; + $extra_data['field_collation'] = $columnCollations[$key]; // HTML for operators - $html = ''; $html .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml( - preg_replace('@\(.*@s', '', $fields_type[$key]), - $fields_null[$key] + preg_replace('@\(.*@s', '', $columnTypes[$key]), + $columnNullFlags[$key] ); $html .= ''; $extra_data['field_operators'] = $html; @@ -127,7 +127,7 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) $foreigners, $foreignData, $field, - array($_REQUEST['it'] => $fields_type[$key]), + array($_REQUEST['it'] => $columnTypes[$key]), $_REQUEST['it'], $_REQUEST['db'], $_REQUEST['table'], @@ -161,17 +161,17 @@ $err_url = $goto . '?' . PMA_generate_common_url($db, $table); // Gets the list and number of fields -list($fields_list, $fields_type, $fields_collation, $fields_null) +list($columnNames, $columnTypes, $columnCollations, $columnNullFlags) = PMA_tbl_getFields($db, $table); -$fields_cnt = count($fields_list); +$columnCount = count($columnNames); // retrieve keys into foreign fields, if any // check also foreigners even if relwork is FALSE (to get // foreign keys from innodb) $foreigners = PMA_getForeigners($db, $table); -$tbl_fields_type = $tbl_fields_collation = $tbl_fields_null = array(); +$tbl_fields_type = $tbl_fields_collation = $tbl_criteriaColumnNullFlags = array(); -if (! isset($zoom_submit) && ! isset($inputs)) { +if (! isset($zoom_submit) && ! isset($criteriaColumnNames)) { $dataLabel = PMA_getDisplayField($db, $table); } ?> @@ -186,30 +186,30 @@ echo PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2'); /** * Set the field name,type,collation and whether null on select of a coulmn */ -if (isset($inputs) && ($inputs[0] != 'pma_null' || $inputs[1] != 'pma_null')) { +if (isset($criteriaColumnNames) && ($criteriaColumnNames[0] != 'pma_null' || $criteriaColumnNames[1] != 'pma_null')) { for ($i = 0 ; $i < 4 ; $i++) { - if ($inputs[$i] != 'pma_null') { - $key = array_search($inputs[$i], $fields_list); - $tbl_fields_type[$i] = $fields_type[$key]; - $tbl_fields_collation[$i] = $fields_collation[$key]; - $tbl_fields_func[$i] = ''; $tbl_fields_func[$i] .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml( - preg_replace('@\(.*@s', '', $fields_type[$key]), - $fields_null[$key], $zoomFunc[$i] + preg_replace('@\(.*@s', '', $columnTypes[$key]), + $columnNullFlags[$key], $criteriaColumnOperators[$i] ); $tbl_fields_func[$i] .= ''; - $foreignData = PMA_getForeignData($foreigners, $inputs[$i], false, '', ''); + $foreignData = PMA_getForeignData($foreigners, $criteriaColumnNames[$i], false, '', ''); $tbl_fields_value[$i] = PMA_getForeignFields_Values( $foreigners, $foreignData, - $inputs[$i], + $criteriaColumnNames[$i], $tbl_fields_type, $i, $db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], - $fields + $criteriaValues ); } } @@ -243,17 +243,17 @@ for ($i = 0; $i < 4; $i++) { } ?> - - + for ($j = 0 ; $j < $columnCount ; $j++) { + if (isset($criteriaColumnNames[$i]) && $criteriaColumnNames[$i] == htmlspecialchars($columnNames[$j])) {?> + - + @@ -264,13 +264,13 @@ for ($i = 0; $i < 4; $i++) { - /> - + '; /** - * Displays column's foreign relations if any + * Displays link to browse foreign data(if any) and criteria inputbox */ $html_output .= ''; $field = $columnNames[$column_index]; @@ -733,7 +733,7 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $column . '' . __('Do a "query by example" (wildcard: "%")') . ''; /** - * Displays table fields + * Displays fields table in search form */ $html_output .= PMA_tblSearchGetFieldsTableHtml( $db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, @@ -745,7 +745,7 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $column . ''; /** - * Displays slider options form + * Displays more search options */ $html_output .= PMA_tblSearchGetOptions($columnNames, $columnCount); From 54be18e0d1075a8bb946332f65432d9e9e791837 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 2 Jun 2012 11:24:57 +0530 Subject: [PATCH 06/38] Generalize some new functions for zoom search --- libraries/tbl_select.lib.php | 143 +++++++++++++++++++++++++++-------- tbl_select.php | 2 +- 2 files changed, 111 insertions(+), 34 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index d5a967fba8..484666dfda 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -623,8 +623,10 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) return $html_output; } + /** - * Generates HTML for displaying fields table in search form + * 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 @@ -636,18 +638,15 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) * @param integer $columnCount Number of columns in the table * @param array $foreigners Array of foreign keys * - * @return string the generated HTML + * @return string the generated table row */ -function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes, +function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners) { - $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(); - + $odd_row = true; + $html_output = ''; // for every column present in table for ($column_index = 0; $column_index < $columnCount; $column_index++) { $html_output .= ''; @@ -692,15 +691,13 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes . ''; } // end for - - $html_output .= '
'; + return $html_output; } /** - * Generates the table search form under table search tab + * Generates HTML for displaying fields table in search form * - * @param string $goto Goto URL * @param string $db Selected Database * @param string $table Selected Table * @param array $columnNames Names of columns in the table @@ -710,11 +707,78 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes * @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 $searchType Whether normal search or zoom search + * + * @return string the generated HTML + */ +function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners, + $searchType) +{ + $html_output = ''; + $html_output .= ''; + $html_output .= PMA_tbl_setTableHeader($geomColumnFlag); + $html_output .= ''; + + if($searchType == 'zoom') { + } else { + $html_output .= PMA_tblSearchGetRowsNormal( + $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners + ); + } + + $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 $searchType Whether normal search or zoom search * * @return string the generated HTML for table search form */ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $columnTypes, - $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners) + $columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners, + $searchType) { $html_output = ''; $html_output .= '
'; @@ -723,38 +787,51 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $column $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 .= '' - . ''; return $html_output; } ?> diff --git a/tbl_select.php b/tbl_select.php index 734b1f5938..dd2a845ec2 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -67,7 +67,7 @@ if (! isset($_POST['columnsToDisplay']) || $_POST['columnsToDisplay'][0] == '') // Displays the table search form echo PMA_tblSearchGetSelectionForm( $goto, $db, $table, $columnNames, $columnTypes, $columnCollations, - $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners + $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners, "normal" ); include 'libraries/footer.inc.php'; From 316dee3ba8143948e0e87104ca401917200c5d57 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 2 Jun 2012 23:16:45 +0530 Subject: [PATCH 07/38] Fix function name: PMA_tbl_setTableHeader -> PMA_tbl_getTableHeader --- libraries/tbl_select.lib.php | 4 ++-- tbl_zoom_select.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 484666dfda..453b7962c6 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -79,7 +79,7 @@ function PMA_tbl_getFields($db, $table) * * @return HTML content, the tags and content for table header */ -function PMA_tbl_setTableHeader($geomColumnFlag = false) +function PMA_tbl_getTableHeader($geomColumnFlag = false) { // Display the Function column only if there is alteast one geomety colum $func = ''; @@ -717,7 +717,7 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes { $html_output = ''; $html_output .= ''; - $html_output .= PMA_tbl_setTableHeader($geomColumnFlag); + $html_output .= PMA_tbl_getTableHeader($geomColumnFlag); $html_output .= ''; if($searchType == 'zoom') { diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 9dfae46f37..53cf19c998 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -230,7 +230,7 @@ if (isset($criteriaColumnNames) && ($criteriaColumnNames[0] != 'pma_null' || $cr
- + Date: Sat, 2 Jun 2012 23:19:18 +0530 Subject: [PATCH 08/38] Fix typo in comment inside PMA_tbl_getTableHeader --- libraries/tbl_select.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 453b7962c6..0ee6c2f29c 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -81,7 +81,7 @@ function PMA_tbl_getFields($db, $table) */ 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 ($geomColumnFlag) { $func = ''; From 72cec141049bd193ffdbdf0bc31d4334d6f9c47a Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 3 Jun 2012 00:00:51 +0530 Subject: [PATCH 09/38] Fix spacing after if statement in tbl_select.lib.php --- libraries/tbl_select.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 0ee6c2f29c..4b7b6bb526 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -720,7 +720,7 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes $html_output .= PMA_tbl_getTableHeader($geomColumnFlag); $html_output .= ''; - if($searchType == 'zoom') { + if ($searchType == 'zoom') { } else { $html_output .= PMA_tblSearchGetRowsNormal( $db, $table, $columnNames, $columnTypes, $columnCollations, @@ -794,7 +794,7 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $column $html_output .= ($searchType == 'zoom' ? '' : '
'); // Set caption for fieldset - if($searchType == 'zoom') { + if ($searchType == 'zoom') { $html_output .= '' . __('Do a "query by example" (wildcard: "%") for two different columns') . ''; @@ -812,7 +812,7 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $column $geomColumnFlag, $columnCount, $foreigners, $searchType ); - if($searchType == 'zoom') { + if ($searchType == 'zoom') { } else { $html_output .= '
' . '' From 43ec1eb54a93e44531c57d27ef24022ac0f5ef77 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Mon, 4 Jun 2012 23:15:11 +0530 Subject: [PATCH 10/38] Some coding style fixes in tbl_select.lib.php --- libraries/tbl_select.lib.php | 73 +++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index bbc525170a..5a17643ab7 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -130,7 +130,7 @@ function PMA_tbl_getSubTabs() * @param array $foreignData Foreign keys data * @param string $field Column name * @param string $tbl_fields_type Column type - * @param int $column_index Column index + * @param int $column_index Column index * @param string $db Selected database * @param string $table Selected table * @param array $titles Selected title @@ -175,13 +175,15 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, } else { $str .= ''; + . ' id="field_' . md5($field) . '[' . $column_index .']" ' + .'class="textfield" />'; } $str .= <<'; + $str .= ''; } @@ -262,7 +264,8 @@ EOT; ) { $str .= ''; + . $column_index .'" value = "' . $criteriaValues[$column_index] + . '"/>'; } else { $str .= ''; $html_output .= PMA_showMySQLDocu('SQL-Syntax', 'Functions'); - $html_output .= '' - . '
'; + $html_output .= ''; + $html_output .= ''; /** * Displays option of changing default number of rows displayed per page @@ -662,8 +668,10 @@ function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, /** * Displays column's name, type and collation */ - $html_output .= ''; - $html_output .= ''; + $html_output .= ''; + $html_output .= ''; $html_output .= ''; /** * Displays column's comparison operators depending on column type @@ -681,16 +689,18 @@ function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, $field = $columnNames[$column_index]; $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); $html_output .= PMA_getForeignFields_Values( - $foreigners, $foreignData, $field, $columnTypes, $column_index, $db, $table, - $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true + $foreigners, $foreignData, $field, $columnTypes, $column_index, $db, + $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true ); - $html_output .= '' - . '' - . ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; } // end for return $html_output; @@ -737,14 +747,15 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes * 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 + * @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) { +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'); @@ -755,7 +766,8 @@ function PMA_tblSearchGetFormTag($goto, $db, $table, $searchType) { $html_output .= PMA_generate_common_hidden_inputs($db, $table); $html_output .= ''; - $html_output .= ''; + $html_output .= ''; return $html_output; } @@ -793,8 +805,9 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $html_output .= PMA_tblSearchGetFormTag($goto, $db, $table, $searchType); $html_output .= '
'; - $html_output .= ($searchType == 'zoom' ? '' : '
'); + . ($searchType == 'zoom' ? 'inputSection' : 'fieldset_table_search' . '">'); + $html_output .= $searchType == 'zoom' + ? '' : '
'; // Set caption for fieldset if ($searchType == 'zoom') { From 27c1ab6c31fda81ae217bef8bc3e171dfc2aaaba Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Wed, 6 Jun 2012 22:56:44 +0530 Subject: [PATCH 11/38] Functions for some part of zoom search form display --- libraries/tbl_select.lib.php | 157 ++++++++++++++++++++++++++++++++++- tbl_zoom_select.php | 84 ++----------------- 2 files changed, 159 insertions(+), 82 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 5a17643ab7..161d38b7fe 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -636,7 +636,7 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) * (for tbl_select.php) * * @param string $db Selected Database - * @param string $table Selected Table + * @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 @@ -706,11 +706,157 @@ function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, 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 integer $columnCount Number of columns in the table + * @param array $foreigners Array of foreign keys + * + * @return string the generated table row + */ +function PMA_tblSearchGetRowsZoom($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $columnCount, $foreigners +) { + $odd_row = true; + $html_output = ''; + /** + * Get already set search criteria (if any) + */ + list ($tbl_fields_type, $tbl_fields_collation, $tbl_fields_func, $tbl_fields_value) + = PMA_tblSearchGetCriteriaInput( + $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $foreigners + ); + + //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 .= ''; + $odd_row = ! $odd_row; + //Select options for column names + $html_output .= ''; + //Column type + $html_output .= ''; + //Column Collation + $html_output .= ''; + //Select options for column operators + $html_output .= ''; + //Inputbox for search criteria value + $html_output .= ''; + $html_output .= ''; + //Displays hidden fields + $html_output .= ''; + }//end for + return $html_output; +} + +/** + * Set the field name, type, collation and value on select of a coulmn + * (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 array Array of Search criteria input + */ +function PMA_tblSearchGetCriteriaInput($db, $table, $columnNames, $columnTypes, + $columnCollations, $columnNullFlags, $foreigners +) { + $tbl_fields_type = $tbl_fields_collation = $tbl_fields_func = $tbl_fields_value + = array(); + $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); + + //Return null if no search criteria is already set + if (!isset($_POST['criteriaColumnNames'])) { + return null; + } + + for ($i = 0 ; $i < 4 ; $i++) { + if ($_POST['criteriaColumnNames'][$i] == 'pma_null') { + continue; + } + $key = array_search($_POST['criteriaColumnNames'][$i], $columnNames); + $tbl_fields_type[$i] = $columnTypes[$key]; + $tbl_fields_collation[$i] = $columnCollations[$key]; + $tbl_fields_func[$i] = ''; + $foreignData = PMA_getForeignData( + $foreigners, $_POST['criteriaColumnNames'][$i], false, '', '' + ); + $tbl_fields_value[$i] = PMA_getForeignFields_Values( + $foreigners, $foreignData, $_POST['criteriaColumnNames'][$i], + $tbl_fields_type, $i, $db, $table, $titles, + $GLOBALS['cfg']['ForeignKeyMaxLimit'], $_POST['criteriaValues'] + ); + } + return array( + $tbl_fields_type, + $tbl_fields_collation, + $tbl_fields_func, + $tbl_fields_value + ); +} + /** * Generates HTML for displaying fields table in search form * * @param string $db Selected Database - * @param string $table Selected Table + * @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 @@ -727,11 +873,16 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes $searchType ) { $html_output = ''; - $html_output .= '
' . __('Function') . '
' . htmlspecialchars($columnNames[$column_index]) . '' . htmlspecialchars($columnTypes[$column_index]) . '' . htmlspecialchars($columnNames[$column_index]) + . '' . htmlspecialchars($columnTypes[$column_index]) + . '' . $columnCollations[$column_index] . '
'; + $html_output .= __("Additional search criteria"); + $html_output .= '
' + . (isset($tbl_fields_type[$i]) ? $tbl_fields_type[$i] : '') + . '' + . (isset($tbl_fields_collation[$i]) ? $tbl_fields_collation[$i] : '') + . '' + . (isset($tbl_fields_func[$i]) ? $tbl_fields_func[$i] : '') + . '' + . (isset($tbl_fields_value[$i]) ? $tbl_fields_value[$i] : '') + . '
'; + $html_output .= ''; + $html_output .= '
'; + $html_output .= '
'; $html_output .= PMA_tbl_getTableHeader($geomColumnFlag); $html_output .= ''; if ($searchType == 'zoom') { + $html_output .= PMA_tblSearchGetRowsZoom( + $db, $table, $columnNames, $columnTypes, $columnCollations, + $columnNullFlags, $geomColumnFlag, $columnCount, $foreigners + ); } else { $html_output .= PMA_tblSearchGetRowsNormal( $db, $table, $columnNames, $columnTypes, $columnCollations, diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 53cf19c998..31095399cd 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -169,7 +169,6 @@ $columnCount = count($columnNames); // check also foreigners even if relwork is FALSE (to get // foreign keys from innodb) $foreigners = PMA_getForeigners($db, $table); -$tbl_fields_type = $tbl_fields_collation = $tbl_criteriaColumnNullFlags = array(); if (! isset($zoom_submit) && ! isset($criteriaColumnNames)) { $dataLabel = PMA_getDisplayField($db, $table); @@ -183,38 +182,6 @@ $url_params['db'] = $db; $url_params['table'] = $table; echo PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2'); -/** - * Set the field name,type,collation and whether null on select of a coulmn - */ -if (isset($criteriaColumnNames) && ($criteriaColumnNames[0] != 'pma_null' || $criteriaColumnNames[1] != 'pma_null')) { - for ($i = 0 ; $i < 4 ; $i++) { - if ($criteriaColumnNames[$i] != 'pma_null') { - $key = array_search($criteriaColumnNames[$i], $columnNames); - $tbl_fields_type[$i] = $columnTypes[$key]; - $tbl_fields_collation[$i] = $columnCollations[$key]; - $tbl_fields_func[$i] = ''; - $foreignData = PMA_getForeignData($foreigners, $criteriaColumnNames[$i], false, '', ''); - $tbl_fields_value[$i] = PMA_getForeignFields_Values( - $foreigners, - $foreignData, - $criteriaColumnNames[$i], - $tbl_fields_type, - $i, - $db, - $table, - $titles, - $GLOBALS['cfg']['ForeignKeyMaxLimit'], - $criteriaValues - ); - } - } -} - /* * Form for input criteria */ @@ -229,54 +196,13 @@ if (isset($criteriaColumnNames) && ($criteriaColumnNames[0] != 'pma_null' || $cr
-
- - -"; - } - ?> - - - - - - - - - - -
"; - echo __("Additional search criteria"); - echo "
- /> - -
Date: Thu, 7 Jun 2012 10:13:08 +0530 Subject: [PATCH 12/38] Remove unnecessary variable columnCount --- libraries/tbl_select.lib.php | 30 ++++++++++++------------------ tbl_select.php | 3 +-- tbl_zoom_select.php | 9 ++++----- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 161d38b7fe..8f3dee17a3 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -560,11 +560,10 @@ function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes, $geom_types * 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 * * @return string the generated HTML */ -function PMA_tblSearchGetOptions($columnNames, $columnCount) +function PMA_tblSearchGetOptions($columnNames) { $html_output = ''; $html_output .= PMA_getDivForSliderEffect('searchoptions', __('Options')); @@ -573,7 +572,7 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount) */ $html_output .= '
' . '' . __('Select columns (at least one):') . '' - . '
@@ -267,7 +231,10 @@ if (isset($zoom_submit) && $criteriaColumnNames[1] != 'pma_null' && $criteriaColumnNames[0] != $criteriaColumnNames[1] ) { - + //Set default datalabel if not selected + if ($_POST['dataLabel'] == '') { + $dataLabel = PMA_getDisplayField($db, $table); + } /* * Query generation part */ From 9b3ae37905d739f7c0b75f85764c8964f692fd41 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Thu, 7 Jun 2012 12:05:35 +0530 Subject: [PATCH 14/38] Some coding style fixes in tbl_select.lib.php --- libraries/tbl_select.lib.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index c32e42c521..0f70aade73 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -559,7 +559,7 @@ function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes, $geom_types /** * Generates formatted HTML for extra search options in table search form * - * @param array $columnNames Array containing types of all columns in the table + * @param array $columnNames Array containing types of all columns in the table * * @return string the generated HTML */ @@ -757,13 +757,13 @@ function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, * 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 + * @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 */ @@ -796,10 +796,10 @@ function PMA_tblSearchGetRowsZoom($db, $table, $columnNames, $columnTypes, . 'tableid_' . $i . '" >'; $html_output .= ''; - for ($j = 0 ; $j < count($columnNames) ; $j++) { + for ($j = 0 ; $j < count($columnNames); $j++) { if (isset($_POST['criteriaColumnNames'][$i]) - && $_POST['criteriaColumnNames'][$i] - == htmlspecialchars($columnNames[$j])) { + && $_POST['criteriaColumnNames'][$i] == htmlspecialchars($columnNames[$j]) + ) { $html_output .= ''; @@ -846,13 +846,13 @@ function PMA_tblSearchGetRowsZoom($db, $table, $columnNames, $columnTypes, * Set the field name, type, collation and value on select of a coulmn * (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 + * @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 array Array of Search criteria input */ From 60ccfbef70249454e6a37af880e5d8beceedf1a3 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Thu, 7 Jun 2012 12:22:46 +0530 Subject: [PATCH 15/38] Improve if statement that sets default datalabel --- tbl_zoom_select.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 2be956031b..bcaf569b23 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -169,9 +169,6 @@ list($columnNames, $columnTypes, $columnCollations, $columnNullFlags) // foreign keys from innodb) $foreigners = PMA_getForeigners($db, $table); -if (! isset($zoom_submit) && ! isset($criteriaColumnNames)) { - $dataLabel = PMA_getDisplayField($db, $table); -} ?>
@@ -201,14 +198,9 @@ echo PMA_tblSearchGetFieldsTableHtml( $db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, NULL, $foreigners, "zoom" ); - //Set default datalabel if not selected -if (isset($_POST['zoom_submit']) - && $_POST['criteriaColumnNames'][0] != 'pma_null' - && $_POST['criteriaColumnNames'][1] != 'pma_null') { - if ($_POST['dataLabel'] == '') { - $dataLabel = PMA_getDisplayField($db, $table); - } +if ( !isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') { + $dataLabel = PMA_getDisplayField($db, $table); } echo PMA_tblSearchGetOptionsZoom($columnNames, $dataLabel); ?> @@ -231,10 +223,6 @@ if (isset($zoom_submit) && $criteriaColumnNames[1] != 'pma_null' && $criteriaColumnNames[0] != $criteriaColumnNames[1] ) { - //Set default datalabel if not selected - if ($_POST['dataLabel'] == '') { - $dataLabel = PMA_getDisplayField($db, $table); - } /* * Query generation part */ From efbe149def3d80f6e33eb26bf6e850685bce2ed1 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Thu, 7 Jun 2012 16:31:04 +0530 Subject: [PATCH 16/38] Use PMA_tblSearchGetSelectionForm to display zoom search form --- libraries/tbl_select.lib.php | 18 +++++++++++----- tbl_zoom_select.php | 42 ++++-------------------------------- 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 0f70aade73..eaedfddc53 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -980,12 +980,13 @@ function PMA_tblSearchGetFormTag($goto, $db, $table, $searchType) * @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 + * @param string $dataLabel Label for points in zoom plot * * @return string the generated HTML for table search form */ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, $geomColumnFlag, $foreigners, - $searchType + $searchType, $dataLabel = null ) { $html_output = ''; $html_output .= '
'; @@ -1022,14 +1023,15 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, $geomColumnFlag, $foreigners, $searchType ); + /** + * Displays more search options + */ if ($searchType == 'zoom') { + $html_output .= PMA_tblSearchGetOptionsZoom($columnNames, $dataLabel); } else { $html_output .= '
' . '' . '
'; - /** - * Displays more search options for normal table search - */ $html_output .= PMA_tblSearchGetOptions($columnNames); } @@ -1041,7 +1043,13 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, . ($searchType == 'zoom' ? 'zoom_submit' : 'submit') . ($searchType == 'zoom' ? '" id="inputFormSubmitId"' : '" ') . 'value="' . __('Go') . '" />'; - $html_output .= '
'; + $html_output .= '
'; + if ($searchType == 'zoom') { + $html_output = '
' + . $html_output . ''; + } else { + $html_output .= '
'; + } return $html_output; } ?> diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index bcaf569b23..f2a71bcc4f 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -169,51 +169,17 @@ list($columnNames, $columnTypes, $columnCollations, $columnNullFlags) // foreign keys from innodb) $foreigners = PMA_getForeigners($db, $table); -?> -
-
- -
> - - - - -
- - - - -
-
- -
-
-
- Date: Thu, 7 Jun 2012 22:45:09 +0530 Subject: [PATCH 17/38] Fix logical distinction between normal and zoom search --- libraries/tbl_select.lib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index eaedfddc53..19489d24d1 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -441,12 +441,13 @@ function PMA_tblSearchBuildSqlQuery() // 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($_POST['criteriaColumnNames']) - || isset($_POST['zoom_submit']) - ) { + 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($_POST['table']); @@ -470,7 +471,7 @@ function PMA_tblSearchGenerateWhereClause() { $fullWhereClause = ''; - if (trim($_POST['customWhereClause']) != '') { + if (! isset($_POST['zoom_submit']) && trim($_POST['customWhereClause']) != '') { $fullWhereClause .= ' WHERE ' . $_POST['customWhereClause']; return $fullWhereClause; } From 8a0d2d6766297b6168aaefbb8cdfbbebcc528351 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 12:00:06 +0530 Subject: [PATCH 18/38] Remove unused variables from post_params array --- tbl_zoom_select.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index f2a71bcc4f..0f05c64311 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -40,13 +40,10 @@ $GLOBALS['js_include'][] = 'tbl_zoom_plot_jqplot.js'; * Sets globals from $_POST */ $post_params = array( - 'criteriaColumnCollations', 'dataLabel', - 'criteriaValues', 'criteriaColumnNullFlags', 'criteriaColumnNames', 'maxPlotLimit', - 'criteriaColumnTypes', 'zoom_submit', 'criteriaColumnOperators' ); From 5d636a8672911cec580e4896bb86402e1e6e4f56 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 12:27:48 +0530 Subject: [PATCH 19/38] Improve some repetitive code --- tbl_zoom_select.php | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 0f05c64311..65cc8d8cb0 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -211,27 +211,14 @@ if (isset($zoom_submit) //Append it to row array as where_clause $row['where_clause'] = $uniqueCondition[0]; - if ($dataLabel == $criteriaColumnNames[0] || $dataLabel == $criteriaColumnNames[1]) { - $data[] = array( - $criteriaColumnNames[0] => $row[$criteriaColumnNames[0]], - $criteriaColumnNames[1] => $row[$criteriaColumnNames[1]], - 'where_clause' => $uniqueCondition[0] - ); - } elseif ($dataLabel) { - $data[] = array( - $criteriaColumnNames[0] => $row[$criteriaColumnNames[0]], - $criteriaColumnNames[1] => $row[$criteriaColumnNames[1]], - $dataLabel => $row[$dataLabel], - 'where_clause' => $uniqueCondition[0] - ); - } else { - $data[] = array( - $criteriaColumnNames[0] => $row[$criteriaColumnNames[0]], - $criteriaColumnNames[1] => $row[$criteriaColumnNames[1]], - $dataLabel => '', - 'where_clause' => $uniqueCondition[0] - ); - } + $tmpData = array( + $criteriaColumnNames[0] => $row[$criteriaColumnNames[0]], + $criteriaColumnNames[1] => $row[$criteriaColumnNames[1]], + 'where_clause' => $uniqueCondition[0] + ); + $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : ''; + + $data[] = $tmpData; } /* * Form for displaying point data and also the scatter plot From a812a8919ed5e9d252624d86b70039346aa4df78 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 12:35:58 +0530 Subject: [PATCH 20/38] Remove variables left in 8a0d2d6766297b6168aae --- tbl_zoom_select.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 65cc8d8cb0..1a0b2a9bac 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -41,11 +41,8 @@ $GLOBALS['js_include'][] = 'tbl_zoom_plot_jqplot.js'; */ $post_params = array( 'dataLabel', - 'criteriaColumnNullFlags', - 'criteriaColumnNames', 'maxPlotLimit', - 'zoom_submit', - 'criteriaColumnOperators' + 'zoom_submit' ); foreach ($post_params as $one_post_param) { if (isset($_POST[$one_post_param])) { @@ -182,9 +179,9 @@ echo PMA_tblSearchGetSelectionForm( * Form for displaying query results */ if (isset($zoom_submit) - && $criteriaColumnNames[0] != 'pma_null' - && $criteriaColumnNames[1] != 'pma_null' - && $criteriaColumnNames[0] != $criteriaColumnNames[1] + && $_POST['criteriaColumnNames'][0] != 'pma_null' + && $_POST['criteriaColumnNames'][1] != 'pma_null' + && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1] ) { /* * Query generation part @@ -212,8 +209,8 @@ if (isset($zoom_submit) //Append it to row array as where_clause $row['where_clause'] = $uniqueCondition[0]; $tmpData = array( - $criteriaColumnNames[0] => $row[$criteriaColumnNames[0]], - $criteriaColumnNames[1] => $row[$criteriaColumnNames[1]], + $_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]], + $_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]], 'where_clause' => $uniqueCondition[0] ); $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : ''; From 3420f14d74ef5a3c0dd8daecd0fb1c6a99d0c727 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 14:01:08 +0530 Subject: [PATCH 21/38] Remove unuseful incremental constant in loop variable --- tbl_zoom_select.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 1a0b2a9bac..c28474b3cb 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -260,22 +260,21 @@ if (isset($zoom_submit) - - + ' + . $column_index . ' ]" id="fields_null_id_' . $column_index . '" />' : ''; ?> From 1b67cbc147cf1f04315580ca83e40115a55a2091 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 17:30:53 +0530 Subject: [PATCH 22/38] Fix legend caption in zoom search --- libraries/tbl_select.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 19489d24d1..f1793649ba 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -1000,10 +1000,10 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames, ); $html_output .= PMA_tblSearchGetFormTag($goto, $db, $table, $searchType); - $html_output .= '
'); - $html_output .= $searchType == 'zoom' - ? '' : '
'; + $html_output .= '
'; + $html_output .= ($searchType == 'zoom' + ? '' : '
'); // Set caption for fieldset if ($searchType == 'zoom') { From 228974283625cd368bc23e302801740d39d525d2 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 18:41:01 +0530 Subject: [PATCH 23/38] Improve fix: 79fcb798def03d9a3700f1aa4225d5ccec0d77b7 --- libraries/tbl_select.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index f1793649ba..61cb7cbec5 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -471,7 +471,7 @@ function PMA_tblSearchGenerateWhereClause() { $fullWhereClause = ''; - if (! isset($_POST['zoom_submit']) && trim($_POST['customWhereClause']) != '') { + if (isset($_POST['customWhereClause']) && trim($_POST['customWhereClause']) != '') { $fullWhereClause .= ' WHERE ' . $_POST['customWhereClause']; return $fullWhereClause; } From 26d8848e2c57bf4f3e61a2a681d81fccbd222002 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 8 Jun 2012 18:58:26 +0530 Subject: [PATCH 24/38] Unset temporary variable --- tbl_zoom_select.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index c28474b3cb..e0a69728d1 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -217,6 +217,7 @@ if (isset($zoom_submit) $data[] = $tmpData; } + unset($tmpData); /* * Form for displaying point data and also the scatter plot */ From 9873bdcb3ff703a99310e164d3bdae5d6aaba5ed Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 9 Jun 2012 09:59:42 +0530 Subject: [PATCH 25/38] Fix wrong function call --- libraries/tbl_select.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 61cb7cbec5..2630bf4bcd 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -926,7 +926,7 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes if ($searchType == 'zoom') { $html_output .= PMA_tblSearchGetRowsZoom( $db, $table, $columnNames, $columnTypes, $columnCollations, - $columnNullFlags, $geomColumnFlag, $foreigners + $columnNullFlags, $foreigners ); } else { $html_output .= PMA_tblSearchGetRowsNormal( From dd52a06570cd98c1247cd9ffc4d8ae628c658ecd Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 9 Jun 2012 10:13:08 +0530 Subject: [PATCH 26/38] Generalize column properties for search scripts --- libraries/tbl_select.lib.php | 166 +++++++++++++++++------------------ tbl_zoom_select.php | 3 +- 2 files changed, 81 insertions(+), 88 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 2630bf4bcd..c5fd7541dd 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -129,7 +129,7 @@ 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 string $field_type Column type * @param int $column_index Column index * @param string $db Selected database * @param string $table Selected table @@ -143,10 +143,11 @@ function PMA_tbl_getSubTabs() * for search criteria input. */ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, - $tbl_fields_type, $column_index, $db, $table, $titles, $foreignMaxLimit, + $field_type, $column_index, $db, $table, $titles, $foreignMaxLimit, $criteriaValues, $in_fbs = false, $in_zoom_search_edit = false ) { $str = ''; + $field_type = (string)$field_type; if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row']) @@ -189,7 +190,7 @@ EOT; } $str .= '>' . str_replace("'", "\'", $titles['Browse']) . ''; - } elseif (in_array($tbl_fields_type[$column_index], PMA_getGISDatatypes())) { + } elseif (in_array($field_type, PMA_getGISDatatypes())) { // g e o m e t r y $str .= ''; @@ -204,8 +205,8 @@ EOT; $str .= ''; } - } elseif (strncasecmp($tbl_fields_type[$column_index], 'enum', 4) == 0 - || (strncasecmp($tbl_fields_type[$column_index], '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 @@ -217,12 +218,12 @@ EOT; $value = explode( ', ', - str_replace("'", '', substr($tbl_fields_type[$column_index], 5, -1)) + str_replace("'", '', substr($field_type, 5, -1)) ); $cnt_value = count($value); - if ((strncasecmp($tbl_fields_type[$column_index], 'enum', 4) && ! $in_zoom_search_edit) - || (strncasecmp($tbl_fields_type[$column_index], '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 .= ''; + $func .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml( + preg_replace('@\(.*@s', '', $columnTypes[$column_index]), + $columnNullFlags[$column_index], $selected_operator + ); + $func .= ''; + $foreignData = PMA_getForeignData($foreigners, $selected_column, false, '', ''); + $value = PMA_getForeignFields_Values( + $foreigners, $foreignData, $selected_column, $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) @@ -737,8 +785,9 @@ function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, $field = $columnNames[$column_index]; $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); $html_output .= PMA_getForeignFields_Values( - $foreigners, $foreignData, $field, $columnTypes, $column_index, $db, - $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true + $foreigners, $foreignData, $field, $columnTypes[$column_index], + $column_index, $db, $table, $titles, + $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true ); $html_output .= ''; - $tbl_fields_func[$i] .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml( - preg_replace('@\(.*@s', '', $columnTypes[$key]), - $columnNullFlags[$key], $_POST['criteriaColumnOperators'][$i] - ); - $tbl_fields_func[$i] .= ''; - $foreignData = PMA_getForeignData( - $foreigners, $_POST['criteriaColumnNames'][$i], false, '', '' - ); - $tbl_fields_value[$i] = PMA_getForeignFields_Values( - $foreigners, $foreignData, $_POST['criteriaColumnNames'][$i], - $tbl_fields_type, $i, $db, $table, $titles, - $GLOBALS['cfg']['ForeignKeyMaxLimit'], $_POST['criteriaValues'] - ); - } - return array( - $tbl_fields_type, - $tbl_fields_collation, - $tbl_fields_func, - $tbl_fields_value - ); -} - /** * Generates HTML for displaying fields table in search form * diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index e0a69728d1..9e389f143a 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -115,13 +115,12 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) // check also foreigners even if relwork is FALSE (to get // foreign keys from innodb) $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); - // HTML for field values $html = PMA_getForeignFields_Values( $foreigners, $foreignData, $field, - array($_REQUEST['it'] => $columnTypes[$key]), + $columnTypes[$key], $_REQUEST['it'], $_REQUEST['db'], $_REQUEST['table'], From 052fd61fddff030ffcf25edcdd69b46202266cee Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 9 Jun 2012 11:21:09 +0530 Subject: [PATCH 27/38] Use PMA_tblSearchGetColumnProperties to change table row --- libraries/tbl_select.lib.php | 3 +++ tbl_zoom_select.php | 40 +++++++----------------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index c5fd7541dd..80a1e99478 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -707,14 +707,17 @@ function PMA_tblSearchGetColumnProperties($db, $table, $columnNames, $columnType $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, $selected_column, false, '', ''); $value = PMA_getForeignFields_Values( $foreigners, $foreignData, $selected_column, $type, $search_index, diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 9e389f143a..910003cd7f 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -90,45 +90,19 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) $extra_data['field_operators'] = ''; PMA_ajaxResponse(null, true, $extra_data); } - - // Gets the list and number of fields list($columnNames, $columnTypes, $columnCollations, $columnNullFlags) = PMA_tbl_getFields($_REQUEST['db'], $_REQUEST['table']); - $foreigners = PMA_getForeigners($db, $table); - $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); $key = array_search($field, $columnNames); - $extra_data['field_type'] = $columnTypes[$key]; - $extra_data['field_collation'] = $columnCollations[$key]; - - // HTML for operators - $html = ''; - $extra_data['field_operators'] = $html; - - // retrieve keys into foreign fields, if any - // check also foreigners even if relwork is FALSE (to get - // foreign keys from innodb) - $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); - // HTML for field values - $html = PMA_getForeignFields_Values( - $foreigners, - $foreignData, - $field, - $columnTypes[$key], - $_REQUEST['it'], - $_REQUEST['db'], - $_REQUEST['table'], - $titles, - $GLOBALS['cfg']['ForeignKeyMaxLimit'], - '' - ); - $extra_data['field_value'] = $html; + $extra_data['field_type'] = $properties['type']; + $extra_data['field_collation'] = $properties['collation']; + $extra_data['field_operators'] = $properties['func']; + $extra_data['field_value'] = $properties['value']; PMA_ajaxResponse(null, true, $extra_data); } From 46d38714272730eca835b0ff0e50d1e67c52657f Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 9 Jun 2012 12:57:27 +0530 Subject: [PATCH 28/38] Use PMA_tblSearchGetColumnProperties to get normal search rows --- libraries/tbl_select.lib.php | 51 +++++++++++------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 80a1e99478..5ea75f1915 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -699,9 +699,6 @@ function PMA_tblSearchGetOptionsZoom($columnNames, $dataLabel) function PMA_tblSearchGetColumnProperties($db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, $foreigners, $search_index, $column_index ) { - $selected_column = isset($_POST['criteriaColumnNames']) - ? $_POST['criteriaColumnNames'][$search_index] - : (isset($_REQUEST['field']) ? $_REQUEST['field'] : ''); $selected_operator = (isset($_POST['criteriaColumnOperators']) ? $_POST['criteriaColumnOperators'][$search_index] : ''); $entered_value = (isset($_POST['criteriaValues']) @@ -718,9 +715,11 @@ function PMA_tblSearchGetColumnProperties($db, $table, $columnNames, $columnType ); $func .= ''; //Gets link to browse foreign data(if any) and criteria inputbox - $foreignData = PMA_getForeignData($foreigners, $selected_column, false, '', ''); + $foreignData = PMA_getForeignData( + $foreigners, $columnNames[$column_index], false, '', '' + ); $value = PMA_getForeignFields_Values( - $foreigners, $foreignData, $selected_column, $type, $search_index, + $foreigners, $foreignData, $columnNames[$column_index], $type, $search_index, $db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], $entered_value ); return array( @@ -757,42 +756,24 @@ function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes, for ($column_index = 0; $column_index < count($columnNames); $column_index++) { $html_output .= ''; $odd_row = !$odd_row; - - /** - * If 'Function' column is present - */ + //If 'Function' column is present $html_output .= PMA_tblSearchGetGeomFuncHtml( $geomColumnFlag, $columnTypes, $geom_types, $column_index ); - /** - * Displays column's name, type and collation - */ + //Displays column's name, type, collation and value $html_output .= '' . htmlspecialchars($columnNames[$column_index]) . ''; - $html_output .= '' . htmlspecialchars($columnTypes[$column_index]) - . ''; - $html_output .= '' . $columnCollations[$column_index] . ''; - /** - * Displays column's comparison operators depending on column type - */ - $html_output .= ''; - /** - * Displays link to browse foreign data(if any) and criteria inputbox - */ - $html_output .= ''; - $field = $columnNames[$column_index]; - $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); - $html_output .= PMA_getForeignFields_Values( - $foreigners, $foreignData, $field, $columnTypes[$column_index], - $column_index, $db, $table, $titles, - $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true - ); - + $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 .= ''; From 291249330a34524d2fb2cf481eb15a4d8edd3198 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 9 Jun 2012 13:16:25 +0530 Subject: [PATCH 29/38] Fix column operator field's name --- libraries/tbl_select.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 5ea75f1915..cf413d8e43 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -708,7 +708,7 @@ function PMA_tblSearchGetColumnProperties($db, $table, $columnNames, $columnType $type = $columnTypes[$column_index]; $collation = $columnCollations[$column_index]; //Gets column's comparison operators depending on column type - $func = ''; $func .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml( preg_replace('@\(.*@s', '', $columnTypes[$column_index]), $columnNullFlags[$column_index], $selected_operator From 745598a090f09d19f38d88e5aa3b5702734674b6 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 9 Jun 2012 13:20:46 +0530 Subject: [PATCH 30/38] Fix AJAX response extra_data in zoom search --- tbl_zoom_select.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 910003cd7f..c1036a1154 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -88,6 +88,7 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) $extra_data['field_type'] = ''; $extra_data['field_collation'] = ''; $extra_data['field_operators'] = ''; + $extra_data['field_value'] = ''; PMA_ajaxResponse(null, true, $extra_data); } // Gets the list and number of fields From 8c2e27e972cabcc4d3c81e5542649cba4e1a3ffd Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 17:47:17 +0100 Subject: [PATCH 31/38] Fixed invalid HTML tag --- js/server_variables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/server_variables.js b/js/server_variables.js index ef453f02d4..c54b27255a 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -170,7 +170,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); From f6330a3f1773092d2e07c6da65116436e0c96187 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 10 Jun 2012 07:53:14 -0400 Subject: [PATCH 32/38] Unnecessary comma is harmful under IE --- js/tbl_zoom_plot_jqplot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 006e6cd15e..7476db0e2f 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); From c4a307f91506e52252d9ed585af437ce476400ae Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 10 Jun 2012 19:03:26 +0530 Subject: [PATCH 33/38] Fix bug introduced due to incremental variable --- js/tbl_zoom_plot_jqplot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 7476db0e2f..27f977c164 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -264,7 +264,7 @@ $(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) { @@ -550,14 +550,14 @@ $(document).ready(function() { $('div#querychart').bind('jqplotDataClick', function(event, seriesIndex, pointIndex, data) { - searchedDataKey = data[4]; // key from searchedData (global) - var field_id = 4; + searchedDataKey = data[0]; // key from searchedData (global) + var field_id = 0; var post_params = { 'ajax_request' : true, 'get_data_row' : true, 'db' : window.parent.db, 'table' : window.parent.table, - 'where_clause' : data[3], + 'where_clause' : data[0], 'token' : window.parent.token }; From 5336e1805194614ef285624d7c48515e1ca814d4 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sun, 10 Jun 2012 14:41:42 +0100 Subject: [PATCH 34/38] Dropped duplicate nocache setting for ajax requests in server_status --- js/server_status.js | 4 ---- 1 file changed, 4 deletions(-) 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 From b1855ec0b428ea8ba62f752e5fdca51c5b3881a9 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sun, 10 Jun 2012 14:46:55 +0100 Subject: [PATCH 35/38] Fixed bug #3534121 - duplicate line in config.sample.inc.php --- ChangeLog | 1 + config.sample.inc.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 310bd1bb0c..571627341a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ phpMyAdmin - ChangeLog - 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 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 a98d548022..da61640ffa 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'; From d7ab56f37bc78945693df8876b35e2e5cde2f7cf Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Mon, 11 Jun 2012 15:52:43 +0530 Subject: [PATCH 36/38] Fix zoom search point edit bug --- js/tbl_zoom_plot_jqplot.js | 14 +++++++------- libraries/tbl_select.lib.php | 17 +++++++++-------- tbl_zoom_select.php | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 27f977c164..994d35e8c2 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -269,9 +269,9 @@ $(document).ready(function() { 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'; } @@ -550,14 +550,14 @@ $(document).ready(function() { $('div#querychart').bind('jqplotDataClick', function(event, seriesIndex, pointIndex, data) { - searchedDataKey = data[0]; // key from searchedData (global) + searchedDataKey = data[4]; // key from searchedData (global) var field_id = 0; var post_params = { 'ajax_request' : true, 'get_data_row' : true, 'db' : window.parent.db, 'table' : window.parent.table, - 'where_clause' : data[0], + 'where_clause' : data[3], 'token' : window.parent.token }; @@ -565,8 +565,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/tbl_select.lib.php b/libraries/tbl_select.lib.php index cf413d8e43..e481e074b8 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -148,13 +148,14 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, ) { $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 @@ -169,12 +170,12 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, if (isset($criteriaValues[$column_index]) && is_string($criteriaValues[$column_index]) ) { - $str .= ''; } else { - $str .= ''; @@ -226,10 +227,10 @@ EOT; || (strncasecmp($field_type, 'set', 3) && $in_zoom_search_edit) ) { $str .= ''; } @@ -263,12 +264,12 @@ EOT; && is_string($criteriaValues[$column_index]) ) { $str .= ''; } else { $str .= ''; } } diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index c1036a1154..f2ddbc7ed8 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -243,7 +243,7 @@ if (isset($zoom_submit) ' + . $column_index . ' ]" id="edit_fields_null_id_' . $column_index . '" />' : ''; ?> Date: Mon, 11 Jun 2012 16:46:41 +0530 Subject: [PATCH 37/38] Fix mangled datalabels bug(zoom search) in case of chromium browser --- js/tbl_zoom_plot_jqplot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 994d35e8c2..e7d60eeb8d 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -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(); From ddd1eac48069ebd0d66acaea802cdcb3ee0fdeac Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 11 Jun 2012 14:00:18 +0100 Subject: [PATCH 38/38] Fixed bug #3534311 - Grid editing incorrectly parses ENUM/SET values --- ChangeLog | 1 + enum_editor.php | 34 ++----------------------------- libraries/common.lib.php | 44 ++++++++++++++++++++++++++++++++++++++++ sql.php | 11 ++++------ 4 files changed, 51 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 571627341a..06335dc854 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ phpMyAdmin - ChangeLog - 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/enum_editor.php b/enum_editor.php index 10e0ba30a9..1c2256f682 100644 --- a/enum_editor.php +++ b/enum_editor.php @@ -43,39 +43,9 @@ require_once './libraries/header_meta_style.inc.php'; foreach ($values as $key => $value) { $values[$key] = htmlentities($value); } - // If the values are in a string } elseif (isset($_GET['values']) && is_string($_GET['values'])) { - // then this page was called via a link from some external page - $values_string = htmlentities($_GET['values']); - // 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; - } + // Parse the values from a string + $values = PMA_parseEnumSetValues($_GET['values']); } // Escape double quotes foreach ($values as $key => $value) { diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 5c1d4b3dba..fb9ac29611 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3839,4 +3839,48 @@ function PMA_printButton() echo ''; echo '

'; } + +/** + * 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/sql.php b/sql.php index a6b9fe29e7..23d886fa37 100644 --- a/sql.php +++ b/sql.php @@ -125,13 +125,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 .= '