diff --git a/ChangeLog b/ChangeLog index 36227f2353..c249cd17e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -55,6 +55,7 @@ VerboseMultiSubmit, ReplaceHelpImg - 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/Documentation.html b/Documentation.html index 42b906ef49..b30cbd54e3 100644 --- a/Documentation.html +++ b/Documentation.html @@ -2700,9 +2700,8 @@ setfacl -d -m "g:www-data:rwx" tmp

This seems to be a PWS bug. Filippo Simoncini found a workaround (at this time there is no better fix): remove or comment the DOCTYPE - declarations (2 lines) from the scripts libraries/header.inc.php, - libraries/header_printview.inc.php, index.php, - navigation.php and libraries/common.lib.php.

+ declarations (2 lines) from the scripts libraries/Header.class.php + and index.php.

1.7 How can I GZip or Bzip a dump or a diff --git a/browse_foreigners.php b/browse_foreigners.php index 0379a2f531..c4b47e7af0 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -6,24 +6,23 @@ * @package PhpMyAdmin */ -/** - * Gets a core script and starts output buffering work - */ require_once 'libraries/common.inc.php'; +require_once 'libraries/transformations.lib.php'; $field = $_REQUEST['field']; PMA_checkParameters(array('db', 'table', 'field')); -require_once 'libraries/ob.lib.php'; -PMA_outBufferPre(); - -require_once 'libraries/header_http.inc.php'; +$response = PMA_Response::getInstance(); +$response->getFooter()->setMinimal(); +$header = $response->getHeader(); +$header->disableMenu(); +$header->setBodyId('body_browse_foreigners'); /** * Displays the frame */ -require_once 'libraries/transformations.lib.php'; // Transformations + $cfgRelation = PMA_getRelationsParam(); $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : false); @@ -79,93 +78,79 @@ if (is_array($foreignData['disp_row'])) { ); } } -?> - - - - - phpMyAdmin - - - - - - + alert('$error'); +} +EOC; +$header->getScripts()->addCode($code); + +?>
@@ -337,6 +322,3 @@ if (is_array($foreignData['disp_row'])) { ?> - - - diff --git a/chk_rel.php b/chk_rel.php index 3e8a0269bb..915e8b24b4 100644 --- a/chk_rel.php +++ b/chk_rel.php @@ -6,21 +6,10 @@ * @package PhpMyAdmin */ -/** - * Gets some core libraries - */ require_once 'libraries/common.inc.php'; -require_once 'libraries/header.inc.php'; +$response = PMA_Response::getInstance(); +$response->addHTML( + PMA_getRelationsParamDiagnostic(PMA_getRelationsParam()) +); - -/** - * Gets the relation settings - */ -$cfgRelation = PMA_getRelationsParam(true); - - -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_create.php b/db_create.php index 0dff8e4553..b04a793f84 100644 --- a/db_create.php +++ b/db_create.php @@ -9,7 +9,6 @@ * Gets some core libraries */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'functions.js'; require_once 'libraries/mysql_charsets.lib.php'; if (! PMA_DRIZZLE) { @@ -62,14 +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 'libraries/header.inc.php'; - include_once 'main.php'; } else { $message = PMA_Message::success(__('Database %1$s has been created.')); $message->addParam($new_db); @@ -79,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 @@ -140,12 +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 'libraries/header.inc.php'; - include_once '' . $cfg['DefaultTabDatabase']; } ?> diff --git a/db_datadict.php b/db_datadict.php index cf77a38904..506a1ba09a 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -283,5 +283,4 @@ foreach ($tables as $table) { */ PMA_printButton(); -require 'libraries/footer.inc.php'; ?> diff --git a/db_events.php b/db_events.php index 84deaade94..b22df7a540 100644 --- a/db_events.php +++ b/db_events.php @@ -15,9 +15,12 @@ require_once 'libraries/common.lib.php'; /** * Include JavaScript libraries */ -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; -$GLOBALS['js_include'][] = 'rte/common.js'; -$GLOBALS['js_include'][] = 'rte/events.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('jquery/timepicker.js'); +$scripts->addFile('rte/common.js'); +$scripts->addFile('rte/events.js'); /** * Include all other files diff --git a/db_export.php b/db_export.php index 732b88b217..00f518f22c 100644 --- a/db_export.php +++ b/db_export.php @@ -11,7 +11,10 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'export.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('export.js'); // $sub_part is also used in db_info.inc.php to see if we are coming from // db_export.php, in which case we don't obey $cfg['MaxTableList'] @@ -28,7 +31,6 @@ $export_page_title = __('View dump (schema) of database'); // exit if no tables in db found if ($num_tables < 1) { PMA_Message::error(__('No tables found in database.'))->display(); - include 'libraries/footer.inc.php'; exit; } // end if @@ -81,8 +83,4 @@ $multi_values .= ''; $export_type = 'database'; require_once 'libraries/display_export.lib.php'; -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_import.php b/db_import.php index 146e331e9c..f8ea8097ac 100644 --- a/db_import.php +++ b/db_import.php @@ -10,7 +10,10 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'import.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('import.js'); /** * Gets tables informations and displays top links @@ -21,9 +24,5 @@ require 'libraries/db_info.inc.php'; $import_type = 'database'; require 'libraries/display_import.lib.php'; -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_operations.php b/db_operations.php index 5a04bde59c..16f6191802 100644 --- a/db_operations.php +++ b/db_operations.php @@ -19,7 +19,10 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/mysql_charsets.lib.php'; // add a javascript file for jQuery functions to handle Ajax actions -$GLOBALS['js_include'][] = 'db_operations.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('db_operations.js'); /** * Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise) @@ -337,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; + } } @@ -633,8 +639,4 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?> echo __('Edit or export relational schema') . '
'; } // end if -/** - * Displays the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_printview.php b/db_printview.php index 7a7bfc6b6b..3160089361 100644 --- a/db_printview.php +++ b/db_printview.php @@ -10,10 +10,9 @@ */ require_once 'libraries/common.inc.php'; -/** - * Gets the variables sent or posted to this script, then displays headers - */ -require_once 'libraries/header_printview.inc.php'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$header->enablePrintView(); PMA_checkParameters(array('db')); @@ -248,6 +247,4 @@ if ($num_tables == 0) { PMA_printButton(); echo "
\n"; - -require 'libraries/footer.inc.php'; ?> diff --git a/db_qbe.php b/db_qbe.php index 27ba771966..df022b4873 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -102,7 +102,6 @@ $tbl_result = PMA_DBI_query( $tbl_result_cnt = PMA_DBI_num_rows($tbl_result); if (0 == $tbl_result_cnt) { PMA_Message::error(__('No tables found in database.'))->display(); - include 'libraries/footer.inc.php'; exit; } @@ -949,9 +948,3 @@ if (! empty($qry_orderby)) {
- diff --git a/db_routines.php b/db_routines.php index 0dd2e66c44..9a54a5815c 100644 --- a/db_routines.php +++ b/db_routines.php @@ -16,9 +16,12 @@ require_once 'libraries/mysql_charsets.lib.php'; /** * Include JavaScript libraries */ -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; -$GLOBALS['js_include'][] = 'rte/common.js'; -$GLOBALS['js_include'][] = 'rte/routines.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('jquery/timepicker.js'); +$scripts->addFile('rte/common.js'); +$scripts->addFile('rte/routines.js'); /** * Include all other files diff --git a/db_search.php b/db_search.php index 17571a7cd7..1222e42d41 100644 --- a/db_search.php +++ b/db_search.php @@ -13,10 +13,13 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'db_search.js'; -$GLOBALS['js_include'][] = 'sql.js'; -$GLOBALS['js_include'][] = 'makegrid.js'; -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('db_search.js'); +$scripts->addFile('sql.js'); +$scripts->addFile('makegrid.js'); +$scripts->addFile('jquery/timepicker.js'); /** * Gets some core libraries and send headers @@ -368,9 +371,3 @@ $alter_select - diff --git a/db_sql.php b/db_sql.php index c4b5c84111..baced44072 100644 --- a/db_sql.php +++ b/db_sql.php @@ -13,9 +13,12 @@ require_once 'libraries/common.inc.php'; /** * Runs common work */ -$GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'makegrid.js'; -$GLOBALS['js_include'][] = 'sql.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('functions.js'); +$scripts->addFile('makegrid.js'); +$scripts->addFile('sql.js'); require 'libraries/db_common.inc.php'; require_once 'libraries/sql_query_form.lib.php'; @@ -59,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 302e036850..d711e0e75a 100644 --- a/db_structure.php +++ b/db_structure.php @@ -10,9 +10,12 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'db_structure.js'; -$GLOBALS['js_include'][] = 'tbl_change.js'; -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('db_structure.js'); +$scripts->addFile('tbl_change.js'); +$scripts->addFile('jquery/timepicker.js'); /** * Sets globals from $_POST @@ -86,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; } @@ -756,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_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 e151977baf..94e4fe4847 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -10,15 +10,18 @@ require_once 'libraries/common.inc.php'; //Get some js files needed for Ajax requests -$GLOBALS['js_include'][] = 'db_structure.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('db_structure.js'); /** * If we are not in an Ajax request, then do the common work and show the links etc. */ 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'; @@ -31,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; } } @@ -49,9 +53,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; } @@ -228,8 +229,4 @@ if (count($data['ddlog']) > 0) { echo PMA_getMessage(__('Database Log'), $log); } -/** - * Display the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/db_triggers.php b/db_triggers.php index d94ea90d69..95dfb7e818 100644 --- a/db_triggers.php +++ b/db_triggers.php @@ -10,13 +10,15 @@ * Include required files */ require_once 'libraries/common.inc.php'; -require_once 'libraries/common.lib.php'; /** * Include JavaScript libraries */ -$GLOBALS['js_include'][] = 'rte/common.js'; -$GLOBALS['js_include'][] = 'rte/triggers.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('rte/common.js'); +$scripts->addFile('rte/triggers.js'); /** * Include all other files diff --git a/export.php b/export.php index 5b49a3145f..ef519cc732 100644 --- a/export.php +++ b/export.php @@ -88,7 +88,6 @@ if ($_REQUEST['output_format'] == 'astext') { // Does export require to be into file? if (isset($export_list[$type]['force_file']) && ! $asfile) { $message = PMA_Message::error(__('Selected export type has to be saved in file!')); - include_once 'libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; include 'server_export.php'; @@ -369,7 +368,6 @@ if ($save_on_server) { } } if (isset($message)) { - include_once 'libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; include 'server_export.php'; @@ -403,14 +401,12 @@ if (! $save_on_server) { $num_tables = count($tables); if ($num_tables == 0) { $message = PMA_Message::error(__('No tables found in database.')); - include_once 'libraries/header.inc.php'; $active_page = 'db_export.php'; include 'db_export.php'; exit(); } } $backup_cfgServer = $cfg['Server']; - include_once 'libraries/header.inc.php'; $cfg['Server'] = $backup_cfgServer; unset($backup_cfgServer); echo "\n" . '
' . "\n"; @@ -720,7 +716,6 @@ do { // End of fake loop if ($save_on_server && isset($message)) { - include_once 'libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; include 'server_export.php'; @@ -768,7 +763,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); @@ -788,7 +783,6 @@ if (! empty($asfile)) { ); } - include_once 'libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; include_once 'server_export.php'; @@ -801,6 +795,7 @@ if (! empty($asfile)) { } exit(); } else { + PMA_Response::getInstance()->disable(); echo $dump_buffer; } } else { @@ -838,6 +833,5 @@ if (! empty($asfile)) { //]]> diff --git a/gis_data_editor.php b/gis_data_editor.php index 70c96718b3..9eb0e99744 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -1,10 +1,6 @@ $visualization, 'openLayers' => $open_layers, ); - PMA_ajaxResponse(null, true, $extra_data); + $response = PMA_Response::getInstance(); + $response->addJSON($extra_data); + exit; } -// If the call is to get the whole content, start buffering, skipping and tags -if (isset($_REQUEST['get_gis_editor']) && $_REQUEST['get_gis_editor'] == true) { - ob_start(); -} else { -?> - - -
@@ -323,18 +313,7 @@ if (isset($_REQUEST['get_gis_editor']) && $_REQUEST['get_gis_editor'] == true) {
- - -addJSON('gis_editor', ob_get_contents()); +ob_end_clean(); ?> diff --git a/import.php b/import.php index 1c93cc119f..85dfaea5e1 100644 --- a/import.php +++ b/import.php @@ -83,7 +83,6 @@ if (! empty($sql_query)) { // upload limit has been reached, let's assume the second possibility. ; if ($_POST == array() && $_GET == array()) { - include_once 'libraries/header.inc.php'; $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]'); @@ -93,7 +92,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 } /** @@ -222,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; } @@ -235,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 @@ -523,5 +528,4 @@ if ($go_sql) { $active_page = $goto; include '' . $goto; } -exit(); ?> diff --git a/index.php b/index.php index 189819f177..99ac95d499 100644 --- a/index.php +++ b/index.php @@ -72,7 +72,11 @@ $lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][1]; // start output -require 'libraries/header_http.inc.php'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$header->sendHttpHeaders(); +$response->disable(); + ?> @@ -135,9 +139,11 @@ require 'libraries/header_http.inc.php'; // ]]> addFile('jquery/jquery-1.6.2.js'); +$scripts->addFile('update-location.js'); +$scripts->addFile('common.js'); +echo $scripts->getDisplay(); ?> " + 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 f5d4db94bb..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, @@ -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 1cf4adc9f3..c907328c1e 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, @@ -1673,7 +1671,7 @@ function PMA_createTableDialog( $div, url , target) buttons: button_options }); // end dialog options } - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); PMA_ajaxRemoveMessage($msgbox); }); // end $.get() @@ -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 @@ -2419,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() } @@ -2444,19 +2439,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 +2530,7 @@ $(function() { if (window.parent && window.parent.frame_navigation) { window.parent.frame_navigation.location.reload(); } - } - else { + } else { PMA_ajaxShowMessage(data.error, false); } }); // end $.post() @@ -2592,16 +2586,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 */ @@ -2631,10 +2620,9 @@ $(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'); PMA_ajaxRemoveMessage($msgbox); } else { @@ -2655,11 +2643,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() @@ -2922,10 +2908,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 +2943,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 +2966,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 @@ -3839,13 +3792,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/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/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 5394f594dd..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('') @@ -218,7 +208,7 @@ $(function() { } }); //dialog options end displayPasswordGenerateButton(); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); PMA_ajaxRemoveMessage($msgbox); $div.find("input[autofocus]").focus(); @@ -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, @@ -354,7 +342,7 @@ $(function() { }); //dialog options end displayPasswordGenerateButton(); PMA_ajaxRemoveMessage($msgbox); - PMA_convertFootnotesToTooltips($div); + PMA_showHints($div); }); // end $.get() }); @@ -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 edd0c54658..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'; @@ -437,7 +437,7 @@ $(function() { if (data != null) { tab.find('.tabInnerContent').html(data); } - PMA_convertFootnotesToTooltips(); + PMA_showHints(); break; case 'statustabs_queries': if (data != null) { @@ -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..895e509386 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,22 @@ $(function() { // unnecessary div that came from data.sql_query $('div.notice').remove(); } else { - $('#sqlqueryform').before(data.message); + $sqlqueryresults + .show() + .html(data.message); } - $sqlqueryresults.show(); + $sqlqueryresults.show().trigger('makegrid'); + $('#togglequerybox').show(); + PMA_init_slider(); + + 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 @@ -236,29 +252,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 +295,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 +319,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 +345,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 +364,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 +414,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 2a931d206a..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, @@ -301,7 +298,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, @@ -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, @@ -542,7 +538,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(); } @@ -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, @@ -620,7 +616,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() @@ -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/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 7476db0e2f..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); } /** @@ -264,14 +261,14 @@ $(document).ready(function() { //Find changed values by comparing form values with selectedRow Object var newValues = new Object();//Stores the values changed from original var sqlTypes = new Object(); - var it = 4; + var it = 0; var xChange = false; var yChange = false; for (key in selectedRow) { var oldVal = selectedRow[key]; - var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val(); + var newVal = ($('#edit_fields_null_id_' + it).attr('checked')) ? null : $('#edit_fieldID_' + it).val(); if (newVal instanceof Array) { // when the column is of type SET - newVal = $('#fieldID_' + it).map(function(){ + newVal = $('#edit_fieldID_' + it).map(function(){ return $(this).val(); }).get().join(","); } @@ -286,7 +283,7 @@ $(document).ready(function() { searchedData[searchedDataKey][yLabel] = newVal; } } - var $input = $('#fieldID_' + it); + var $input = $('#edit_fieldID_' + it); if ($input.hasClass('bit')) { sqlTypes[key] = 'bit'; } @@ -534,6 +531,7 @@ $(document).ready(function() { // resizing, it's ok // under IE 9, everything is fine currentChart = $.jqplot('querychart', series, options); + currentChart.resetZoom(); $('button.button-reset').click(function(event) { event.preventDefault(); @@ -551,7 +549,7 @@ $(document).ready(function() { $('div#querychart').bind('jqplotDataClick', function(event, seriesIndex, pointIndex, data) { searchedDataKey = data[4]; // key from searchedData (global) - var field_id = 4; + var field_id = 0; var post_params = { 'ajax_request' : true, 'get_data_row' : true, @@ -565,8 +563,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/Error.class.php b/libraries/Error.class.php index 06498917a3..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']; } @@ -317,6 +319,7 @@ class PMA_Error extends PMA_Message */ public function getDisplay() { + $this->isDisplayed(true); $retval = '
'; if (! $this->isUserError()) { $retval .= '' . $this->getType() . ''; diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index ef3ed50fba..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; } } @@ -205,17 +205,29 @@ class PMA_Error_Handler } /** - * display user errors not displayed + * Displays user errors not displayed * * @return void */ public function dispUserErrors() { + echo $this->getDispUserErrors(); + } + + /** + * Renders user errors not displayed + * + * @return string + */ + public function getDispUserErrors() + { + $retval = ''; foreach ($this->getErrors() as $error) { if ($error->isUserError() && ! $error->isDisplayed()) { - $error->display(); + $retval .= $error->getDisplay(); } } + return $retval; } /** @@ -227,6 +239,7 @@ class PMA_Error_Handler */ protected function dispPageStart($error = null) { + PMA_Response::getInstance()->disable(); echo ''; if ($error) { echo $error->getTitle(); @@ -259,25 +272,39 @@ class PMA_Error_Handler } /** - * display errors not displayed + * renders errors not displayed + * + * @return void + */ + public function getDispErrors() + { + $retval = ''; + if ($GLOBALS['cfg']['Error_Handler']['display']) { + foreach ($this->getErrors() as $error) { + if ($error instanceof PMA_Error) { + if (! $error->isDisplayed()) { + $retval .= $error->getDisplay(); + } + } else { + ob_start(); + var_dump($error); + $retval .= ob_end_clean(); + } + } + } else { + $retval .= $this->getDispUserErrors(); + } + return $retval; + } + + /** + * displays errors not displayed * * @return void */ public function dispErrors() { - if ($GLOBALS['cfg']['Error_Handler']['display']) { - foreach ($this->getErrors() as $error) { - if ($error instanceof PMA_Error) { - if (! $error->isDisplayed()) { - $error->display(); - } - } else { - var_dump($error); - } - } - } else { - $this->dispUserErrors(); - } + echo $this->getDispErrors(); } /** @@ -297,7 +324,7 @@ class PMA_Error_Handler } //$this->errors = array_merge($_SESSION['errors'], $this->errors); - // delet stored errors + // delete stored errors $_SESSION['errors'] = array(); unset($_SESSION['errors']); } diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php new file mode 100644 index 0000000000..d231e134cc --- /dev/null +++ b/libraries/Footer.class.php @@ -0,0 +1,334 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Used to render the footer of PMA's pages + * + * @package PhpMyAdmin + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +require_once 'libraries/Scripts.class.php'; + +/** + * Class used to output the footer + * + * @package PhpMyAdmin + */ +class PMA_Footer +{ + /** + * PMA_Scripts instance + * + * @access private + * @var object + */ + private $_scripts; + /** + * Whether we are servicing an ajax request. + * We can't simply use $GLOBALS['is_ajax_request'] + * here since it may have not been initialised yet. + * + * @access private + * @var bool + */ + private $_isAjax; + /** + * Whether to only close the BODY and HTML tags + * or also include scripts, errors and links + * + * @access private + * @var bool + */ + private $_isMinimal; + /** + * Whether to display anything + * + * @access private + * @var bool + */ + private $_isEnabled; + + /** + * Creates a new class instance + * + * @return new PMA_Footer object + */ + public function __construct() + { + $this->_isEnabled = true; + $this->_scripts = new PMA_Scripts(); + $this->_isMinimal = false; + $this->_addDefaultScripts(); + } + + /** + * Loads common scripts + * + * @return void + */ + private function _addDefaultScripts() + { + if (empty($GLOBALS['error_message'])) { + $this->_scripts->addCode(" + $(function() { + // updates current settings + if (window.parent.setAll) { + window.parent.setAll( + '" . PMA_escapeJsString($GLOBALS['lang']) . "', + '" . PMA_escapeJsString($GLOBALS['collation_connection']) . "', + '" . PMA_escapeJsString($GLOBALS['server']) . "', + '" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "', + '" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "', + '" . PMA_escapeJsString($_SESSION[' PMA_token ']) . "' + ); + } + }); + "); + if (! empty($GLOBALS['reload'])) { + $this->_scripts->addCode(" + // refresh navigation frame content + if (window.parent.refreshNavigation) { + window.parent.refreshNavigation(); + } + "); + } else if (isset($_GET['reload_left_frame']) + && $_GET['reload_left_frame'] == '1' + ) { + // reload left frame (used by user preferences) + $this->_scripts->addCode(" + if (window.parent && window.parent.frame_navigation) { + window.parent.frame_navigation.location.reload(); + } + "); + } + + // set current db, table and sql query in the querywindow + $query = ''; + if (strlen($GLOBALS['sql_query']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { + $query = PMA_escapeJsString($GLOBALS['sql_query']); + } + $this->_scripts->addCode(" + if (window.parent.reload_querywindow) { + window.parent.reload_querywindow( + '" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "', + '" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "', + '" . $query . "' + ); + } + "); + + if (! empty($GLOBALS['focus_querywindow'])) { + // set focus to the querywindow + $this->_scripts->addCode(" + if (parent.querywindow && !parent.querywindow.closed + && parent.querywindow.location + ) { + self.focus(); + } + "); + } + $this->_scripts->addCode(" + if (window.parent.frame_content) { + // reset content frame name, as querywindow needs + // to set a unique name before submitting form data, + // and navigation frame needs the original name + if (typeof(window.parent.frame_content.name) != 'undefined' + && window.parent.frame_content.name != 'frame_content') { + window.parent.frame_content.name = 'frame_content'; + } + if (typeof(window.parent.frame_content.id) != 'undefined' + && window.parent.frame_content.id != 'frame_content') { + window.parent.frame_content.id = 'frame_content'; + } + //window.parent.frame_content.setAttribute('name', 'frame_content'); + //window.parent.frame_content.setAttribute('id', 'frame_content'); + } + "); + } + } + + /** + * Renders the debug messages + * + * @return string + */ + private function _getDebugMessage() + { + $retval = ''; + if (! empty($_SESSION['debug'])) { + $sum_time = 0; + $sum_exec = 0; + foreach ($_SESSION['debug']['queries'] as $query) { + $sum_time += $query['count'] * $query['time']; + $sum_exec += $query['count']; + } + + $retval .= '<div>'; + $retval .= count($_SESSION['debug']['queries']) . ' queries executed '; + $retval .= $sum_exec . ' times in ' . $sum_time . ' seconds'; + $retval .= '<pre>'; + + ob_start(); + print_r($_SESSION['debug']); + $retval .= ob_end_clean(); + + $retval .= '</pre>'; + $retval .= '</div>'; + $_SESSION['debug'] = array(); + } + return $retval; + } + + /** + * Renders the link to open a new page + * + * @param string $url_params URL paramater string + * + * @return string + */ + private function _getSelfLink($url_params) + { + $retval = ''; + $retval .= '<div id="selflink" class="print_ignore">'; + $retval .= '<a href="index.php' . PMA_generate_common_url($url_params) . '"' + . ' title="' . __('Open new phpMyAdmin window') . '" target="_blank">'; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $retval .= PMA_getImage( + 'window-new.png', + __('Open new phpMyAdmin window') + ); + } else { + $retval .= __('Open new phpMyAdmin window'); + } + $retval .= '</a>'; + $retval .= '</div>'; + return $retval; + } + + /** + * Renders the link to open a new page + * + * @return string + */ + private function _getErrorMessages() + { + $retval = ''; + if ($GLOBALS['error_handler']->hasDisplayErrors()) { + $retval .= '<div class="clearfloat">'; + $retval .= $GLOBALS['error_handler']->getDispErrors(); + $retval .= '</div>'; + } + return $retval; + } + + /** + * Saves query in history + * + * @return void + */ + private function _setHistory() + { + if (! PMA_isValid($_REQUEST['no_history']) + && empty($GLOBALS['error_message']) + && ! empty($GLOBALS['sql_query']) + ) { + PMA_setHistory( + PMA_ifSetOr($GLOBALS['db'], ''), + PMA_ifSetOr($GLOBALS['table'], ''), + $GLOBALS['cfg']['Server']['user'], + $GLOBALS['sql_query'] + ); + } + } + + /** + * Disables the rendering of the footer + * + * @return void + */ + public function disable() + { + $this->_isEnabled = false; + } + + /** + * 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 == true); + } + + /** + * Turn on minimal display mode + * + * @return void + */ + public function setMinimal() + { + $this->_isMinimal = true; + } + + /** + * Returns the PMA_Scripts object + * + * @return PMA_Scripts object + */ + public function getScripts() + { + return $this->_scripts; + } + + /** + * Renders the footer + * + * @return string + */ + public function getDisplay() + { + $retval = ''; + $this->_setHistory(); + if ($this->_isEnabled) { + if (! $this->_isAjax && ! $this->_isMinimal) { + // Link to itself to replicate windows including frameset + if (! isset($GLOBALS['checked_special'])) { + $GLOBALS['checked_special'] = false; + } + if (PMA_getenv('SCRIPT_NAME') + && empty($_POST) + && ! $GLOBALS['checked_special'] + && ! $this->_isAjax + ) { + $url_params['target'] = basename(PMA_getenv('SCRIPT_NAME')); + $url = PMA_generate_common_url($url_params, 'text', ''); + $this->_scripts->addCode(" + // Store current location in hash part + // of URL to allow direct bookmarking + setURLHash('$url'); + "); + $retval .= $this->_getSelfLink($url_params); + } + $retval .= $this->_getDebugMessage(); + $retval .= $this->_getErrorMessages(); + $retval .= $this->_scripts->getDisplay(); + // Include possible custom footers + if (file_exists(CUSTOM_FOOTER_FILE)) { + ob_start(); + include CUSTOM_FOOTER_FILE; + $retval .= ob_end_clean(); + } + } else if (! $this->_isAjax) { + $retval .= "</body></html>"; + } + } + + return $retval; + } +} diff --git a/libraries/Header.class.php b/libraries/Header.class.php new file mode 100644 index 0000000000..eaabde56c8 --- /dev/null +++ b/libraries/Header.class.php @@ -0,0 +1,528 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Used to render the header of PMA's pages + * + * @package PhpMyAdmin + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +require_once 'libraries/Scripts.class.php'; +require_once 'libraries/RecentTable.class.php'; +require_once 'libraries/Menu.class.php'; + +/** + * Class used to output the HTTP and HTML headers + * + * @package PhpMyAdmin + */ +class PMA_Header +{ + /** + * PMA_Scripts instance + * + * @access private + * @var object + */ + private $_scripts; + /** + * PMA_Menu instance + * + * @access private + * @var object + */ + private $_menu; + /** + * Whether to offer the option of importing user settings + * + * @access private + * @var bool + */ + private $_userprefsOfferImport; + /** + * The page title + * + * @access private + * @var string + */ + private $_title; + /** + * The value for the id attribute for the body tag + * + * @access private + * @var string + */ + private $_bodyId; + /** + * Whether to show the top menu + * + * @access private + * @var bool + */ + private $_menuEnabled; + /** + * Whether to show the warnings + * + * @access private + * @var bool + */ + private $_warningsEnabled; + /** + * Whether the page is in 'print view' mode + * + * @access private + * @var bool + */ + private $_isPrintView; + /** + * Whether we are servicing an ajax request. + * We can't simply use $GLOBALS['is_ajax_request'] + * here since it may have not been initialised yet. + * + * @access private + * @var bool + */ + private $_isAjax; + /** + * Whether to display anything + * + * @access private + * @var bool + */ + private $_isEnabled; + /** + * Whether the HTTP headers (and possibly some HTML) + * have already been sent to the browser + * + * @access private + * @var bool + */ + private $_headerIsSent; + + /** + * Creates a new class instance + * + * @return new PMA_Header object + */ + public function __construct() + { + $this->_isEnabled = true; + $this->_isAjax = false; + $this->_bodyId = ''; + $this->_title = ''; + $this->_menu = new PMA_Menu( + $GLOBALS['server'], + $GLOBALS['db'], + $GLOBALS['table'] + ); + $this->_menuEnabled = true; + $this->_warningsEnabled = true; + $this->_isPrintView = false; + $this->_scripts = new PMA_Scripts(); + $this->_addDefaultScripts(); + $this->_headerIsSent = false; + // if database storage for user preferences is transient, + // offer to load exported settings from localStorage + // (detection will be done in JavaScript) + $this->_userprefsOfferImport = false; + if ($GLOBALS['PMA_Config']->get('user_preferences') == 'session' + && ! isset($_SESSION['userprefs_autoload']) + ) { + $this->_userprefsOfferImport = true; + } + } + + /** + * Loads common scripts + * + * @return void + */ + private function _addDefaultScripts() + { + $this->_scripts->addFile('jquery/jquery-1.6.2.js'); + $this->_scripts->addFile('jquery/jquery-ui-1.8.16.custom.js'); + $this->_scripts->addFile('jquery/jquery.sprintf.js'); + $this->_scripts->addFile('update-location.js'); + + $this->_scripts->addFile('jquery/jquery.qtip-1.0.0-rc3.js'); + if ($GLOBALS['cfg']['CodemirrorEnable']) { + $this->_scripts->addFile('codemirror/lib/codemirror.js'); + $this->_scripts->addFile('codemirror/mode/mysql/mysql.js'); + } + // Cross-framing protection + if ($GLOBALS['cfg']['AllowThirdPartyFraming'] === false) { + $this->_scripts->addFile('cross_framing_protection.js'); + } + // Localised strings + $params = array('lang' => $GLOBALS['lang']); + if (isset($GLOBALS['db'])) { + $params['db'] = $GLOBALS['db']; + } + $this->_scripts->addFile('messages.php' . PMA_generate_common_url($params)); + // Append the theme id to this url to invalidate + // the cache on a theme change + $this->_scripts->addFile( + 'get_image.js.php?theme=' + . urlencode($_SESSION['PMA_Theme']->getId()) + ); + $this->_scripts->addFile('functions.js'); + $this->_scripts->addCode(PMA_getReloadNavigationScript(true)); + } + + /** + * Disables the rendering of the header + * + * @return void + */ + public function disable() + { + $this->_isEnabled = false; + } + + /** + * 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 == true); + } + + /** + * Returns the PMA_Scripts object + * + * @return PMA_Scripts object + */ + public function getScripts() + { + return $this->_scripts; + } + + /** + * Setter for the ID attribute in the BODY tag + * + * @param string $id Value for the ID attribute + * + * @return void + */ + public function setBodyId($id) + { + $this->_bodyId = htmlspecialchars($id); + } + + /** + * Setter for the title of the page + * + * @param string $title New title + * + * @return void + */ + public function setTitle($title) + { + $this->_title = htmlspecialchars($title); + } + + /** + * Disables the display of the top menu + * + * @return void + */ + public function disableMenu() + { + $this->_menuEnabled = false; + } + + /** + * Disables the display of the top menu + * + * @return void + */ + public function disableWarnings() + { + $this->_warningsEnabled = false; + } + + /** + * Turns on 'print view' mode + * + * @return void + */ + public function enablePrintView() + { + $this->disableMenu(); + $this->setTitle(__('Print view') . ' - phpMyAdmin ' . PMA_VERSION); + $this->_isPrintView = true; + } + + /** + * Generates the header + * + * @return string The header + */ + public function getDisplay() + { + $retval = ''; + if (! $this->_headerIsSent) { + if (! $this->_isAjax && $this->_isEnabled) { + $this->sendHttpHeaders(); + $retval .= $this->_getHtmlStart(); + $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'); + } + $retval .= $this->_scripts->getDisplay(); + $retval .= $this->_getBodyStart(); + // Include possible custom headers + if (file_exists(CUSTOM_HEADER_FILE)) { + ob_start(); + include CUSTOM_HEADER_FILE; + $retval .= ob_end_clean(); + } + // offer to load user preferences from localStorage + if ($this->_userprefsOfferImport) { + include_once './libraries/user_preferences.lib.php'; + $retval .= PMA_userprefsAutoloadGetHeader(); + } + // pass configuration for hint tooltip display + // (to be used by PMA_createqTip in js/functions.js) + if (! $GLOBALS['cfg']['ShowHint']) { + $retval .= '<span id="no_hint" class="hide"></span>'; + } + $retval .= $this->_getWarnings(); + if ($this->_menuEnabled && $GLOBALS['server'] > 0) { + $retval .= $this->_menu->getDisplay(); + } + $retval .= $this->_addRecentTable( + $GLOBALS['db'], + $GLOBALS['table'] + ); + } + } + return $retval; + } + + /** + * Sends out the HTTP headers + * + * @return void + */ + public function sendHttpHeaders() + { + /** + * Sends http headers + */ + $GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT'; + /* Prevent against ClickJacking by allowing frames only from same origin */ + if (! $GLOBALS['cfg']['AllowThirdPartyFraming']) { + header( + 'X-Frame-Options: SAMEORIGIN' + ); + header( + "X-Content-Security-Policy: allow 'self'; " + . "options inline-script eval-script; " + . "frame-ancestors 'self'; img-src 'self' data:; " + . "script-src 'self' http://www.phpmyadmin.net" + ); + header( + "X-WebKit-CSP: allow 'self' http://www.phpmyadmin.net; " + . "options inline-script eval-script" + ); + } + PMA_noCacheHeader(); + if (! defined('IS_TRANSFORMATION_WRAPPER')) { + // Define the charset to be used + header('Content-Type: text/html; charset=utf-8'); + } + $this->_headerIsSent = true; + } + + /** + * Returns the DOCTYPE and the start HTML tag + * + * @return string DOCTYPE and HTML tags + */ + private function _getHtmlStart() + { + $lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1]; + $dir = $GLOBALS['text_dir']; + + $retval = "<!DOCTYPE HTML>"; + $retval .= "<html lang='$lang' dir='$dir'>"; + + return $retval; + } + + /** + * Returns the META tags + * + * @return string the META tags + */ + private function _getMetaTags() + { + $retval = '<meta charset="utf-8" />'; + $retval .= '<meta name="robots" content="noindex,nofollow" />'; + return $retval; + } + + /** + * Returns the LINK tags for the favicon and the stylesheets + * + * @return string the LINK tags + */ + private function _getLinkTags() + { + $retval = '<link rel="icon" href="favicon.ico" ' + . 'type="image/x-icon" />' + . '<link rel="shortcut icon" href="favicon.ico" ' + . 'type="image/x-icon" />'; + // stylesheets + $basedir = defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : ''; + $common_url = PMA_generate_common_url(array('server' => $GLOBALS['server'])); + $theme_id = $GLOBALS['PMA_Config']->getThemeUniqueValue(); + $theme_path = $GLOBALS['pmaThemePath']; + + if ($this->_isPrintView) { + $retval .= '<link rel="stylesheet" type="text/css" href="' + . $basedir . 'print.css" media="print" />'; + } else { + $retval .= '<link rel="stylesheet" type="text/css" href="' + . $basedir . 'phpmyadmin.css.php' + . $common_url . '&nocache=' + . $theme_id . '" />'; + $retval .= '<link rel="stylesheet" type="text/css" href="' + . $theme_path . '/jquery/jquery-ui-1.8.16.custom.css" />'; + } + + return $retval; + } + + /** + * Returns the TITLE tag + * + * @return string the TITLE tag + */ + private function _getTitleTag() + { + $retval = "<title>"; + $retval .= $this->_getPageTitle(); + $retval .= ""; + 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)) { + 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 + * + * @return string HEAD and BODY tags + */ + private function _getBodyStart() + { + $retval = "_bodyId)) { + $retval .= " id='" . $this->_bodyId . "'"; + } + $retval .= ">"; + return $retval; + } + + /** + * Returns some warnings to be displayed at the top of the page + * + * @return string The warnings + */ + private function _getWarnings() + { + $retval = ''; + 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 .= ""; + } + return $retval; + } + + /** + * Add recently used table and reload the navigation. + * + * @param string $db Database name where the table is located. + * @param string $table The table name + * + * @return string + */ + private function _addRecentTable($db, $table) + { + $retval = ''; + if (strlen($table) && $GLOBALS['cfg']['LeftRecentTable'] > 0) { + $tmp_result = PMA_RecentTable::getInstance()->add($db, $table); + if ($tmp_result === true) { + $retval = ''; + } else { + $error = $tmp_result; + $retval = $error->getDisplay(); + } + } + return $retval; + } +} + +?> diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 4d4f5d668f..f1b192929e 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -10,7 +10,7 @@ if (! defined('PHPMYADMIN')) { } /** - * Singleton class for generating the top menu + * Class for generating the top menu * * @package PhpMyAdmin */ @@ -37,17 +37,9 @@ class PMA_Menu * @var string */ private $_table; - /** - * PMA_Menu instance - * - * @access private - * @static - * @var object - */ - private static $_instance; /** - * Private constructor disables direct object creation + * Creates a new instance of PMA_Menu * * @param int $server Server id * @param string $db Database name @@ -55,28 +47,11 @@ class PMA_Menu * * @return New PMA_Table */ - private function __construct($server, $db, $table) + public function __construct($server, $db, $table) { $this->_server = $server; - $this->_db = $db; - $this->_table = $table; - } - - /** - * Prints the menu and the breadcrumbs - * - * @return void - */ - public static function getInstance() - { - if (empty(self::$_instance)) { - self::$_instance = new PMA_Menu( - $GLOBALS['server'], - $GLOBALS['db'], - $GLOBALS['table'] - ); - } - return self::$_instance; + $this->_db = $db; + $this->_table = $table; } /** @@ -86,12 +61,29 @@ class PMA_Menu */ public function display() { - echo $this->_getBreadcrumbs(); - echo $this->_getMenu(); + echo $this->getDisplay(); + } + + /** + * Returns the menu and the breadcrumbs as a string + * + * @return string + */ + public function getDisplay() + { + $retval = $this->_getBreadcrumbs(); + $retval .= $this->_getMenu(); if (! empty($GLOBALS['message'])) { - echo PMA_getMessage($GLOBALS['message']); + if (isset($GLOBALS['buffer_message'])) { + $buffer_message = $GLOBALS['buffer_message']; + } + $retval .= PMA_getMessage($GLOBALS['message']); unset($GLOBALS['message']); + if (isset($buffer_message)) { + $GLOBALS['buffer_message'] = $buffer_message; + } } + return $retval; } /** @@ -214,10 +206,6 @@ class PMA_Menu } // end if } else { // no table selected, display database comment if present - /** - * Settings for relations stuff - */ - include_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); // Get additional information about tables for tooltip is done @@ -353,7 +341,7 @@ class PMA_Menu * export, search and qbe links if there is at least one table */ if ($num_tables == 0) { - $tabs['qbe']['warning'] = __('Database seems to be empty!'); + $tabs['qbe']['warning'] = __('Database seems to be empty!'); $tabs['search']['warning'] = __('Database seems to be empty!'); $tabs['export']['warning'] = __('Database seems to be empty!'); } @@ -480,9 +468,9 @@ class PMA_Menu $tabs['import']['link'] = 'server_import.php'; $tabs['import']['text'] = __('Import'); - $tabs['settings']['icon'] = 'b_tblops.png'; - $tabs['settings']['link'] = 'prefs_manage.php'; - $tabs['settings']['text'] = __('Settings'); + $tabs['settings']['icon'] = 'b_tblops.png'; + $tabs['settings']['link'] = 'prefs_manage.php'; + $tabs['settings']['text'] = __('Settings'); $tabs['settings']['active'] = in_array( basename($GLOBALS['PMA_PHP_SELF']), array('prefs_forms.php', 'prefs_manage.php') diff --git a/libraries/Message.class.php b/libraries/Message.class.php index b17ec31b95..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 ... @@ -700,6 +700,7 @@ class PMA_Message */ public function getDisplay() { + $this->isDisplayed(true); return '
' . $this->getMessage() . '
'; } diff --git a/libraries/OutputBuffering.class.php b/libraries/OutputBuffering.class.php new file mode 100644 index 0000000000..782e7d0686 --- /dev/null +++ b/libraries/OutputBuffering.class.php @@ -0,0 +1,129 @@ +_mode = $this->_getMode(); + $this->_on = false; + } + + /** + * This function could be used eventually to support more modes. + * + * @return integer the output buffer mode + */ + private function _getMode() + { + $mode = 0; + if ($GLOBALS['cfg']['OBGzip'] && function_exists('ob_start')) { + if (ini_get('output_handler') == 'ob_gzhandler') { + // If a user sets the output_handler in php.ini to ob_gzhandler, then + // any right frame file in phpMyAdmin will not be handled properly by + // the browser. My fix was to check the ini file within the + // PMA_outBufferModeGet() function. + $mode = 0; + } elseif (function_exists('ob_get_level') && ob_get_level() > 0) { + // If output buffering is enabled in php.ini it's not possible to + // add the ob_gzhandler without a warning message from php 4.3.0. + // Being better safe than sorry, check for any existing output handler + // instead of just checking the 'output_buffering' setting. + $mode = 0; + } else { + $mode = 1; + } + } + // Zero (0) is no mode or in other words output buffering is OFF. + // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes. + // Usefull if we ever decide to combine modes. Then a bitmask field of + // the sum of all modes will be the natural choice. + return $mode; + } + + /** + * Returns the singleton PMA_OutputBuffering object + * + * @return PMA_OutputBuffering object + */ + public static function getInstance() + { + if (empty(self::$_instance)) { + self::$_instance = new PMA_OutputBuffering(); + } + return self::$_instance; + } + + /** + * This function will need to run at the top of all pages if output + * output buffering is turned on. It also needs to be passed $mode from + * the PMA_outBufferModeGet() function or it will be useless. + * + */ + public function start() + { + if (! $this->_on) { + if ($this->_mode) { + ob_start('ob_gzhandler'); + } + ob_start(); + header('X-ob_mode: ' . $this->_mode); + register_shutdown_function('PMA_OutputBuffering::stop'); + $this->_on = true; + } + } + + /** + * This function will need to run at the bottom of all pages if output + * buffering is turned on. It also needs to be passed $mode from the + * PMA_outBufferModeGet() function or it will be useless. + * + */ + public static function stop() + { + $buffer = PMA_OutputBuffering::getInstance(); + if ($buffer->_on) { + $buffer->_on = false; + $buffer->_content = ob_get_contents(); + ob_end_clean(); + } + PMA_Response::response(); + } + + public function getContents() + { + return $this->_content; + } + + public function flush() + { + if (ob_get_status() && $this->_mode) { + ob_flush(); + } + /** + * previously we had here an "else flush()" but some PHP versions + * (at least PHP 5.2.11) have a bug (49816) that produces garbled + * data + */ + } +} + +?> diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php index 99ea2035a9..54b83e1203 100644 --- a/libraries/PDF.class.php +++ b/libraries/PDF.class.php @@ -85,9 +85,8 @@ class PMA_PDF extends TCPDF */ function Error($error_message = '') { - include './libraries/header.inc.php'; PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display(); - include './libraries/footer.inc.php'; + exit; } /** diff --git a/libraries/Response.class.php b/libraries/Response.class.php new file mode 100644 index 0000000000..c341acc614 --- /dev/null +++ b/libraries/Response.class.php @@ -0,0 +1,315 @@ +start(); + $this->_header = new PMA_Header(); + $this->_HTML = ''; + $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; + } + $this->_header->setAjax($this->_isAjax); + $this->_footer->setAjax($this->_isAjax); + $this->_CWD = getcwd(); + } + + /** + * Returns the singleton PMA_Response object + * + * @return PMA_Response object + */ + public static function getInstance() + { + if (empty(self::$_instance)) { + self::$_instance = new PMA_Response(); + } + return self::$_instance; + } + + /** + * 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) + { + $this->_isSuccess = ($state == true); + } + + /** + * 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 + * 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 + * + * @return void + */ + public function disable() + { + $this->_header->disable(); + $this->_footer->disable(); + } + + /** + * Returns a PMA_Header object + * + * @return object + */ + public function getHeader() + { + return $this->_header; + } + + /** + * Returns a PMA_Footer object + * + * @return object + */ + public function getFooter() + { + return $this->_footer; + } + + /** + * Add HTML code to the response + * + * @param string $content A string to be appended to + * the current output buffer + * + * @return void + */ + public function addHTML($content) + { + if ($content instanceof PMA_Message) { + $this->_HTML .= $content->getDisplay(); + } else { + $this->_HTML .= $content; + } + } + + /** + * Add JSON code to the response + * + * @param mixed $json Either a key (string) or an + * array or key-value pairs + * @param mixed $value Null, if passing an array in $json otherwise + * it's a string value to the key + * + * @return void + */ + public function addJSON($json, $value = null) + { + if (is_array($json)) { + foreach ($json as $key => $value) { + $this->addJSON($key, $value); + } + } else { + if ($value instanceof PMA_Message) { + $this->_JSON[$json] = $value->getDisplay(); + } else { + $this->_JSON[$json] = $value; + } + } + + } + + /** + * Renders the HTML response text + * + * @return string + */ + private function _getDisplay() + { + // The header may contain nothing at all, + // if it's content was already rendered + // and, in this case, the header will be + // in the content part of the request + $retval = $this->_header->getDisplay(); + $retval .= $this->_HTML; + $retval .= $this->_footer->getDisplay(); + return $retval; + } + + /** + * Sends an HTML response to the browser + * + * @return void + */ + private function _htmlResponse() + { + echo $this->_getDisplay(); + } + + /** + * Sends a JSON response to the browser + * + * @return void + */ + private function _ajaxResponse() + { + 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); + } + + /** + * Sends an HTML response to the browser + * + * @static + * @return void + */ + public static function response() + { + $response = PMA_Response::getInstance(); + chdir($response->getCWD()); + $buffer = PMA_OutputBuffering::getInstance(); + if (empty($response->_HTML)) { + $response->_HTML = $buffer->getContents(); + } + if ($response->isAjax()) { + $response->_ajaxResponse(); + } else { + $response->_htmlResponse(); + } + $buffer->flush(); + exit; + } +} + +?> diff --git a/libraries/Scripts.class.php b/libraries/Scripts.class.php new file mode 100644 index 0000000000..604f310ede --- /dev/null +++ b/libraries/Scripts.class.php @@ -0,0 +1,174 @@ +' . "\n "; + } else { + $include .= '' . "\n"; + } + return $include; + } + + /** + * Generates new PMA_Scripts objects + * + * @return PMA_Scripts object + */ + public function __construct() + { + $this->_files = array(); + $this->_code = ''; + $this->_events = array(); + + } + + /** + * Adds a new file to the list of scripts + * + * @param string $filename The name of the file to include + * @param bool $conditional_ie Whether to wrap the script tag in + * conditional comments for IE + * + * @return void + */ + 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 + ); + } + } + + /** + * Adds a new code snippet to the code to be executed + * + * @param string $code The JS code to be added + * + * @return void + */ + public function addCode($code) + { + $this->_code .= "$code\n"; + } + + /** + * Adds a new event to the list of events + * + * @param string $event The name of the event to register + * @param string $function The code to execute when the event fires + * E.g: 'function () { doSomething(); }' + * or 'doSomething' + * + * @return void + */ + public function addEvent($event, $function) + { + $this->_events[] = array( + 'event' => $event, + 'function' => $function + ); + } + + /** + * Renders all the JavaScript file inclusions, code and events + * + * @return string + */ + public function getDisplay() + { + $retval = ''; + + foreach ($this->_files as $file) { + $retval .= $this->_includeFile( + $file['filename'], + $file['conditional_ie'] + ); + } + $retval .= ''; + + return $retval; + } +} diff --git a/libraries/Theme.class.php b/libraries/Theme.class.php index cdb91b5334..4658cb67da 100644 --- a/libraries/Theme.class.php +++ b/libraries/Theme.class.php @@ -429,35 +429,39 @@ class PMA_Theme } /** - * prints out the preview for this theme + * Renders the preview for this theme * - * @return void + * @return string * @access public */ - public function printPreview() + public function getPrintPreview() { - echo ''; + return $retval; } /** diff --git a/libraries/Theme_Manager.class.php b/libraries/Theme_Manager.class.php index 3aa286c119..2ecfb05c6a 100644 --- a/libraries/Theme_Manager.class.php +++ b/libraries/Theme_Manager.class.php @@ -400,16 +400,18 @@ class PMA_Theme_Manager } /** - * prints out preview for every theme + * Renders the previews for all themes * - * @return void + * @return string * @access public */ - public function printPreviews() + public function getPrintPreviews() { + $retval = ''; foreach ($this->themes as $each_theme) { - $each_theme->printPreview(); + $retval .= $each_theme->getPrintPreview(); } // end 'open themes' + return $retval; } /** diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index fbe39e7c8b..da81d5c73a 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -68,21 +68,18 @@ function PMA_auth_set_user() function PMA_auth_fails() { $conn_error = PMA_DBI_getError(); - if (!$conn_error) { + if (! $conn_error) { $conn_error = __('Cannot connect: invalid settings.'); } - // Defines the charset to be used - header('Content-Type: text/html; charset=utf-8'); /* HTML header */ - $page_title = __('Access denied'); - include './libraries/header_meta_style.inc.php'; - include './libraries/header_scripts.inc.php'; - ?> + $response = PMA_Response::getInstance(); + $response->getFooter()->setMinimal(); + $header = $response->getHeader(); + $header->setTitle(__('Access denied')); + $header->disableMenu(); - - - +?>

@@ -91,9 +88,7 @@ function PMA_auth_fails()
- ' . "\n"; } echo '
' . "\n"; - include './libraries/footer.inc.php'; + exit; return true; } // end of the 'PMA_auth_fails()' function diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 0d1c48533a..c4f5d2fc35 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', PMA_Message::error(__('Your session has expired. Please login again.'))); + } + exit; + } + /* Perform logout to custom URL */ if (! empty($_REQUEST['old_usr']) && ! empty($GLOBALS['cfg']['Server']['LogoutURL']) @@ -154,20 +165,13 @@ function PMA_auth() $cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right'; - // Defines the charset to be used - header('Content-Type: text/html; charset=utf-8'); + $response->getFooter()->setMinimal(); + $header = $response->getHeader(); + $header->setBodyId('loginform'); + $header->setTitle('phpMyAdmin'); + $header->disableMenu(); + $header->disableWarnings(); - /* HTML header; do not show here the PMA version to improve security */ - $page_title = 'phpMyAdmin '; - include './libraries/header_meta_style.inc.php'; - // if $page_title is set, this script uses it as the title: - include './libraries/header_scripts.inc.php'; - ?> - - - - - ' . $page_title . '' + 'phpMyAdmin' ); ?>

@@ -306,13 +310,11 @@ function PMA_auth() - - delete password cookie(s) @@ -581,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/auth/http.auth.lib.php b/libraries/auth/http.auth.lib.php index 7881750544..422fcbbe26 100644 --- a/libraries/auth/http.auth.lib.php +++ b/libraries/auth/http.auth.lib.php @@ -48,20 +48,14 @@ function PMA_auth() header('status: 401 Unauthorized'); } - // Defines the charset to be used - header('Content-Type: text/html; charset=utf-8'); /* HTML header */ - $page_title = __('Access denied'); - include './libraries/header_meta_style.inc.php'; - ?> - - - + $response = PMA_Response::getInstance(); + $response->getFooter()->setMinimal(); + $header = $response->getHeader(); + $header->setTitle(__('Access denied')); + $header->disableMenu(); +?>

@@ -74,12 +68,8 @@ function PMA_auth() if (file_exists(CUSTOM_FOOTER_FILE)) { include CUSTOM_FOOTER_FILE; } - ?> - - - 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 @@ -489,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 @@ -558,40 +547,6 @@ if (PMA_isValid($_REQUEST['sql_query'])) { //$_REQUEST['server']; // checked later in this file //$_REQUEST['lang']; // checked by LABEL_loading_language_file - -/** - * holds name of JavaScript files to be included in HTML header - * @global array $js_include - */ -$GLOBALS['js_include'] = array(); -$GLOBALS['js_include'][] = 'jquery/jquery-1.6.2.js'; -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js'; -$GLOBALS['js_include'][] = 'update-location.js'; - -/** - * holds an array of javascript code snippets to be included in the HTML header - * Can be used with PMA_addJSCode() to pass on js variables to the browser. - * @global array $js_script - */ -$GLOBALS['js_script'] = array(); - -/** - * Add common jQuery functions script here if necessary. - */ - -/** - * JavaScript events that will be registered - * @global array $js_events - */ -$GLOBALS['js_events'] = array(); - -/** - * footnotes to be displayed ot the page bottom - * @global array $footnotes - */ -$GLOBALS['footnotes'] = array(); - /******************************************************************************/ /* loading language file LABEL_loading_language_file */ @@ -600,6 +555,15 @@ $GLOBALS['footnotes'] = array(); */ require './libraries/select_lang.lib.php'; +// Defines the cell alignment values depending on text direction +if ($GLOBALS['text_dir'] == 'ltr') { + $GLOBALS['cell_align_left'] = 'left'; + $GLOBALS['cell_align_right'] = 'right'; +} else { + $GLOBALS['cell_align_left'] = 'right'; + $GLOBALS['cell_align_right'] = 'left'; +} + /** * check for errors occurred while loading configuration * this check is done here after loading language files to present errors in locale @@ -766,6 +730,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. */ @@ -881,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(); @@ -932,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? @@ -940,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? @@ -948,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 @@ -1099,6 +1063,32 @@ 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); + +// 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 @@ -1106,4 +1096,5 @@ if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) { include $__redirect; exit(); } + ?> diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 50b57a4085..77bb491e4e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -528,49 +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, $bbcode = false, $type = 'notice') +function PMA_showHint($message) { - if ($message instanceof PMA_Message) { - $key = $message->getHash(); - $type = $message->getLevel(); - } else { - $key = md5($message); - } - - if (! isset($GLOBALS['footnotes'][$key])) { - if (empty($GLOBALS['footnotes']) || ! is_array($GLOBALS['footnotes'])) { - $GLOBALS['footnotes'] = array(); - } - $nr = count($GLOBALS['footnotes']) + 1; - $GLOBALS['footnotes'][$key] = array( - 'note' => $message, - 'type' => $type, - 'nr' => $nr, - ); - } else { - $nr = $GLOBALS['footnotes'][$key]['nr']; - } - - if ($bbcode) { - return '[sup]' . $nr . '[/sup]'; - } - - // footnotemarker used in js/tooltip.js - return '' . $nr . '' - . PMA_getImage( - 'b_help.png', '', - array('class' => 'footnotemarker footnote_' . $nr) - ); + $retval = ''; + $retval .= PMA_getImage('b_help.png'); + $retval .= ''; + $retval .= $message; + $retval .= ''; + $retval .= ''; + return $retval; } /** @@ -595,11 +569,6 @@ function PMA_mysqlDie( ) { global $table, $db; - /** - * start http output, display html headers - */ - include_once './libraries/header.inc.php'; - $error_msg = ''; if (! $error_message) { @@ -710,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, '?')) { @@ -730,10 +702,7 @@ function PMA_mysqlDie( } echo $error_msg; - /** - * display footer and exit - */ - include './libraries/footer.inc.php'; + exit; } else { echo $error_msg; } @@ -939,8 +908,9 @@ function PMA_whichCrlf() * * @access public */ -function PMA_reloadNavigation($jsonly = false) +function PMA_getReloadNavigationScript($jsonly = false) { + $retval = ''; // Reloads the navigation frame via JavaScript if required if (isset($GLOBALS['reload']) && $GLOBALS['reload']) { // one of the reasons for a reload is when a table is dropped @@ -948,29 +918,29 @@ function PMA_reloadNavigation($jsonly = false) // we have a problem when dropping a table on the last page // and the offset becomes greater than the total number of tables unset($_SESSION['tmp_user_values']['table_limit_offset']); - echo "\n"; $reload_url = './navigation.php?' . PMA_generate_common_url( $GLOBALS['db'], '', '&' ); if (! $jsonly) { - echo '' . PHP_EOL; + $retval .= '' . PHP_EOL; } unset($GLOBALS['reload']); } + return $retval; } /** @@ -3277,61 +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 = 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; - } -} - /** * Display the form used to browse anywhere on the local server for a file to * import @@ -3945,4 +3860,48 @@ function PMA_printButton() . __('Print') . '" />'; 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/libraries/core.lib.php b/libraries/core.lib.php index ffcde8c867..b83614cccb 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -515,6 +515,7 @@ function PMA_sendHeaderLocation($uri, $use_refresh = false) { if (PMA_IS_IIS && strlen($uri) > 600) { include_once './libraries/js_escape.lib.php'; + PMA_Response::getInstance()->disable(); echo '- - -' . "\n"; echo '' . "\n"; @@ -742,40 +743,8 @@ function PMA_linkURL($url) } /** - * Returns HTML code to include javascript file. - * - * @param string $url Location of javascript, relative to js/ folder. - * @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. - */ -function PMA_includeJS($url, $ie_conditional = false) -{ - $include = ''; - if ($ie_conditional !== false) { - if ($ie_conditional === true) { - $include .= '' . "\n"; - } - return $include; -} - -/** - * Adds JS code snippets to be displayed by header.inc.php. Adds a - * newline to each snippet. + * Adds JS code snippets to be displayed by the PMA_Response class. + * Adds a newline to each snippet. * * @param string $str Js code to be added (e.g. "token=1234;") * @@ -783,11 +752,15 @@ function PMA_includeJS($url, $ie_conditional = false) */ function PMA_addJSCode($str) { - $GLOBALS['js_script'][] = $str; + $response = PMA_Response::getInstance(); + $header = $response->getHeader(); + $scripts = $header->getScripts(); + $scripts->addCode($str); } /** - * Adds JS code snippet for variable assignment to be displayed by header.inc.php. + * Adds JS code snippet for variable assignment + * to be displayed by the PMA_Response class. * * @param string $key Name of value to set * @param mixed $value Value to set, can be either string or array of strings diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php index 296685cdb4..75ae3a280d 100644 --- a/libraries/db_common.inc.php +++ b/libraries/db_common.inc.php @@ -72,12 +72,13 @@ 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; + } } -require_once './libraries/header.inc.php'; - /** * Set parameters for links */ diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index f21a71bc9d..bb9346cd15 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; } ?> @@ -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); ?> 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/libraries/display_import.lib.php b/libraries/display_import.lib.php index f8ff0c25eb..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; } ?> @@ -130,7 +130,7 @@ if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") { } // if finished diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 8287dbe335..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')) - && (! isset($GLOBALS['is_header_sent']) || ! $GLOBALS['is_header_sent']) ) { // ... elseif no button, displays empty columns if required // (unless coming from Browse mode print view) diff --git a/libraries/error.inc.php b/libraries/error.inc.php index f1f42e43c5..b6df839632 100644 --- a/libraries/error.inc.php +++ b/libraries/error.inc.php @@ -10,9 +10,12 @@ if (! defined('PHPMYADMIN')) { exit; } -if (!defined('TESTSUITE')) { +if (! defined('TESTSUITE')) { header('Content-Type: text/html; charset=utf-8'); } + +PMA_Response::getInstance()->disable(); + ?> diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php deleted file mode 100644 index 83ff7f783a..0000000000 --- a/libraries/footer.inc.php +++ /dev/null @@ -1,196 +0,0 @@ -hasDisplayErrors()) { - echo '
'; - $GLOBALS['error_handler']->dispErrors(); - echo '
'; -} - -if (count($GLOBALS['footnotes'])) { - echo '
'; - foreach ($GLOBALS['footnotes'] as $footnote) { - echo '' - . $footnote['nr'] . ' ' . $footnote['note'] . '
'; - } - echo '
'; -} - -if (! empty($_SESSION['debug'])) { - $sum_time = 0; - $sum_exec = 0; - foreach ($_SESSION['debug']['queries'] as $query) { - $sum_time += $query['count'] * $query['time']; - $sum_exec += $query['count']; - } - - echo '
'; - echo count($_SESSION['debug']['queries']) . ' queries executed ' - . $sum_exec . ' times in ' . $sum_time . ' seconds'; - echo '
';
-    print_r($_SESSION['debug']);
-    echo '
'; - echo '
'; - $_SESSION['debug'] = array(); -} - -if (!$GLOBALS['is_ajax_request']) { -?> - -' . "\n"; - $url_params['target'] = basename(PMA_getenv('SCRIPT_NAME')); - ?> - -'; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - echo PMA_getImage('window-new.png', __('Open new phpMyAdmin window')); - } - if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { - echo __('Open new phpMyAdmin window'); - } - echo '' . "\n"; - echo '' . "\n"; -} - -// Include possible custom footers -if (! $GLOBALS['is_ajax_request'] && file_exists(CUSTOM_FOOTER_FILE)) { - include CUSTOM_FOOTER_FILE; -} - -/** - * If we are in an AJAX request, we do not need to generate the closing tags for - * body and html. - */ -if (! $GLOBALS['is_ajax_request']) { -?> - - - diff --git a/libraries/header.inc.php b/libraries/header.inc.php deleted file mode 100644 index be455590a3..0000000000 --- a/libraries/header.inc.php +++ /dev/null @@ -1,135 +0,0 @@ -add($db, $table); - if ($tmp_result === true) { - echo ''; - } else { - $error = $tmp_result; - $error->display(); - } -} - -/** - * This is not an Ajax request so we need to generate all this output. - */ -if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { - - if (empty($GLOBALS['is_header_sent'])) { - - /** - * Gets a core script and starts output buffering work - */ - include_once './libraries/ob.lib.php'; - PMA_outBufferPre(); - - // if database storage for user preferences is transient, offer to load - // exported settings from localStorage (detection will be done in JavaScript) - $userprefs_offer_import = $GLOBALS['PMA_Config']->get('user_preferences') == 'session' - && ! isset($_SESSION['userprefs_autoload']); - if ($userprefs_offer_import) { - $GLOBALS['js_include'][] = 'config.js'; - } - - // For re-usability, moved http-headers and stylesheets - // to a seperate file. It can now be included by header.inc.php, - // querywindow.php. - - include_once './libraries/header_http.inc.php'; - include_once './libraries/header_meta_style.inc.php'; - include_once './libraries/header_scripts.inc.php'; - - /* remove vertical scroll bar bug in ie */ ?> - - - - - display(); - } - - echo "\n"; - - // offer to load user preferences from localStorage - if ($userprefs_offer_import) { - include_once './libraries/user_preferences.lib.php'; - PMA_userprefs_autoload_header(); - } - - // add recently used table and reload the navigation - if (strlen($GLOBALS['table']) && $GLOBALS['cfg']['LeftRecentTable'] > 0) { - PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']); - } - - if (! defined('PMA_DISPLAY_HEADING')) { - define('PMA_DISPLAY_HEADING', 1); - } - - // pass configuration for hint tooltip display - // (to be used by PMA_createqTip in js/functions.js) - if (! $GLOBALS['cfg']['ShowHint']) { - echo ''; - } - - /** - * Display heading if needed. Design can be set in css file. - */ - if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { - PMA_Menu::getInstance()->display(); - } - } - - /** - * Sets a variable to remember headers have been sent - */ - $GLOBALS['is_header_sent'] = true; - //end if (!$GLOBALS['is_ajax_request']) -} else { - if (empty($GLOBALS['is_header_sent'])) { - include_once './libraries/header_http.inc.php'; - $GLOBALS['is_header_sent'] = true; - } -} -?> diff --git a/libraries/header_http.inc.php b/libraries/header_http.inc.php deleted file mode 100644 index a375d398c8..0000000000 --- a/libraries/header_http.inc.php +++ /dev/null @@ -1,33 +0,0 @@ - diff --git a/libraries/header_meta_style.inc.php b/libraries/header_meta_style.inc.php deleted file mode 100644 index 66c5b75deb..0000000000 --- a/libraries/header_meta_style.inc.php +++ /dev/null @@ -1,50 +0,0 @@ -'; */ - -?> - - - - - - - <?php - if (!empty($page_title)) { - echo htmlspecialchars($page_title); - } else { - echo 'phpMyAdmin'; - } -?> - - - - diff --git a/libraries/header_printview.inc.php b/libraries/header_printview.inc.php deleted file mode 100644 index 47188ad472..0000000000 --- a/libraries/header_printview.inc.php +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - -<?php echo __('Print view'); ?> - phpMyAdmin <?php echo PMA_VERSION ?> - - - - - - diff --git a/libraries/header_scripts.inc.php b/libraries/header_scripts.inc.php deleted file mode 100644 index 61fc2643d9..0000000000 --- a/libraries/header_scripts.inc.php +++ /dev/null @@ -1,95 +0,0 @@ - 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 = $page_title; -} -// here, the function does not exist with this configuration: -// $cfg['ServerDefault'] = 0; -$is_superuser = function_exists('PMA_isSuperuser') && PMA_isSuperuser(); - -$GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.qtip-1.0.0-rc3.js'; -if ($GLOBALS['cfg']['CodemirrorEnable']) { - $GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js'; - $GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js'; -} - -$params = array('lang' => $GLOBALS['lang']); -if (isset($GLOBALS['db'])) { - $params['db'] = $GLOBALS['db']; -} -$GLOBALS['js_include'][] = 'messages.php' . PMA_generate_common_url($params); -// Append the theme id to this url to invalidate the cache on a theme change -$GLOBALS['js_include'][] = 'get_image.js.php?theme=' - . urlencode($_SESSION['PMA_Theme']->getId()); - -/** - * Here we add a timestamp when loading the file, so that users who - * upgrade phpMyAdmin are not stuck with older .js files in their - * browser cache. This produces an HTTP 304 request for each file. - */ - -// avoid loading twice a js file -$GLOBALS['js_include'] = array_unique($GLOBALS['js_include']); -foreach ($GLOBALS['js_include'] as $js_script_file) { - $ie_conditional = false; - if (is_array($js_script_file)) { - list($js_script_file, $ie_conditional) = $js_script_file; - } - echo PMA_includeJS($js_script_file, $ie_conditional); -} - -$title_to_set = isset($title) - ? PMA_sanitize(PMA_escapeJsString($title), false, true) - : ''; -// Below javascript Updates the title of the frameset if possible -?> - - diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 1a9678bf6e..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) @@ -1551,8 +1550,10 @@ function PMA_isInsertRow() && $_REQUEST['insert_rows'] != $GLOBALS['cfg']['InsertRows'] ) { $GLOBALS['cfg']['InsertRows'] = $_REQUEST['insert_rows']; - $GLOBALS['js_include'][] = 'tbl_change.js'; - include_once 'libraries/header.inc.php'; + $response = PMA_Response::getInstance(); + $header = $response->getHeader(); + $scripts = $header->getScripts(); + $scripts->addFile('tbl_change.js'); include 'tbl_change.php'; exit; } diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 476e5c4f20..856742a021 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -142,7 +142,6 @@ if (! empty($submit_mult) if (!empty($submit_mult) && !empty($what)) { unset($message); - include_once './libraries/header.inc.php'; if (strlen($table)) { include './libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; @@ -325,7 +324,7 @@ if (!empty($submit_mult) && !empty($what)) {
- diff --git a/querywindow.php b/querywindow.php index 200a106fc8..8ba3530c3e 100644 --- a/querywindow.php +++ b/querywindow.php @@ -19,12 +19,6 @@ $is_superuser = PMA_isSuperuser(); */ require_once 'libraries/sql_query_form.lib.php'; -/** - * starts output buffering if requested and supported - */ -require_once 'libraries/ob.lib.php'; -PMA_outBufferPre(); - /** * load relation params */ @@ -118,41 +112,27 @@ $sql_query = ''; /** * prepare JavaScript functionality */ -$js_include[] = 'common.js'; -$js_include[] = 'querywindow.js'; +$response = PMA_Response::getInstance(); +$response->getFooter()->setMinimal(); +$header = $response->getHeader(); +$header->disableMenu(); +$header->setBodyId('bodyquerywindow'); +$scripts = $header->getScripts(); +$scripts->addFile('common.js'); +$scripts->addFile('querywindow.js'); if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) { - $js_events[] = array( - 'event' => 'load', - 'function' => 'PMA_queryAutoCommit', - ); + $scripts->addEvent('load','PMA_queryAutoCommit'); } if (PMA_isValid($_REQUEST['init'])) { - $js_events[] = array( - 'event' => 'load', - 'function' => 'PMA_querywindowResize', - ); + $scripts->addEvent('load','PMA_querywindowResize'); } // always set focus to the textarea if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') { - $js_events[] = array( - 'event' => 'load', - 'function' => 'PMA_querywindowSetFocus', - ); + $scripts->addEvent('load','PMA_querywindowSetFocus'); } -/** - * start HTTP/HTML output - */ -require_once 'libraries/header_http.inc.php'; -require_once 'libraries/header_meta_style.inc.php'; -require_once 'libraries/header_scripts.inc.php'; -?> - - - -
-'; if ($tabs) { echo PMA_generateHtmlTabs($tabs, array()); @@ -220,5 +200,3 @@ if (! empty($_sql_history)
- - diff --git a/schema_edit.php b/schema_edit.php index 6fcfacb784..6067cb42b7 100644 --- a/schema_edit.php +++ b/schema_edit.php @@ -19,11 +19,9 @@ $url_query .= '&goto=schema_edit.php'; require_once 'libraries/db_info.inc.php'; /** - * Includ settings for relation stuff * get all variables needed for exporting relational schema * in $cfgRelation */ -require_once 'libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); /** @@ -37,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']) { @@ -125,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/schema_export.php b/schema_export.php index cafeea7492..26d2c6e6ae 100644 --- a/schema_export.php +++ b/schema_export.php @@ -12,11 +12,9 @@ require_once 'libraries/common.inc.php'; require 'libraries/StorageEngine.class.php'; /** - * Include settings for relation stuff * get all variables needed for exporting relational schema * in $cfgRelation */ -require_once 'libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); require_once 'libraries/transformations.lib.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 143e1f1c39..a15e2cd178 100644 --- a/server_databases.php +++ b/server_databases.php @@ -9,9 +9,10 @@ * Does the common work */ require_once 'libraries/common.inc.php'; - -$GLOBALS['js_include'][] = 'server_databases.js'; -$GLOBALS['js_include'][] = 'functions.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_databases.js'); require 'libraries/server_common.inc.php'; if (! PMA_DRIZZLE) { @@ -116,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; } } @@ -312,9 +316,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 3f5d50b7cf..a080fd0946 100644 --- a/server_export.php +++ b/server_export.php @@ -9,9 +9,13 @@ * Does the common work */ require_once 'libraries/common.inc.php'; -require 'libraries/server_common.inc.php'; -$GLOBALS['js_include'][] = 'export.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('export.js'); + +require 'libraries/server_common.inc.php'; $export_page_title = __('View dump (schema) of databases') . "\n"; $checkall_url = 'server_export.php?' @@ -56,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 ef6200d468..2a7d38f7df 100644 --- a/server_import.php +++ b/server_import.php @@ -10,7 +10,10 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'import.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('import.js'); /** * Does the common work @@ -19,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 04d638fa67..5c4c6ffdda 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -13,9 +13,12 @@ require_once 'libraries/common.inc.php'; /** * JS includes */ -$GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js'; -$GLOBALS['js_include'][] = 'server_plugins.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('jquery/jquery.cookie.js'); +$scripts->addFile('jquery/jquery.tablesorter.js'); +$scripts->addFile('server_plugins.js'); /** * Does the common work @@ -180,10 +183,3 @@ pma_theme_image = ''; - diff --git a/server_privileges.php b/server_privileges.php index 006f2e8933..cb9cc59b7c 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -13,8 +13,10 @@ require_once 'libraries/common.inc.php'; /** * Does the common work */ -$GLOBALS['js_include'][] = 'server_privileges.js'; -$GLOBALS['js_include'][] = 'functions.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_privileges.js'); $_add_user_error = false; @@ -175,13 +177,12 @@ if (isset($dbname)) { * Checks if the user is allowed to do what he tries to... */ if (! $is_superuser) { - include 'libraries/header.inc.php'; echo '

' . "\n" . PMA_getIcon('b_usrlist.png') . __('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 @@ -1184,7 +1185,7 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) { // this is needed in case tracking is on: $GLOBALS['db'] = $username; $GLOBALS['reload'] = true; - PMA_reloadNavigation(); + echo PMA_getReloadNavigationScript(); } $q = 'GRANT ALL PRIVILEGES ON ' @@ -1474,7 +1475,7 @@ if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST[ $GLOBALS['reload'] = true; if ($GLOBALS['is_ajax_request'] != true) { - PMA_reloadNavigation(); + echo PMA_getReloadNavigationScript(); } } } @@ -1642,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; } } @@ -1704,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"; } @@ -2033,7 +2041,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"; @@ -2567,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" @@ -2583,11 +2593,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 7f10eeed72..dcecc0e422 100644 --- a/server_replication.php +++ b/server_replication.php @@ -13,8 +13,11 @@ require_once 'libraries/common.inc.php'; /** * Does the common work */ -$GLOBALS['js_include'][] = 'server_privileges.js'; -$GLOBALS['js_include'][] = 'replication.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_privileges.js'); +$scripts->addFile('replication.js'); require 'libraries/server_common.inc.php'; require 'libraries/replication.inc.php'; @@ -25,13 +28,12 @@ require_once 'libraries/server_synchronize.lib.php'; * Checks if the user is allowed to do what he tries to... */ if (! $is_superuser) { - include 'libraries/header.inc.php'; echo '

' . "\n" . PMA_getIcon('s_replication.png') . __('Replication') . "\n" . '

' . "\n"; PMA_Message::error(__('No Privileges'))->display(); - include 'libraries/footer.inc.php'; + exit; } /** @@ -263,7 +265,6 @@ if (isset($GLOBALS['mr_configure'])) { echo ' '; echo '
'; - include 'libraries/footer.inc.php'; exit; } @@ -396,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 82924a22f0..408d2b2858 100644 --- a/server_sql.php +++ b/server_sql.php @@ -13,9 +13,11 @@ require_once 'libraries/common.inc.php'; /** * Does the common work */ -$GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'makegrid.js'; -$GLOBALS['js_include'][] = 'sql.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('makegrid.js'); +$scripts->addFile('sql.js'); require_once 'libraries/server_common.inc.php'; require_once 'libraries/sql_query_form.lib.php'; @@ -25,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 75b7695d10..301ea93c27 100644 --- a/server_status.php +++ b/server_status.php @@ -7,10 +7,6 @@ * @package PhpMyAdmin */ -if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { - $GLOBALS['is_header_sent'] = true; -} - require_once 'libraries/common.inc.php'; /** @@ -429,23 +425,26 @@ if (PMA_DRIZZLE) { /** * JS Includes */ +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_status.js'); -$GLOBALS['js_include'][] = 'server_status.js'; - -$GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence +$scripts->addFile('jquery/jquery.tablesorter.js'); +$scripts->addFile('jquery/jquery.cookie.js'); // For tab persistence // Charting -$GLOBALS['js_include'][] = 'highcharts/highcharts.js'; +$scripts->addFile('highcharts/highcharts.js'); /* Files required for chart exporting */ -$GLOBALS['js_include'][] = 'highcharts/exporting.js'; +$scripts->addFile('highcharts/exporting.js'); /* < IE 9 doesn't support canvas natively */ if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) { - $GLOBALS['js_include'][] = 'canvg/flashcanvas.js'; + $scripts->addFile('canvg/flashcanvas.js'); } -$GLOBALS['js_include'][] = 'canvg/canvg.js'; + +$scripts->addFile('canvg/canvg.js'); // for profiling chart -$GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js'; -$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.pieRenderer.js'; +$scripts->addFile('jqplot/jquery.jqplot.js'); +$scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js'); /** * flush status variables if requested @@ -1836,8 +1835,4 @@ function cleanDeprecated(&$server_status) } } -/** - * Sends the footer - */ -require 'libraries/footer.inc.php'; ?> diff --git a/server_synchronize.php b/server_synchronize.php index e7aba3ad43..51fc214044 100644 --- a/server_synchronize.php +++ b/server_synchronize.php @@ -14,7 +14,10 @@ require_once 'libraries/common.inc.php'; /** * Does the common work */ -$GLOBALS['js_include'][] = 'server_synchronize.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_synchronize.js'); require_once 'libraries/server_common.inc.php'; /** @@ -1484,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 ab023a97e6..59a3238bfa 100644 --- a/server_variables.php +++ b/server_variables.php @@ -7,7 +7,10 @@ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'server_variables.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_variables.js'); PMA_addJSVar('pma_token', $_SESSION[' PMA_token ']); PMA_addJSVar('url_query', str_replace('&', '&', PMA_generate_common_url($db))); @@ -30,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' @@ -64,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) ) { @@ -72,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; } } @@ -181,9 +177,4 @@ function formatVariable($name, $value) return htmlspecialchars($value); } -/** - * Sends the footer - */ -require 'libraries/footer.inc.php'; - ?> diff --git a/setup/index.php b/setup/index.php index 7fa24aec3f..a2b657b7c9 100644 --- a/setup/index.php +++ b/setup/index.php @@ -26,8 +26,8 @@ if (!file_exists("./setup/frames/$page.inc.php")) { $action_done = filter_input(INPUT_GET, 'action_done'); $action_done = preg_replace('/[^a-z_]/', '', $action_done); -// send no-cache headers -require './libraries/header_http.inc.php'; +PMA_noCacheHeader(); + ?> 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/sql.php b/sql.php index ed5a76e2cd..0a109a9b5a 100644 --- a/sql.php +++ b/sql.php @@ -11,15 +11,19 @@ */ require_once 'libraries/common.inc.php'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Header.class.php'; require_once 'libraries/check_user_privileges.lib.php'; require_once 'libraries/bookmark.lib.php'; -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; -$GLOBALS['js_include'][] = 'tbl_change.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('jquery/timepicker.js'); +$scripts->addFile('tbl_change.js'); // the next one needed because sql.php may do a "goto" to tbl_structure.php -$GLOBALS['js_include'][] = 'tbl_structure.js'; -$GLOBALS['js_include'][] = 'indexes.js'; -$GLOBALS['js_include'][] = 'gis_data_editor.js'; +$scripts->addFile('tbl_structure.js'); +$scripts->addFile('indexes.js'); +$scripts->addFile('gis_data_editor.js'); /** * Sets globals from $_POST @@ -55,12 +59,16 @@ if (isset($_REQUEST['printview'])) { } if (isset($_SESSION['profiling'])) { + $response = PMA_Response::getInstance(); + $header = $response->getHeader(); + $scripts = $header->getScripts(); /* < IE 9 doesn't support canvas natively */ if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) { - $GLOBALS['js_include'][] = 'canvg/flashcanvas.js'; + $scripts->addFile('canvg/flashcanvas.js'); } - $GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js'; - $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.pieRenderer.js'; + $scripts->addFile('jqplot/jquery.jqplot.js'); + $scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js'); + $scripts->addFile('canvg/canvg.js'); } /** @@ -104,7 +112,6 @@ if (isset($fields['dbase'])) { * better place either. */ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true) { - include_once 'libraries/relation.lib.php'; $column = $_REQUEST['column']; $foreigners = PMA_getForeigners($db, $table, $column); @@ -139,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; } /** @@ -153,13 +161,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 .= '

' . __( 'You are about to DESTROY a complete database!' @@ -412,10 +425,7 @@ if ($do_confirm) { echo '' . "\n" . '' . "\n"; - /** - * Displays the footer and exit - */ - include 'libraries/footer.inc.php'; + exit; } // end if $do_confirm @@ -573,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; } /** @@ -821,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 : '')); + $response = PMA_Response::getInstance(); + $response->isSuccess($message->isSuccess()); + $response->addJSON('message', $message); + $response->addJSON(isset($extra_data) ? $extra_data : array()); + exit; } if ($is_gotofile) { @@ -847,9 +864,6 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { $goto = 'main.php'; } // Loads to target script - if ($goto != 'main.php') { - include_once 'libraries/header.inc.php'; - } $active_page = $goto; include '' . $goto; } else { @@ -867,15 +881,17 @@ 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'])) { - $GLOBALS['js_include'][] = 'functions.js'; - $GLOBALS['js_include'][] = 'makegrid.js'; - $GLOBALS['js_include'][] = 'sql.js'; + $response = PMA_Response::getInstance(); + $header = $response->getHeader(); + $scripts = $header->getScripts(); + $scripts->addFile('makegrid.js'); + $scripts->addFile('sql.js'); // Gets the list of fields properties if (isset($result) && $result) { @@ -909,7 +925,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { if (isset($printview) && $printview == '1') { PMA_checkParameters(array('db', 'full_sql_query')); - include_once 'libraries/header_printview.inc.php'; + $response = PMA_Response::getInstance(); + $header = $response->getHeader(); + $header->enablePrintView(); $hostname = ''; if ($cfg['Server']['verbose']) { @@ -939,9 +957,11 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { echo "

"; } else { - $GLOBALS['js_include'][] = 'functions.js'; - $GLOBALS['js_include'][] = 'makegrid.js'; - $GLOBALS['js_include'][] = 'sql.js'; + $response = PMA_Response::getInstance(); + $header = $response->getHeader(); + $scripts = $header->getScripts(); + $scripts->addFile('makegrid.js'); + $scripts->addFile('sql.js'); unset($message); @@ -957,7 +977,6 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { include 'libraries/server_common.inc.php'; } } else { - include_once 'libraries/header.inc.php'; //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; @@ -1116,6 +1135,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 4d24a49469..efde25c048 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -10,8 +10,6 @@ */ require_once 'libraries/common.inc.php'; -require_once 'libraries/header.inc.php'; - // Check parameters PMA_checkParameters(array('db', 'table')); @@ -190,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'; @@ -229,9 +229,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 053ea71f95..b7e1d74b91 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -14,8 +14,6 @@ */ require_once 'libraries/common.inc.php'; -require_once 'libraries/header.inc.php'; - if (isset($_REQUEST['field'])) { $GLOBALS['field'] = $_REQUEST['field']; } @@ -115,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); @@ -124,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; } /** @@ -251,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'; @@ -319,10 +323,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 59addef9ad..8613410c4f 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -12,7 +12,6 @@ * Gets the variables sent or posted to this script and displays the header */ require_once 'libraries/common.inc.php'; -require_once 'libraries/common.lib.php'; /** * Ensures db and table are valid, else moves to the "parent" script @@ -108,17 +107,15 @@ if ($GLOBALS['cfg']['ShowPropertyComments']) { */ /** - * used in ./libraries/header.inc.php to load JavaScript library file + * Load JavaScript files */ -$GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'tbl_change.js'; -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; -$GLOBALS['js_include'][] = 'gis_data_editor.js'; - -/** - * HTTP and HTML headers - */ -require_once 'libraries/header.inc.php'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('functions.js'); +$scripts->addFile('tbl_change.js'); +$scripts->addFile('jquery/timepicker.js'); +$scripts->addFile('gis_data_editor.js'); /** * Displays the query submitted and its result @@ -385,9 +382,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 8a6d059c09..66f7419b10 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -11,15 +11,18 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'tbl_chart.js'; -$GLOBALS['js_include'][] = 'highcharts/highcharts.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('tbl_chart.js'); +$scripts->addFile('highcharts/highcharts.js'); /* Files required for chart exporting */ -$GLOBALS['js_include'][] = 'highcharts/exporting.js'; +$scripts->addFile('highcharts/exporting.js'); /* < IE 9 doesn't support canvas natively */ if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) { - $GLOBALS['js_include'][] = 'canvg/flashcanvas.js'; + $scripts->addFile('canvg/flashcanvas.js'); } -$GLOBALS['js_include'][] = 'canvg/canvg.js'; +$scripts->addFile('canvg/canvg.js'); /** * Runs common work @@ -155,10 +158,3 @@ url_query = ''; chart_data = '<', '>' => '>')); ?>; //]]> - diff --git a/tbl_create.php b/tbl_create.php index 10580095f3..78f687129e 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -11,7 +11,6 @@ require_once 'libraries/common.inc.php'; $action = 'tbl_create.php'; -require_once 'libraries/header.inc.php'; $titles = PMA_buildActionTitles(); // Check parameters @@ -321,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. @@ -353,6 +354,7 @@ if (isset($_REQUEST['do_save_data'])) { $regenerate = true; } } + exit; } // end do create table /** @@ -365,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 57e2364e6d..042fd9a001 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -10,7 +10,10 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'export.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('export.js'); /** * Gets tables informations and displays top links @@ -81,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 7060737ea1..73ea8210ab 100644 --- a/tbl_gis_visualization.php +++ b/tbl_gis_visualization.php @@ -8,12 +8,15 @@ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'openlayers/OpenLayers.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.svg.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.mousewheel.js'; -$GLOBALS['js_include'][] = 'jquery/jquery.event.drag-2.0.js'; -$GLOBALS['js_include'][] = 'tbl_gis_visualization.js'; -$GLOBALS['js_include'][] = 'OpenStreetMap.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('openlayers/OpenLayers.js'); +$scripts->addFile('jquery/jquery.svg.js'); +$scripts->addFile('jquery/jquery.mousewheel.js'); +$scripts->addFile('jquery/jquery.event.drag-2.0.js'); +$scripts->addFile('tbl_gis_visualization.js'); +$scripts->addFile('OpenStreetMap.js'); // Allows for resending headers even after sending some data ob_start(); @@ -189,10 +192,3 @@ $visualization = PMA_GIS_visualizationResults($data, $visualizationSettings, $fo - diff --git a/tbl_import.php b/tbl_import.php index abe6f10a1c..9c399e0bd6 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -10,7 +10,10 @@ */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'import.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('import.js'); /** * Gets tables informations and displays top links @@ -23,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 af268a61ae..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 @@ -129,7 +133,10 @@ if (isset($_REQUEST['do_save_data'])) { */ // Displays headers (if needed) -$GLOBALS['js_include'][] = 'indexes.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('indexes.js'); require_once 'libraries/tbl_info.inc.php'; if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) { @@ -317,10 +324,3 @@ echo '' . "\n" ?> - 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 9baa8c5d2a..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); } @@ -860,13 +866,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 78d5876154..4c7ec509dc 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -11,12 +11,8 @@ */ require_once 'libraries/common.inc.php'; -/** - * Gets the variables sent or posted to this script, then displays headers - */ -if (! isset($selected_tbl)) { - include_once 'libraries/header_printview.inc.php'; -} +$response = PMA_Response::getInstance(); +$response->getHeader()->enablePrintView(); require 'libraries/tbl_common.inc.php'; @@ -61,9 +57,6 @@ if (isset($selected_tbl) && is_array($selected_tbl)) { $multi_tables = (count($the_tables) > 1); if ($multi_tables) { - if (empty($GLOBALS['is_header_sent'])) { - include_once 'libraries/header.inc.php'; - } $tbl_list = ''; foreach ($the_tables as $key => $table) { $tbl_list .= (empty($tbl_list) ? '' : ', ') @@ -479,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 06df554797..0bf1941393 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -17,7 +17,10 @@ * Gets some core libraries */ require_once 'libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'tbl_relation.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('tbl_relation.js'); require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php'; @@ -572,8 +575,4 @@ if (count($columns) > 0) { diff --git a/tbl_replace.php b/tbl_replace.php index 98ce3765b6..adb51c2106 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -32,9 +32,12 @@ PMA_DBI_select_db($GLOBALS['db']); */ $goto_include = false; -$GLOBALS['js_include'][] = 'makegrid.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('makegrid.js'); // Needed for generation of Inline Edit anchors -$GLOBALS['js_include'][] = 'sql.js'; +$scripts->addFile('sql.js'); // check whether insert row moode, if so include tbl_change.php PMA_isInsertRow(); @@ -276,9 +279,6 @@ if ($is_insert && count($value_sets) > 0) { // Note: logic passes here for inline edit $message = PMA_Message::success(__('No change')); $active_page = $goto_include; - if (! $GLOBALS['is_ajax_request'] == true) { - include_once 'libraries/header.inc.php'; - } include '' . PMA_securePath($goto_include); exit; } @@ -322,8 +322,6 @@ if ($GLOBALS['is_ajax_request'] == true) { */ if (isset($_REQUEST['rel_fields_list']) && $_REQUEST['rel_fields_list'] != '') { - //handle relations work here for updated row. - include_once 'libraries/relation.lib.php'; $map = PMA_getForeigners($db, $table, '', 'both'); @@ -452,7 +450,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)) { @@ -462,7 +465,7 @@ if (isset($return_to_sql_query)) { $GLOBALS['sql_query'] = $return_to_sql_query; } -$GLOBALS['js_include'][] = 'tbl_change.js'; +$scripts->addFile('tbl_change.js'); $active_page = $goto_include; @@ -475,10 +478,6 @@ if (isset($_REQUEST['after_insert']) && 'new_insert' == $_REQUEST['after_insert' unset($_REQUEST['where_clause']); } -/** - * Load header. - */ -require_once 'libraries/header.inc.php'; /** * Load target page. */ 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 dd3dd733ec..d956d5009c 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -16,23 +16,19 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/mysql_charsets.lib.php'; require_once 'libraries/tbl_select.lib.php'; -$GLOBALS['js_include'][] = 'makegrid.js'; -$GLOBALS['js_include'][] = 'sql.js'; -$GLOBALS['js_include'][] = 'tbl_select.js'; -$GLOBALS['js_include'][] = 'tbl_change.js'; -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; -$GLOBALS['js_include'][] = 'gis_data_editor.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('makegrid.js'); +$scripts->addFile('sql.js'); +$scripts->addFile('tbl_select.js'); +$scripts->addFile('tbl_change.js'); +$scripts->addFile('jquery/timepicker.js'); +$scripts->addFile('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])) { @@ -64,7 +60,6 @@ if (! isset($_POST['columnsToDisplay']) || $_POST['columnsToDisplay'][0] == '') // Gets the list and number of fields list($columnNames, $columnTypes, $columnCollations, $columnNullFlags, $geomColumnFlag) = PMA_tbl_getFields($db, $table); - $columnCount = count($columnNames); // retrieve keys into foreign fields, if any // check also foreigners even if relwork is FALSE (to get @@ -73,19 +68,14 @@ 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, $foreigners, "normal" ); - - include 'libraries/footer.inc.php'; } else { /** * 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'; } ?> diff --git a/tbl_sql.php b/tbl_sql.php index 3420a051af..b06be2760c 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -13,9 +13,11 @@ require_once 'libraries/common.inc.php'; /** * Runs common work */ -$GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'makegrid.js'; -$GLOBALS['js_include'][] = 'sql.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('makegrid.js'); +$scripts->addFile('sql.js'); require 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; @@ -41,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 013cab4bc5..8ccc21782d 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -12,8 +12,11 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/mysql_charsets.lib.php'; -$GLOBALS['js_include'][] = 'tbl_structure.js'; -$GLOBALS['js_include'][] = 'indexes.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('tbl_structure.js'); +$scripts->addFile('indexes.js'); /** * handle multiple field commands if required @@ -69,7 +72,6 @@ if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) { // handle confirmation of deleting multiple fields/columns $action = 'tbl_structure.php'; include 'libraries/mult_submits.inc.php'; - //require_once 'libraries/header.inc.php'; if (empty($message)) { $message = PMA_Message::success(); @@ -999,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 0e705ddf58..0ff020be97 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -14,41 +14,35 @@ require_once './libraries/common.inc.php'; require_once './libraries/mysql_charsets.lib.php'; require_once './libraries/tbl_select.lib.php'; -require_once './libraries/relation.lib.php'; require_once './libraries/tbl_info.inc.php'; -$GLOBALS['js_include'][] = 'makegrid.js'; -$GLOBALS['js_include'][] = 'sql.js'; -$GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'date.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('makegrid.js'); +$scripts->addFile('sql.js'); +$scripts->addFile('date.js'); /* < IE 9 doesn't support canvas natively */ if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) { - $GLOBALS['js_include'][] = 'canvg/flashcanvas.js'; + $scripts->addFile('canvg/flashcanvas.js'); } - -$GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js'; -$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasTextRenderer.js'; -$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js'; -$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.dateAxisRenderer.js'; -$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.highlighter.js'; -$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.cursor.js'; -$GLOBALS['js_include'][] = 'canvg/canvg.js'; -$GLOBALS['js_include'][] = 'jquery/timepicker.js'; -$GLOBALS['js_include'][] = 'tbl_zoom_plot_jqplot.js'; +$scripts->addFile('jqplot/jquery.jqplot.js'); +$scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js'); +$scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js'); +$scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js'); +$scripts->addFile('jqplot/plugins/jqplot.highlighter.js'); +$scripts->addFile('jqplot/plugins/jqplot.cursor.js'); +$scripts->addFile('canvg/canvg.js'); +$scripts->addFile('jquery/timepicker.js'); +$scripts->addFile('tbl_zoom_plot_jqplot.js'); /** * Sets globals from $_POST */ $post_params = array( - 'collations', 'dataLabel', - 'fields', - 'fields_null', - 'inputs', 'maxPlotLimit', - 'types', - 'zoom_submit', - 'zoomFunc' + 'zoom_submit' ); foreach ($post_params as $one_post_param) { if (isset($_POST[$one_post_param])) { @@ -78,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; } /** @@ -88,55 +83,29 @@ 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'] = ''; - 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($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]; - - // 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, - array($_REQUEST['it'] => $fields_type[$key]), - $_REQUEST['it'], - $_REQUEST['db'], - $_REQUEST['table'], - $titles, - $GLOBALS['cfg']['ForeignKeyMaxLimit'], - '' - ); - $extra_data['field_value'] = $html; - 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')); @@ -161,218 +130,38 @@ $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); // 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(); - -if (! isset($zoom_submit) && ! isset($inputs)) { - $dataLabel = PMA_getDisplayField($db, $table); -} -?> -
-
-'; - $tbl_fields_func[$i] .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml( - preg_replace('@\(.*@s', '', $fields_type[$key]), - $fields_null[$key], $zoomFunc[$i] - ); - $tbl_fields_func[$i] .= ''; - $foreignData = PMA_getForeignData($foreigners, $inputs[$i], false, '', ''); - $tbl_fields_value[$i] = PMA_getForeignFields_Values( - $foreigners, - $foreignData, - $inputs[$i], - $tbl_fields_type, - $i, - $db, - $table, - $titles, - $GLOBALS['cfg']['ForeignKeyMaxLimit'], - $fields - ); - } - } -} - -/* - * Form for input criteria - */ - -?> -
> - - - - -
- - - - - -"; - } - ?> - - - - - - - - - - -
"; - echo __("Additional search criteria"); - echo "
- /> - -
- - - - - - - '; -?> -
-
-
- -
-
- -
-
-
isUnaryOperator($func_type); - $whereClause = PMA_tbl_search_getWhereClause( - $fields[$i], $inputs[$i], $types[$i], - $collations[$i], $func_type, $unaryFlag - ); - if ($whereClause) { - $w[] = $whereClause; - } - } // end for - if ($w) { - $sql_query .= ' WHERE ' . implode(' AND ', $w); - } + $sql_query = PMA_tblSearchBuildSqlQuery(); $sql_query .= ' LIMIT ' . $maxPlotLimit; /* @@ -389,33 +178,21 @@ if (isset($zoom_submit) } //Get unique conditon on each row (will be needed for row update) $uniqueCondition = PMA_getUniqueCondition( - $result, $fields_cnt, $fields_meta, $tmpRow, true + $result, count($columnNames), $fields_meta, $tmpRow, true ); //Append it to row array as where_clause $row['where_clause'] = $uniqueCondition[0]; - if ($dataLabel == $inputs[0] || $dataLabel == $inputs[1]) { - $data[] = array( - $inputs[0] => $row[$inputs[0]], - $inputs[1] => $row[$inputs[1]], - 'where_clause' => $uniqueCondition[0] - ); - } elseif ($dataLabel) { - $data[] = array( - $inputs[0] => $row[$inputs[0]], - $inputs[1] => $row[$inputs[1]], - $dataLabel => $row[$dataLabel], - 'where_clause' => $uniqueCondition[0] - ); - } else { - $data[] = array( - $inputs[0] => $row[$inputs[0]], - $inputs[1] => $row[$inputs[1]], - $dataLabel => '', - 'where_clause' => $uniqueCondition[0] - ); - } + $tmpData = array( + $_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]], + $_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]], + 'where_clause' => $uniqueCondition[0] + ); + $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : ''; + + $data[] = $tmpData; } + unset($tmpData); /* * Form for displaying point data and also the scatter plot */ @@ -459,22 +236,21 @@ if (isset($zoom_submit) - - ' + + ' : ''; ?> @@ -489,5 +265,4 @@ if (isset($zoom_submit) 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/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/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)); - } - } diff --git a/test/libraries/core/PMA_headerLocation_test_disabled.php b/test/libraries/core/PMA_headerLocation_test_disabled.php index 240352ff69..4869483b40 100644 --- a/test/libraries/core/PMA_headerLocation_test_disabled.php +++ b/test/libraries/core/PMA_headerLocation_test_disabled.php @@ -277,7 +277,7 @@ class PMA_headerLocation_test extends PHPUnit_Framework_TestCase $GLOBALS['db'] = 'test_db'; $url = './navigation.php?'.PMA_generate_common_url($GLOBALS['db'], '', '&'); - $write = PHP_EOL . '' . PHP_EOL; $this->expectOutputString($write); - PMA_reloadNavigation(); + echo PMA_getReloadNavigationScript(); $this->assertFalse(isset($GLOBALS['reload'])); unset($GLOBALS['db']); diff --git a/themes.php b/themes.php index 9c6d6731f2..4328383a73 100644 --- a/themes.php +++ b/themes.php @@ -9,25 +9,23 @@ * get some globals */ require './libraries/common.inc.php'; +$response = PMA_Response::getInstance(); +$response->getFooter()->setMinimal(); +$header = $response->getHeader(); +$header->setBodyId('bodythemes'); +$header->setTitle('phpMyAdmin - ' . __('Theme')); +$header->disableMenu(); -/* Theme Select */ -$path_to_themes = $cfg['ThemePath'] . '/'; +$hash = '#pma_' . preg_replace('/([0-9]*)\.([0-9]*)\..*/', '\1_\2', PMA_VERSION); +$url = PMA_linkURL('http://www.phpmyadmin.net/home_page/themes.php') . $hash; +$output = '

phpMyAdmin - ' . __('Theme') . '

'; +$output .= '

'; +$output .= ''; +$output .= __('Get more themes!'); +$output .= ''; +$output .= '

'; +$output .= $_SESSION['PMA_Theme_Manager']->getPrintPreviews(); -/* set language and charset */ -require './libraries/header_http.inc.php'; +$response->addHTML($output); -/* HTML header */ -$page_title = 'phpMyAdmin - ' . __('Theme'); -require './libraries/header_meta_style.inc.php'; -require './libraries/header_scripts.inc.php'; ?> - - - -

phpMyAdmin -

-

-printPreviews(); -?> - - diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index d882651936..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; @@ -641,17 +635,18 @@ div#querychart { /** * login form */ -body.loginform h1, -body.loginform a.logo { +body#loginform h1, +body#loginform a.logo { display: block; text-align: center; } -body.loginform { +body#loginform { + margin-top: 1em; text-align: center; } -body.loginform div.container { +body#loginform div.container { text-align: ; width: 30em; margin: 0 auto; diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index 79f59b6fc8..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; @@ -855,17 +846,18 @@ td.disabled { /** * login form */ -body.loginform h1, -body.loginform a.logo { +body#loginform h1, +body#loginform a.logo { display: block; text-align: center; } -body.loginform { +body#loginform { + margin-top: 1em; text-align: center; } -body.loginform div.container { +body#loginform div.container { text-align: ; width: 30em; margin: 0 auto; 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; diff --git a/transformation_overview.php b/transformation_overview.php index ae80a506e8..50a3ab8e9c 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -5,19 +5,16 @@ * @package PhpMyAdmin */ -/** - * Don't display the page heading - * @ignore - */ -define('PMA_DISPLAY_HEADING', 0); - /** * Gets some core libraries and displays a top message if required */ require_once './libraries/common.inc.php'; -require_once './libraries/header.inc.php'; require_once './libraries/transformations.lib.php'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$header->disableMenu(); + $types = PMA_getAvailableMIMEtypes(); ?> @@ -64,9 +61,3 @@ foreach ($types['transformation'] as $key => $transform) { - diff --git a/transformation_wrapper.php b/transformation_wrapper.php index 722ef2b2d6..ab1625c234 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -84,11 +84,10 @@ if ($cfgRelation['commwork'] && $cfgRelation['mimework']) { } } -// For re-usability, moved http-headers and stylesheets -// to a seperate file. It can now be included by libraries/header.inc.php, -// querywindow.php. +// Only output the http headers +$response = PMA_Response::getInstance(); +$response->getHeader()->sendHttpHeaders(); -require_once './libraries/header_http.inc.php'; // [MIME] if (isset($ct) && !empty($ct)) { $mime_type = $ct; diff --git a/user_password.php b/user_password.php index 8a9937eb00..258585e019 100644 --- a/user_password.php +++ b/user_password.php @@ -12,7 +12,10 @@ */ require_once './libraries/common.inc.php'; -$GLOBALS['js_include'][] = 'server_privileges.js'; +$response = PMA_Response::getInstance(); +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('server_privileges.js'); /** * Displays an error message and exits if the user isn't allowed to use this @@ -22,9 +25,8 @@ if (! $cfg['ShowChgPassword']) { $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql'); } if ($cfg['Server']['auth_type'] == 'config' || ! $cfg['ShowChgPassword']) { - include_once './libraries/header.inc.php'; PMA_Message::error(__('You don\'t have sufficient privileges to be here right now!'))->display(); - include './libraries/footer.inc.php'; + exit; } // end if /** @@ -50,20 +52,15 @@ if (isset($_REQUEST['nopass'])) { * If the "change password" form hasn't been submitted or the values submitted * aren't valid -> displays the form */ -// Loads the headers -require_once './libraries/header.inc.php'; // Displays an error message if required if (isset($message)) { $message->display(); + unset($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 @@ -79,12 +76,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; } } @@ -180,7 +184,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 @@ -203,11 +210,10 @@ function PMA_changePassAuthType($_url_params, $password) */ function PMA_changePassDisplayPage($message, $sql_query, $_url_params) { - include_once './libraries/header.inc.php'; echo '

' . __('Change password') . '

' . "\n\n"; 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..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; } } } @@ -186,10 +198,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';
-