From 9f14151c7ca8968210346ab1cacfda071fdf306e Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 1 Jun 2012 12:42:50 +0530 Subject: [PATCH 001/116] 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 002/116] 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 003/116] 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 006/116] 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 007/116] 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 008/116] 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 009/116] 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 010/116] 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 011/116] 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 012/116] 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 014/116] 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 015/116] 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 016/116] 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 017/116] 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 018/116] 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 019/116] 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 020/116] 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 021/116] 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 022/116] 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 023/116] 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 024/116] 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 025/116] 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 026/116] 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 027/116] 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 028/116] 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 029/116] 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 030/116] 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 c4a307f91506e52252d9ed585af437ce476400ae Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 10 Jun 2012 19:03:26 +0530 Subject: [PATCH 031/116] 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 d7ab56f37bc78945693df8876b35e2e5cde2f7cf Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Mon, 11 Jun 2012 15:52:43 +0530 Subject: [PATCH 032/116] 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 033/116] 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 034/116] 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 .= '
- diff --git a/db_search.php b/db_search.php index 4d12e8fe3a..1222e42d41 100644 --- a/db_search.php +++ b/db_search.php @@ -371,9 +371,3 @@ $alter_select - diff --git a/db_sql.php b/db_sql.php index aa82ef946b..baced44072 100644 --- a/db_sql.php +++ b/db_sql.php @@ -62,8 +62,4 @@ PMA_sqlQueryForm( isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';' ); -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_structure.php b/db_structure.php index cb5a765fa7..d711e0e75a 100644 --- a/db_structure.php +++ b/db_structure.php @@ -89,11 +89,6 @@ if ($num_tables == 0) { if (empty($db_is_information_schema)) { include 'libraries/display_create_table.lib.php'; } // end if (Create Table dialog) - - /** - * Displays the footer - */ - include_once 'libraries/footer.inc.php'; exit; } @@ -759,8 +754,4 @@ if (empty($db_is_information_schema)) { include 'libraries/display_create_table.lib.php'; } // end if (Create Table dialog) -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_tracking.php b/db_tracking.php index 5cc0b90e30..91b33147a3 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -52,9 +52,6 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) { if (empty($db_is_information_schema)) { include 'libraries/display_create_table.lib.php'; } - - // Display the footer - include 'libraries/footer.inc.php'; exit; } @@ -231,8 +228,4 @@ if (count($data['ddlog']) > 0) { echo PMA_getMessage(__('Database Log'), $log); } -/** - * Display the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/export.php b/export.php index c79ebe9e4e..48dbb58a56 100644 --- a/export.php +++ b/export.php @@ -765,7 +765,7 @@ if (! empty($asfile)) { } } - /* If ve saved on server, we have to close file now */ + /* If we saved on server, we have to close file now */ if ($save_on_server) { $write_result = @fwrite($file_handle, $dump_buffer); fclose($file_handle); @@ -797,6 +797,7 @@ if (! empty($asfile)) { } exit(); } else { + PMA_Response::getInstance()->disable(); echo $dump_buffer; } } else { @@ -834,6 +835,5 @@ if (! empty($asfile)) { //]]> diff --git a/import.php b/import.php index 7dcf9966c6..cc8cd5f811 100644 --- a/import.php +++ b/import.php @@ -94,7 +94,7 @@ if ($_POST == array() && $_GET == array()) { $_SESSION['Import_message']['go_back_url'] = $goto; $message->display(); - include 'libraries/footer.inc.php'; + exit; // the footer is displayed automatically } /** @@ -524,5 +524,4 @@ if ($go_sql) { $active_page = $goto; include '' . $goto; } -exit(); ?> diff --git a/js/common.js b/js/common.js index 79453153cb..449f35ff94 100644 --- a/js/common.js +++ b/js/common.js @@ -159,7 +159,7 @@ function markDbTable(db, table) } /** - * sets current selected server, table and db (called from libraries/footer.inc.php) + * sets current selected server, table and db (called from the footer) */ function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token ) { diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php index 013c0f0235..e11a2f49c6 100644 --- a/libraries/PDF.class.php +++ b/libraries/PDF.class.php @@ -88,7 +88,7 @@ class PMA_PDF extends TCPDF $response = PMA_Response::getInstance(); $response->getHeader()->display(); PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display(); - include './libraries/footer.inc.php'; + exit; } /** diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 01a32d4cc3..a6ed1e640d 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -703,10 +703,7 @@ function PMA_mysqlDie( } echo $error_msg; - /** - * display footer and exit - */ - include './libraries/footer.inc.php'; + exit; } else { echo $error_msg; } diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index f21a71bc9d..37cc81b4c3 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -38,7 +38,7 @@ $export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $exp /* Fail if we didn't find any plugin */ if (empty($export_list)) { PMA_Message::error(__('Could not load export plugins, please check your installation!'))->display(); - include './libraries/footer.inc.php'; + exit; } ?> diff --git a/libraries/display_import.lib.php b/libraries/display_import.lib.php index b25a679525..7d5d5fb950 100644 --- a/libraries/display_import.lib.php +++ b/libraries/display_import.lib.php @@ -21,7 +21,7 @@ $import_list = PMA_getPlugins('./libraries/import/', $import_type); /* Fail if we didn't find any plugin */ if (empty($import_list)) { PMA_Message::error(__('Could not load import plugins, please check your installation!'))->display(); - include './libraries/footer.inc.php'; + exit; } ?> diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php deleted file mode 100644 index 1f5e448c87..0000000000 --- a/libraries/footer.inc.php +++ /dev/null @@ -1,27 +0,0 @@ -getFooter(); -//$footer->display(); - -exit; - -?> diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 4500c393e2..007c1a3eb1 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -126,8 +126,7 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id, if (! $rows[$key_id]) { unset($rows[$key_id], $where_clause_array[$key_id]); PMA_showMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query); - echo "\n"; - include 'libraries/footer.inc.php'; + exit; } else {// end if (no row returned) $meta = PMA_DBI_get_fields_meta($result[$key_id]); list($unique_condition, $tmp_clause_is_unique) diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 5b7dd44ea8..856742a021 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -324,7 +324,7 @@ if (!empty($submit_mult) && !empty($what)) {
$title\n\n$editor"; unset($_POST); - include './libraries/footer.inc.php'; } - // exit; + exit; } else { $message = __('Error in processing request') . ' : '; $message .= sprintf( diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php index fa5226bda9..b9a559ac8b 100644 --- a/libraries/rte/rte_main.inc.php +++ b/libraries/rte/rte_main.inc.php @@ -87,11 +87,4 @@ case 'EVN': break; } -/** - * Display the footer, if necessary - */ -if ($GLOBALS['is_ajax_request'] != true) { - include './libraries/footer.inc.php'; -} - ?> diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 69cda0d833..da85edd8ee 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -366,8 +366,7 @@ function PMA_RTN_handleEditor() PMA_ajaxResponse($editor, true, $extra_data); } echo "\n\n

$title

\n\n$editor"; - include './libraries/footer.inc.php'; - // exit; + exit; } else { $message = __('Error in processing request') . ' : '; $message .= sprintf( @@ -1317,8 +1316,7 @@ function PMA_RTN_handleExecute() } else { echo "\n\n

" . __("Execute routine") . "

\n\n"; echo $form; - include './libraries/footer.inc.php'; - // exit; + exit; } } else if (($GLOBALS['is_ajax_request'] == true)) { $message = __('Error in processing request') . ' : '; diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php index 11a4592bb5..25414eadd3 100644 --- a/libraries/rte/rte_triggers.lib.php +++ b/libraries/rte/rte_triggers.lib.php @@ -180,9 +180,8 @@ function PMA_TRI_handleEditor() } else { echo "\n\n

$title

\n\n$editor"; unset($_POST); - include './libraries/footer.inc.php'; } - // exit; + exit; } else { $message = __('Error in processing request') . ' : '; $message .= sprintf( diff --git a/libraries/schema/Export_Relation_Schema.class.php b/libraries/schema/Export_Relation_Schema.class.php index 26bc8f19cd..3c61e8e07e 100644 --- a/libraries/schema/Export_Relation_Schema.class.php +++ b/libraries/schema/Export_Relation_Schema.class.php @@ -239,8 +239,7 @@ class PMA_Export_Relation_Schema . '&do=selectpage&chpage=' . $pageNumber . '&action_choose=0' . '">' . __('Back') . ''; echo "\n"; - include_once './libraries/footer.inc.php'; - exit(); + exit; } } ?> diff --git a/main.php b/main.php index 6da2886067..def28a0521 100644 --- a/main.php +++ b/main.php @@ -453,9 +453,4 @@ function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = nu } echo ''; } - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/prefs_forms.php b/prefs_forms.php index 5b7c435667..b0ae664978 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -89,9 +89,4 @@ if ($form_display->hasErrors()) { display(true, true); - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/prefs_manage.php b/prefs_manage.php index 94977aa6de..ff639e082b 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -133,8 +133,7 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') ==
- diff --git a/schema_edit.php b/schema_edit.php index e472ab5f6e..6067cb42b7 100644 --- a/schema_edit.php +++ b/schema_edit.php @@ -35,24 +35,24 @@ $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['relwork']) { echo sprintf(__('%s table not found or not set in %s'), 'relation', 'config.inc.php') . '
' . "\n" . PMA_showDocu('relation') . "\n"; - include_once 'libraries/footer.inc.php'; + exit; } if (! $cfgRelation['displaywork']) { echo sprintf(__('%s table not found or not set in %s'), 'table_info', 'config.inc.php') . '
' . "\n" . PMA_showDocu('table_info') . "\n"; - include_once 'libraries/footer.inc.php'; + exit; } if (! isset($cfgRelation['table_coords'])) { echo sprintf(__('%s table not found or not set in %s'), 'table_coords', 'config.inc.php') . '
' . "\n" . PMA_showDocu('table_coords') . "\n"; - include_once 'libraries/footer.inc.php'; + exit; } if (! isset($cfgRelation['pdf_pages'])) { echo sprintf(__('%s table not found or not set in %s'), 'pdf_page', 'config.inc.php') . '
' . "\n" . PMA_showDocu('pdf_pages') . "\n"; - include_once 'libraries/footer.inc.php'; + exit; } if ($cfgRelation['pdfwork']) { @@ -123,9 +123,4 @@ if ($cfgRelation['pdfwork']) { } // end if } // end if ($cfgRelation['pdfwork']) -/** - * Displays the footer - */ -echo "\n"; -require_once 'libraries/footer.inc.php'; ?> diff --git a/server_binlog.php b/server_binlog.php index 679674bc57..81fa58c8e3 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -202,12 +202,3 @@ while ($value = PMA_DBI_fetch_assoc($result)) { ?> - diff --git a/server_collations.php b/server_collations.php index 5e7844345b..b3872fc253 100644 --- a/server_collations.php +++ b/server_collations.php @@ -81,6 +81,4 @@ unset($table_row_count); echo '' . "\n" . '' . "\n"; -require 'libraries/footer.inc.php'; - ?> diff --git a/server_databases.php b/server_databases.php index cacf35c9be..f267fb9d7d 100644 --- a/server_databases.php +++ b/server_databases.php @@ -313,9 +313,4 @@ if ($databases_count > 0) { } unset($databases_count); -/** - * Sends the footer - */ -require 'libraries/footer.inc.php'; - ?> diff --git a/server_engines.php b/server_engines.php index c50723ce78..1a8a0cadf6 100644 --- a/server_engines.php +++ b/server_engines.php @@ -126,9 +126,4 @@ if (empty($_REQUEST['engine']) } } -/** - * Sends the footer - */ -require 'libraries/footer.inc.php'; - ?> diff --git a/server_export.php b/server_export.php index 910d574730..a080fd0946 100644 --- a/server_export.php +++ b/server_export.php @@ -60,9 +60,4 @@ $multi_values .= ''; $export_type = 'server'; require_once 'libraries/display_export.lib.php'; - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/server_import.php b/server_import.php index 13c93df45b..2a7d38f7df 100644 --- a/server_import.php +++ b/server_import.php @@ -22,9 +22,6 @@ require 'libraries/server_common.inc.php'; $import_type = 'server'; require 'libraries/display_import.lib.php'; -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; + ?> diff --git a/server_plugins.php b/server_plugins.php index 16fb6d5799..5c4c6ffdda 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -183,10 +183,3 @@ pma_theme_image = ''; - diff --git a/server_privileges.php b/server_privileges.php index 673d3fd47c..0bf3955079 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -182,7 +182,7 @@ if (! $is_superuser) { . __('Privileges') . "\n" . '' . "\n"; PMA_Message::error(__('No Privileges'))->display(); - include 'libraries/footer.inc.php'; + exit; } // a random number that will be appended to the id of the user forms @@ -2034,7 +2034,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs if ($user_does_not_exists) { PMA_Message::error(__('The selected user was not found in the privilege table.'))->display(); PMA_displayLoginInformationFields(); - //require 'libraries/footer.inc.php'; + //exit; } echo '
' . "\n"; @@ -2584,11 +2584,4 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } // end if (empty($_REQUEST['adduser']) && empty($checkprivs)) ... elseif ... else ... - -/** - * Displays the footer - */ -echo "\n\n"; -require 'libraries/footer.inc.php'; - ?> diff --git a/server_replication.php b/server_replication.php index bdace06135..dcecc0e422 100644 --- a/server_replication.php +++ b/server_replication.php @@ -33,7 +33,7 @@ if (! $is_superuser) { . __('Replication') . "\n" . '' . "\n"; PMA_Message::error(__('No Privileges'))->display(); - include 'libraries/footer.inc.php'; + exit; } /** @@ -265,7 +265,6 @@ if (isset($GLOBALS['mr_configure'])) { echo '
'; echo '
'; - include 'libraries/footer.inc.php'; exit; } @@ -398,5 +397,4 @@ if (! isset($GLOBALS['repl_clear_scr'])) { if (isset($GLOBALS['sl_configure'])) { PMA_replication_gui_changemaster("slave_changemaster"); } -require 'libraries/footer.inc.php'; ?> diff --git a/server_sql.php b/server_sql.php index fbaf554556..408d2b2858 100644 --- a/server_sql.php +++ b/server_sql.php @@ -27,8 +27,4 @@ require_once 'libraries/sql_query_form.lib.php'; */ PMA_sqlQueryForm(); -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/server_status.php b/server_status.php index 737b861178..93d0157042 100644 --- a/server_status.php +++ b/server_status.php @@ -1839,8 +1839,4 @@ function cleanDeprecated(&$server_status) } } -/** - * Sends the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/server_synchronize.php b/server_synchronize.php index cceb1ec2d1..51fc214044 100644 --- a/server_synchronize.php +++ b/server_synchronize.php @@ -1487,8 +1487,4 @@ if (! isset($_REQUEST['submit_connect'])
' . __('Target database will be completely synchronized with source database. Source database will remain unchanged.') . '
'; } - /** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/server_variables.php b/server_variables.php index 41f01b62fb..7a5e1c49fe 100644 --- a/server_variables.php +++ b/server_variables.php @@ -184,9 +184,4 @@ function formatVariable($name, $value) return htmlspecialchars($value); } -/** - * Sends the footer - */ -require 'libraries/footer.inc.php'; - ?> diff --git a/sql.php b/sql.php index 5343b5fcfe..b018530e90 100644 --- a/sql.php +++ b/sql.php @@ -418,10 +418,7 @@ if ($do_confirm) { echo '
' . "\n" . '' . "\n"; - /** - * Displays the footer and exit - */ - include 'libraries/footer.inc.php'; + exit; } // end if $do_confirm @@ -1127,6 +1124,6 @@ $(makeProfilingChart); * Displays the footer */ if (! isset($_REQUEST['table_maintenance'])) { - include 'libraries/footer.inc.php'; + exit; } ?> diff --git a/tbl_addfield.php b/tbl_addfield.php index 74664c55ec..015c235bd9 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -230,9 +230,6 @@ if ($abort == false) { */ $action = 'tbl_addfield.php'; include_once 'libraries/tbl_properties.inc.php'; - - // Diplays the footer - include 'libraries/footer.inc.php'; } ?> diff --git a/tbl_alter.php b/tbl_alter.php index 4da743c6cc..8c41860fa0 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -317,10 +317,4 @@ if ($abort == false) { */ include 'libraries/tbl_properties.inc.php'; } - - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_change.php b/tbl_change.php index ea89f7b500..db2a667826 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -387,9 +387,5 @@ if ($insert_mode) { $html_output .= PMA_getContinueInsertionForm($table, $db, $where_clause_array, $err_url); } echo $html_output; -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_chart.php b/tbl_chart.php index ce35a8ce18..66f7419b10 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -158,10 +158,3 @@ url_query = ''; chart_data = '<', '>' => '>')); ?>; //]]> - diff --git a/tbl_create.php b/tbl_create.php index 6051751c4e..b4945a93b2 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -367,8 +367,6 @@ if ($GLOBALS['is_ajax_request'] != true) { } require 'libraries/tbl_properties.inc.php'; -// Displays the footer -require 'libraries/footer.inc.php'; if ($GLOBALS['is_ajax_request'] != true) { echo(''); diff --git a/tbl_export.php b/tbl_export.php index 7d261f8d39..042fd9a001 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -84,10 +84,4 @@ if (! empty($sql_query)) { $export_type = 'table'; require_once 'libraries/display_export.lib.php'; - - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_gis_visualization.php b/tbl_gis_visualization.php index 98baeaf8ee..73ea8210ab 100644 --- a/tbl_gis_visualization.php +++ b/tbl_gis_visualization.php @@ -192,10 +192,3 @@ $visualization = PMA_GIS_visualizationResults($data, $visualizationSettings, $fo - diff --git a/tbl_import.php b/tbl_import.php index fb864b2fe1..9c399e0bd6 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -26,9 +26,5 @@ require_once 'libraries/tbl_info.inc.php'; $import_type = 'table'; require_once 'libraries/display_import.lib.php'; -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_indexes.php b/tbl_indexes.php index 2eca4f94e9..dc07c9c925 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -320,10 +320,3 @@ echo '' . "\n" ?> - diff --git a/tbl_operations.php b/tbl_operations.php index 9baa8c5d2a..3d44a7e684 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -860,13 +860,6 @@ if ($cfgRelation['relwork'] && ! $is_innodb) { } // end if (!empty($cfg['Server']['relation'])) - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; - - function PMA_set_global_variables_for_engine($tbl_storage_engine) { global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt; diff --git a/tbl_printview.php b/tbl_printview.php index 4da57090aa..4c7ec509dc 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -472,6 +472,4 @@ foreach ($the_tables as $key => $table) { PMA_printButton(); echo "
\n"; - -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_relation.php b/tbl_relation.php index cbe36ceee6..0bf1941393 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -575,8 +575,4 @@ if (count($columns) > 0) { diff --git a/tbl_row_action.php b/tbl_row_action.php index f4414a1a85..d55e5e0b03 100644 --- a/tbl_row_action.php +++ b/tbl_row_action.php @@ -21,7 +21,7 @@ if (! PMA_isValid($_REQUEST['rows_to_delete'], 'array') $disp_message = __('No rows selected'); $disp_query = ''; include 'sql.php'; - include 'libraries/footer.inc.php'; + exit; } if (isset($_REQUEST['submit_mult'])) { @@ -137,11 +137,6 @@ if (!empty($submit_mult)) { $active_page = 'sql.php'; include 'sql.php'; - - /** - * Displays the footer - */ - include 'libraries/footer.inc.php'; break; } } diff --git a/tbl_select.php b/tbl_select.php index 81762f60cf..d956d5009c 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -71,8 +71,6 @@ if (! isset($_POST['columnsToDisplay']) || $_POST['columnsToDisplay'][0] == '') $goto, $db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, $geomColumnFlag, $foreigners, "normal" ); - - include 'libraries/footer.inc.php'; } else { /** * Selection criteria have been submitted -> do the work diff --git a/tbl_sql.php b/tbl_sql.php index 3ec346bb7f..b06be2760c 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -43,8 +43,4 @@ PMA_sqlQueryForm( isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';' ); -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_structure.php b/tbl_structure.php index 2bf35b1906..8ccc21782d 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -1001,8 +1001,4 @@ if ($cfg['ShowStats']) { echo '
' . "\n"; -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/tbl_tracking.php b/tbl_tracking.php index eb9d760bd8..17ab096eaf 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -816,9 +816,3 @@ if ($last_version > 0) {
- diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 27a16633ed..cdb37b5b38 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -264,5 +264,4 @@ if (isset($zoom_submit) diff --git a/transformation_overview.php b/transformation_overview.php index cfe0d809b2..6caea6a4d1 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -62,9 +62,3 @@ foreach ($types['transformation'] as $key => $transform) { - diff --git a/user_password.php b/user_password.php index 2be7b839c6..575cc575e0 100644 --- a/user_password.php +++ b/user_password.php @@ -27,7 +27,7 @@ if (! $cfg['ShowChgPassword']) { if ($cfg['Server']['auth_type'] == 'config' || ! $cfg['ShowChgPassword']) { $header->display(); PMA_Message::error(__('You don\'t have sufficient privileges to be here right now!'))->display(); - include './libraries/footer.inc.php'; + exit; } // end if /** @@ -61,11 +61,7 @@ if (isset($message)) { } require_once './libraries/display_change_password.lib.php'; - -/** - * Displays the footer - */ -require './libraries/footer.inc.php'; +exit; /** * Send the message as an ajax request @@ -211,6 +207,6 @@ function PMA_changePassDisplayPage($message, $sql_query, $_url_params) echo PMA_getMessage($message, $sql_query, 'success'); echo ''. "\n" .''.__('Back').''; - include './libraries/footer.inc.php'; + exit; } ?> diff --git a/view_create.php b/view_create.php index 2808144638..b0cf55764b 100644 --- a/view_create.php +++ b/view_create.php @@ -186,10 +186,3 @@ $url_params['reload'] = 1; ?> - diff --git a/view_operations.php b/view_operations.php index 700610fe56..7205668cbc 100644 --- a/view_operations.php +++ b/view_operations.php @@ -96,9 +96,3 @@ $url_params['back'] = 'view_operations.php'; - From ed853f9e7c8e35be073457df632a9fc5416a674b Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 2 Jun 2012 14:56:02 +0100 Subject: [PATCH 080/116] Fixed undefined variable --- user_password.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/user_password.php b/user_password.php index 575cc575e0..d43959dc4b 100644 --- a/user_password.php +++ b/user_password.php @@ -178,7 +178,10 @@ function PMA_changePassAuthType($_url_params, $password) * Duration = till the browser is closed for password (we don't want this to be saved) */ if ($GLOBALS['cfg']['Server']['auth_type'] == 'cookie') { - $GLOBALS['PMA_Config']->setCookie('pmaPass-' . $server, PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret'])); + $GLOBALS['PMA_Config']->setCookie( + 'pmaPass-' . $GLOBALS['server'], + PMA_blowfish_encrypt($password, $GLOBALS['cfg']['blowfish_secret']) + ); } /** * For http auth. mode, the "back" link will also enforce new From bc7753ee7ccdd6c6509c0656470795c3403820fa Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 2 Jun 2012 14:56:32 +0100 Subject: [PATCH 081/116] Don't display error messages in ajax responses --- libraries/Footer.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 2241b00103..711472f822 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -327,9 +327,9 @@ class PMA_Footer // display Footnotes and error messages even in ajax reqests // FIXME: nootnotes should be sent as JSON $retval .= $this->_footnotes->getDisplay(); - $retval .= $this->_getErrorMessages(); } if (! $this->_isAjax && ! $this->_isMinimal) { + $retval .= $this->_getErrorMessages(); $retval .= $this->_scripts->getDisplay(); // Include possible custom footers if (file_exists(CUSTOM_FOOTER_FILE)) { From 3cf937022ee6d0a164f39780acf69b4602642d95 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 2 Jun 2012 15:34:32 +0100 Subject: [PATCH 082/116] Integrated ajax responses from user_password.php with PMA_Response class --- js/functions.js | 2 +- libraries/Response.class.php | 46 +++++++++++++++++++++++++++++------- user_password.php | 13 +++++++--- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/js/functions.js b/js/functions.js index 1cf4adc9f3..5dd7c8d65b 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2631,7 +2631,7 @@ $(function() { $.post($the_form.attr('action'), $the_form.serialize() + '&change_pw='+ this_value, function(data) { if (data.success == true) { - $("#floating_menubar").after(data.sql_query); + $("#floating_menubar").after(data.message); $("#change_password_dialog").hide().remove(); $("#edit_user_dialog").dialog("close").remove(); $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax'); diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 79bda66f21..10bed3d265 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -66,6 +66,14 @@ class PMA_Response * @var bool */ private $_isAjax; + /** + * Whether there were any errors druing the processing of the request + * Only used for ajax responses + * + * @access private + * @var bool + */ + private $_isSuccess; /** * Cretes a new class instance @@ -81,6 +89,7 @@ class PMA_Response $this->_JSON = array(); $this->_footer = new PMA_Footer(); + $this->_isSuccess = true; $this->_isAjax = false; if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { $this->_isAjax = true; @@ -102,6 +111,20 @@ class PMA_Response return self::$_instance; } + /** + * FIXME + * + * @return void + */ + public function isSuccess($state) + { + if ($state) { + $this->_isSuccess = true; + } else { + $this->_isSuccess = false; + } + } + /** * Disables the rendering of the header * and the footer in responses @@ -144,8 +167,10 @@ class PMA_Response */ public function addHTML($content) { - if (is_string($content)) { - $this->_HTML .= $content; + if ($value instanceof PMA_Message) { + $this->_HTML = $value->getDisplay(); + } else { + $this->_HTML = $value; } } @@ -166,7 +191,11 @@ class PMA_Response $this->addJSON($key, $value); } } else { - $this->_JSON[$json] .= $value; + if ($value instanceof PMA_Message) { + $this->_JSON[$json] = $value->getDisplay(); + } else { + $this->_JSON[$json] = $value; + } } } @@ -209,13 +238,12 @@ class PMA_Response // header('Content-Type: text/html; charset=utf-8'); echo $this->_getDisplay(); } else { - if (isset($this->_JSON['message'])) { - $message = $this->_JSON['message']; - unset($this->_JSON['message']); - } else { - $message = $this->_getDisplay(); + if (! isset($this->_JSON['message'])) { + $this->_JSON['message'] = $this->_getDisplay(); } - PMA_ajaxResponse($message, true, $this->_JSON); + $message = $this->_JSON['message']; + unset($this->_JSON['message']); + PMA_ajaxResponse($message, $this->_isSuccess, $this->_JSON); } } diff --git a/user_password.php b/user_password.php index d43959dc4b..a462ba2951 100644 --- a/user_password.php +++ b/user_password.php @@ -77,12 +77,19 @@ function PMA_getChangePassMessage($change_password_message, $sql_query = '') /** * If in an Ajax request, we don't need to show the rest of the page */ + $response = PMA_Response::getInstance(); if ($change_password_message['error']) { - PMA_ajaxResponse($change_password_message['msg'], false); + $response->addJSON('message', $change_password_message['msg']); + $response->isSuccess(false); } else { - $extra_data['sql_query'] = PMA_getMessage($change_password_message['msg'], $sql_query, 'success'); - PMA_ajaxResponse($change_password_message['msg'], true, $extra_data); + $sql_query = PMA_getMessage( + $change_password_message['msg'], + $sql_query, + 'success' + ); + $response->addJSON('message', $sql_query); } + exit; } } From 9c144428770d0676ca3db6cbc8e5865e9dca284d Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Sun, 3 Jun 2012 20:46:19 +0200 Subject: [PATCH 083/116] Fix typo --- libraries/Footer.class.php | 2 +- libraries/Header.class.php | 2 +- libraries/Response.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 711472f822..546640381f 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -59,7 +59,7 @@ class PMA_Footer private $_isEnabled; /** - * Cretes a new class instance + * Creates a new class instance * * @return new PMA_Footer object */ diff --git a/libraries/Header.class.php b/libraries/Header.class.php index efda2dd91c..4f031e4f78 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -101,7 +101,7 @@ class PMA_Header public static $headerIsSent; /** - * Cretes a new class instance + * Creates a new class instance * * @return new PMA_Header object */ diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 10bed3d265..f3ad1aca55 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -76,7 +76,7 @@ class PMA_Response private $_isSuccess; /** - * Cretes a new class instance + * Creates a new class instance * * @return new PMA_Response object */ From 4edb55f722e442b48550018aefdbf4bb0ad7db20 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Sun, 3 Jun 2012 21:32:28 +0200 Subject: [PATCH 084/116] improve DocBlock --- libraries/OutputBuffering.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/OutputBuffering.class.php b/libraries/OutputBuffering.class.php index 2941c7bcd1..782e7d0686 100644 --- a/libraries/OutputBuffering.class.php +++ b/libraries/OutputBuffering.class.php @@ -60,9 +60,9 @@ class PMA_OutputBuffering } /** - * Returns the singleton PMA_Response object + * Returns the singleton PMA_OutputBuffering object * - * @return PMA_Response object + * @return PMA_OutputBuffering object */ public static function getInstance() { From 0b3c5b9694547e2310f0f210b057fe3129d8bad5 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 4 Jun 2012 15:32:04 +0100 Subject: [PATCH 085/116] Fixed variable name --- libraries/Response.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/Response.class.php b/libraries/Response.class.php index f3ad1aca55..5d0e4669ef 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -167,10 +167,10 @@ class PMA_Response */ public function addHTML($content) { - if ($value instanceof PMA_Message) { - $this->_HTML = $value->getDisplay(); + if ($content instanceof PMA_Message) { + $this->_HTML .= $content->getDisplay(); } else { - $this->_HTML = $value; + $this->_HTML .= $content; } } From e7cd6a1e8aa60924ffc264942df3ab53827df4a1 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 4 Jun 2012 16:50:09 +0100 Subject: [PATCH 086/116] PHP seems to reset the CWD after a call to exit, so we need to collect the file timestamps early --- libraries/Scripts.class.php | 38 ++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/libraries/Scripts.class.php b/libraries/Scripts.class.php index 6ad3a18351..604f310ede 100644 --- a/libraries/Scripts.class.php +++ b/libraries/Scripts.class.php @@ -41,6 +41,36 @@ class PMA_Scripts */ private $_events; + /** + * Returns HTML code to include javascript file. + * + * @param string $url Location of javascript, relative to js/ folder. + * @param int $timestamp The date when the file was last modified + * @param string $ie_conditional true - wrap with IE conditional comment + * 'lt 9' etc. - wrap for specific IE version + * + * @return string HTML code for javascript inclusion. + */ + private function _includeFile($url, $timestamp = null, $ie_conditional = false) + { + $include = ''; + if ($ie_conditional !== false) { + if ($ie_conditional === true) { + $include .= '' . "\n"; + } + return $include; + } /** * Generates new PMA_Scripts objects @@ -66,10 +96,16 @@ class PMA_Scripts */ public function addFile($filename, $conditional_ie = false) { + $filename = 'js/' . $filename; $hash = md5($filename); if (empty($this->_files[$hash])) { + $timestamp = null; + if (strpos($filename, '?') === false) { + $timestamp = filemtime($filename); + } $this->_files[$hash] = array( 'filename' => $filename, + 'timestamp' => $timestamp, 'conditional_ie' => $conditional_ie ); } @@ -115,7 +151,7 @@ class PMA_Scripts $retval = ''; foreach ($this->_files as $file) { - $retval .= PMA_includeJS( + $retval .= $this->_includeFile( $file['filename'], $file['conditional_ie'] ); From 1f7daca60072a23b237a1f2025c7f5fbacf95bc1 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 4 Jun 2012 17:03:09 +0100 Subject: [PATCH 087/116] Dropped PMA_includeJS() in favor of the PMA_Scripts class --- index.php | 8 +++--- libraries/core.lib.php | 32 ----------------------- test/libraries/core/PMA_getLinks_test.php | 21 +-------------- 3 files changed, 6 insertions(+), 55 deletions(-) diff --git a/index.php b/index.php index e3a7fd5488..99ac95d499 100644 --- a/index.php +++ b/index.php @@ -139,9 +139,11 @@ $response->disable(); // ]]> addFile('jquery/jquery-1.6.2.js'); +$scripts->addFile('update-location.js'); +$scripts->addFile('common.js'); +echo $scripts->getDisplay(); ?> ' . "\n "; - } - } - if (strpos($url, '?') === false) { - $include .= '' . "\n"; - } else { - $include .= '' . "\n"; - } - if ($ie_conditional !== false) { - $include .= '' . "\n"; - } - return $include; -} - /** * Adds JS code snippets to be displayed by the PMA_Response class. * Adds a newline to each snippet. diff --git a/test/libraries/core/PMA_getLinks_test.php b/test/libraries/core/PMA_getLinks_test.php index 069e633bfc..2082c7926f 100644 --- a/test/libraries/core/PMA_getLinks_test.php +++ b/test/libraries/core/PMA_getLinks_test.php @@ -1,7 +1,7 @@ assertEquals(PMA_linkURL($link), $url); } - - public function testPMA_includeJS() - { - $filename = "common.js"; - $mod = 0; - - if (file_exists('./js/'.$filename)) { - $mod = filemtime('./js/'.$filename); - } else { - $this->fail("JS file doesn't exists."); - } - $this->assertEquals(PMA_includeJS($filename), ''. "\n"); - - $filename = '?file.js'; - $this->assertEquals(PMA_includeJS($filename), ''."\n"); - - //$this->assertFalse(PMA_includeJS(null)); - } - } From fd005fe4c48a8569b9ecef95ed0b0c9f5f20f752 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 4 Jun 2012 18:35:01 +0100 Subject: [PATCH 088/116] The filename and line number sometimes are unavailable --- libraries/Error.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/Error.class.php b/libraries/Error.class.php index 698ff7b5d7..306d2c19b5 100644 --- a/libraries/Error.class.php +++ b/libraries/Error.class.php @@ -255,7 +255,9 @@ class PMA_Error extends PMA_Message $retval = ''; foreach ($this->getBacktrace() as $step) { - $retval .= PMA_Error::relPath($step['file']) . '#' . $step['line'] . ': '; + if (isset($step['file']) && isset($step['line'])) { + $retval .= PMA_Error::relPath($step['file']) . '#' . $step['line'] . ': '; + } if (isset($step['class'])) { $retval .= $step['class'] . $step['type']; } From 4995de86f4c9b00c34276ebf52283aeedb8903a5 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 4 Jun 2012 19:21:29 +0100 Subject: [PATCH 089/116] Display "Too many error messages" only once --- libraries/Error_Handler.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 31e3b33ee1..d623c321ca 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -64,8 +64,8 @@ class PMA_Error_Handler if (count($_SESSION['errors']) >= 20) { $error = new PMA_Error(0, __('Too many error messages, some are not displayed.'), __FILE__, __LINE__); $_SESSION['errors'][$error->getHash()] = $error; - } - if (($error instanceof PMA_Error) && ! $error->isDisplayed()) { + break; + } else if (($error instanceof PMA_Error) && ! $error->isDisplayed()) { $_SESSION['errors'][$key] = $error; } } From ec4b3d9e4621ce8f9f318ddd7364f67ae46e2854 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 10:54:39 +0100 Subject: [PATCH 090/116] Disable warnings in header for cookie auth --- libraries/Header.class.php | 22 +++++++++++++++++++++- libraries/auth/cookie.auth.lib.php | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 4f031e4f78..1684d82f0e 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -67,6 +67,13 @@ class PMA_Header * @var bool */ private $_menuEnabled; + /** + * Whether to show the warnings + * + * @access private + * @var bool + */ + private $_warningsEnabled; /** * Whether the page is in 'print view' mode * @@ -117,6 +124,7 @@ class PMA_Header $GLOBALS['table'] ); $this->_menuEnabled = true; + $this->_warningsEnabled = true; $this->_isPrintView = false; $this->_scripts = new PMA_Scripts(); $this->_addDefaultScripts(); @@ -267,6 +275,16 @@ class PMA_Header $this->_menuEnabled = false; } + /** + * Disables the display of the top menu + * + * @return void + */ + public function disableWarnings() + { + $this->_warningsEnabled = false; + } + /** * Turns on 'print view' mode * @@ -325,7 +343,9 @@ class PMA_Header if (! $GLOBALS['cfg']['ShowHint']) { $retval .= ''; } - $retval .= $this->_getWarnings(); + if ($this->_warningsEnabled) { + $retval .= $this->_getWarnings(); + } if ($this->_menuEnabled && $GLOBALS['server'] > 0) { $retval .= $this->_menu->getDisplay(); } diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 2082f65057..24c8b6a049 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -160,6 +160,7 @@ function PMA_auth() $header = $response->getHeader(); $header->setBodyId('loginform'); $header->disableMenu(); + $header->disableWarnings(); $header->display(); if (file_exists(CUSTOM_HEADER_FILE)) { From ae6e50a8a82a70a1bff90cadc200f06819306615 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 15:08:09 +0100 Subject: [PATCH 091/116] Drop display() from Header and Footer classes. The Response class will do all the rendering. --- browse_foreigners.php | 2 +- db_printview.php | 1 - export.php | 2 -- import.php | 2 -- libraries/Footer.class.php | 10 ---------- libraries/Header.class.php | 10 ---------- libraries/PDF.class.php | 2 -- libraries/auth/config.auth.lib.php | 1 - libraries/auth/cookie.auth.lib.php | 1 - libraries/auth/http.auth.lib.php | 1 - libraries/common.lib.php | 6 ------ libraries/db_common.inc.php | 6 ------ libraries/schema/Export_Relation_Schema.class.php | 2 -- libraries/server_common.inc.php | 6 ------ libraries/tbl_common.inc.php | 6 ------ main.php | 2 -- navigation.php | 1 - pmd_pdf.php | 1 - prefs_forms.php | 1 - prefs_manage.php | 4 +--- querywindow.php | 2 -- sql.php | 7 ------- tbl_addfield.php | 3 --- tbl_change.php | 5 ----- tbl_create.php | 3 --- transformation_overview.php | 1 - user_password.php | 4 ---- 27 files changed, 2 insertions(+), 90 deletions(-) diff --git a/browse_foreigners.php b/browse_foreigners.php index 0799b9594e..c4b47e7af0 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -14,6 +14,7 @@ $field = $_REQUEST['field']; PMA_checkParameters(array('db', 'table', 'field')); $response = PMA_Response::getInstance(); +$response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->disableMenu(); $header->setBodyId('body_browse_foreigners'); @@ -148,7 +149,6 @@ function formupdate(fieldmd5, key) { EOC; $header->getScripts()->addCode($code); -$header->display(); ?>
diff --git a/db_printview.php b/db_printview.php index d3433ea918..3160089361 100644 --- a/db_printview.php +++ b/db_printview.php @@ -13,7 +13,6 @@ require_once 'libraries/common.inc.php'; $response = PMA_Response::getInstance(); $header = $response->getHeader(); $header->enablePrintView(); -$header->display(); PMA_checkParameters(array('db')); diff --git a/export.php b/export.php index 48dbb58a56..ef519cc732 100644 --- a/export.php +++ b/export.php @@ -407,8 +407,6 @@ if (! $save_on_server) { } } $backup_cfgServer = $cfg['Server']; - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); $cfg['Server'] = $backup_cfgServer; unset($backup_cfgServer); echo "\n" . '
' . "\n"; diff --git a/import.php b/import.php index cc8cd5f811..1522c0d048 100644 --- a/import.php +++ b/import.php @@ -83,8 +83,6 @@ if (! empty($sql_query)) { // upload limit has been reached, let's assume the second possibility. ; if ($_POST == array() && $_GET == array()) { - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); $message = PMA_Message::error(__('You probably tried to upload too large file. Please refer to %sdocumentation%s for ways to workaround this limit.')); $message->addParam('[a@./Documentation.html#faq1_16@_blank]'); $message->addParam('[/a]'); diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 546640381f..21bf6a734e 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -345,14 +345,4 @@ class PMA_Footer return $retval; } - - /** - * Renders and displays the footer - * - * @return void - */ - public function display() - { - echo $this->getDisplay(); - } } diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 1684d82f0e..d609f6e0bc 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -297,16 +297,6 @@ class PMA_Header $this->_isPrintView = true; } - /** - * Generates and outputs the header - * - * @return void - */ - public function display() - { - echo $this->getDisplay(); - } - /** * Generates the header * diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php index e11a2f49c6..54b83e1203 100644 --- a/libraries/PDF.class.php +++ b/libraries/PDF.class.php @@ -85,8 +85,6 @@ class PMA_PDF extends TCPDF */ function Error($error_message = '') { - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display(); exit; } diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index 698ca7e859..4378913a0c 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -79,7 +79,6 @@ function PMA_auth_fails() $header = $response->getHeader(); $header->setTitle(__('Access denied')); $header->disableMenu(); - $header->display(); ?>

diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 24c8b6a049..a9f30f9121 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -161,7 +161,6 @@ function PMA_auth() $header->setBodyId('loginform'); $header->disableMenu(); $header->disableWarnings(); - $header->display(); if (file_exists(CUSTOM_HEADER_FILE)) { include CUSTOM_HEADER_FILE; diff --git a/libraries/auth/http.auth.lib.php b/libraries/auth/http.auth.lib.php index bf0d8f718f..757df24fff 100644 --- a/libraries/auth/http.auth.lib.php +++ b/libraries/auth/http.auth.lib.php @@ -55,7 +55,6 @@ function PMA_auth() $header = $response->getHeader(); $header->setTitle(__('Access denied')); $header->disableMenu(); - $header->display(); ?>

diff --git a/libraries/common.lib.php b/libraries/common.lib.php index a6ed1e640d..9c98073818 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -567,12 +567,6 @@ function PMA_mysqlDie( ) { global $table, $db; - /** - * start http output, display html headers - */ - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); - $error_msg = ''; if (! $error_message) { diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php index 42f8a18461..7516a2dd20 100644 --- a/libraries/db_common.inc.php +++ b/libraries/db_common.inc.php @@ -76,12 +76,6 @@ if (isset($submitcollation) && !empty($db_collation)) { }; } -/** - * Displays headers - */ -$response = PMA_Response::getInstance(); -$response->getHeader()->display(); - /** * Set parameters for links */ diff --git a/libraries/schema/Export_Relation_Schema.class.php b/libraries/schema/Export_Relation_Schema.class.php index 3c61e8e07e..e160681d1b 100644 --- a/libraries/schema/Export_Relation_Schema.class.php +++ b/libraries/schema/Export_Relation_Schema.class.php @@ -226,8 +226,6 @@ class PMA_Export_Relation_Schema { global $db; - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); echo "

" . __("SCHEMA ERROR: ") . $type . "

" . "\n"; if (!empty($error_message)) { $error_message = htmlspecialchars($error_message); diff --git a/libraries/server_common.inc.php b/libraries/server_common.inc.php index e64e769611..129a4feb67 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -27,12 +27,6 @@ $url_query = PMA_generate_common_url($db); */ $err_url = 'main.php' . $url_query; -/** - * Displays headers - */ -$response = PMA_Response::getInstance(); -$response->getHeader()->display(); - /** * @global boolean Checks for superuser privileges */ diff --git a/libraries/tbl_common.inc.php b/libraries/tbl_common.inc.php index 54586fd560..4be5ff7b58 100644 --- a/libraries/tbl_common.inc.php +++ b/libraries/tbl_common.inc.php @@ -45,12 +45,6 @@ $err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params); */ require_once './libraries/db_table_exists.lib.php'; -/** - * Displays headers - */ -$response = PMA_Response::getInstance(); -$response->getHeader()->display(); - if (PMA_Tracker::isActive() && PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"]) ) { diff --git a/main.php b/main.php index def28a0521..96034690a6 100644 --- a/main.php +++ b/main.php @@ -26,8 +26,6 @@ if ($GLOBALS['PMA_Config']->isGitRevision()) { $GLOBALS['db'] = ''; $GLOBALS['table'] = ''; $show_query = '1'; -$response = PMA_Response::getInstance(); -$response->getHeader()->display(); // Any message to display? if (! empty($message)) { diff --git a/navigation.php b/navigation.php index 2730de57d4..f92abf2883 100644 --- a/navigation.php +++ b/navigation.php @@ -112,7 +112,6 @@ $scripts->addCode(' } }; '); -$header->display(); require 'libraries/navigation_header.inc.php'; diff --git a/pmd_pdf.php b/pmd_pdf.php index 6ec716ab10..18b3bc2a02 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -81,7 +81,6 @@ $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->disableMenu(); -$header->display(); ?>
diff --git a/prefs_forms.php b/prefs_forms.php index b0ae664978..023d8ba18c 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -73,7 +73,6 @@ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('config.js'); -$header->display(); require 'libraries/user_preferences.inc.php'; if ($error) { diff --git a/prefs_manage.php b/prefs_manage.php index ff639e082b..2cf8dd0a68 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -109,8 +109,6 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == } if (!$all_ok) { // mimic original form and post json in a hidden field - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); include 'libraries/user_preferences.inc.php'; $msg = PMA_Message::error(__('Configuration contains incorrect data for some fields.')); $msg->display(); @@ -220,7 +218,7 @@ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('config.js'); -$header->display(); + require 'libraries/user_preferences.inc.php'; if ($error) { if (!$error instanceof PMA_Message) { diff --git a/querywindow.php b/querywindow.php index b69101e584..8ba3530c3e 100644 --- a/querywindow.php +++ b/querywindow.php @@ -132,8 +132,6 @@ if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') { $scripts->addEvent('load','PMA_querywindowSetFocus'); } -$header->display(); - echo '
'; if ($tabs) { diff --git a/sql.php b/sql.php index b018530e90..40b430f281 100644 --- a/sql.php +++ b/sql.php @@ -290,8 +290,6 @@ if (! defined('PMA_CHK_DROP') && $is_drop_database && ! $is_superuser ) { - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); PMA_mysqlDie(__('"DROP DATABASE" statements are disabled.'), '', '', $err_url); } // end if @@ -387,8 +385,6 @@ if (! $cfg['Confirm'] if ($do_confirm) { $stripped_sql_query = $sql_query; - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); if ($is_drop_database) { echo '

' . __( 'You are about to DESTROY a complete database!' @@ -914,7 +910,6 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { $response = PMA_Response::getInstance(); $header = $response->getHeader(); $header->enablePrintView(); - $header->display(); $hostname = ''; if ($cfg['Server']['verbose']) { @@ -964,8 +959,6 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { include 'libraries/server_common.inc.php'; } } else { - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); //we don't need to buffer the output in PMA_getMessage here. //set a global variable and check against it in the function $GLOBALS['buffer_message'] = false; diff --git a/tbl_addfield.php b/tbl_addfield.php index 015c235bd9..e0cf74dda1 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -10,9 +10,6 @@ */ require_once 'libraries/common.inc.php'; -$response = PMA_Response::getInstance(); -$response->getHeader()->display(); - // Check parameters PMA_checkParameters(array('db', 'table')); diff --git a/tbl_change.php b/tbl_change.php index db2a667826..8613410c4f 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -117,11 +117,6 @@ $scripts->addFile('tbl_change.js'); $scripts->addFile('jquery/timepicker.js'); $scripts->addFile('gis_data_editor.js'); -/** - * HTTP and HTML headers - */ -$header->display(); - /** * Displays the query submitted and its result * diff --git a/tbl_create.php b/tbl_create.php index b4945a93b2..43832a887f 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -11,9 +11,6 @@ require_once 'libraries/common.inc.php'; $action = 'tbl_create.php'; -$response = PMA_Response::getInstance(); -$response->getHeader()->display(); - $titles = PMA_buildActionTitles(); // Check parameters diff --git a/transformation_overview.php b/transformation_overview.php index 6caea6a4d1..50a3ab8e9c 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -14,7 +14,6 @@ require_once './libraries/transformations.lib.php'; $response = PMA_Response::getInstance(); $header = $response->getHeader(); $header->disableMenu(); -$header->display(); $types = PMA_getAvailableMIMEtypes(); ?> diff --git a/user_password.php b/user_password.php index a462ba2951..470ab460f6 100644 --- a/user_password.php +++ b/user_password.php @@ -25,7 +25,6 @@ if (! $cfg['ShowChgPassword']) { $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql'); } if ($cfg['Server']['auth_type'] == 'config' || ! $cfg['ShowChgPassword']) { - $header->display(); PMA_Message::error(__('You don\'t have sufficient privileges to be here right now!'))->display(); exit; } // end if @@ -53,7 +52,6 @@ if (isset($_REQUEST['nopass'])) { * If the "change password" form hasn't been submitted or the values submitted * aren't valid -> displays the form */ -$header->display(); // Displays an error message if required if (isset($message)) { @@ -211,8 +209,6 @@ function PMA_changePassAuthType($_url_params, $password) */ function PMA_changePassDisplayPage($message, $sql_query, $_url_params) { - $response = PMA_Response::getInstance(); - $response->getHeader()->display(); echo '

' . __('Change password') . '

' . "\n\n"; echo PMA_getMessage($message, $sql_query, 'success'); echo ''. "\n" From 3b2c2ec8611d5ec51f7c510a31a860e4410ffecf Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 15:17:26 +0100 Subject: [PATCH 092/116] Remember CWD after the initial script has shutdown --- libraries/Response.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 5d0e4669ef..e7b2923a3a 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -74,6 +74,13 @@ class PMA_Response * @var bool */ private $_isSuccess; + /** + * Workaround for PHP bug + * + * @access private + * @var bool + */ + private $_CWD; /** * Creates a new class instance @@ -96,6 +103,7 @@ class PMA_Response } $this->_header->isAjax($this->_isAjax); $this->_footer->isAjax($this->_isAjax); + $this->_CWD = getcwd(); } /** @@ -125,6 +133,18 @@ class PMA_Response } } + /** + * Returns the path to the current working directory + * Necessary to work around a PHP bug where the CWD is + * reset after the initial script exits + * + * @return string + */ + public function getCWD() + { + return $this->_CWD; + } + /** * Disables the rendering of the header * and the footer in responses @@ -256,6 +276,7 @@ class PMA_Response public static function response() { $response = PMA_Response::getInstance(); + chdir($response->getCWD()); $buffer = PMA_OutputBuffering::getInstance(); if (empty($response->_HTML)) { $response->_HTML = $buffer->getContents(); From 015fce08ee014d42c4ed4042901e412548671831 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 15:20:10 +0100 Subject: [PATCH 093/116] Fixed bad variable name --- libraries/display_export.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index 37cc81b4c3..bb9346cd15 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -232,18 +232,18 @@ if (isset($_GET['sql_query'])) { } } - $message = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.')); - $message->addParam( + $msg = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.')); + $msg->addParam( '', false ); - $message->addParam('', false); - $message->addParam($trans); - $message->addParam('', false); - $message->addParam('', false); + $msg->addParam('', false); + $msg->addParam($trans); + $msg->addParam('', false); + $msg->addParam('', false); - echo PMA_showHint($message); + echo PMA_showHint($msg); ?> Date: Tue, 5 Jun 2012 15:36:38 +0100 Subject: [PATCH 094/116] Ensure that PMA_Response is instanciated in common.inc.php --- libraries/common.inc.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 3e803768c8..659963aeff 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -130,11 +130,6 @@ require './libraries/Table.class.php'; require './libraries/Types.class.php'; if (! defined('PMA_MINIMUM_COMMON')) { - /** - * Used to generate the page - */ - include_once 'libraries/Response.class.php'; - /** * common functions */ @@ -149,6 +144,11 @@ if (! defined('PMA_MINIMUM_COMMON')) { * Include URL/hidden inputs generating. */ include_once './libraries/url_generating.lib.php'; + + /** + * Used to generate the page + */ + include_once 'libraries/Response.class.php'; } /******************************************************************************/ @@ -756,6 +756,9 @@ if (@file_exists($_SESSION['PMA_Theme']->getLayoutFile())) { } if (! defined('PMA_MINIMUM_COMMON')) { + // get a dummy object to ensure that the class is instanciated + PMA_Response::getInstance(); + /** * Character set conversion. */ From 31c8ca63011aaa8b08ea69a9cb37ea94077e5a7d Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 16:03:04 +0100 Subject: [PATCH 095/116] Disable Response class for XHR requests in PMD --- pmd_display_field.php | 2 ++ pmd_relation_new.php | 3 +++ pmd_relation_upd.php | 3 +++ 3 files changed, 8 insertions(+) diff --git a/pmd_display_field.php b/pmd_display_field.php index dcf195f17c..dfe61593e4 100644 --- a/pmd_display_field.php +++ b/pmd_display_field.php @@ -9,6 +9,8 @@ */ require_once './libraries/common.inc.php'; +PMA_Response::getInstance()->disable(); + require_once 'libraries/pmd_common.php'; diff --git a/pmd_relation_new.php b/pmd_relation_new.php index a7ca02fce9..e531611ff7 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -9,6 +9,9 @@ * */ require_once './libraries/common.inc.php'; + +PMA_Response::getInstance()->disable(); + require_once 'libraries/pmd_common.php'; $die_save_pos = 0; require_once 'pmd_save_pos.php'; diff --git a/pmd_relation_upd.php b/pmd_relation_upd.php index 4681e544ab..f29424514a 100644 --- a/pmd_relation_upd.php +++ b/pmd_relation_upd.php @@ -9,6 +9,9 @@ * */ require_once './libraries/common.inc.php'; + +PMA_Response::getInstance()->disable(); + require_once 'libraries/pmd_common.php'; extract($_POST, EXTR_SKIP); extract($_GET, EXTR_SKIP); From f6bcab642526f0e7c0c06cf2acdc65510f719099 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 16:03:30 +0100 Subject: [PATCH 096/116] Don't die before the Response class is instanciated --- libraries/common.inc.php | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 659963aeff..d3dfffe78d 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -154,28 +154,6 @@ if (! defined('PMA_MINIMUM_COMMON')) { /******************************************************************************/ /* start procedural code label_start_procedural */ -if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) { - PMA_fatalError(__("GLOBALS overwrite attempt")); -} - -/** - * protect against possible exploits - there is no need to have so much variables - */ -if (count($_REQUEST) > 1000) { - PMA_fatalError(__('possible exploit')); -} - -/** - * Check for numeric keys - * (if register_globals is on, numeric key can be found in $GLOBALS) - */ -foreach ($GLOBALS as $key => $dummy) { - if (is_numeric($key)) { - PMA_fatalError(__('numeric key detected')); - } -} -unset($dummy); - /** * PATH_INFO could be compromised if set, so remove it from PHP_SELF * and provide a clean PHP_SELF here @@ -1092,6 +1070,28 @@ if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) { $GLOBALS['grid_edit'] = false; } +if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) { + PMA_fatalError(__("GLOBALS overwrite attempt")); +} + +/** + * protect against possible exploits - there is no need to have so much variables + */ +if (count($_REQUEST) > 1000) { + PMA_fatalError(__('possible exploit')); +} + +/** + * Check for numeric keys + * (if register_globals is on, numeric key can be found in $GLOBALS) + */ +foreach ($GLOBALS as $key => $dummy) { + if (is_numeric($key)) { + PMA_fatalError(__('numeric key detected')); + } +} +unset($dummy); + if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) { /** * include subform target page From ca2f16194867fa0de9dd7731360c88532ce39ad2 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 21:57:22 +0100 Subject: [PATCH 097/116] Dropped $GLOBALS['page_title'] --- libraries/Header.class.php | 78 +++++++++++++++--------------- libraries/auth/config.auth.lib.php | 1 - libraries/auth/cookie.auth.lib.php | 2 +- libraries/auth/http.auth.lib.php | 1 - 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index d609f6e0bc..f54a906b1a 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -117,7 +117,7 @@ class PMA_Header $this->_isEnabled = true; $this->_isAjax = false; $this->_bodyId = ''; - $this->_title = 'phpMyAdmin'; + $this->_title = ''; $this->_menu = new PMA_Menu( $GLOBALS['server'], $GLOBALS['db'], @@ -174,40 +174,6 @@ class PMA_Header . urlencode($_SESSION['PMA_Theme']->getId()) ); $this->_scripts->addFile('functions.js'); - - // generate title (unless we already have - // $GLOBALS['page_title'], from cookie auth) - if (! isset($GLOBALS['page_title'])) { - if ($GLOBALS['server'] > 0) { - if (! empty($GLOBALS['table'])) { - $temp_title = $GLOBALS['cfg']['TitleTable']; - } else if (! empty($GLOBALS['db'])) { - $temp_title = $GLOBALS['cfg']['TitleDatabase']; - } elseif (! empty($GLOBALS['cfg']['Server']['host'])) { - $temp_title = $GLOBALS['cfg']['TitleServer']; - } else { - $temp_title = $GLOBALS['cfg']['TitleDefault']; - } - $title = PMA_expandUserString($temp_title); - } - } else { - $title = $GLOBALS['page_title']; - } - if (isset($title)) { - $title = PMA_sanitize( - PMA_escapeJsString($title), - false, - true - ); - $this->_scripts->addCode( - "if (typeof(parent.document) != 'undefined'" - . " && typeof(parent.document) != 'unknown'" - . " && typeof(parent.document.title) == 'string')" - . "{" - . "parent.document.title = '$title'" - . "}" - ); - } $this->_scripts->addCode(PMA_getReloadNavigationScript(true)); } @@ -312,6 +278,19 @@ class PMA_Header $retval .= $this->_getMetaTags(); $retval .= $this->_getLinkTags(); $retval .= $this->_getTitleTag(); + $title = PMA_sanitize( + PMA_escapeJsString($this->_getPageTitle()), + false, + true + ); + $this->_scripts->addCode( + "if (typeof(parent.document) != 'undefined'" + . " && typeof(parent.document) != 'unknown'" + . " && typeof(parent.document.title) == 'string')" + . "{" + . "parent.document.title = '$title'" + . "}" + ); if ($this->_userprefsOfferImport) { $this->_scripts->addFile('config.js'); } @@ -451,15 +430,34 @@ class PMA_Header private function _getTitleTag() { $retval = ""; - if (! empty($GLOBALS['page_title'])) { - $retval .= htmlspecialchars($GLOBALS['page_title']); - } else { - $retval .= $this->_title; - } + $retval .= $this->_getPageTitle(); $retval .= ""; return $retval; } + private function _getPageTitle() + { + if (empty($this->_title)) { + if ($GLOBALS['server'] > 0) { + if (! empty($GLOBALS['table'])) { + $temp_title = $GLOBALS['cfg']['TitleTable']; + } else if (! empty($GLOBALS['db'])) { + $temp_title = $GLOBALS['cfg']['TitleDatabase']; + } elseif (! empty($GLOBALS['cfg']['Server']['host'])) { + $temp_title = $GLOBALS['cfg']['TitleServer']; + } else { + $temp_title = $GLOBALS['cfg']['TitleDefault']; + } + $this->_title = htmlspecialchars( + PMA_expandUserString($temp_title) + ); + } else { + $this->_title = 'phpMyAdmin'; + } + } + return $this->_title; + } + /** * Returns the close tag to the HEAD * and the start tag for the BODY diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index 4378913a0c..cea96b9cb1 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -73,7 +73,6 @@ function PMA_auth_fails() } /* HTML header */ - $GLOBALS['page_title'] = __('Access denied'); $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index a9f30f9121..333732ecd7 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -154,11 +154,11 @@ function PMA_auth() $cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right'; - $GLOBALS['page_title'] = 'phpMyAdmin'; $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setBodyId('loginform'); + $header->setTitle('phpMyAdmin'); $header->disableMenu(); $header->disableWarnings(); diff --git a/libraries/auth/http.auth.lib.php b/libraries/auth/http.auth.lib.php index 757df24fff..422fcbbe26 100644 --- a/libraries/auth/http.auth.lib.php +++ b/libraries/auth/http.auth.lib.php @@ -49,7 +49,6 @@ function PMA_auth() } /* HTML header */ - $GLOBALS['page_title'] = __('Access denied'); $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); From 30d7d92e0254acd7ada4706e64a8dce43ecfebe3 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jun 2012 22:56:48 +0100 Subject: [PATCH 098/116] BBCode is never used with PMA_showHint() in the code base --- libraries/Footnotes.class.php | 33 +++++++++------------------------ libraries/common.lib.php | 4 ++-- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/libraries/Footnotes.class.php b/libraries/Footnotes.class.php index 392124cf8f..eb6ee41339 100644 --- a/libraries/Footnotes.class.php +++ b/libraries/Footnotes.class.php @@ -39,12 +39,11 @@ class PMA_Footnotes * * @param mixed $message The message to be used for the footnote. * Can be a string or a PMA_Message object. - * @param bool $bbc Whether to generate BBCode or HTML * * @return string The marker to be displayed near the element * that is being referenced by the footnote */ - public function add($message, $bbc = false) + public function add($message) { if ($message instanceof PMA_Message) { $key = $message->getHash(); @@ -57,8 +56,7 @@ class PMA_Footnotes $id = count($this->_footnotes) + 1; $this->_footnotes[$key] = new PMA_Footnote( $id, - $message, - $bbc + $message ); } return $this->_footnotes[$key]->getMarker(); @@ -105,27 +103,18 @@ class PMA_Footnote * @access private */ private $_message; - /** - * Whether to generate BBCode or HTML - * - * @var bool - * @access private - */ - private $_bbc; /** * Generates new PMA_Footnotes objects * * @param int $id Footnote identifier * @param string $message The message to be used for the footnote - * @param bool $bbc Whether to generate BBCode or HTML * * @return PMA_Footnote object */ - public function __construct($id, $message, $bbc = false) + public function __construct($id, $message) { $this->_id = $id; - $this->_bbc = $bbc; $this->_message = $message; } @@ -137,16 +126,12 @@ class PMA_Footnote */ public function getMarker() { - if ($this->_bbc) { - $retval = '[sup]' . $this->_id . '[/sup]'; - } else { - $retval = '' . $this->_id . ''; - $retval .= PMA_getImage( - 'b_help.png', - '', - array('class' => 'footnotemarker footnote_' . $this->_id) - ); - } + $retval = '' . $this->_id . ''; + $retval .= PMA_getImage( + 'b_help.png', + '', + array('class' => 'footnotemarker footnote_' . $this->_id) + ); return $retval; } diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 9c98073818..41634c20d3 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -538,11 +538,11 @@ function PMA_showPHPDocu($target) * * @access public */ -function PMA_showHint($message, $bbcode = false) +function PMA_showHint($message) { $response = PMA_Response::getInstance(); $footnotes = $response->getFooter()->getFootnotes(); - return $footnotes->add($message, $bbcode); + return $footnotes->add($message); } /** From 796012fcc574215cf95e4fb631501d2b198c70e9 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 6 Jun 2012 12:42:39 +0100 Subject: [PATCH 099/116] Completely drop footnotes and use tooltips instead --- js/db_structure.js | 2 +- js/functions.js | 63 +++------- js/server_privileges.js | 4 +- js/server_status.js | 2 +- js/tbl_structure.js | 6 +- libraries/Footer.class.php | 31 +---- libraries/Footnotes.class.php | 153 ----------------------- libraries/Message.class.php | 8 +- libraries/common.inc.php | 6 - libraries/common.lib.php | 18 +-- setup/styles.css | 12 +- test/PMA_showHint_test.php | 189 ----------------------------- themes/original/css/common.css.php | 14 +-- themes/pmahomme/css/common.css.php | 17 +-- themes/sprites.css.php | 2 +- 15 files changed, 51 insertions(+), 476 deletions(-) delete mode 100644 libraries/Footnotes.class.php delete mode 100644 test/PMA_showHint_test.php diff --git a/js/db_structure.js b/js/db_structure.js index f5d4db94bb..5305431334 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -194,7 +194,7 @@ $(function() { $("table.insertRowTable").addClass("ajax"); $("#buttonYes").addClass("ajax"); $div = $("#insert_table_dialog"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); } PMA_ajaxRemoveMessage($msgbox); }); // end $.get() diff --git a/js/functions.js b/js/functions.js index 5dd7c8d65b..7dbb67110c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1673,7 +1673,7 @@ function PMA_createTableDialog( $div, url , target) buttons: button_options }); // end dialog options } - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); PMA_ajaxRemoveMessage($msgbox); }); // end $.get() @@ -2922,10 +2922,6 @@ $(function() { }); }); -$(function() { - PMA_convertFootnotesToTooltips(); -}); - /** * Ensures indexes names are valid according to their type and, for a primary * key, lock index name to 'PRIMARY' @@ -2961,55 +2957,22 @@ function checkIndexName(form_id) } // end of the 'checkIndexName()' function /** - * function to convert the footnotes to tooltips + * Function to display tooltips that were + * generated on the PHP side by PMA_showHint() * - * @param jquery-Object $div a div jquery object which specifies the - * domain for searching footnootes. If we - * ommit this parameter the function searches - * the footnotes in the whole body + * @param object $div a div jquery object which specifies the + * domain for searching for tooltips. If we + * omit this parameter the function searches + * in the whole body **/ -function PMA_convertFootnotesToTooltips($div) +function PMA_showHints($div) { - // Hide the footnotes from the footer (which are displayed for - // JavaScript-disabled browsers) since the tooltip is sufficient - if ($div == undefined || ! $div instanceof jQuery || $div.length == 0) { $div = $("body"); } - - $footnotes = $div.find(".footnotes"); - - $footnotes.hide(); - $footnotes.find('span').each(function() { - $(this).children("sup").remove(); - }); - // The border and padding must be removed otherwise a thin yellow box remains visible - $footnotes.css("border", "none"); - $footnotes.css("padding", "0px"); - - // Replace the superscripts with the help icon - $div.find("sup.footnotemarker").hide(); - $div.find("img.footnotemarker").show(); - - $div.find("img.footnotemarker").each(function() { - var img_class = $(this).attr("class"); - /** img contains two classes, as example "footnotemarker footnote_1". - * We split it by second class and take it for the id of span - */ - img_class = img_class.split(" "); - for (i = 0; i < img_class.length; i++) { - if (img_class[i].split("_")[0] == "footnote") { - var span_id = img_class[i].split("_")[1]; - } - } - /** - * Now we get the #id of the span with span_id variable. As an example if we - * initially get the img class as "footnotemarker footnote_2", now we get - * #2 as the span_id. Using that we can find footnote_2 in footnotes. - * */ - var tooltip_text = $footnotes.find("span#footnote_" + span_id).html(); - $(this).qtip({ - content: tooltip_text, + $div.find('.pma_hint').each(function () { + $(this).children('img').qtip({ + content: $(this).children('span').html(), show: { delay: 0 }, hide: { delay: 1000 }, style: { background: '#ffffcc' } @@ -3017,6 +2980,10 @@ function PMA_convertFootnotesToTooltips($div) }); } +$(function() { + PMA_showHints(); +}); + /** * This function handles the resizing of the content frame * and adjusts the top menu according to the new size of the frame diff --git a/js/server_privileges.js b/js/server_privileges.js index 5394f594dd..d4c8d8d37b 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -218,7 +218,7 @@ $(function() { } }); //dialog options end displayPasswordGenerateButton(); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); PMA_ajaxRemoveMessage($msgbox); $div.find("input[autofocus]").focus(); @@ -354,7 +354,7 @@ $(function() { }); //dialog options end displayPasswordGenerateButton(); PMA_ajaxRemoveMessage($msgbox); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); }); // end $.get() }); diff --git a/js/server_status.js b/js/server_status.js index edd0c54658..243cbe84d3 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -437,7 +437,7 @@ $(function() { if (data != null) { tab.find('.tabInnerContent').html(data); } - PMA_convertFootnotesToTooltips(); + PMA_showHints(); break; case 'statustabs_queries': if (data != null) { diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 2a931d206a..c93826504f 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -301,7 +301,7 @@ $(function() { }); checkIndexType(); checkIndexName("index_frm"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); // Add a slider for selecting how many columns to add to the index $div.find('.slider').slider({ animate: true, @@ -542,7 +542,7 @@ $(function() { $div = $("#add_columns"); /*changed the z-index of the enum editor to allow the edit*/ $("#enum_editor").css("z-index", "1100"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); // set focus on first column name input $div.find("input.textfield").eq(0).focus(); } @@ -620,7 +620,7 @@ function changeColumns(action,url) /*changed the z-index of the enum editor to allow the edit*/ $("#enum_editor").css("z-index", "1100"); $div = $("#change_column_dialog"); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); } PMA_ajaxRemoveMessage($msgbox); }); // end $.get() diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 21bf6a734e..5be2168c8d 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -10,7 +10,6 @@ if (! defined('PHPMYADMIN')) { } require_once 'libraries/Scripts.class.php'; -require_once 'libraries/Footnotes.class.php'; /** * Class used to output the footer @@ -19,13 +18,6 @@ require_once 'libraries/Footnotes.class.php'; */ class PMA_Footer { - /** - * PMA_Footnotes instance - * - * @access private - * @var object - */ - private $_footnotes; /** * PMA_Scripts instance * @@ -44,7 +36,7 @@ class PMA_Footer private $_isAjax; /** * Whether to only close the BODY and HTML tags - * or also include scripts, footnotes, errors and links + * or also include scripts, errors and links * * @access private * @var bool @@ -66,7 +58,6 @@ class PMA_Footer public function __construct() { $this->_isEnabled = true; - $this->_footnotes = new PMA_Footnotes(); $this->_scripts = new PMA_Scripts(); $this->_isMinimal = false; $this->_addDefaultScripts(); @@ -282,16 +273,6 @@ class PMA_Footer $this->_isMinimal = true; } - /** - * Returns the PMA_Footnotes object - * - * @return PMA_Footnotes object - */ - public function getFootnotes() - { - return $this->_footnotes; - } - /** * Renders the footer * @@ -322,13 +303,6 @@ class PMA_Footer $retval .= $this->_getSelfLink($url_params); } $retval .= $this->_getDebugMessage(); - } - if (! $this->_isMinimal) { - // display Footnotes and error messages even in ajax reqests - // FIXME: nootnotes should be sent as JSON - $retval .= $this->_footnotes->getDisplay(); - } - if (! $this->_isAjax && ! $this->_isMinimal) { $retval .= $this->_getErrorMessages(); $retval .= $this->_scripts->getDisplay(); // Include possible custom footers @@ -337,8 +311,7 @@ class PMA_Footer include CUSTOM_FOOTER_FILE; $retval .= ob_end_clean(); } - } - if (! $this->_isAjax) { + } else if (! $this->_isAjax) { $retval .= ""; } } diff --git a/libraries/Footnotes.class.php b/libraries/Footnotes.class.php deleted file mode 100644 index eb6ee41339..0000000000 --- a/libraries/Footnotes.class.php +++ /dev/null @@ -1,153 +0,0 @@ -_footnotes = array(); - } - - /** - * Setter for the ID attribute in the BODY tag - * - * @param mixed $message The message to be used for the footnote. - * Can be a string or a PMA_Message object. - * - * @return string The marker to be displayed near the element - * that is being referenced by the footnote - */ - public function add($message) - { - if ($message instanceof PMA_Message) { - $key = $message->getHash(); - $message = $message->getDisplay(); - } else { - $key = md5($message); - } - - if (! isset($this->_footnotes[$key])) { - $id = count($this->_footnotes) + 1; - $this->_footnotes[$key] = new PMA_Footnote( - $id, - $message - ); - } - return $this->_footnotes[$key]->getMarker(); - } - - /** - * Renders the footnotes - * - * @return string - */ - public function getDisplay() - { - $retval = ''; - if (count($this->_footnotes)) { - $retval .= '
'; - foreach ($this->_footnotes as $footnote) { - $retval .= $footnote->getDisplay(); - } - $retval .= '
'; - } - return $retval; - } -} - -/** - * Each object of this class represents a footnote - * Used by PMA_Footnotes - * - * @package PhpMyAdmin - */ -class PMA_Footnote -{ - /** - * Footnote identifier - * - * @var int - * @access private - */ - private $_id; - /** - * The message to be used for the footnote - * - * @var string - * @access private - */ - private $_message; - - /** - * Generates new PMA_Footnotes objects - * - * @param int $id Footnote identifier - * @param string $message The message to be used for the footnote - * - * @return PMA_Footnote object - */ - public function __construct($id, $message) - { - $this->_id = $id; - $this->_message = $message; - } - - /** - * Returns the marker to be displayed near the element - * that is being referenced by this footnote - * - * @return string - */ - public function getMarker() - { - $retval = '' . $this->_id . ''; - $retval .= PMA_getImage( - 'b_help.png', - '', - array('class' => 'footnotemarker footnote_' . $this->_id) - ); - return $retval; - } - - /** - * Renders the footnote - * - * @return string - */ - public function getDisplay() - { - $retval = ''; - $retval .= '' . $this->_id . ' '; - $retval .= $this->_message; - $retval .= '
'; - return $retval; - } -} - -?> diff --git a/libraries/Message.class.php b/libraries/Message.class.php index 61e7cda64b..de7cfe9fba 100644 --- a/libraries/Message.class.php +++ b/libraries/Message.class.php @@ -27,15 +27,15 @@ * $message = PMA_Message::success('strSomeLocaleMessage'); * * // create another message, a hint, with a localized string which expects - * // two parameters: $strSomeFootnote = 'Read the %smanual%s' - * $hint = PMA_Message::notice('strSomeFootnote'); + * // two parameters: $strSomeTooltip = 'Read the %smanual%s' + * $hint = PMA_Message::notice('strSomeTooltip'); * // replace %d with the following params * $hint->addParam('[a@./Documentation.html#cfg_Example@_blank]'); * $hint->addParam('[/a]'); - * // add this hint as a footnote + * // add this hint as a tooltip * $hint = PMA_showHint($hint); * - * // add the retrieved footnote reference to the original message + * // add the retrieved tooltip reference to the original message * $message->addMessage($hint); * * // create another message ... diff --git a/libraries/common.inc.php b/libraries/common.inc.php index d3dfffe78d..d0a84f92eb 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -545,12 +545,6 @@ if (PMA_isValid($_REQUEST['sql_query'])) { //$_REQUEST['server']; // checked later in this file //$_REQUEST['lang']; // checked by LABEL_loading_language_file -/** - * footnotes to be displayed ot the page bottom - * @global array $footnotes - */ -$GLOBALS['footnotes'] = array(); - /******************************************************************************/ /* loading language file LABEL_loading_language_file */ diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 41634c20d3..22bf6e6b50 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -528,21 +528,23 @@ function PMA_showPHPDocu($target) } // end of the 'PMA_showPHPDocu()' function /** - * returns HTML for a footnote marker and add the messsage to the footnotes + * Returns HTML code for a tooltip * - * @param string $message the error message - * @param bool $bbcode whether to interpret BB code - * @param string $type message types + * @param string $message the message for the tooltip * - * @return string html code for a footnote marker + * @return string * * @access public */ function PMA_showHint($message) { - $response = PMA_Response::getInstance(); - $footnotes = $response->getFooter()->getFootnotes(); - return $footnotes->add($message); + $retval = ''; + $retval .= PMA_getImage('b_help.png'); + $retval .= ''; + $retval .= $message; + $retval .= ''; + $retval .= ''; + return $retval; } /** diff --git a/setup/styles.css b/setup/styles.css index e7e955c275..c6798c74e2 100644 --- a/setup/styles.css +++ b/setup/styles.css @@ -118,8 +118,7 @@ div.error h4 { div.success, div.notice, -div.error, -div.footnotes { +div.error { margin: .5em 0 1.3em 0; border: 1px solid; background-repeat: no-repeat; @@ -137,8 +136,7 @@ div.footnotes { .success a, .notice a, -.error a, -.footnotes a { +.error a { text-decoration: underline; } @@ -158,15 +156,13 @@ div.success { border-color: #00FF00; } -.notice, -.footnotes { +.notice { color: #000; background-color: #e8eef1; } h1.notice, -div.notice, -div.footnotes { +div.notice { border-color: #3a6c7e; background-image: url(../themes/pmahomme/img/s_notice.png); background-repeat: no-repeat; diff --git a/test/PMA_showHint_test.php b/test/PMA_showHint_test.php deleted file mode 100644 index e99114cb48..0000000000 --- a/test/PMA_showHint_test.php +++ /dev/null @@ -1,189 +0,0 @@ -tmpGlobals = $GLOBALS; - $this->tmpSession = $_SESSION; - } - - /** - * recovering globals and session - */ - public function tearDown() - { - $GLOBALS = $this->tmpGlobals; - $_SESSION = $this->tmpSession; - } - - /** - * PMA_showHint with defined GLOBALS - */ - public function testShowHintReturnValue() - { - $key = md5('test'); - $nr = 1234; - $instance = 1; - - $GLOBALS['footnotes'][$key]['nr'] = $nr; - $GLOBALS['footnotes'][$key]['instance'] = $instance; - $this->assertEquals( - sprintf( - '%d', - $nr, $instance + 1, $nr - ), - PMA_showHint('test') - ); - } - - /** - * PMA_showHint with defined GLOBALS formatted as BB - */ - public function testShowHintReturnValueBbFormat() - { - $key = md5('test'); - $nr = 1234; - $instance = 1; - - $GLOBALS['footnotes'][$key]['nr'] = $nr; - $GLOBALS['footnotes'][$key]['instance'] = $instance; - $this->assertEquals( - sprintf('[sup]%d[/sup]', $nr), - PMA_showHint('test', true) - ); - } - - /** - * PMA_showHint with not defined GLOBALS - */ - public function testShowHintSetting() - { - $key = md5('test'); - $nr = 1; - $instance = 1; - - $this->assertEquals(sprintf('%d', $nr, $instance, $nr), PMA_showHint('test', false, 'notice')); - - $expArray = array( - 'note' => 'test', - 'type' => 'notice', - 'nr' => count($GLOBALS['footnotes']), - 'instance' => 1, - ); - - $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]); - } - - /** - * PMA_showHint with not defined GLOBALS formatted as BB - * @depends testShowHintSetting - */ - public function testShowHintSettingBbFormat() - { - $key = md5('test'); - $nr = 1; - $instance = 1; - - $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice')); - - $expArray = array( - 'note' => 'test', - 'type' => 'notice', - 'nr' => count($GLOBALS['footnotes']), - 'instance' => 1, - ); - - $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]); - } - - /** - * PMA_showHint with defined GLOBALS using PMA_Message object - */ - public function testShowHintPmaMessageReturnValue() - { - $nr = 1; - $instance = 1; - - $oMock = $this->getMock( - 'PMA_Message', - array('setMessage', 'setNumber', 'getHash', 'getLevel') - ); - $oMock->setMessage('test'); - $oMock->setNumber($nr); - - $key = $oMock->getHash(); - - $GLOBALS['footnotes'][$key]['nr'] = $nr; - $GLOBALS['footnotes'][$key]['instance'] = $instance; - - $this->assertEquals( - sprintf( - '%d', - $nr, $instance + 1, $nr - ), - PMA_showHint($oMock) - ); - } - - /** - * PMA_showHint with not defined GLOBALS using PMA_Message object - */ - public function testShowHintPmaMessageSetting() - { - $nr = 1; - $instance = 1; - - $oMock = $this->getMock( - 'PMA_Message', - array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber') - ); - $oMock->setMessage('test'); - $oMock->setNumber($nr); - - $this->assertEquals( - sprintf( - '%d', - $nr, $instance, $nr - ), - PMA_showHint($oMock, false) - ); - - $key = $oMock->getHash(); - - $expArray = array( - 'note' => $oMock, - 'type' => $oMock->getLevel(), - 'nr' => count($GLOBALS['footnotes']), - 'instance' => 1, - ); - - $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]); - } -} -?> diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index 91c3a65d45..dfbb8882ac 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -427,16 +427,12 @@ img.lightbulb { } /* leave some space between icons and text */ -.icon, img.footnotemarker { +.icon { vertical-align: middle; margin-right: 0.3em; margin-left: 0.3em; } -img.footnotemarker { - display: none; -} - /* no extra space in table cells */ td .icon { margin: 0; @@ -459,8 +455,7 @@ div.error h1 { div.success, div.notice, -div.error, -div.footnotes { +div.error { margin: 0.3em 0 0 0; border: 2px solid; background-repeat: no-repeat; @@ -494,13 +489,12 @@ div.success { border-color: #00FF00; } -.notice, .footnotes { +.notice { color: #000000; background-color: #FFFFDD; } h1.notice, -div.notice, -div.footnotes { +div.notice { border-color: #FFD700; background-image: url(getImgPath(); ?>s_notice.png); background-repeat: no-repeat; diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index ef19d2dd33..5379c5bc6e 100644 --- a/themes/pmahomme/css/common.css.php +++ b/themes/pmahomme/css/common.css.php @@ -652,11 +652,6 @@ img.lightbulb { .syntax_quote_backtick { } -/* leave some space between icons and text */ -img.footnotemarker { - display: none; -} - /* no extra space in table cells */ td .icon { margin: 0; @@ -679,8 +674,7 @@ div.error h1 { div.success, div.notice, -div.error, -div.footnotes { +div.error { margin: .5em 0 1.3em 0; border: 1px solid; background-repeat: no-repeat; @@ -703,8 +697,7 @@ div.footnotes { .success a, .notice a, -.error a, -.footnotes a { +.error a { text-decoration: underline; } @@ -728,15 +721,13 @@ div.success { border-color: #00FF00; } -.notice, -.footnotes { +.notice { color: #000; background-color: #e8eef1; } h1.notice, -div.notice, -div.footnotes { +div.notice { border-color: #3a6c7e; background-image: url(getImgPath(); ?>s_notice.png); background-repeat: no-repeat; diff --git a/themes/sprites.css.php b/themes/sprites.css.php index e51e1a557a..2c12589a41 100644 --- a/themes/sprites.css.php +++ b/themes/sprites.css.php @@ -17,7 +17,7 @@ if (is_readable($_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php')) { ?> /* Icon sprites */ -.icon, .footnotemarker { +.icon { margin: 0 .3em; padding: 0 !important; width: 16px; From a3d7a055ee2efaa5c1713642affb8ee9113d142d Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 6 Jun 2012 13:17:42 +0100 Subject: [PATCH 100/116] Docblock fixes --- libraries/Footer.class.php | 4 ++-- libraries/Header.class.php | 13 +++++++++++-- libraries/Response.class.php | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 5be2168c8d..5420abbc53 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -244,9 +244,9 @@ class PMA_Footer } /** - * + * Disables the rendering of the footer * - * @return + * @return void */ public function disable() { diff --git a/libraries/Header.class.php b/libraries/Header.class.php index f54a906b1a..e1c22b855b 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -101,6 +101,9 @@ class PMA_Header * Whether the HTTP headers (and possibly some HTML) * have already been sent to the browser * + * FIXME: Shouldn't be static or public, but first + * need to remove references to it from the code base + * * @access public * @static * @var bool @@ -178,9 +181,9 @@ class PMA_Header } /** - * + * Disables the rendering of the header * - * @return + * @return void */ public function disable() { @@ -435,6 +438,12 @@ class PMA_Header return $retval; } + /** + * If the page is missing the title, this function + * will set it to something reasonable + * + * @return string + */ private function _getPageTitle() { if (empty($this->_title)) { diff --git a/libraries/Response.class.php b/libraries/Response.class.php index e7b2923a3a..ede4ac1062 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -120,7 +120,8 @@ class PMA_Response } /** - * FIXME + * Set the status of an ajax response, + * whether it is a success or an error * * @return void */ From 74199dd1146ca7684f997476f8fb34c24c177d88 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 6 Jun 2012 13:18:54 +0100 Subject: [PATCH 101/116] Display messages once on password change --- user_password.php | 1 + 1 file changed, 1 insertion(+) diff --git a/user_password.php b/user_password.php index 470ab460f6..258585e019 100644 --- a/user_password.php +++ b/user_password.php @@ -56,6 +56,7 @@ if (isset($_REQUEST['nopass'])) { // Displays an error message if required if (isset($message)) { $message->display(); + unset($message); } require_once './libraries/display_change_password.lib.php'; From c7d835347ca80e15b93e20e523519ec3842e0bf5 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 7 Jun 2012 11:18:37 +0100 Subject: [PATCH 102/116] Force JSON response for AJAX requests --- libraries/Footer.class.php | 5 ++-- libraries/Header.class.php | 7 +++-- libraries/Response.class.php | 48 ++++++++++++++++++++++-------- libraries/auth/cookie.auth.lib.php | 16 ++++++++-- libraries/common.inc.php | 9 +++--- 5 files changed, 60 insertions(+), 25 deletions(-) diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 5420abbc53..f3874fc53e 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -254,11 +254,12 @@ class PMA_Footer } /** - * + * Set the ajax flag to indicate whether + * we are sevicing an ajax request * * @return void */ - public function isAjax($isAjax) + public function setAjax($isAjax) { $this->_isAjax = $isAjax; } diff --git a/libraries/Header.class.php b/libraries/Header.class.php index e1c22b855b..9582936d45 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -191,11 +191,12 @@ class PMA_Header } /** - * + * Set the ajax flag to indicate whether + * we are sevicing an ajax request * - * @return + * @return void */ - public function isAjax($isAjax) + public function setAjax($isAjax) { $this->_isAjax = $isAjax; } diff --git a/libraries/Response.class.php b/libraries/Response.class.php index ede4ac1062..498703ab83 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -101,8 +101,8 @@ class PMA_Response if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { $this->_isAjax = true; } - $this->_header->isAjax($this->_isAjax); - $this->_footer->isAjax($this->_isAjax); + $this->_header->setAjax($this->_isAjax); + $this->_footer->setAjax($this->_isAjax); $this->_CWD = getcwd(); } @@ -134,6 +134,17 @@ class PMA_Response } } + /** + * Returns true or false depending on whether + * we are servicing an ajax request + * + * @return void + */ + public function isAjax() + { + return $this->_isAjax; + } + /** * Returns the path to the current working directory * Necessary to work around a PHP bug where the CWD is @@ -255,17 +266,28 @@ class PMA_Response */ private function _ajaxResponse() { - if (empty($this->_JSON)) { - // header('Content-Type: text/html; charset=utf-8'); - echo $this->_getDisplay(); - } else { - if (! isset($this->_JSON['message'])) { - $this->_JSON['message'] = $this->_getDisplay(); - } - $message = $this->_JSON['message']; - unset($this->_JSON['message']); - PMA_ajaxResponse($message, $this->_isSuccess, $this->_JSON); + if (! isset($this->_JSON['message'])) { + $this->_JSON['message'] = $this->_getDisplay(); + } else if ($this->_JSON['message'] instanceof PMA_Message) { + $this->_JSON['message'] = $this->_JSON['message']->getDisplay(); } + + if ($this->_isSuccess) { + $this->_JSON['success'] = true; + } else { + $this->_JSON['success'] = false; + $this->_JSON['error'] = $this->_JSON['message']; + unset($this->_JSON['message']); + } + + // Set the Content-Type header to JSON so that jQuery parses the + // response correctly. + if (! defined('TESTSUITE')) { + header('Cache-Control: no-cache'); + header('Content-Type: application/json'); + } + + echo json_encode($this->_JSON); } /** @@ -282,7 +304,7 @@ class PMA_Response if (empty($response->_HTML)) { $response->_HTML = $buffer->getContents(); } - if ($response->_isAjax) { + if ($response->isAjax()) { $response->_ajaxResponse(); } else { $response->_htmlResponse(); diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 333732ecd7..7eb487c014 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -130,6 +130,17 @@ function PMA_auth() { global $conn_error; + $response = PMA_Response::getInstance(); + if ($response->isAjax()) { + $response->isSuccess(false); + if (! empty($conn_error)) { + $response->addJSON('message', $conn_error); + } else { + $response->addJSON('message', __('Session expired')); + } + exit; + } + /* Perform logout to custom URL */ if (! empty($_REQUEST['old_usr']) && ! empty($GLOBALS['cfg']['Server']['LogoutURL']) @@ -154,7 +165,6 @@ function PMA_auth() $cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right'; - $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setBodyId('loginform'); @@ -571,11 +581,13 @@ function PMA_auth_set_user() */ PMA_clearUserCache(); + PMA_Response::getInstance()->disable(); + PMA_sendHeaderLocation( $redirect_url . PMA_generate_common_url($url_params, '&'), true ); - exit(); + exit; } // end if return true; diff --git a/libraries/common.inc.php b/libraries/common.inc.php index d0a84f92eb..d4593423b2 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -476,7 +476,9 @@ if (! PMA_isValid($_REQUEST['token']) /* Cookie preferences */ 'pma_lang', 'pma_collation_connection', /* Possible login form */ - 'pma_servername', 'pma_username', 'pma_password' + 'pma_servername', 'pma_username', 'pma_password', + /* Needed to send the correct reply */ + 'ajax_request' ); /** * Allow changing themes in test/theme.php @@ -846,7 +848,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { * the required auth type plugin */ include_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php'; - if (!PMA_auth_check()) { + if (! PMA_auth_check()) { /* Force generating of new session on login */ PMA_secureSession(); PMA_auth(); @@ -897,7 +899,6 @@ if (! defined('PMA_MINIMUM_COMMON')) { PMA_log_user($cfg['Server']['user'], 'allow-denied'); PMA_auth_fails(); } - unset($allowDeny_forbidden); //Clean up after you! } // end if // is root allowed? @@ -905,7 +906,6 @@ if (! defined('PMA_MINIMUM_COMMON')) { $allowDeny_forbidden = true; PMA_log_user($cfg['Server']['user'], 'root-denied'); PMA_auth_fails(); - unset($allowDeny_forbidden); //Clean up after you! } // is a login without password allowed? @@ -913,7 +913,6 @@ if (! defined('PMA_MINIMUM_COMMON')) { $login_without_password_is_forbidden = true; PMA_log_user($cfg['Server']['user'], 'empty-denied'); PMA_auth_fails(); - unset($login_without_password_is_forbidden); //Clean up after you! } // if using TCP socket is not needed From bdb33e4548ab33bf8b4c10674d4b2d02b9a9e76c Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 7 Jun 2012 11:30:03 +0100 Subject: [PATCH 103/116] Fixed ajax response for change password form --- js/functions.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/js/functions.js b/js/functions.js index 7dbb67110c..40a5c2f38f 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2592,16 +2592,11 @@ $(function() { * Attach Ajax event handler on the change password anchor * @see $cfg['AjaxEnable'] */ - $('#change_password_anchor.dialog_active').live('click', function(event) { - event.preventDefault(); - return false; - }); $('#change_password_anchor.ajax').live('click', function(event) { event.preventDefault(); var $msgbox = PMA_ajaxShowMessage(); - $(this).removeClass('ajax').addClass('dialog_active'); /** * @var button_options Object containing options to be passed to jQueryUI's dialog */ @@ -2634,7 +2629,6 @@ $(function() { $("#floating_menubar").after(data.message); $("#change_password_dialog").hide().remove(); $("#edit_user_dialog").dialog("close").remove(); - $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax'); PMA_ajaxRemoveMessage($msgbox); } else { @@ -2655,11 +2649,9 @@ $(function() { $(this).remove(); }, buttons : button_options, - beforeClose: function(ev, ui) { - $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax'); - } + modal: true }) - .append(data); + .append(data.message); // for this dialog, we remove the fieldset wrapping due to double headings $("fieldset#fieldset_change_password") .find("legend").remove().end() From 1e4d8fd6b45d7da5a558095f265e61c177700b8e Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 7 Jun 2012 11:30:54 +0100 Subject: [PATCH 104/116] Fixed ajax response for "display git revision" --- libraries/display_git_revision.lib.php | 8 +++----- main.php | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/display_git_revision.lib.php b/libraries/display_git_revision.lib.php index 51b6553a06..f5dee92990 100644 --- a/libraries/display_git_revision.lib.php +++ b/libraries/display_git_revision.lib.php @@ -17,7 +17,9 @@ if (! defined('PHPMYADMIN')) { function PMA_printGitRevision() { if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) { - PMA_ajaxResponse('', false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + return; } // load revision data from repo @@ -56,7 +58,6 @@ function PMA_printGitRevision() $branch = $commit_hash . ' (' . __('no branch') . ')'; } - ob_start(); $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER'); $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR'); PMA_printListItem( @@ -79,7 +80,4 @@ function PMA_printGitRevision() : ''), 'li_pma_version_git', null, null, null ); - $item = ob_get_contents(); - ob_end_clean(); - PMA_ajaxResponse($item, true); } diff --git a/main.php b/main.php index 96034690a6..6bbd41d632 100644 --- a/main.php +++ b/main.php @@ -18,6 +18,7 @@ require_once 'libraries/display_git_revision.lib.php'; if ($GLOBALS['PMA_Config']->isGitRevision()) { if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) { PMA_printGitRevision(); + exit; } PMA_addJSVar('is_git_revision', true); } From 11ccc109513c0b3cf7ae61878e7a70091ed55ee2 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 14:05:12 +0100 Subject: [PATCH 105/116] Moved the check for whether warnings are enabled inside function --- libraries/Header.class.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 9582936d45..6b635737f5 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -316,9 +316,7 @@ class PMA_Header if (! $GLOBALS['cfg']['ShowHint']) { $retval .= ''; } - if ($this->_warningsEnabled) { - $retval .= $this->_getWarnings(); - } + $retval .= $this->_getWarnings(); if ($this->_menuEnabled && $GLOBALS['server'] > 0) { $retval .= $this->_menu->getDisplay(); } @@ -492,19 +490,21 @@ class PMA_Header private function _getWarnings() { $retval = ''; - // message of "Cookies required" displayed for auth_type http or config - // note: here, the decoration won't work because without cookies, - // our standard CSS is not operational - if (empty($_COOKIE)) { - $retval .= PMA_Message::notice( - __('Cookies must be enabled past this point.') + if ($this->_warningsEnabled) { + // message of "Cookies required" displayed for auth_type http or config + // note: here, the decoration won't work because without cookies, + // our standard CSS is not operational + if (empty($_COOKIE)) { + $retval .= PMA_Message::notice( + __('Cookies must be enabled past this point.') + )->getDisplay(); + } + $retval .= ""; } - $retval .= ""; return $retval; } From ef2b98dd8e12c7f7bd11de65930c69556cf0c28b Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 14:18:49 +0100 Subject: [PATCH 106/116] Use PMA_Response class in PMA_ajaxResponse() --- libraries/Response.class.php | 2 +- libraries/common.lib.php | 43 +++++------------------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 498703ab83..f78d98cc98 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -216,7 +216,7 @@ class PMA_Response * * @return void */ - public function addJSON($json, $value) + public function addJSON($json, $value = null) { if (is_array($json)) { foreach ($json as $key => $value) { diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 22bf6e6b50..08b0437c94 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3259,44 +3259,11 @@ function PMA_expandUserString($string, $escape = null, $updates = array()) */ function PMA_ajaxResponse($message, $success = true, $extra_data = array()) { - $response = array(); - if ( $success == true ) { - $response['success'] = true; - if ($message instanceof PMA_Message) { - $response['message'] = $message->getDisplay(); - } else { - $response['message'] = $message; - } - } else { - $response['success'] = false; - if ($message instanceof PMA_Message) { - $response['error'] = $message->getDisplay(); - } else { - $response['error'] = $message; - } - } - - // If extra_data has been provided, append it to the response array - if ( ! empty($extra_data) && count($extra_data) > 0 ) { - $response = array_merge($response, $extra_data); - } - - // Set the Content-Type header to JSON so that jQuery parses the - // response correctly. - // - // At this point, other headers might have been sent; - // even if $GLOBALS['is_header_sent'] is true, - // we have to send these additional headers. - if (! defined('TESTSUITE')) { - header('Cache-Control: no-cache'); - header("Content-Type: application/json"); - } - - echo json_encode($response); - - if (! defined('TESTSUITE')) { - exit; - } + $response = PMA_Response::getInstance(); + $response->isSuccess($success); + $response->addJSON('message', $message); + $response->addJSON($extra_data); + exit; } /** From 971db49c1143446238157c9bf6b8fc5bed3b55fb Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 17:46:00 +0100 Subject: [PATCH 107/116] Expect JSON for every ajax request in JavaScript --- js/db_operations.js | 9 +++---- js/db_search.js | 8 +++--- js/db_structure.js | 2 +- js/functions.js | 47 ++++++++++++++++----------------- js/makegrid.js | 3 +-- js/navigation.js | 2 ++ js/server_databases.js | 3 +-- js/server_privileges.js | 35 ++++++++----------------- js/server_status.js | 4 +-- js/server_status_monitor.js | 8 +++--- js/server_variables.js | 2 +- js/sql.js | 52 ++++++++++++++----------------------- js/tbl_change.js | 3 +++ js/tbl_select.js | 15 +++-------- js/tbl_structure.js | 28 +++++++++----------- sql.php | 2 +- 16 files changed, 92 insertions(+), 131 deletions(-) diff --git a/js/db_operations.js b/js/db_operations.js index 170ff1ec0e..42c0f4552c 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -69,8 +69,7 @@ $(function() { $("" + PMA_messages['strReloadDatabase'] + "?").dialog({ buttons: button_options }) //end dialog options - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }) // end $.get() @@ -106,8 +105,7 @@ $(function() { // not refresh it window.parent.refreshNavigation(true); } - } - else { + } else { $('#floating_menubar').after(data.error); } @@ -131,8 +129,7 @@ $(function() { $.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").val(), function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }) // end $.get() diff --git a/js/db_search.js b/js/db_search.js index 5c80bb2f90..f1a18d48b4 100644 --- a/js/db_search.js +++ b/js/db_search.js @@ -193,10 +193,10 @@ $(function() { PMA_prepareForAjaxRequest($form); var url = $form.serialize() + "&submit_search=" + $("#buttonGo").val(); - $.post($form.attr('action'), url, function(response) { - if (typeof response == 'string') { + $.post($form.attr('action'), url, function(data) { + if (data.success == true) { // found results - $("#searchresults").html(response); + $("#searchresults").html(data.message); $('#togglesearchresultlink') // always start with the Show message @@ -219,7 +219,7 @@ $(function() { .show(); } else { // error message (zero rows) - $("#sqlqueryresults").html(response['message']); + $("#sqlqueryresults").html(data.error); } PMA_ajaxRemoveMessage($msgbox); diff --git a/js/db_structure.js b/js/db_structure.js index 5305431334..8b0629713e 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -173,7 +173,7 @@ $(function() { }); // end dialog options } else { var $dialog = $div - .append(data) + .append(data.message) .dialog({ title: PMA_messages['strInsertTable'], height: 600, diff --git a/js/functions.js b/js/functions.js index 40a5c2f38f..a20a204e6b 100644 --- a/js/functions.js +++ b/js/functions.js @@ -157,10 +157,9 @@ function PMA_display_git_revision() $.get("main.php?token=" + $("input[type=hidden][name=token]").val() + "&git_revision=1&ajax_request=true", function (data) { - if (data.error != "undefined" && data.error) { - return; + if (data.success == true) { + $(data.message).insertAfter('#li_pma_version'); } - $(data.message).insertAfter('#li_pma_version'); }); } @@ -1612,12 +1611,11 @@ function PMA_createTableDialog( $div, url , target) })// end dialog options //remove the redundant [Back] link in the error message. .find('fieldset').remove(); - } - else { + } else { var size = getWindowSize(); var timeout; $div - .append(data) + .append(data.message) .dialog({ dialogClass: 'create-table', resizable: false, @@ -1730,7 +1728,7 @@ function PMA_createChart(passedSettings) thisChart.options.realtime.postData, function(data) { try { - curValue = jQuery.parseJSON(data); + curValue = jQuery.parseJSON(data.message); } catch (err) { if (thisChart.options.realtime.error) { thisChart.options.realtime.error(err); @@ -2335,11 +2333,11 @@ $(function() { $.post($form.attr('action'), $form.serialize() + "&submit_num_fields=" + $(this).val(), function(data) { // if 'create_table_dialog' exists if ($("#create_table_dialog").length > 0) { - $("#create_table_dialog").html(data); + $("#create_table_dialog").html(data.message); } // if 'create_table_div' exists if ($("#create_table_div").length > 0) { - $("#create_table_div").html(data); + $("#create_table_div").html(data.message); } PMA_verifyColumnsProperties(); PMA_ajaxRemoveMessage($msgbox); @@ -2375,7 +2373,7 @@ $(function() { $("
").insertAfter("#floating_menubar"); $("#sqlqueryresults").html(data.sql_query); $("#result_query .notice").remove(); - $("#result_query").prepend((data.message)); + $("#result_query").prepend(data.message); } else { var $temp_div = $("
"); $temp_div.html(data.error); @@ -2411,7 +2409,7 @@ $(function() { $("
").insertAfter("#floating_menubar"); $("#sqlqueryresults").html(data.sql_query); $("#result_query .notice").remove(); - $("#result_query").prepend((data.message)); + $("#result_query").prepend(data.message); $("#copyTable").find("select[name='target_db'] option").filterByValue(data.db).prop('selected', true); //Refresh navigation frame when the table is coppied @@ -2444,19 +2442,19 @@ $(function() { } //variables which stores the common attributes $.post(href[0], href[1]+"&ajax_request=true", function(data) { - if (data.success == undefined) { - var $temp_div = $("
"); - $temp_div.html(data); - var $success = $temp_div.find("#result_query .success"); - PMA_ajaxShowMessage($success); - $("
").insertAfter("#floating_menubar"); - $("#sqlqueryresults").html(data); - PMA_init_slider(); - $("#sqlqueryresults").children("fieldset").remove(); - } else if (data.success == true ) { + if (data.success == true && data.sql_query != undefined) { PMA_ajaxShowMessage(data.message); $("
").insertAfter("#floating_menubar"); $("#sqlqueryresults").html(data.sql_query); + } else if (data.success == true) { + var $temp_div = $("
"); + $temp_div.html(data.message); + var $success = $temp_div.find("#result_query .success"); + PMA_ajaxShowMessage($success); + $("
").insertAfter("#floating_menubar"); + $("#sqlqueryresults").html(data.message); + PMA_init_slider(); + $("#sqlqueryresults").children("fieldset").remove(); } else { var $temp_div = $("
"); $temp_div.html(data.error); @@ -2535,8 +2533,7 @@ $(function() { if (window.parent && window.parent.frame_navigation) { window.parent.frame_navigation.location.reload(); } - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }); // end $.post() @@ -3798,13 +3795,13 @@ $(document).ready(function () { buttonOptions[PMA_messages['strClose']] = function () { $(this).dialog("close"); }; - var $dialog = $('
').attr('id', 'createViewDialog').append(data).dialog({ + var $dialog = $('
').attr('id', 'createViewDialog').append(data.message).dialog({ width: 500, minWidth: 300, maxWidth: 620, modal: true, buttons: buttonOptions, - title: $('legend', $(data)).html(), + title: $('legend', $(data.message)).html(), close: function () { $(this).remove(); } diff --git a/js/makegrid.js b/js/makegrid.js index 00f49ea8a9..3edcb7f699 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -950,8 +950,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $editArea.find('textarea').val($(this).val()); }); $editArea.append('
' + g.cellEditHint + '
'); - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }); // end $.post() diff --git a/js/navigation.js b/js/navigation.js index cd65e595d8..f8e335cf16 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -180,12 +180,14 @@ function fast_filter(value) } fast_filter.ajax_semaphore = true; $.get('db_tables_search.php?db=' + db +'&table=' + lowercase_value, function(data) { + if (data.tables) { var tables = data.tables; var l = tables.length; for(var i = 0; i < l; i++) { $('#subel0').append(tables[i].line); } fast_filter.ajax_semaphore = false; + } }); } } diff --git a/js/server_databases.js b/js/server_databases.js index 5fdff9344b..14684279f0 100644 --- a/js/server_databases.js +++ b/js/server_databases.js @@ -59,8 +59,7 @@ $(function() { window.parent.frame_navigation.location.reload(); } $('#tableslistcontainer').load('server_databases.php form#dbStatsForm'); - } - else { + } else { PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + ": " + data.error, false); } }); // end $.post() diff --git a/js/server_privileges.js b/js/server_privileges.js index d4c8d8d37b..5303ac276f 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -169,22 +169,12 @@ $(function() { } else { $("#usersForm").remove(); } - var $user_div = $('
'); - /*If the JSON string parsed correctly*/ - if (typeof priv_data.success != 'undefined') { - if (priv_data.success == true) { - $user_div - .html(priv_data.user_form) - .insertAfter('#result_query'); - } else { - PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + priv_data.error, false); - } + if (priv_data.success == true) { + $('
') + .html(priv_data.user_form) + .insertAfter('#result_query'); } else { - /*parse the JSON string*/ - var obj = $.parseJSON(priv_data); - $user_div - .html(obj.user_form) - .insertAfter('#result_query'); + PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + priv_data.error, false); } }); } else { @@ -199,7 +189,7 @@ $(function() { $.get($(this).attr("href"), {'ajax_request':true}, function(data) { var $div = $('
') - .prepend(data) + .prepend(data.message) .find("#fieldset_add_user_footer").hide() //showing the "Go" and "Create User" buttons together will confuse the user .end() .find("form[name=usersForm]").append('') @@ -251,8 +241,7 @@ $(function() { $.get($(this).attr("href"), {'ajax_request': true}, function(data) { if(data.success == true) { PMA_ajaxRemoveMessage($msgbox); - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }); //end $.get() @@ -300,8 +289,7 @@ $(function() { .find('tr:even') .removeClass('odd').addClass('even'); }); - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }); // end $.post() @@ -343,7 +331,7 @@ $(function() { }, function(data) { var $div = $('
') - .append(data) + .append(data.message) .dialog({ width: 900, height: 600, @@ -436,8 +424,7 @@ $(function() { $("#usersForm") .find('.current_row') .removeClass('current_row'); - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }); @@ -562,7 +549,7 @@ $(function() { $("#usersForm").hide("medium").remove(); $("#fieldset_add_user").hide("medium").remove(); $("#initials_table") - .after(data).show("medium") + .after(data.message).show("medium") .siblings("h2").not(":first").remove(); PMA_ajaxRemoveMessage($msgbox); diff --git a/js/server_status.js b/js/server_status.js index 243cbe84d3..eb0dfc1c3e 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -220,7 +220,7 @@ $(function() { $.get($(this).attr('href'), { ajax_request: 1 }, function(data) { $(that).find('img').hide(); - initTab(tab, data); + initTab(tab, data.message); }); tabStatus[tab.attr('id')] = 'data'; @@ -646,7 +646,7 @@ $(function() { $.get('server_status.php?' + url_query, { ajax_request: true, advisor: true }, function(data) { var $tbody, $tr, str, even = true; - data = $.parseJSON(data); + data = $.parseJSON(data.message); $cnt.html(''); diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index 6904beb21b..c24c91ab09 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -621,7 +621,7 @@ $(function() { $.get('server_status.php?' + url_query, vars, function(data) { - var logVars = $.parseJSON(data), + var logVars = $.parseJSON(data.message), icon = PMA_getImage('s_success.png'), msg='', str=''; if (logVars['general_log'] == 'ON') { @@ -1202,7 +1202,7 @@ $(function() { }, function(data) { var chartData; try { - chartData = $.parseJSON(data); + chartData = $.parseJSON(data.message); } catch(err) { return serverResponseError(); } @@ -1388,7 +1388,7 @@ $(function() { function(data) { var logData; try { - logData = $.parseJSON(data); + logData = $.parseJSON(data.message); } catch(err) { return serverResponseError(); } @@ -1773,7 +1773,7 @@ $(function() { query: codemirror_editor ? codemirror_editor.getValue() : $('#sqlquery').val(), database: db }, function(data) { - data = $.parseJSON(data); + data = $.parseJSON(data.message); var totalTime = 0; if (data.error) { diff --git a/js/server_variables.js b/js/server_variables.js index 94ca6110da..1e952f4784 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -174,7 +174,7 @@ function editVariable(link) $cell.html(''); // put edit field and save/cancel link $cell.prepend('
' + - '
'); + ''); $cell.find('table td:first').append(mySaveLink); $cell.find('table td:first').append(' '); $cell.find('table td:first').append(myCancelLink); diff --git a/js/sql.js b/js/sql.js index 22c37305a3..a31709effc 100644 --- a/js/sql.js +++ b/js/sql.js @@ -197,6 +197,7 @@ $(function() { // // fade out previous messages, if any $('div.success, div.sqlquery_message').fadeOut(); + // show a message that stays on screen if (typeof data.action_bookmark != 'undefined') { // view only @@ -209,7 +210,9 @@ $(function() { if ('2' == data.action_bookmark) { $("#id_bookmark option[value='" + data.id_bookmark + "']").remove(); } - $('#sqlqueryform').before(data.message); + $sqlqueryresults + .show() + .html(data.message); } else if (typeof data.sql_query != 'undefined') { $('
') .html(data.sql_query) @@ -217,9 +220,18 @@ $(function() { // unnecessary div that came from data.sql_query $('div.notice').remove(); } else { - $('#sqlqueryform').before(data.message); + $sqlqueryresults + .show() + .html(data.message); + } + $sqlqueryresults.show().trigger('makegrid'); + $('#togglequerybox').show(); + PMA_init_slider(); + if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) { + if ($("#togglequerybox").siblings(":visible").length > 0) { + $("#togglequerybox").trigger('click'); + } } - $sqlqueryresults.show(); // this happens if a USE command was typed if (typeof data.reload != 'undefined') { // Unbind the submit event before reloading. See bug #3295529 @@ -236,29 +248,6 @@ $(function() { // show an error message that stays on screen $('#sqlqueryform').before(data.error); $sqlqueryresults.hide(); - } else { - // real results are returned - // fade out previous messages, if any - $('div.success, div.sqlquery_message').fadeOut(); - var $received_data = $(data); - var $zero_row_results = $received_data.find('textarea[name="sql_query"]'); - // if zero rows are returned from the query execution - if ($zero_row_results.length > 0) { - $('#sqlquery').val($zero_row_results.val()); - setQuery($('#sqlquery').val()); - } else { - $sqlqueryresults - .show() - .html(data) - .trigger('makegrid'); - $('#togglequerybox').show(); - if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) { - if ($("#togglequerybox").siblings(":visible").length > 0) { - $("#togglequerybox").trigger('click'); - } - } - PMA_init_slider(); - } } PMA_ajaxRemoveMessage($msgbox); }); // end $.post() @@ -302,10 +291,9 @@ $(function() { $.post($form.attr('action'), $form.serialize(), function(data) { $("#sqlqueryresults") - .html(data) + .html(data.message) .trigger('makegrid'); PMA_init_slider(); - PMA_ajaxRemoveMessage($msgbox); }); // end $.post() } @@ -327,7 +315,7 @@ $(function() { $.post($form.attr('action'), $form.serialize() + '&ajax_request=true', function(data) { $("#sqlqueryresults") - .html(data) + .html(data.message) .trigger('makegrid'); PMA_init_slider(); PMA_ajaxRemoveMessage($msgbox); @@ -353,7 +341,7 @@ $(function() { $.get($anchor.attr('href'), $anchor.serialize() + '&ajax_request=true', function(data) { $("#sqlqueryresults") - .html(data) + .html(data.message) .trigger('makegrid'); PMA_ajaxRemoveMessage($msgbox); }); // end $.get() @@ -372,7 +360,7 @@ $(function() { $.post($form.attr('action'), $form.serialize() + '&ajax_request=true' , function(data) { $("#sqlqueryresults") - .html(data) + .html(data.message) .trigger('makegrid'); PMA_init_slider(); }); // end $.post() @@ -422,7 +410,7 @@ $(function() { }); // end dialog options } else { $div - .append(data) + .append(data.message) .dialog({ title: PMA_messages['strChangeTbl'], height: 600, diff --git a/js/tbl_change.js b/js/tbl_change.js index 04c5247fac..22fb5f8f70 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -322,6 +322,9 @@ $(function() { * to previous page" and "insert another new row" actions, using AJAX * has no obvious advantage. If inserting, the "go back to previous" * action needs a page refresh anyway. + * + * 3. The handling of the response is also broken because PMA + * no longher returns plain HTML for an ajax request */ $("#insertFormDEACTIVATED").live('submit', function(event) { diff --git a/js/tbl_select.js b/js/tbl_select.js index bd50a10733..b8c9f386d5 100644 --- a/js/tbl_select.js +++ b/js/tbl_select.js @@ -52,11 +52,11 @@ $(function() { PMA_prepareForAjaxRequest($search_form); - $.post($search_form.attr('action'), $search_form.serialize(), function(response) { + $.post($search_form.attr('action'), $search_form.serialize(), function(data) { PMA_ajaxRemoveMessage($msgbox); - if (typeof response == 'string') { + if (data.success == true) { // found results - $("#sqlqueryresults").html(response); + $("#sqlqueryresults").html(data.message); $("#sqlqueryresults").trigger('makegrid'); $('#tbl_search_form') // workaround for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome. @@ -71,14 +71,7 @@ $(function() { // needed for the display options slider in the results PMA_init_slider(); } else { - // error message (zero rows) - if (response.message != undefined) { - $("#sqlqueryresults").html(response['message']); - } - // other error (syntax error?) - if (response.error != undefined) { - $("#sqlqueryresults").html(response['error']); - } + $("#sqlqueryresults").html(data.error); } }); // end $.post() }); diff --git a/js/tbl_structure.js b/js/tbl_structure.js index c93826504f..64800daf5b 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -64,8 +64,7 @@ $(function() { $curr_row.hide("medium").remove(); // refresh the list of indexes (comes from sql.php) $('#indexes').html(data.indexes_list); - } - else { + } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false); } }); // end $.get() @@ -104,8 +103,7 @@ $(function() { if (typeof data.reload != 'undefined') { window.parent.frame_content.location.reload(); } - } - else { + } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false); } }); // end $.get() @@ -158,8 +156,7 @@ $(function() { $(this).remove(); }); } - } - else { + } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false); } }); // end $.get() @@ -265,7 +262,7 @@ $(function() { $("#edit_index_dialog").dialog("close"); } $('div.no_indexes_defined').hide(); - } else if (data.error != undefined) { + } else { var $temp_div = $("
").append(data.error); if ($temp_div.find(".error code").length != 0) { var $error = $temp_div.find(".error code").addClass("error"); @@ -281,14 +278,14 @@ $(function() { }; var $msgbox = PMA_ajaxShowMessage(); $.get("tbl_indexes.php", url, function(data) { - if (data.error) { + if (data.success == false) { //in the case of an error, show the error message returned. PMA_ajaxShowMessage(data.error, false); } else { PMA_ajaxRemoveMessage($msgbox); // Show dialog if the request was successful $div - .append(data) + .append(data.message) .dialog({ title: title, width: 450, @@ -390,7 +387,7 @@ $(function() { } $.post($form.prop("action"), serialized + "&ajax_request=true", function (data) { - if (data.success != undefined && data.success == false) { + if (data.success == false) { PMA_ajaxRemoveMessage($msgbox); $this .clone() @@ -410,8 +407,7 @@ $(function() { // loop through the correct order for (var i in data.columns) { var the_column = data.columns[i]; - var $the_row - = $rows + var $the_row = $rows .find("input:checkbox[value=" + the_column + "]") .closest("tr"); // append the row for this column to the table @@ -526,7 +522,7 @@ $(function() { }); // end dialog options } else { $div - .append(data) + .append(data.message) .dialog({ title: PMA_messages['strAddColumns'], height: 600, @@ -604,7 +600,7 @@ function changeColumns(action,url) }); // end dialog options } else { $div - .append(data) + .append(data.message) .dialog({ title: PMA_messages['strChangeTbl'], height: 600, @@ -673,7 +669,7 @@ $(function() { /*Reload the field form*/ reloadFieldForm(data.message); } else { - var $temp_div = $("
").append(data); + var $temp_div = $("
").append(data.error); var $error = $temp_div.find(".error code").addClass("error"); PMA_ajaxShowMessage($error, false); } @@ -693,7 +689,7 @@ $(function() { */ function reloadFieldForm(message) { $.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) { - var $temp_div = $("
").append(form_data); + var $temp_div = $("
").append(form_data.message); $("#fieldsForm").replaceWith($temp_div.find("#fieldsForm")); $("#addColumns").replaceWith($temp_div.find("#addColumns")); $('#move_columns_dialog ul').replaceWith($temp_div.find("#move_columns_dialog ul")); diff --git a/sql.php b/sql.php index 40b430f281..c20ed2bc7f 100644 --- a/sql.php +++ b/sql.php @@ -820,7 +820,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { $extra_data['reload'] = 1; $extra_data['db'] = $GLOBALS['db']; } - PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : '')); + PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : array())); } if ($is_gotofile) { From ec5322ed2617b902144c9b4857b3c2c4dc5becbe Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 18:30:36 +0100 Subject: [PATCH 108/116] Fixed conflicting global variable names --- libraries/user_preferences.inc.php | 3 +-- prefs_manage.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php index 50398ceac9..9e81795a03 100644 --- a/libraries/user_preferences.inc.php +++ b/libraries/user_preferences.inc.php @@ -43,8 +43,7 @@ echo '
'; // show "configuration saved" message and reload navigation frame if needed if (!empty($_GET['saved'])) { - $message = PMA_Message::rawSuccess(__('Configuration has been saved')); - $message->display(); + PMA_Message::rawSuccess(__('Configuration has been saved'))->display(); } /* debug code diff --git a/prefs_manage.php b/prefs_manage.php index 2cf8dd0a68..0f55689089 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -295,8 +295,7 @@ PMA_printJsValue("PMA_messages['strSavedOn']", __('Saved on: @DATE@'));

From 8b0f21aa0d38751b674abf949223b0085eb03c97 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 20:07:51 +0100 Subject: [PATCH 109/116] Fixed user preferences export/import --- js/config.js | 1 + prefs_manage.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/config.js b/js/config.js index df9cbaa6b5..cdd9156ad2 100644 --- a/js/config.js +++ b/js/config.js @@ -690,6 +690,7 @@ function savePrefsToLocalStorage(form) cache: false, type: 'POST', data: { + ajax_request: true, token: form.find('input[name=token]').val(), submit_get_json: true }, diff --git a/prefs_manage.php b/prefs_manage.php index 0f55689089..d18479dfe8 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -23,6 +23,7 @@ PMA_userprefs_pageinit(); $error = ''; if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == 'text_file') { // export to JSON file + PMA_Response::getInstance()->disable(); $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json'; PMA_downloadHeader($filename, 'application/json'); $settings = PMA_load_userprefs(); @@ -30,8 +31,9 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == return; } else if (isset($_POST['submit_get_json'])) { $settings = PMA_load_userprefs(); - header('Content-Type: application/json'); - echo json_encode( + PMA_ajaxResponse( + '', + true, array( 'prefs' => json_encode($settings['config_data']), 'mtime' => $settings['mtime'] From 1871e8279e26c91deea2b0e642dbdd9de479492e Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 9 Jun 2012 20:43:51 +0100 Subject: [PATCH 110/116] Fixed ajax responses in server_variable.php --- server_variables.php | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/server_variables.php b/server_variables.php index 7a5e1c49fe..59a3238bfa 100644 --- a/server_variables.php +++ b/server_variables.php @@ -33,11 +33,10 @@ require 'libraries/server_variables_doc.php'; if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { // Send with correct charset - header('Content-Type: text/html; charset=UTF-8'); - if (isset($_REQUEST['type'])) { switch($_REQUEST['type']) { case 'getval': + header('Content-Type: text/html; charset=UTF-8'); $varValue = PMA_DBI_fetch_single_row( 'SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM' @@ -67,6 +66,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { $value="'" . $value . "'"; } + $response = PMA_Response::getInstance(); if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value) ) { @@ -75,25 +75,18 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { 'SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM' ); - - exit( - json_encode( - array( - 'success' => true, - 'variable' => formatVariable($_REQUEST['varName'], $varValue[1]) - ) - ) + $response->addJSON( + 'variable', + formatVariable($_REQUEST['varName'], $varValue[1]) + ); + } else { + $response->isSuccess(false); + $response->addJSON( + 'error', + __('Setting variable failed') ); } - - exit( - json_encode( - array( - 'success' => false, - 'error' => __('Setting variable failed') - ) - ) - ); + exit; break; } } From a16e723048940f87b4be4b4097d16c4376826f2c Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 11 Jun 2012 17:58:35 +0100 Subject: [PATCH 111/116] Dropped PMA_ajaxResponse() --- db_create.php | 28 ++++---- db_operations.php | 15 ++-- db_tables_search.php | 3 +- db_tracking.php | 9 +-- gis_data_editor.php | 8 ++- import.php | 18 +++-- js/functions.js | 5 +- js/gis_data_editor.js | 9 +-- js/sql.js | 10 ++- js/tbl_zoom_plot_jqplot.js | 5 +- libraries/auth/cookie.auth.lib.php | 2 +- libraries/common.lib.php | 29 ++------ libraries/db_common.inc.php | 7 +- libraries/rte/rte_events.lib.php | 25 ++++--- libraries/rte/rte_export.lib.php | 11 ++- libraries/rte/rte_routines.lib.php | 66 +++++++++-------- libraries/rte/rte_triggers.lib.php | 33 +++++---- navigation.php | 9 +-- prefs_manage.php | 15 ++-- server_databases.php | 5 +- server_privileges.php | 17 +++-- sql.php | 46 ++++++++---- tbl_addfield.php | 8 ++- tbl_alter.php | 30 ++++---- tbl_create.php | 41 ++++++----- tbl_indexes.php | 26 ++++--- tbl_move_copy.php | 23 +++--- tbl_operations.php | 16 +++-- tbl_replace.php | 7 +- tbl_zoom_select.php | 25 +++---- .../common/PMA_ajaxResponse_test.php | 71 ------------------- view_create.php | 18 ++++- 32 files changed, 330 insertions(+), 310 deletions(-) delete mode 100644 test/libraries/common/PMA_ajaxResponse_test.php diff --git a/db_create.php b/db_create.php index c0618b1ca8..b04a793f84 100644 --- a/db_create.php +++ b/db_create.php @@ -61,12 +61,15 @@ if (! $result) { $GLOBALS['table'] = ''; /** - * If in an Ajax request, just display the message with {@link PMA_ajaxResponse} + * If in an Ajax request, just display the message with {@link PMA_Response} */ if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($message, false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $message); + } else { + include_once 'main.php'; } - include_once 'main.php'; } else { $message = PMA_Message::success(__('Database %1$s has been created.')); $message->addParam($new_db); @@ -76,14 +79,6 @@ if (! $result) { * If in an Ajax request, build the output and send it */ if ($GLOBALS['is_ajax_request'] == true) { - - /** - * String containing the SQL Query formatted in pretty HTML - * @global array $GLOBALS['extra_data'] - * @name $extra_data - */ - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query, 'success'); - //Construct the html for the new database, so that it can be appended to // the list of databases on server_databases.php @@ -137,11 +132,12 @@ if (! $result) { $new_db_string .= ''; - $extra_data['new_db_string'] = $new_db_string; - - PMA_ajaxResponse($message, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $message); + $response->addJSON('new_db_string', $new_db_string); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query, 'success')); + } else { + include_once '' . $cfg['DefaultTabDatabase']; } - - include_once '' . $cfg['DefaultTabDatabase']; } ?> diff --git a/db_operations.php b/db_operations.php index 4e77fe8822..16f6191802 100644 --- a/db_operations.php +++ b/db_operations.php @@ -340,13 +340,16 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { /** * Database has been successfully renamed/moved. If in an Ajax request, - * generate the output with {@link PMA_ajaxResponse} and exit + * generate the output with {@link PMA_Response} and exit */ - if ( $GLOBALS['is_ajax_request'] == true) { - $extra_data['newname'] = $newname; - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); - }; + if ($GLOBALS['is_ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON('newname', $newname); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + exit; + } } diff --git a/db_tables_search.php b/db_tables_search.php index 6dbb1a4e8f..53542ca9c7 100644 --- a/db_tables_search.php +++ b/db_tables_search.php @@ -63,5 +63,6 @@ foreach ($tables_full as $key => $table) { } } -PMA_ajaxResponse('', true, array('tables' => $tables_response)); +$response = PMA_Response::getInstance(); +$response->addJSON('tables', $tables_response); ?> diff --git a/db_tracking.php b/db_tracking.php index 91b33147a3..94e4fe4847 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -20,8 +20,8 @@ $scripts->addFile('db_structure.js'); */ if ($GLOBALS['is_ajax_request'] != true) { include 'libraries/db_common.inc.php'; + $url_query .= '&goto=tbl_tracking.php&back=db_tracking.php'; } -$url_query .= '&goto=tbl_tracking.php&back=db_tracking.php'; // Get the database structure $sub_part = '_structure'; @@ -34,11 +34,12 @@ if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) { /** * If in an Ajax request, generate the success message and use - * {@link PMA_ajaxResponse()} to send the output + * {@link PMA_Response()} to send the output */ if ($GLOBALS['is_ajax_request'] == true) { - $message = PMA_Message::success(); - PMA_ajaxResponse($message, true); + $response = PMA_Response::getInstance(); + $response->addJSON('message', PMA_Message::success()); + exit; } } diff --git a/gis_data_editor.php b/gis_data_editor.php index 83b59fe34a..9eb0e99744 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -62,7 +62,9 @@ if (isset($_REQUEST['generate']) && $_REQUEST['generate'] == true) { 'visualization' => $visualization, 'openLayers' => $open_layers, ); - PMA_ajaxResponse(null, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON($extra_data); + exit; } ob_start(); @@ -311,7 +313,7 @@ ob_start(); addJSON('gis_editor', ob_get_contents()); +ob_end_clean(); ?> diff --git a/import.php b/import.php index 1522c0d048..85dfaea5e1 100644 --- a/import.php +++ b/import.php @@ -221,10 +221,13 @@ if (! empty($id_bookmark)) { case 1: // bookmarked query that have to be displayed $import_text = PMA_Bookmark_get($db, $id_bookmark); if ($GLOBALS['is_ajax_request'] == true) { - $extra_data['sql_query'] = $import_text; - $extra_data['action_bookmark'] = $action_bookmark; $message = PMA_Message::success(__('Showing bookmark')); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON('sql_query', $import_text); + $response->addJSON('action_bookmark', $action_bookmark); + exit; } else { $run_query = false; } @@ -234,9 +237,12 @@ if (! empty($id_bookmark)) { PMA_Bookmark_delete($db, $id_bookmark); if ($GLOBALS['is_ajax_request'] == true) { $message = PMA_Message::success(__('The bookmark has been deleted.')); - $extra_data['action_bookmark'] = $action_bookmark; - $extra_data['id_bookmark'] = $id_bookmark; - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON('action_bookmark', $action_bookmark); + $response->addJSON('id_bookmark', $id_bookmark); + exit; } else { $run_query = false; $error = true; // this is kind of hack to skip processing the query diff --git a/js/functions.js b/js/functions.js index a20a204e6b..c907328c1e 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2417,10 +2417,7 @@ $(function() { window.parent.frame_navigation.location.reload(); } } else { - var $temp_div = $("
"); - $temp_div.html(data.error); - var $error = $temp_div.find("code").addClass("error"); - PMA_ajaxShowMessage($error, false); + PMA_ajaxShowMessage(data.error, false); } }); // end $.post() } diff --git a/js/gis_data_editor.js b/js/gis_data_editor.js index 477b3988a9..9cba83659d 100644 --- a/js/gis_data_editor.js +++ b/js/gis_data_editor.js @@ -142,7 +142,8 @@ function loadGISEditor(value, field, type, input_name, token) { 'type' : type, 'input_name' : input_name, 'get_gis_editor' : true, - 'token' : token + 'token' : token, + 'ajax_request': true }, function(data) { if (data.success == true) { $gis_editor.html(data.gis_editor); @@ -190,7 +191,7 @@ function insertDataAndClose() { var $form = $('form#gis_data_editor_form'); var input_name = $form.find("input[name='input_name']").val(); - $.post('gis_data_editor.php', $form.serialize() + "&generate=true", function(data) { + $.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function(data) { if(data.success == true) { $("input[name='" + input_name + "']").val(data.result); } else { @@ -226,7 +227,7 @@ $(function() { */ $('#gis_editor').find("input[type='text']").live('change', function() { var $form = $('form#gis_data_editor_form'); - $.post('gis_data_editor.php', $form.serialize() + "&generate=true", function(data) { + $.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function(data) { if(data.success == true) { $('#gis_data_textarea').val(data.result); $('#placeholder').empty().removeClass('hasSVG').html(data.visualization); @@ -246,7 +247,7 @@ $(function() { var $gis_editor = $("#gis_editor"); var $form = $('form#gis_data_editor_form'); - $.post('gis_data_editor.php', $form.serialize() + "&get_gis_editor=true", function(data) { + $.post('gis_data_editor.php', $form.serialize() + "&get_gis_editor=true&ajax_request=true", function(data) { if(data.success == true) { $gis_editor.html(data.gis_editor); initGISEditorVisualization(); diff --git a/js/sql.js b/js/sql.js index a31709effc..895e509386 100644 --- a/js/sql.js +++ b/js/sql.js @@ -227,11 +227,15 @@ $(function() { $sqlqueryresults.show().trigger('makegrid'); $('#togglequerybox').show(); PMA_init_slider(); - if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) { - if ($("#togglequerybox").siblings(":visible").length > 0) { - $("#togglequerybox").trigger('click'); + + if (typeof data.action_bookmark == 'undefined') { + if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) { + if ($("#togglequerybox").siblings(":visible").length > 0) { + $("#togglequerybox").trigger('click'); + } } } + // this happens if a USE command was typed if (typeof data.reload != 'undefined') { // Unbind the submit event before reloading. See bug #3295529 diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index e7d60eeb8d..4c3b0706fa 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -12,10 +12,7 @@ ** Display Help/Info **/ function displayHelp() { - var msgbox = PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000); - msgbox.click(function() { - PMA_ajaxRemoveMessage(msgbox); - }); + PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000); } /** diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 7eb487c014..c4f5d2fc35 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -136,7 +136,7 @@ function PMA_auth() if (! empty($conn_error)) { $response->addJSON('message', $conn_error); } else { - $response->addJSON('message', __('Session expired')); + $response->addJSON('message', PMA_Message::error(__('Your session has expired. Please login again.'))); } exit; } diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 08b0437c94..77bb491e4e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -679,10 +679,13 @@ function PMA_mysqlDie( /** * If in an Ajax request * - avoid displaying a Back link - * - use PMA_ajaxResponse() to transmit the message and exit + * - use PMA_Response() to transmit the message and exit */ if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($error_msg, false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $error_msg); + exit; } if (! empty($back_url)) { if (strstr($back_url, '?')) { @@ -3244,28 +3247,6 @@ function PMA_expandUserString($string, $escape = null, $updates = array()) return strtr(strftime($string), $replace); } -/** - * function that generates a json output for an ajax request and ends script - * execution - * - * @param PMA_Message|string $message message string containing the - * html of the message - * @param bool $success success whether the ajax request - * was successfull - * @param array $extra_data extra data optional - any other data - * as part of the json request - * - * @return void - */ -function PMA_ajaxResponse($message, $success = true, $extra_data = array()) -{ - $response = PMA_Response::getInstance(); - $response->isSuccess($success); - $response->addJSON('message', $message); - $response->addJSON($extra_data); - exit; -} - /** * Display the form used to browse anywhere on the local server for a file to * import diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php index 7516a2dd20..75ae3a280d 100644 --- a/libraries/db_common.inc.php +++ b/libraries/db_common.inc.php @@ -72,8 +72,11 @@ if (isset($submitcollation) && !empty($db_collation)) { * other pages, we might have to move this to a different location. */ if ( $GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($message, $message->isSuccess()); - }; + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + exit; + } } /** diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php index 55d7b9c02e..3c5832614e 100644 --- a/libraries/rte/rte_events.lib.php +++ b/libraries/rte/rte_events.lib.php @@ -148,21 +148,22 @@ function PMA_EVN_handleEditor() $output = PMA_getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { - $extra_data = array(); + $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $columns = "`EVENT_NAME`, `EVENT_TYPE`, `STATUS`"; $where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "' " . "AND EVENT_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'"; $query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where;"; $event = PMA_DBI_fetch_single_row($query); - $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name'])); - $extra_data['new_row'] = PMA_EVN_getRowForList($event); - $extra_data['insert'] = ! empty($event); - $response = $output; + $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name']))); + $response->addJSON('new_row', PMA_EVN_getRowForList($event)); + $response->addJSON('insert', ! empty($event)); + $response->addJSON('message', $output); } else { - $response = $message; + $response->isSuccess(false); + $response->addJSON('message', $message); } - PMA_ajaxResponse($response, $message->isSuccess(), $extra_data); + exit; } } /** @@ -200,8 +201,9 @@ function PMA_EVN_handleEditor() // Show form $editor = PMA_EVN_getEditorForm($mode, $operation, $item); if ($GLOBALS['is_ajax_request']) { - $extra_data = array('title' => $title); - PMA_ajaxResponse($editor, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $editor); + $response->addJSON('title', $title); } else { echo "\n\n

$title

\n\n$editor"; unset($_POST); @@ -216,7 +218,10 @@ function PMA_EVN_handleEditor() ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { - PMA_ajaxResponse($message, false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $message); + exit; } else { $message->display(); } diff --git a/libraries/rte/rte_export.lib.php b/libraries/rte/rte_export.lib.php index 45adb0edea..47751fb4a3 100644 --- a/libraries/rte/rte_export.lib.php +++ b/libraries/rte/rte_export.lib.php @@ -26,8 +26,10 @@ function PMA_RTE_handleExport($item_name, $export_data) . htmlspecialchars(trim($export_data)) . ''; $title = sprintf(PMA_RTE_getWord('export'), $item_name); if ($GLOBALS['is_ajax_request'] == true) { - $extra_data = array('title' => $title); - PMA_ajaxResponse($export_data, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $export_data); + $response->addJSON('title', $title); + exit; } else { echo "
\n" . "$title\n" @@ -40,7 +42,10 @@ function PMA_RTE_handleExport($item_name, $export_data) . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db); $response = PMA_message::error($response); if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($response, false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $response); + exit; } else { $response->display(); } diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index da85edd8ee..c5654635d6 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -301,21 +301,22 @@ function PMA_RTN_handleEditor() $output = PMA_getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { - $extra_data = array(); + $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`"; $where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' " . "AND ROUTINE_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'" . "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($_REQUEST['item_type']) . "'"; $routine = PMA_DBI_fetch_single_row("SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;"); - $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name'])); - $extra_data['new_row'] = PMA_RTN_getRowForList($routine); - $extra_data['insert'] = ! empty($routine); - $response = $output; + $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name']))); + $response->addJSON('new_row', PMA_RTN_getRowForList($routine)); + $response->addJSON('insert', ! empty($routine)); + $response->addJSON('message', $output); } else { - $response = $message; + $response->isSuccess(false); + $response->addJSON('message', $output); } - PMA_ajaxResponse($response, $message->isSuccess(), $extra_data); + exit; } } @@ -359,13 +360,14 @@ function PMA_RTN_handleEditor() // Show form $editor = PMA_RTN_getEditorForm($mode, $operation, $routine); if ($GLOBALS['is_ajax_request']) { - $template = PMA_RTN_getParameterRow(); - $extra_data = array('title' => $title, - 'param_template' => $template, - 'type' => $routine['item_type']); - PMA_ajaxResponse($editor, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $editor); + $response->addJSON('title', $title); + $response->addJSON('param_template', PMA_RTN_getParameterRow()); + $response->addJSON('type', $routine['item_type']); + } else { + echo "\n\n

$title

\n\n$editor"; } - echo "\n\n

$title

\n\n$editor"; exit; } else { $message = __('Error in processing request') . ' : '; @@ -376,7 +378,9 @@ function PMA_RTN_handleEditor() ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { - PMA_ajaxResponse($message, false); + $response->isSuccess(false); + $response->addJSON('message', $message); + exit; } else { $message->display(); } @@ -1267,12 +1271,11 @@ function PMA_RTN_handleExecute() } // Print/send output if ($GLOBALS['is_ajax_request']) { - $extra_data = array('dialog' => false); - PMA_ajaxResponse( - $message->getDisplay() . $output, - $message->isSuccess(), - $extra_data - ); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message->getDisplay() . $output); + $response->addJSON('dialog', false); + exit; } else { echo $message->getDisplay() . $output; if ($message->isError()) { @@ -1292,7 +1295,10 @@ function PMA_RTN_handleExecute() ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { - PMA_ajaxResponse($message, $message->isSuccess()); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $message); + exit; } else { echo $message->getDisplay(); unset($_POST); @@ -1306,18 +1312,18 @@ function PMA_RTN_handleExecute() if ($routine !== false) { $form = PMA_RTN_getExecuteForm($routine); if ($GLOBALS['is_ajax_request'] == true) { - $extra_data = array(); - $extra_data['dialog'] = true; - $extra_data['title'] = __("Execute routine") . " "; - $extra_data['title'] .= PMA_backquote( + $title = __("Execute routine") . " " . PMA_backquote( htmlentities($_GET['item_name'], ENT_QUOTES) ); - PMA_ajaxResponse($form, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $form); + $response->addJSON('title', $title); + $response->addJSON('dialog', true); } else { echo "\n\n

" . __("Execute routine") . "

\n\n"; echo $form; - exit; } + exit; } else if (($GLOBALS['is_ajax_request'] == true)) { $message = __('Error in processing request') . ' : '; $message .= sprintf( @@ -1326,7 +1332,11 @@ function PMA_RTN_handleExecute() htmlspecialchars(PMA_backquote($db)) ); $message = PMA_message::error($message); - PMA_ajaxResponse($message, false); + + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $message); + exit; } } } diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php index 25414eadd3..ba8d3f8b30 100644 --- a/libraries/rte/rte_triggers.lib.php +++ b/libraries/rte/rte_triggers.lib.php @@ -121,7 +121,7 @@ function PMA_TRI_handleEditor() $output = PMA_getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { - $extra_data = array(); + $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $items = PMA_DBI_get_triggers($db, $table, ''); $trigger = false; @@ -130,19 +130,24 @@ function PMA_TRI_handleEditor() $trigger = $value; } } - $extra_data['insert'] = false; + $insert = false; if (empty($table) || ($trigger !== false && $table == $trigger['table'])) { - $extra_data['insert'] = true; - $extra_data['new_row'] = PMA_TRI_getRowForList($trigger); - $extra_data['name'] = htmlspecialchars( - strtoupper($_REQUEST['item_name']) + $insert = true; + $response->addJSON('new_row', PMA_TRI_getRowForList($trigger)); + $response->addJSON( + 'name', + htmlspecialchars( + strtoupper($_REQUEST['item_name']) + ) ); } - $response = $output; + $response->addJSON('insert', $insert); + $response->addJSON('message', $output); } else { - $response = $message; + $response->addJSON('message', $message); + $response->isSuccess(false); } - PMA_ajaxResponse($response, $message->isSuccess(), $extra_data); + exit; } } @@ -175,8 +180,9 @@ function PMA_TRI_handleEditor() // Show form $editor = PMA_TRI_getEditorForm($mode, $item); if ($GLOBALS['is_ajax_request']) { - $extra_data = array('title' => $title); - PMA_ajaxResponse($editor, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $editor); + $response->addJSON('title', $title); } else { echo "\n\n

$title

\n\n$editor"; unset($_POST); @@ -191,7 +197,10 @@ function PMA_TRI_handleEditor() ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { - PMA_ajaxResponse($message, false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $message); + exit; } else { $message->display(); } diff --git a/navigation.php b/navigation.php index f92abf2883..17d649b6da 100644 --- a/navigation.php +++ b/navigation.php @@ -29,11 +29,12 @@ require_once 'libraries/RecentTable.class.php'; * Check if it is an ajax request to reload the recent tables list. */ if ($GLOBALS['is_ajax_request'] && $_REQUEST['recent_table']) { - PMA_ajaxResponse( - '', - true, - array('options' => PMA_RecentTable::getInstance()->getHtmlSelectOption()) + $response = PMA_Response::getInstance(); + $response->addJSON( + 'options', + PMA_RecentTable::getInstance()->getHtmlSelectOption() ); + exit; } // keep the offset of the db list in session before closing it diff --git a/prefs_manage.php b/prefs_manage.php index d18479dfe8..fac699bfec 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -28,18 +28,13 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == PMA_downloadHeader($filename, 'application/json'); $settings = PMA_load_userprefs(); echo json_encode($settings['config_data']); - return; + exit; } else if (isset($_POST['submit_get_json'])) { $settings = PMA_load_userprefs(); - PMA_ajaxResponse( - '', - true, - array( - 'prefs' => json_encode($settings['config_data']), - 'mtime' => $settings['mtime'] - ) - ); - return; + $response = PMA_Response::getInstance(); + $response->addJSON('prefs', json_encode($settings['config_data'])); + $response->addJSON('mtime', $settings['mtime']); + exit; } else if (isset($_POST['submit_import'])) { // load from JSON file $json = ''; diff --git a/server_databases.php b/server_databases.php index f267fb9d7d..a15e2cd178 100644 --- a/server_databases.php +++ b/server_databases.php @@ -117,7 +117,10 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type'])) } } if ($GLOBALS['is_ajax_request'] && $message instanceof PMA_Message) { - PMA_ajaxResponse($message, $message->isSuccess()); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + exit; } } diff --git a/server_privileges.php b/server_privileges.php index 0bf3955079..cb9cc59b7c 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -1643,7 +1643,11 @@ if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_RE } if ($message instanceof PMA_Message) { - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON($extra_data); + exit; } } @@ -1705,7 +1709,10 @@ if (isset($_REQUEST['export']) || (isset($_REQUEST['submit_mult']) && $_REQUEST[ $response .= ''; unset($username, $hostname, $grants, $one_grant); if ($GLOBALS['is_ajax_request']) { - PMA_ajaxResponse($response, 1, array('title' => $title)); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $response); + $response->addJSON('title', $title); + exit; } else { echo "

$title

$response"; } @@ -2568,9 +2575,11 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . '
' . "\n"; if ($GLOBALS['is_ajax_request'] == true) { - $extra_data['user_form'] = $user_form; $message = PMA_Message::success(__('User has been added.')); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('message', $message); + $response->addJSON('user_form', $user_form); + exit; } else { // Offer to create a new user for the current database $user_form .= '
' . "\n" diff --git a/sql.php b/sql.php index c20ed2bc7f..0a109a9b5a 100644 --- a/sql.php +++ b/sql.php @@ -146,8 +146,9 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_value $dropdown = ''; } - $extra_data['dropdown'] = $dropdown; - PMA_ajaxResponse(null, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('dropdown', $dropdown); + exit; } /** @@ -173,8 +174,9 @@ if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) $dropdown = ''; - $extra_data['dropdown'] = $dropdown; - PMA_ajaxResponse(null, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('dropdown', $dropdown); + exit; } /** @@ -201,8 +203,9 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { $select_size = (sizeof($values) > 10) ? 10 : sizeof($values); $select = ''; - $extra_data['select'] = $select; - PMA_ajaxResponse(null, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('select', $select); + exit; } /** @@ -220,7 +223,10 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) { $_REQUEST['table_create_time'] ); if (gettype($retval) != 'boolean') { - PMA_ajaxResponse($retval->getString(), false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $retval->getString()); + exit; } } @@ -232,11 +238,16 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) { $_REQUEST['table_create_time'] ); if (gettype($retval) != 'boolean') { - PMA_ajaxResponse($retval->getString(), false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $retval->getString()); + exit; } } - PMA_ajaxResponse(null, ($retval == true)); + $response = PMA_Response::getInstance(); + $response->isSuccess($retval == true); + exit; } // Default to browse if no query set and we have table @@ -572,7 +583,10 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) { $message = PMA_Message::rawError($error); if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($message, false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $message); + exit; } /** @@ -820,7 +834,11 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { $extra_data['reload'] = 1; $extra_data['db'] = $GLOBALS['db']; } - PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : array())); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON(isset($extra_data) ? $extra_data : array()); + exit; } if ($is_gotofile) { @@ -863,9 +881,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { // value of a transformed field, show it here and exit if ($GLOBALS['grid_edit'] == true && $GLOBALS['cfg']['AjaxEnable']) { $row = PMA_DBI_fetch_row($result); - $extra_data = array(); - $extra_data['value'] = $row[0]; - PMA_ajaxResponse(null, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON('value', $row[0]); + exit; } if (isset($_REQUEST['ajax_request']) && isset($_REQUEST['table_maintenance'])) { diff --git a/tbl_addfield.php b/tbl_addfield.php index e0cf74dda1..efde25c048 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -188,9 +188,11 @@ if (isset($_REQUEST['do_save_data'])) { $message = PMA_Message::success(__('Table %1$s has been altered successfully')); $message->addParam($table); - if ( $GLOBALS['is_ajax_request'] == true) { - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + if ($GLOBALS['is_ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->addJSON('message', $message); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + exit; } $active_page = 'tbl_structure.php'; diff --git a/tbl_alter.php b/tbl_alter.php index 8c41860fa0..b7e1d74b91 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -113,8 +113,10 @@ if (isset($_REQUEST['move_columns']) // insert moved column array_splice($column_names, $i, 0, $column); } + $response = PMA_Response::getInstance(); if (empty($changes)) { // should never happen - PMA_ajaxResponse('', true); + $response->isSuccess(false); + exit; } $move_query = 'ALTER TABLE ' . PMA_backquote($table) . ' '; $move_query .= implode(', ', $changes); @@ -122,15 +124,16 @@ if (isset($_REQUEST['move_columns']) $result = PMA_DBI_try_query($move_query); $tmp_error = PMA_DBI_getError(); if ($tmp_error) { - PMA_ajaxResponse(PMA_Message::error($tmp_error), false); + $response->isSuccess(false); + $response->addJSON('message', PMA_Message::error($tmp_error)); + } else { + $message = PMA_Message::success( + __('The columns have been moved successfully.') + ); + $response->addJSON('message', $message); + $response->addJSON('columns', $column_names); } - PMA_ajaxResponse( - PMA_Message::success(__('The columns have been moved successfully.')), - true, - array( - 'columns' => $column_names - ) - ); + exit; } /** @@ -249,9 +252,12 @@ if (isset($_REQUEST['do_save_data'])) { } } - if ( $_REQUEST['ajax_request'] == true) { - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + if ($_REQUEST['ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + exit; } $active_page = 'tbl_structure.php'; diff --git a/tbl_create.php b/tbl_create.php index 43832a887f..78f687129e 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -320,29 +320,31 @@ if (isset($_REQUEST['do_save_data'])) { $new_table_string .= '' . "\n"; - $extra_data['new_table_string'] = $new_table_string; - - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); - } - - $display_query = $sql_query; - $sql_query = ''; - - // read table info on this newly created table, in case - // the next page is Structure - $reread_info = true; - include 'libraries/tbl_info.inc.php'; - - // do not switch to sql.php - as there is no row to be displayed on a new table - if ($cfg['DefaultTabTable'] === 'sql.php') { - include 'tbl_structure.php'; + $response = PMA_Response::getInstance(); + $response->addJSON('message', $message); + $response->addJSON('new_table_string', $new_table_string); } else { - include '' . $cfg['DefaultTabTable']; + + $display_query = $sql_query; + $sql_query = ''; + + // read table info on this newly created table, in case + // the next page is Structure + $reread_info = true; + include 'libraries/tbl_info.inc.php'; + + // do not switch to sql.php - as there is no row to be displayed on a new table + if ($cfg['DefaultTabTable'] === 'sql.php') { + include 'tbl_structure.php'; + } else { + include '' . $cfg['DefaultTabTable']; + } } - exit; } else { if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse(PMA_DBI_getError(), false); + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', PMA_DBI_getError()); } else { PMA_mysqlDie('', '', '', $err_url, false); // An error happened while inserting/updating a table definition. @@ -352,6 +354,7 @@ if (isset($_REQUEST['do_save_data'])) { $regenerate = true; } } + exit; } // end do create table /** diff --git a/tbl_indexes.php b/tbl_indexes.php index dc07c9c925..5b1462585f 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -105,21 +105,25 @@ if (isset($_REQUEST['do_save_data'])) { 'Table %1$s has been altered successfully')); $message->addParam($table); - if ( $GLOBALS['is_ajax_request'] == true) { - $extra_data['index_table'] = PMA_Index::getView($table, $db); - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + if ($GLOBALS['is_ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->addJSON('message', $message); + $response->addJSON('index_table', PMA_Index::getView($table, $db)); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + } else { + $active_page = 'tbl_structure.php'; + include 'tbl_structure.php'; } - - $active_page = 'tbl_structure.php'; - include 'tbl_structure.php'; exit; } else { - if ( $GLOBALS['is_ajax_request'] == true) { - $extra_data['error'] = $error; - PMA_ajaxResponse($error, false); + if ($GLOBALS['is_ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $error); + exit; + } else { + $error->display(); } - $error->display(); } } // end builds the new index diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 6779754a59..c9a6d3aad4 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -64,16 +64,9 @@ if (PMA_isValid($_REQUEST['new_name'])) { /* Check: Work on new table or on old table? */ if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) { - $db = $_REQUEST['target_db']; - $table = $_REQUEST['new_name']; + $db = $_REQUEST['target_db']; + $table = $_REQUEST['new_name']; } - - if ( $_REQUEST['ajax_request'] == true) { - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); - $extra_data['db'] = $GLOBALS['db']; - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); - } - $reload = 1; } } else { @@ -84,6 +77,18 @@ if (PMA_isValid($_REQUEST['new_name'])) { $result = false; } +if ($GLOBALS['is_ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->addJSON('message', $message); + if ($message->isSuccess()) { + $response->addJSON('db', $GLOBALS['db']); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + } else { + $response->isSuccess(false); + } + exit; +} + /** * Back to the calling script */ diff --git a/tbl_operations.php b/tbl_operations.php index 3d44a7e684..e2d1e25319 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -231,17 +231,23 @@ if (isset($result) && empty($message_to_show)) { $_message = $result ? $message = PMA_Message::success(__('Your SQL query has been executed successfully')) : PMA_Message::error(__('Error')); // $result should exist, regardless of $_message $_type = $result ? 'success' : 'error'; - if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { - $extra_data['sql_query'] = PMA_getMessage(null, $sql_query); - PMA_ajaxResponse($_message, $_message->isSuccess(), $extra_data); + if ($GLOBALS['ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->isSuccess($_message->isSuccess()); + $response->addJSON('message', $_message); + $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + exit; } } if (! empty($warning_messages)) { $_message = new PMA_Message; $_message->addMessages($warning_messages); $_message->isError(true); - if ( $_REQUEST['ajax_request'] == true) { - PMA_ajaxResponse($_message, false); + if ($GLOBALS['ajax_request'] == true) { + $response = PMA_Response::getInstance(); + $response->isSuccess(false); + $response->addJSON('message', $_message); + exit; } unset($warning_messages); } diff --git a/tbl_replace.php b/tbl_replace.php index 2f75331b06..f74281dd69 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -421,7 +421,12 @@ if ($GLOBALS['is_ajax_request'] == true) { /**Get the total row count of the table*/ $extra_data['row_count'] = PMA_Table::countRecords($_REQUEST['db'], $_REQUEST['table']); $extra_data['sql_query'] = PMA_getMessage($message, $GLOBALS['display_query']); - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON($extra_data); + exit; } if (isset($return_to_sql_query)) { diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index cdb37b5b38..0ff020be97 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -72,7 +72,8 @@ if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) { } $extra_data['row_info'] = $row; } - PMA_ajaxResponse(null, true, $extra_data); + PMA_Response::getInstance()->addJSON($extra_data); + exit; } /** @@ -82,14 +83,14 @@ if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) { */ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) { - $extra_data = array(); + $response = PMA_Response::getInstance(); $field = $_REQUEST['field']; if ($field == 'pma_null') { - $extra_data['field_type'] = ''; - $extra_data['field_collation'] = ''; - $extra_data['field_operators'] = ''; - $extra_data['field_value'] = ''; - PMA_ajaxResponse(null, true, $extra_data); + $response->addJSON('field_type', ''); + $response->addJSON('field_collation', ''); + $response->addJSON('field_operators', ''); + $response->addJSON('field_value', ''); + exit; } // Gets the list and number of fields list($columnNames, $columnTypes, $columnCollations, $columnNullFlags) @@ -100,11 +101,11 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) $db, $table, $columnNames, $columnTypes, $columnCollations, $columnNullFlags, $foreigners, $_REQUEST['it'], $key ); - $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); + $response->addJSON('field_type', $properties['type']); + $response->addJSON('field_collation', $properties['collation']); + $response->addJSON('field_operators', $properties['func']); + $response->addJSON('field_value', $properties['value']); + exit; } $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); diff --git a/test/libraries/common/PMA_ajaxResponse_test.php b/test/libraries/common/PMA_ajaxResponse_test.php deleted file mode 100644 index 916f15b2b4..0000000000 --- a/test/libraries/common/PMA_ajaxResponse_test.php +++ /dev/null @@ -1,71 +0,0 @@ -expectOutputString('{"success":true,"message":"' . $message . '"}'); - PMA_ajaxResponse($message); - } - - function testAjaxResponseTextWithExtra() - { - $message = 'text'; - $exra = array('str_val' => 'te\x/t"1', 'int_val' => 10); - - $this->expectOutputString('{"success":true,"message":"' . $message . '","str_val":"te\\\\x\/t\"1","int_val":10}'); - PMA_ajaxResponse($message, true, $exra); - } - - function testAjaxResponseTextError() - { - $message = 'error_text'; - - $this->expectOutputString('{"success":false,"error":"' . $message . '"}'); - PMA_ajaxResponse($message, false); - } - - function testAjaxResponseMessage() - { - $message = new PMA_Message("Message Text", 1); - - $this->expectOutputString('{"success":true,"message":"
Message Text<\/div>"}'); - PMA_ajaxResponse($message); - } - - function testAjaxResponseMessageWithExtra() - { - - $message = new PMA_Message("Message Text", 1); - $exra = array('str_val' => 'te\x/t"1', 'int_val' => 10); - - $this->expectOutputString('{"success":true,"message":"
Message Text<\/div>","str_val":"te\\\\x\/t\"1","int_val":10}'); - PMA_ajaxResponse($message, true, $exra); - } - - function testAjaxResponseMessageError() - { - - $message = new PMA_Message("Error Message Text", 1); - - // TODO: class for output div should be "error" - $this->expectOutputString('{"success":false,"error":"
Error Message Text<\/div>"}'); - PMA_ajaxResponse($message, false); - } - -} \ No newline at end of file diff --git a/view_create.php b/view_create.php index b0cf55764b..10ccfbc9d1 100644 --- a/view_create.php +++ b/view_create.php @@ -66,15 +66,27 @@ if (isset($_REQUEST['createview'])) { if ($GLOBALS['is_ajax_request'] != true) { $message = PMA_Message::success(); include './' . $cfg['DefaultTabDatabase']; - exit(); } else { - PMA_ajaxResponse(PMA_getMessage(PMA_Message::success(), $sql_query), 1); + $response = PMA_Response::getInstance(); + $response->addJSON( + 'message', + PMA_getMessage(PMA_Message::success(), $sql_query) + ); } + exit; } else { if ($GLOBALS['is_ajax_request'] != true) { $message = PMA_Message::rawError(PMA_DBI_getError()); } else { - PMA_ajaxResponse(PMA_Message::error("$sql_query

" . PMA_DBI_getError()), 0); + $response = PMA_Response::getInstance(); + $response->addJSON( + 'message', + PMA_Message::error( + "$sql_query

" . PMA_DBI_getError() + ) + ); + $response->isSuccess(false); + exit; } } } From ffe5d7fdc38fa7b0f8d6e851bc94660b9ecfec9c Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 12 Jun 2012 13:55:34 +0100 Subject: [PATCH 112/116] Added missing API call to the PMA_Footer class --- libraries/Footer.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index f3874fc53e..c0c4282db4 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -274,6 +274,16 @@ class PMA_Footer $this->_isMinimal = true; } + /** + * Returns the PMA_Scripts object + * + * @return PMA_Scripts object + */ + public function getScripts() + { + return $this->_scripts; + } + /** * Renders the footer * From 1c01c222efd37f889194a85e48df5809f4a8de40 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 12 Jun 2012 14:04:39 +0100 Subject: [PATCH 113/116] Coding style fixes --- libraries/Footer.class.php | 4 +++- libraries/Header.class.php | 7 +++++-- libraries/Response.class.php | 14 ++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index c0c4282db4..d231e134cc 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -257,11 +257,13 @@ class PMA_Footer * Set the ajax flag to indicate whether * we are sevicing an ajax request * + * @param bool $isAjax Whether we are sevicing an ajax request + * * @return void */ public function setAjax($isAjax) { - $this->_isAjax = $isAjax; + $this->_isAjax = ($isAjax == true); } /** diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 6b635737f5..02f69a981f 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -1,6 +1,7 @@ _isAjax = $isAjax; + $this->_isAjax = ($isAjax == true); } /** @@ -431,7 +434,7 @@ class PMA_Header */ private function _getTitleTag() { - $retval = ""; + $retval = "<title>"; $retval .= $this->_getPageTitle(); $retval .= ""; return $retval; diff --git a/libraries/Response.class.php b/libraries/Response.class.php index f78d98cc98..c341acc614 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -97,7 +97,7 @@ class PMA_Response $this->_footer = new PMA_Footer(); $this->_isSuccess = true; - $this->_isAjax = false; + $this->_isAjax = false; if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { $this->_isAjax = true; } @@ -123,15 +123,13 @@ class PMA_Response * Set the status of an ajax response, * whether it is a success or an error * + * @param bool $state Whether the request was successfully processed + * * @return void */ public function isSuccess($state) { - if ($state) { - $this->_isSuccess = true; - } else { - $this->_isSuccess = false; - } + $this->_isSuccess = ($state == true); } /** @@ -276,7 +274,7 @@ class PMA_Response $this->_JSON['success'] = true; } else { $this->_JSON['success'] = false; - $this->_JSON['error'] = $this->_JSON['message']; + $this->_JSON['error'] = $this->_JSON['message']; unset($this->_JSON['message']); } @@ -300,7 +298,7 @@ class PMA_Response { $response = PMA_Response::getInstance(); chdir($response->getCWD()); - $buffer = PMA_OutputBuffering::getInstance(); + $buffer = PMA_OutputBuffering::getInstance(); if (empty($response->_HTML)) { $response->_HTML = $buffer->getContents(); } From 007b10e90a23ee798d95d90a0cac7bb9af2b7fbd Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 12 Jun 2012 14:07:00 +0100 Subject: [PATCH 114/116] Moved lost global --- libraries/Header.class.php | 6 ------ libraries/common.inc.php | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 02f69a981f..c7fc7c34fa 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -13,12 +13,6 @@ require_once 'libraries/Scripts.class.php'; require_once 'libraries/RecentTable.class.php'; require_once 'libraries/Menu.class.php'; - -// FIXME: this global got lost :( -// here, the function does not exist with this configuration: -// $cfg['ServerDefault'] = 0; -$is_superuser = function_exists('PMA_isSuperuser') && PMA_isSuperuser(); - /** * Class used to output the HTTP and HTML headers * diff --git a/libraries/common.inc.php b/libraries/common.inc.php index d4593423b2..e0eb6e786c 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -1085,6 +1085,10 @@ foreach ($GLOBALS as $key => $dummy) { } unset($dummy); +// here, the function does not exist with this configuration: +// $cfg['ServerDefault'] = 0; +$GLOBALS['is_superuser'] = function_exists('PMA_isSuperuser') && PMA_isSuperuser(); + if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) { /** * include subform target page From 5e1cb4e7a688373681c81c2b4318956438a4843e Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 12 Jun 2012 14:13:07 +0100 Subject: [PATCH 115/116] Fixed config auth --- libraries/auth/config.auth.lib.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index cea96b9cb1..da81d5c73a 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -88,9 +88,7 @@ function PMA_auth_fails()
- Date: Tue, 12 Jun 2012 14:21:48 +0100 Subject: [PATCH 116/116] Set headerIsSent property of PMA_Header class as private, as it's no longer necessary to access it externally --- libraries/Header.class.php | 14 +++++--------- libraries/display_tbl.lib.php | 1 - server_status.php | 4 ---- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index c7fc7c34fa..eaabde56c8 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -96,14 +96,10 @@ class PMA_Header * Whether the HTTP headers (and possibly some HTML) * have already been sent to the browser * - * FIXME: Shouldn't be static or public, but first - * need to remove references to it from the code base - * - * @access public - * @static + * @access private * @var bool */ - public static $headerIsSent; + private $_headerIsSent; /** * Creates a new class instance @@ -126,7 +122,7 @@ class PMA_Header $this->_isPrintView = false; $this->_scripts = new PMA_Scripts(); $this->_addDefaultScripts(); - self::$headerIsSent = false; + $this->_headerIsSent = false; // if database storage for user preferences is transient, // offer to load exported settings from localStorage // (detection will be done in JavaScript) @@ -272,7 +268,7 @@ class PMA_Header public function getDisplay() { $retval = ''; - if (! self::$headerIsSent) { + if (! $this->_headerIsSent) { if (! $this->_isAjax && $this->_isEnabled) { $this->sendHttpHeaders(); $retval .= $this->_getHtmlStart(); @@ -358,7 +354,7 @@ class PMA_Header // Define the charset to be used header('Content-Type: text/html; charset=utf-8'); } - self::$headerIsSent = true; + $this->_headerIsSent = true; } /** diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 45021d66fc..503f06d15d 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1061,7 +1061,6 @@ function PMA_getTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, } elseif ((($GLOBALS['cfg']['RowActionLinks'] == 'left') || ($GLOBALS['cfg']['RowActionLinks'] == 'both')) && (($is_display['edit_lnk'] == 'nn') && ($is_display['del_lnk'] == 'nn')) - && ! PMA_Header::$headerIsSent ) { // ... elseif no button, displays empty columns if required // (unless coming from Browse mode print view) diff --git a/server_status.php b/server_status.php index 93d0157042..301ea93c27 100644 --- a/server_status.php +++ b/server_status.php @@ -9,10 +9,6 @@ require_once 'libraries/common.inc.php'; -if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { - PMA_Header::$headerIsSent = true; -} - /** * Ajax request */