Skip to content

Commit

Permalink
PMA_Footer and PMA_Header no longer need to be singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Jun 11, 2012
1 parent c2ae2ae commit a054562
Show file tree
Hide file tree
Showing 67 changed files with 206 additions and 137 deletions.
3 changes: 2 additions & 1 deletion browse_foreigners.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

PMA_checkParameters(array('db', 'table', 'field'));

$header = PMA_Header::getInstance();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$header->disableMenu();
$header->setBodyId('body_browse_foreigners');

Expand Down
4 changes: 3 additions & 1 deletion db_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
/**
* Include JavaScript libraries
*/
$scripts = PMA_Header::getInstance()->getScripts();
$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');
Expand Down
4 changes: 3 additions & 1 deletion db_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
*/
require_once 'libraries/common.inc.php';

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

$scripts = PMA_Header::getInstance()->getScripts();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('import.js');

/**
Expand Down
4 changes: 3 additions & 1 deletion db_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
require_once 'libraries/mysql_charsets.lib.php';

// add a javascript file for jQuery functions to handle Ajax actions
$scripts = PMA_Header::getInstance()->getScripts();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_operations.js');

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

$header = PMA_Header::getInstance();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$header->enablePrintView();
$header->display();

Expand Down
4 changes: 3 additions & 1 deletion db_routines.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
/**
* Include JavaScript libraries
*/
$scripts = PMA_Header::getInstance()->getScripts();
$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');
Expand Down
4 changes: 3 additions & 1 deletion db_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
*/
require_once 'libraries/common.inc.php';

$scripts = PMA_Header::getInstance()->getScripts();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_search.js');
$scripts->addFile('sql.js');
$scripts->addFile('makegrid.js');
Expand Down
4 changes: 3 additions & 1 deletion db_sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
/**
* Runs common work
*/
$scripts = PMA_Header::getInstance()->getScripts();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('functions.js');
$scripts->addFile('makegrid.js');
$scripts->addFile('sql.js');
Expand Down
4 changes: 3 additions & 1 deletion db_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
*/
require_once 'libraries/common.inc.php';

$scripts = PMA_Header::getInstance()->getScripts();
$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');
Expand Down
4 changes: 3 additions & 1 deletion db_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
require_once 'libraries/common.inc.php';

//Get some js files needed for Ajax requests
$scripts = PMA_Header::getInstance()->getScripts();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_structure.js');

/**
Expand Down
4 changes: 3 additions & 1 deletion db_triggers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
/**
* Include JavaScript libraries
*/
$scripts = PMA_Header::getInstance()->getScripts();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('rte/common.js');
$scripts->addFile('rte/triggers.js');

Expand Down
3 changes: 2 additions & 1 deletion export.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ function PMA_exportOutputHandler($line)
}
}
$backup_cfgServer = $cfg['Server'];
PMA_Header::getInstance()->display();
$response = PMA_Response::getInstance();
$response->getHeader()->display();
$cfg['Server'] = $backup_cfgServer;
unset($backup_cfgServer);
echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
Expand Down
3 changes: 2 additions & 1 deletion import.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
// upload limit has been reached, let's assume the second possibility.
;
if ($_POST == array() && $_GET == array()) {
PMA_Header::getInstance()->display();
$response = PMA_Response::getInstance();
$response->getHeader()->display();
$message = PMA_Message::error(__('You probably tried to upload too large file. Please refer to %sdocumentation%s for ways to workaround this limit.'));
$message->addParam('[a@./Documentation.html#faq1_16@_blank]');
$message->addParam('[/a]');
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@


// start output
PMA_Header::getInstance()->sendHttpHeaders();
$response = PMA_Response::getInstance();
$response->getHeader()->sendHttpHeaders();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Expand Down
26 changes: 2 additions & 24 deletions libraries/Footer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@
require_once 'libraries/Footnotes.class.php';

/**
* Singleton class used to output the footer
* Class used to output the footer
*
* @package PhpMyAdmin
*/
class PMA_Footer
{
/**
* PMA_Footer instance
*
* @access private
* @static
* @var object
*/
private static $_instance;

/**
* PMA_Footnotes instance
*
Expand All @@ -48,7 +39,7 @@ class PMA_Footer
*
* @return new PMA_Footer object
*/
private function __construct()
public function __construct()
{
$this->_footnotes = new PMA_Footnotes();
$this->_scripts = new PMA_Scripts();
Expand Down Expand Up @@ -235,19 +226,6 @@ private function _setHistory()
}
}

/**
* Returns the singleton PMA_Footer object
*
* @return PMA_Footer object
*/
public static function getInstance()
{
if (empty(self::$_instance)) {
self::$_instance = new PMA_Footer();
}
return self::$_instance;
}

/**
* Returns the PMA_Footnotes object
*
Expand Down
25 changes: 2 additions & 23 deletions libraries/Header.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,12 @@
$is_superuser = function_exists('PMA_isSuperuser') && PMA_isSuperuser();

/**
* Singleton class used to output the HTTP and HTML headers
* Class used to output the HTTP and HTML headers
*
* @package PhpMyAdmin
*/
class PMA_Header
{
/**
* PMA_Header instance
*
* @access private
* @static
* @var object
*/
private static $_instance;
/**
* PMA_Scripts instance
*
Expand Down Expand Up @@ -107,7 +99,7 @@ class PMA_Header
*
* @return new PMA_Header object
*/
private function __construct()
public function __construct()
{
$this->_isAjax = false;
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
Expand Down Expand Up @@ -207,19 +199,6 @@ private function _addDefaultScripts()
$this->_scripts->addCode(PMA_getReloadNavigationScript(true));
}

/**
* Returns the singleton PMA_Header object
*
* @return PMA_Header object
*/
public static function getInstance()
{
if (empty(self::$_instance)) {
self::$_instance = new PMA_Header();
}
return self::$_instance;
}

/**
* Returns the PMA_Scripts object
*
Expand Down
3 changes: 2 additions & 1 deletion libraries/PDF.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ function _putpages()
*/
function Error($error_message = '')
{
PMA_Header::getInstance()->display();
$response = PMA_Response::getInstance();
$response->getHeader()->display();
PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display();
include './libraries/footer.inc.php';
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/Response.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* Manages the rendering of pages in PMA
*
* @package PhpMyAdmin
*/
Expand All @@ -13,7 +13,7 @@
require_once 'libraries/Footer.class.php';

/**
*
* Singleton class used to manage the rendering of pages in PMA
*
* @package PhpMyAdmin
*/
Expand All @@ -40,9 +40,9 @@ class PMA_Response
private function __construct()
{
$this->_data = array();
$this->_header = PMA_Header::getInstance();
$this->_header = new PMA_Header();
$this->_content = '';
$this->_footer = PMA_Footer::getInstance();
$this->_footer = new PMA_Footer();
}

/**
Expand Down
5 changes: 3 additions & 2 deletions libraries/auth/config.auth.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function PMA_auth_fails()

/* HTML header */
$GLOBALS['page_title'] = __('Access denied');
$header = PMA_Header::getInstance();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$header->setTitle(__('Access denied'));
$header->disableMenu();
$header->display();
Expand All @@ -90,7 +91,7 @@ function PMA_auth_fails()
<td>

<?php
PMA_Header::getInstance()->isHeaderSent = true;
PMA_Header::$headerIsSent = true;

if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
trigger_error(__('Access denied'), E_USER_NOTICE);
Expand Down
3 changes: 2 additions & 1 deletion libraries/auth/cookie.auth.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ function PMA_auth()
$cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right';

$GLOBALS['page_title'] = 'phpMyAdmin';
$header = PMA_Header::getInstance();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$header->setBodyId('loginform');
$header->disableMenu();
$header->display();
Expand Down
3 changes: 2 additions & 1 deletion libraries/auth/http.auth.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function PMA_auth()

/* HTML header */
$GLOBALS['page_title'] = __('Access denied');
$header = PMA_Header::getInstance();
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$header->setTitle(__('Access denied'));
$header->disableMenu();
$header->display();
Expand Down
6 changes: 4 additions & 2 deletions libraries/common.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ function PMA_showPHPDocu($target)
*/
function PMA_showHint($message, $bbcode = false)
{
$footnotes = PMA_Footer::getInstance()->getFootnotes();
$response = PMA_Response::getInstance();
$footnotes = $response->getFooter()->getFootnotes();
return $footnotes->add($message, $bbcode);
}

Expand Down Expand Up @@ -569,7 +570,8 @@ function PMA_mysqlDie(
/**
* start http output, display html headers
*/
PMA_Header::getInstance()->display();
$response = PMA_Response::getInstance();
$response->getHeader()->display();

$error_msg = '';

Expand Down
9 changes: 6 additions & 3 deletions libraries/core.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function PMA_includeJS($url, $ie_conditional = false)
}

/**
* Adds JS code snippets to be displayed by the PMA_Header class.
* 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;")
Expand All @@ -783,12 +783,15 @@ function PMA_includeJS($url, $ie_conditional = false)
*/
function PMA_addJSCode($str)
{
PMA_Header::getInstance()->getScripts()->addCode($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 the PMA_Header class.
* 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
Expand Down
3 changes: 2 additions & 1 deletion libraries/db_common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
/**
* Displays headers
*/
PMA_Header::getInstance()->display();
$response = PMA_Response::getInstance();
$response->getHeader()->display();

/**
* Set parameters for links
Expand Down
Loading

0 comments on commit a054562

Please sign in to comment.