Introduced initWebOutputInstance() which will initialize a web output instance.
authorRoland Haeder <roland@mxchange.org>
Sun, 22 Mar 2015 21:54:18 +0000 (22:54 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 22 Mar 2015 21:54:18 +0000 (22:54 +0100)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
db/.htaccess [new file with mode: 0644]
db/news/.htaccess [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/output/class_ConsoleOutput.php
inc/classes/main/output/class_WebOutput.php
inc/classes/main/response/console/class_ConsoleResponse.php
inc/classes/main/response/http/class_HttpResponse.php

diff --git a/db/.htaccess b/db/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/db/news/.htaccess b/db/news/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
index c5226fe..c3bb447 100644 (file)
@@ -2950,6 +2950,28 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
+        * 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'
         *
         * @param       $boolean                Boolean value
index 7d70a8c..c2ff3d4 100644 (file)
@@ -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]
index e875aa8..c000ebc 100644 (file)
@@ -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]
index 7309a2c..194c0b3 100644 (file)
@@ -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;
        }
index 7dc2e46..d26b33b 100644 (file)
@@ -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;
        }