X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fresponse%2Fclass_BaseResponse.php;h=8fc37c14fa7283b82e0102b7a8bddc3a21426fa2;hp=694996b9b017e7caf15309f764e29b59807f78a7;hb=fdc6a02b5e6c2155cda61fcc345c7583b734ab85;hpb=0cd57c3885f00ad77fc599e53ed2f2d5e7ac267f diff --git a/inc/classes/main/response/class_BaseResponse.php b/inc/classes/main/response/class_BaseResponse.php index 694996b9..8fc37c14 100644 --- a/inc/classes/main/response/class_BaseResponse.php +++ b/inc/classes/main/response/class_BaseResponse.php @@ -2,11 +2,11 @@ /** * A generic request class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ class BaseResponse extends BaseFrameworkSystem { /** * Response status */ - private $responseStatus = "200 OK"; + private $responseStatus = '200 OK'; /** * Array with all headers @@ -48,12 +48,7 @@ class BaseResponse extends BaseFrameworkSystem { /** * Instance of the template engine */ - private $templateInstance = null; - - /** - * Fatal resolved messages from filters and so on - */ - private $fatalMessages = array(); + private $templateInstance = NULL; /** * Protected constructor @@ -64,10 +59,6 @@ class BaseResponse extends BaseFrameworkSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -129,7 +120,7 @@ class BaseResponse extends BaseFrameworkSystem { */ public final function addFatalMessage ($messageId) { // Adds the resolved message id to the fatal message list - $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId); + $this->addFatalMessagePlain($this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId)); } /** @@ -140,25 +131,25 @@ class BaseResponse extends BaseFrameworkSystem { */ public final function addFatalMessagePlain ($message) { // Adds the resolved message id to the fatal message list - $this->fatalMessages[] = $message; + $this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message); } /** * Flushs the cached HTTP response to the outer world * - * @param $force Wether we shall force the output or abort if headers are + * @param $force Whether we shall force the output or abort if headers are * already sent with an exception * @return void * @throws ResponseHeadersAlreadySentException Thrown if headers are * already sent */ - public function flushBuffer ($force = false) { - if ((headers_sent()) && ($force === false)) { + public function flushBuffer ($force = FALSE) { + if ((headers_sent()) && ($force === FALSE)) { // Headers are already sent! throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); } elseif (!headers_sent()) { // Send headers out - header("HTTP/1.1 {$this->responseStatus}"); + header('HTTP/1.1 ' . $this->responseStatus); // Used later $now = gmdate('D, d M Y H:i:s') . ' GMT'; @@ -170,19 +161,19 @@ class BaseResponse extends BaseFrameworkSystem { $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0 // Define the charset to be used - //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset'))); + //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->getConfigEntry('header_charset'))); // Send all headers foreach ($this->responseHeaders as $name => $value) { - header("{$name}: {$value}"); - //* DEBUG: */ echo "{$name}: {$value}
\n"; + header($name . ': ' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('name=' . $name . ',value=' . $value); } // END - foreach // Send cookies out? if (count($this->cookies) > 0) { // Send all cookies $cookieString = implode(' ', $this->cookies); - header("Set-Cookie: {$cookieString}"); + header('Set-Cookie: ' . $cookieString); // Remove them all $this->cookies = array(); @@ -190,12 +181,12 @@ class BaseResponse extends BaseFrameworkSystem { } // Are there some error messages? - if (count($this->fatalMessages) == 0) { + if ($this->countGenericArrayElements('fatal_messages', 'generic', 'message') == 0) { // Flush the output to the world $this->getWebOutputInstance()->output($this->responseBody); } else { // Display all error messages - $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages); + $this->getApplicationInstance()->handleFatalMessages($this->getGenericArrayKey('fatal_messages', 'generic', 'message')); // Send the error messages out to the world $this->getWebOutputInstance()->output($this->responseBody);