From bb1e3a7f36ad3f7fa235c7601586d0caebd71ed1 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 23 Mar 2015 03:17:22 +0100 Subject: [PATCH] HttpRequest and HttpResponse were to generic as they were only used for HTML responses. Later on this framework will also handle other protocols or formats that are based on HTTP (such as RSS). So by using Http as class prefix but actually responding with HTML will exclude such other response types which is not a good idea. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- inc/classes/main/class_BaseFrameworkSystem.php | 7 +++++-- .../main/request/{web => html}/.htaccess | 0 .../class_HtmlRequest.php} | 18 +++++++++--------- .../main/response/{http => html}/.htaccess | 0 .../class_HtmlResponse.php} | 12 +++++++----- 5 files changed, 21 insertions(+), 16 deletions(-) rename inc/classes/main/request/{web => html}/.htaccess (100%) rename inc/classes/main/request/{web/class_HttpRequest.php => html/class_HtmlRequest.php} (86%) rename inc/classes/main/response/{http => html}/.htaccess (100%) rename inc/classes/main/response/{http/class_HttpResponse.php => html/class_HtmlResponse.php} (95%) diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index c3bb447f..88fdae37 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -2229,8 +2229,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Is 'HTTP_HOST' set? if (isset($_SERVER['HTTP_HOST'])) { - // Then it is a HTTP response/request - $responseType = 'http'; + /* + * Then it is a HTML response/request as RSS and so on may be + * transfered over HTTP as well. + */ + $responseType = 'html'; } // END - if // Return it diff --git a/inc/classes/main/request/web/.htaccess b/inc/classes/main/request/html/.htaccess similarity index 100% rename from inc/classes/main/request/web/.htaccess rename to inc/classes/main/request/html/.htaccess diff --git a/inc/classes/main/request/web/class_HttpRequest.php b/inc/classes/main/request/html/class_HtmlRequest.php similarity index 86% rename from inc/classes/main/request/web/class_HttpRequest.php rename to inc/classes/main/request/html/class_HtmlRequest.php index 37628136..63ccd826 100644 --- a/inc/classes/main/request/web/class_HttpRequest.php +++ b/inc/classes/main/request/html/class_HtmlRequest.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -22,7 +22,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HttpRequest extends BaseRequest implements Requestable { +class HtmlRequest extends BaseRequest implements Requestable { /** * Protected constructor * @@ -36,21 +36,21 @@ class HttpRequest extends BaseRequest implements Requestable { /** * Creates an instance of this class and prepares it a little * - * @return $httpInstance An instance of this class + * @return $requestInstance An instance of this class */ - public static final function createHttpRequest () { + public static final function createHtmlRequest () { // Create an instance - $httpInstance = new HttpRequest(); + $requestInstance = new HtmlRequest(); - // Prepare the HTTP request data for usage - $httpInstance->prepareRequestData(); + // Prepare the HTML request data for usage + $requestInstance->prepareRequestData(); // Return the prepared instance - return $httpInstance; + return $requestInstance; } /** - * Prepares the HTTP request data for usage by currently copying + * Prepares the HTML request data for usage by currently copying * $_REQUEST into a private attribute. Later on we can add more * things for initialization here. * diff --git a/inc/classes/main/response/http/.htaccess b/inc/classes/main/response/html/.htaccess similarity index 100% rename from inc/classes/main/response/http/.htaccess rename to inc/classes/main/response/html/.htaccess diff --git a/inc/classes/main/response/http/class_HttpResponse.php b/inc/classes/main/response/html/class_HtmlResponse.php similarity index 95% rename from inc/classes/main/response/http/class_HttpResponse.php rename to inc/classes/main/response/html/class_HtmlResponse.php index d26b33bc..80b50e88 100644 --- a/inc/classes/main/response/http/class_HttpResponse.php +++ b/inc/classes/main/response/html/class_HtmlResponse.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -24,7 +24,7 @@ * The extended headers are taken from phpMyAdmin setup tool, written by * Michal Cihar , licensed under GNU GPL 2.0. */ -class HttpResponse extends BaseResponse implements Responseable { +class HtmlResponse extends BaseResponse implements Responseable { /** * Protected constructor * @@ -41,9 +41,9 @@ class HttpResponse extends BaseResponse implements Responseable { * @param $applicationInstance An instance of a manageable application * @return $responseInstance A prepared instance of this class */ - public static final function createHttpResponse (ManageableApplication $applicationInstance) { + public static final function createHtmlResponse (ManageableApplication $applicationInstance) { // Get a new instance - $responseInstance = new HttpResponse(); + $responseInstance = new HtmlResponse(); // Set the application instance $responseInstance->setApplicationInstance($applicationInstance); @@ -148,7 +148,9 @@ class HttpResponse extends BaseResponse implements Responseable { // Do we have a 'http' in front of the URL? if (substr(strtolower($url), 0, 4) != 'http') { // Is there a / in front of the relative URL? - if (substr($url, 0, 1) == '/') $url = substr($url, 1); + if (substr($url, 0, 1) == '/') { + $url = substr($url, 1); + } // END - if // No, then extend it with our base URL $url = $this->getConfigInstance()->getConfigEntry('base_url') . '/' . $url; -- 2.30.2