X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fresponse%2Fclass_ImageResponse.php;h=abf349150c8c92cd72b2479cfbcb804414d23995;hp=2e2fd09c121a7789c8513d872b3d28abf39fb89f;hb=5c3d5d84f8f862d0d51f095f9858860f86788ae8;hpb=835d890d25d67c76e40ffdf3ba525b8b18c5d007 diff --git a/inc/classes/main/response/class_ImageResponse.php b/inc/classes/main/response/class_ImageResponse.php index 2e2fd09..abf3491 100644 --- a/inc/classes/main/response/class_ImageResponse.php +++ b/inc/classes/main/response/class_ImageResponse.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -46,14 +46,14 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable { private $responseBody = ""; /** - * Instance of the template engine + * Fatal resolved messages from filters and so on */ - private $templateEngine = null; + private $fatalMessages = array(); /** - * Fatal resolved messages from filters and so on + * Instance of the image */ - private $fatalMessages = array(); + private $imageInstance = null; /** * Protected constructor @@ -170,6 +170,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 +192,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 @@ -217,23 +216,14 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable { $cfg = $this->getConfigInstance(); // Set new template engine - $cfg->setConfigEntry('template_class', "ImageTemplateEngine"); - $cfg->setConfigEntry('raw_template_extension', ".img"); - $cfg->setConfigEntry('code_template_extension', ".img"); - $cfg->setConfigEntry('tpl_base_path', "templates/images/"); - $cfg->setConfigEntry('code_template_type', "image"); + $cfg->setConfigEntry('template_class' , "ImageTemplateEngine"); + $cfg->setConfigEntry('raw_template_extension' , ".img"); + $cfg->setConfigEntry('code_template_extension', ".itp"); + $cfg->setConfigEntry('tpl_base_path' , "templates/images/"); + $cfg->setConfigEntry('code_template_type' , "image"); // Get a prepared instance - $this->templateEngine = $this->prepareTemplateEngine($appInstance); - } - - /** - * Getter for the template engine instance - * - * @return $templateEngine An instance of the used template engine - */ - public final function getTemplateEngine () { - return $this->templateEngine; + $this->setTemplateInstance($this->prepareTemplateInstance($appInstance)); } /** @@ -370,6 +360,26 @@ 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; + } + + /** + * Getter for default command + * + * @return $defaultCommand Default command for this response + */ + public function getDefaultCommand () { + $defaultCommand = $this->getConfigInstance()->readConfig('default_image_command'); + return $defaultCommand; + } } // [EOF]