Image generator added, first CAPTCHA added with missing controller (partly work)
[shipsimu.git] / inc / classes / main / response / class_ImageResponse.php
index 2e2fd09c121a7789c8513d872b3d28abf39fb89f..3d16954207dde2a8425aedb034bc3570df9b8f27 100644 (file)
@@ -55,6 +55,11 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable {
         */
        private $fatalMessages = array();
 
+       /**
+        * Instance of the image
+        */
+       private $imageInstance = null;
+
        /**
         * Protected constructor
         *
@@ -170,6 +175,7 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable {
                        $this->addHeader('Last-Modified', $now);
                        $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
                        $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0
+                       $this->addHeader('Content-type', 'image/'.$this->imageInstance->getImageType());
 
                        // Define the charset to be used
                        //$this->addHeader('Content-Type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset')));
@@ -191,14 +197,12 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable {
 
                // Are there some error messages?
                if (count($this->fatalMessages) == 0) {
-                       // Flush the output to the world
-                       $this->getWebOutputInstance()->output($this->responseBody);
+                       // Get image content from cache
+                       $imageContent = $this->imageInstance->getContent();
+                       die($imageContent);
                } else {
                        // Display all error messages
-                       $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
-
-                       // Send the error messages out to the world
-                       $this->getWebOutputInstance()->output($this->responseBody);
+                       $this->partialStub("Fatal messages are currently unsupported in image response.");
                }
 
                // Clear response header and body
@@ -218,8 +222,8 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable {
 
                // Set new template engine
                $cfg->setConfigEntry('template_class', "ImageTemplateEngine");
-               $cfg->setConfigEntry('raw_template_extension', ".img");
-               $cfg->setConfigEntry('code_template_extension', ".img");
+               $cfg->setConfigEntry('raw_template_extension', ".itp");
+               $cfg->setConfigEntry('code_template_extension', ".itp");
                $cfg->setConfigEntry('tpl_base_path', "templates/images/");
                $cfg->setConfigEntry('code_template_type', "image");
 
@@ -370,6 +374,16 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable {
                        $this->addCookie($cookieName, $_COOKIE[$cookieName], false);
                } // END - if
        }
+
+       /**
+        * Setter for image instanxe
+        *
+        * @param       $imageInstance  An instance of an image
+        * @return      void
+        */
+       public final function setImageInstance (BaseImage $imageInstance) {
+               $this->imageInstance = $imageInstance;
+       }
 }
 
 // [EOF]