From df2e651915deb67dc47b37943afb31298d185dc9 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 22 Mar 2015 22:54:18 +0100 Subject: [PATCH] Introduced initWebOutputInstance() which will initialize a web output instance. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- db/.htaccess | 1 + db/news/.htaccess | 1 + .../main/class_BaseFrameworkSystem.php | 22 ++++++++++++ .../main/output/class_ConsoleOutput.php | 35 ++++++++++++++++++- inc/classes/main/output/class_WebOutput.php | 33 +++++++++++++++++ .../console/class_ConsoleResponse.php | 3 ++ .../main/response/http/class_HttpResponse.php | 3 ++ 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 db/.htaccess create mode 100644 db/news/.htaccess diff --git a/db/.htaccess b/db/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/db/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/db/news/.htaccess b/db/news/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/db/news/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index c5226fed..c3bb447f 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -2949,6 +2949,28 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $isValid; } + /** + * Initializes the web output instance + * + * @return void + */ + protected function initWebOutputInstance () { + // Get application instance + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Is this a response instance? + if ($this instanceof Responseable) { + // Then set it in application instance + $applicationInstance->setResponseInstance($this); + } // END - if + + // Init web output instance + $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); + + // Set it locally + $this->setWebOutputInstance($outputInstance); + } + /** * Translates boolean TRUE to 'Y' and FALSE to 'N' * diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php index 7d70a8c4..c2ff3d4f 100644 --- a/inc/classes/main/output/class_ConsoleOutput.php +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -55,7 +55,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { // Set the content type // @TODO Need to rewrite this to $requestInstance->addHeader() if (!empty($contentType)) { - @header(sprintf("Content-type: %s", + @header(sprintf('Content-type: %s', $contentType )); } // END - if @@ -90,6 +90,39 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { public final function output ($outStream = FALSE, $stripTags = FALSE) { print trim($outStream) . PHP_EOL; } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } } // [EOF] diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php index e875aa8e..c000ebcc 100644 --- a/inc/classes/main/output/class_WebOutput.php +++ b/inc/classes/main/output/class_WebOutput.php @@ -74,6 +74,39 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registera public final function output ($outStream = FALSE, $stripTags = FALSE) { print(stripslashes($outStream)); } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } } // [EOF] diff --git a/inc/classes/main/response/console/class_ConsoleResponse.php b/inc/classes/main/response/console/class_ConsoleResponse.php index 7309a2c8..194c0b32 100644 --- a/inc/classes/main/response/console/class_ConsoleResponse.php +++ b/inc/classes/main/response/console/class_ConsoleResponse.php @@ -51,6 +51,9 @@ class ConsoleResponse extends BaseResponse implements Responseable { // Initialize the template engine here $responseInstance->initTemplateEngine($applicationInstance); + // Init web output instance + $responseInstance->initWebOutputInstance(); + // Return the prepared instance return $responseInstance; } diff --git a/inc/classes/main/response/http/class_HttpResponse.php b/inc/classes/main/response/http/class_HttpResponse.php index 7dc2e468..d26b33bc 100644 --- a/inc/classes/main/response/http/class_HttpResponse.php +++ b/inc/classes/main/response/http/class_HttpResponse.php @@ -51,6 +51,9 @@ class HttpResponse extends BaseResponse implements Responseable { // Initialize the template engine here $responseInstance->initTemplateEngine($applicationInstance); + // Init web output instance + $responseInstance->initWebOutputInstance(); + // Return the prepared instance return $responseInstance; } -- 2.39.5