Skip to content

Commit

Permalink
Dropped header.inc.php in favor of the PMA_Header class
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Jun 11, 2012
1 parent 97449da commit 4a74037
Show file tree
Hide file tree
Showing 63 changed files with 210 additions and 361 deletions.
2 changes: 1 addition & 1 deletion chk_rel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Gets some core libraries
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/header.inc.php';
PMA_Header::getInstance()->display();


/**
Expand Down
4 changes: 0 additions & 4 deletions db_create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -67,8 +66,6 @@
if ($GLOBALS['is_ajax_request'] == true) {
PMA_ajaxResponse($message, false);
}

include_once 'libraries/header.inc.php';
include_once 'main.php';
} else {
$message = PMA_Message::success(__('Database %1$s has been created.'));
Expand Down Expand Up @@ -145,7 +142,6 @@
PMA_ajaxResponse($message, true, $extra_data);
}

include_once 'libraries/header.inc.php';
include_once '' . $cfg['DefaultTabDatabase'];
}
?>
7 changes: 4 additions & 3 deletions db_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
/**
* Include JavaScript libraries
*/
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'rte/common.js';
$GLOBALS['js_include'][] = 'rte/events.js';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('jquery/timepicker.js');
$scripts->addFile('rte/common.js');
$scripts->addFile('rte/events.js');

/**
* Include all other files
Expand Down
3 changes: 2 additions & 1 deletion db_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
*/
require_once 'libraries/common.inc.php';

$GLOBALS['js_include'][] = 'export.js';
$scripts = PMA_Header::getInstance()->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']
Expand Down
3 changes: 2 additions & 1 deletion db_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
*/
require_once 'libraries/common.inc.php';

$GLOBALS['js_include'][] = 'import.js';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('import.js');

/**
* Gets tables informations and displays top links
Expand Down
3 changes: 2 additions & 1 deletion db_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
require_once 'libraries/mysql_charsets.lib.php';

// add a javascript file for jQuery functions to handle Ajax actions
$GLOBALS['js_include'][] = 'db_operations.js';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('db_operations.js');

/**
* Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise)
Expand Down
7 changes: 4 additions & 3 deletions db_routines.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
/**
* Include JavaScript libraries
*/
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'rte/common.js';
$GLOBALS['js_include'][] = 'rte/routines.js';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('jquery/timepicker.js');
$scripts->addFile('rte/common.js');
$scripts->addFile('rte/routines.js');

/**
* Include all other files
Expand Down
9 changes: 5 additions & 4 deletions db_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
*/
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';
$scripts = PMA_Header::getInstance()->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
Expand Down
7 changes: 4 additions & 3 deletions db_sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
/**
* Runs common work
*/
$GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'makegrid.js';
$GLOBALS['js_include'][] = 'sql.js';
$scripts = PMA_Header::getInstance()->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';
Expand Down
7 changes: 4 additions & 3 deletions db_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
*/
require_once 'libraries/common.inc.php';

$GLOBALS['js_include'][] = 'db_structure.js';
$GLOBALS['js_include'][] = 'tbl_change.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('db_structure.js');
$scripts->addFile('tbl_change.js');
$scripts->addFile('jquery/timepicker.js');

/**
* Sets globals from $_POST
Expand Down
3 changes: 2 additions & 1 deletion db_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
require_once 'libraries/common.inc.php';

//Get some js files needed for Ajax requests
$GLOBALS['js_include'][] = 'db_structure.js';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('db_structure.js');

/**
* If we are not in an Ajax request, then do the common work and show the links etc.
Expand Down
6 changes: 3 additions & 3 deletions db_triggers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* 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';
$scripts = PMA_Header::getInstance()->getScripts();
$scripts->addFile('rte/common.js');
$scripts->addFile('rte/triggers.js');

/**
* Include all other files
Expand Down
7 changes: 1 addition & 6 deletions export.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
// 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';
Expand Down Expand Up @@ -369,7 +368,6 @@ function PMA_exportOutputHandler($line)
}
}
if (isset($message)) {
include_once 'libraries/header.inc.php';
if ($export_type == 'server') {
$active_page = 'server_export.php';
include 'server_export.php';
Expand Down Expand Up @@ -403,14 +401,13 @@ function PMA_exportOutputHandler($line)
$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';
PMA_Header::getInstance()->display();
$cfg['Server'] = $backup_cfgServer;
unset($backup_cfgServer);
echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
Expand Down Expand Up @@ -720,7 +717,6 @@ function PMA_exportOutputHandler($line)
// 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';
Expand Down Expand Up @@ -788,7 +784,6 @@ function PMA_exportOutputHandler($line)
);
}

include_once 'libraries/header.inc.php';
if ($export_type == 'server') {
$active_page = 'server_export.php';
include_once 'server_export.php';
Expand Down
2 changes: 1 addition & 1 deletion import.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
// upload limit has been reached, let's assume the second possibility.
;
if ($_POST == array() && $_GET == array()) {
include_once 'libraries/header.inc.php';
PMA_Header::getInstance()->display();
$message = PMA_Message::error(__('You probably tried to upload too large file. Please refer to %sdocumentation%s for ways to workaround this limit.'));
$message->addParam('[a@./Documentation.html#faq1_16@_blank]');
$message->addParam('[/a]');
Expand Down
2 changes: 1 addition & 1 deletion libraries/PDF.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function _putpages()
*/
function Error($error_message = '')
{
include './libraries/header.inc.php';
PMA_Header::getInstance()->display();
PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display();
include './libraries/footer.inc.php';
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/auth/config.auth.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function PMA_auth_fails()
<td>

<?php
$GLOBALS['is_header_sent'] = true;
PMA_Header::getInstance()->isHeaderSent = true;

if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
trigger_error(__('Access denied'), E_USER_NOTICE);
Expand Down
41 changes: 13 additions & 28 deletions libraries/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
/******************************************************************************/
/* start procedural code label_start_procedural */

if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
PMA_fatalError(__("GLOBALS overwrite attempt"));
}

/**
* protect against possible exploits - there is no need to have so much variables
*/
Expand Down Expand Up @@ -558,34 +562,6 @@
//$_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
Expand All @@ -600,6 +576,15 @@
*/
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
Expand Down
2 changes: 1 addition & 1 deletion libraries/common.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ function PMA_mysqlDie(
/**
* start http output, display html headers
*/
include_once './libraries/header.inc.php';
PMA_Header::getInstance()->display();

$error_msg = '';

Expand Down
2 changes: 1 addition & 1 deletion libraries/core.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ function PMA_includeJS($url, $ie_conditional = false)
*/
function PMA_addJSCode($str)
{
$GLOBALS['js_script'][] = $str;
PMA_Header::getInstance()->getScripts()->addCode($str);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion libraries/db_common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@
};
}

require_once './libraries/header.inc.php';
/**
* Displays headers
*/
PMA_Header::getInstance()->display();

/**
* Set parameters for links
Expand Down
2 changes: 1 addition & 1 deletion libraries/display_tbl.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ 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'])
&& ! PMA_Header::getInstance()->headerIsSent
) {
// ... elseif no button, displays empty columns if required
// (unless coming from Browse mode print view)
Expand Down
Loading

0 comments on commit 4a74037

Please sign in to comment.