From 835d890d25d67c76e40ffdf3ba525b8b18c5d007 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 22 Jun 2008 22:22:39 +0000 Subject: [PATCH] TemplateEngine is known as WebTemplateEngine (most parts are in BasTemplateEngine), image creation supported added with a lot (!) stubs --- .gitattributes | 28 +- .../ship-simu/class_ApplicationHelper.php | 15 +- .../ship-simu/templates/images/.htaccess | 1 + .../ship-simu/templates/images/de/.htaccess | 1 + .../templates/images/de/image/.htaccess | 1 + ...on.php => class_FileNotFoundException.php} | 6 +- inc/classes/exceptions/xml/.htaccess | 1 + .../xml/class_InvalidXmlNodeException.php | 54 +++ .../xml/class_XmlParserException.php | 47 +++ .../helper/class_HelpableTemplate.php | 34 ++ .../template/class_CompileableTemplate.php | 8 +- .../main/class_BaseFrameworkSystem.php | 11 +- .../web/class_GraphicalCodeCaptcha.php | 12 +- inc/classes/main/helper/class_BaseHelper.php | 4 + inc/classes/main/helper/images/.htaccess | 1 + .../main/helper/images/class_ImageHelper.php | 253 ++++++++++++ .../main/helper/web/class_WebFormHelper.php | 101 +++-- inc/classes/main/images/.htaccess | 1 + inc/classes/main/images/class_ | 56 +++ inc/classes/main/images/class_BaseImage.php | 42 ++ inc/classes/main/images/extended/.htaccess | 1 + .../main/images/extended/class_PngImage.php | 56 +++ .../io/class_FrameworkFileInputPointer.php | 2 +- .../main/response/class_ImageResponse.php | 376 ++++++++++++++++++ .../main/rng/class_RandomNumberGenerator.php | 2 +- ...ngine.php => class_BaseTemplateEngine.php} | 149 +++---- inc/classes/main/template/image/.htaccess | 1 + .../image/class_ImageTemplateEngine.php | 210 ++++++++++ inc/classes/main/template/web/.htaccess | 1 + .../template/web/class_WebTemplateEngine.php | 104 +++++ inc/config.php | 2 +- templates/images/.htaccess | 1 + templates/images/de/.htaccess | 1 + templates/images/de/image/.htaccess | 1 + templates/images/de/image/base_image.img | 20 + templates/images/de/image/emergency_exit.img | 22 + 36 files changed, 1484 insertions(+), 142 deletions(-) create mode 100644 application/ship-simu/templates/images/.htaccess create mode 100644 application/ship-simu/templates/images/de/.htaccess create mode 100644 application/ship-simu/templates/images/de/image/.htaccess rename inc/classes/exceptions/io/{class_FileIsMissingException.php => class_FileNotFoundException.php} (89%) create mode 100644 inc/classes/exceptions/xml/.htaccess create mode 100644 inc/classes/exceptions/xml/class_InvalidXmlNodeException.php create mode 100644 inc/classes/exceptions/xml/class_XmlParserException.php create mode 100644 inc/classes/interfaces/helper/class_HelpableTemplate.php create mode 100644 inc/classes/main/helper/images/.htaccess create mode 100644 inc/classes/main/helper/images/class_ImageHelper.php create mode 100644 inc/classes/main/images/.htaccess create mode 100644 inc/classes/main/images/class_ create mode 100644 inc/classes/main/images/class_BaseImage.php create mode 100644 inc/classes/main/images/extended/.htaccess create mode 100644 inc/classes/main/images/extended/class_PngImage.php create mode 100644 inc/classes/main/response/class_ImageResponse.php rename inc/classes/main/template/{class_TemplateEngine.php => class_BaseTemplateEngine.php} (90%) create mode 100644 inc/classes/main/template/image/.htaccess create mode 100644 inc/classes/main/template/image/class_ImageTemplateEngine.php create mode 100644 inc/classes/main/template/web/.htaccess create mode 100644 inc/classes/main/template/web/class_WebTemplateEngine.php create mode 100644 templates/images/.htaccess create mode 100644 templates/images/de/.htaccess create mode 100644 templates/images/de/image/.htaccess create mode 100644 templates/images/de/image/base_image.img create mode 100644 templates/images/de/image/emergency_exit.img diff --git a/.gitattributes b/.gitattributes index 96837fa..513b4ff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -149,6 +149,9 @@ application/ship-simu/templates/de/code/shipsimu_main.ctp -text application/ship-simu/templates/de/html/.htaccess -text application/ship-simu/templates/de/html/nav_advert.tpl -text application/ship-simu/templates/de/html/selector_ship-simu.tpl -text +application/ship-simu/templates/images/.htaccess -text +application/ship-simu/templates/images/de/.htaccess -text +application/ship-simu/templates/images/de/image/.htaccess -text db/.htaccess -text db/news/.htaccess -text db/user/.htaccess -text @@ -202,7 +205,7 @@ inc/classes/exceptions/helper/class_InvalidFormNameException.php -text inc/classes/exceptions/helper/class_UserInstanceMissingException.php -text inc/classes/exceptions/io/.htaccess -text inc/classes/exceptions/io/class_DirPointerNotOpenedException.php -text -inc/classes/exceptions/io/class_FileIsMissingException.php -text +inc/classes/exceptions/io/class_FileNotFoundException.php -text inc/classes/exceptions/io/class_FilePointerNotOpenedException.php -text inc/classes/exceptions/io/class_FileReadProtectedException.php -text inc/classes/exceptions/io/class_InvalidDataLengthException.php -text @@ -259,6 +262,9 @@ inc/classes/exceptions/user/class_AccountPasswordMismatchException.php -text inc/classes/exceptions/user/class_UserEmailMissingException.php -text inc/classes/exceptions/user/class_UserPasswordMismatchException.php -text inc/classes/exceptions/user/class_UsernameMissingException.php -text +inc/classes/exceptions/xml/.htaccess -text +inc/classes/exceptions/xml/class_InvalidXmlNodeException.php -text +inc/classes/exceptions/xml/class_XmlParserException.php -text inc/classes/interfaces/.htaccess -text inc/classes/interfaces/actions/.htaccess -text inc/classes/interfaces/actions/class_PerformableAction.php -text @@ -298,6 +304,7 @@ inc/classes/interfaces/filter/.htaccess -text inc/classes/interfaces/filter/class_Filterable.php -text inc/classes/interfaces/helper/.htaccess -text inc/classes/interfaces/helper/class_HelpableLogin.php -text +inc/classes/interfaces/helper/class_HelpableTemplate.php -text inc/classes/interfaces/io/.htaccess -text inc/classes/interfaces/io/class_Streamable.php -text inc/classes/interfaces/io/file/.htaccess -text @@ -462,10 +469,17 @@ inc/classes/main/helper/captcha/web/.htaccess -text inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php -text inc/classes/main/helper/class_ -text inc/classes/main/helper/class_BaseHelper.php -text +inc/classes/main/helper/images/.htaccess -text +inc/classes/main/helper/images/class_ImageHelper.php -text inc/classes/main/helper/login/.htaccess -text inc/classes/main/helper/login/class_BaseLoginHelper.php -text inc/classes/main/helper/web/.htaccess -text inc/classes/main/helper/web/class_WebFormHelper.php -text +inc/classes/main/images/.htaccess -text +inc/classes/main/images/class_ -text +inc/classes/main/images/class_BaseImage.php -text +inc/classes/main/images/extended/.htaccess -text +inc/classes/main/images/extended/class_PngImage.php -text inc/classes/main/io/.htaccess -text inc/classes/main/io/class_FileIoStream.php -text inc/classes/main/io/class_FrameworkDirectoryPointer.php -text @@ -505,12 +519,17 @@ inc/classes/main/resolver/controller/web/.htaccess -text inc/classes/main/resolver/controller/web/class_WebControllerResolver.php -text inc/classes/main/response/.htaccess -text inc/classes/main/response/class_HttpResponse.php -text +inc/classes/main/response/class_ImageResponse.php -text inc/classes/main/result/.htaccess -text inc/classes/main/result/class_DatabaseResult.php -text inc/classes/main/rng/.htaccess -text inc/classes/main/rng/class_RandomNumberGenerator.php -text inc/classes/main/template/.htaccess -text -inc/classes/main/template/class_TemplateEngine.php -text +inc/classes/main/template/class_BaseTemplateEngine.php -text +inc/classes/main/template/image/.htaccess -text +inc/classes/main/template/image/class_ImageTemplateEngine.php -text +inc/classes/main/template/web/.htaccess -text +inc/classes/main/template/web/class_WebTemplateEngine.php -text inc/classes/main/user/.htaccess -text inc/classes/main/user/class_Guest.php -text inc/classes/main/user/class_User.php -text @@ -618,6 +637,11 @@ templates/de/code/emergency_exit.ctp -text templates/de/code/footer_msg.ctp -text templates/de/code/header.ctp -text templates/de/html/.htaccess -text +templates/images/.htaccess -text +templates/images/de/.htaccess -text +templates/images/de/image/.htaccess -text +templates/images/de/image/base_image.img -text +templates/images/de/image/emergency_exit.img -text tests/ConfigTest.php -text tests/RegistryTest.php -text tests/RequestTest.php -text diff --git a/application/ship-simu/class_ApplicationHelper.php b/application/ship-simu/class_ApplicationHelper.php index 32bd764..370bd02 100644 --- a/application/ship-simu/class_ApplicationHelper.php +++ b/application/ship-simu/class_ApplicationHelper.php @@ -185,8 +185,19 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // Create a new request object $requestInstance = ObjectFactory::createObjectByName('HttpRequest'); + // Default response is HTTP (HTML page) and type is "Web" + $response = "http"; + $responseType = "web"; + + // Do we have another response? + if ($requestInstance->isRequestElementSet('response')) { + // Then use it + $response = strtolower($requestInstance->getRequestElement('response')); + $responseType = $response; + } // END - if + // ... and a new response object - $responseInstance = ObjectFactory::createObjectByName('HttpResponse', array($this)); + $responseInstance = ObjectFactory::createObjectByName(ucfirst($response)."Response", array($this)); // Remember both in this application $this->setRequestInstance($requestInstance); @@ -201,7 +212,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica } // END - if // Get a resolver - $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this); + $resolverInstance = ObjectFactory::createObjectByName(ucfirst($responseType)."ControllerResolver", array($commandName, $this)); // Get a controller instance as well $this->controllerInstance = $resolverInstance->resolveController(); diff --git a/application/ship-simu/templates/images/.htaccess b/application/ship-simu/templates/images/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/templates/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/templates/images/de/.htaccess b/application/ship-simu/templates/images/de/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/templates/images/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/templates/images/de/image/.htaccess b/application/ship-simu/templates/images/de/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/templates/images/de/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/io/class_FileIsMissingException.php b/inc/classes/exceptions/io/class_FileNotFoundException.php similarity index 89% rename from inc/classes/exceptions/io/class_FileIsMissingException.php rename to inc/classes/exceptions/io/class_FileNotFoundException.php index 61fa308..a8ff449 100644 --- a/inc/classes/exceptions/io/class_FileIsMissingException.php +++ b/inc/classes/exceptions/io/class_FileNotFoundException.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class FileIsMissingException extends FrameworkException { +class FileNotFoundException extends FrameworkException { /** * The constructor * @@ -31,7 +31,7 @@ class FileIsMissingException extends FrameworkException { */ public function __construct ($fqfn, $code) { // Add a message around the missing class - $message = sprintf("The requested file %s is missing.", $fqfn); + $message = sprintf("The requested file %s was not found.", $fqfn); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/xml/.htaccess b/inc/classes/exceptions/xml/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/exceptions/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php new file mode 100644 index 0000000..75a2353 --- /dev/null +++ b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php @@ -0,0 +1,54 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidXmlNodeException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Extract attributes + $attributes = "None"; + if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) { + $attributes = implode(", ", $classArray[2]); + } // END - if + + // Construct our message + $message = sprintf("[%s:%d] Invalid XML node found: %s, attributes: %s.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $attributes + ); + die($message); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/xml/class_XmlParserException.php b/inc/classes/exceptions/xml/class_XmlParserException.php new file mode 100644 index 0000000..1f14281 --- /dev/null +++ b/inc/classes/exceptions/xml/class_XmlParserException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlParserException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Construct our message + $message = sprintf("[%s:%d] XML Error: %s at line %d.", + $classArray[0]->__toString(), + $this->getLine(), + xml_error_string(xml_get_error_code($classArray[1])), + xml_get_current_line_number($classArray[1]) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/helper/class_HelpableTemplate.php b/inc/classes/interfaces/helper/class_HelpableTemplate.php new file mode 100644 index 0000000..c9d61cd --- /dev/null +++ b/inc/classes/interfaces/helper/class_HelpableTemplate.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableTemplate extends FrameworkInterface { + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + function flushContent (); +} + +// +?> diff --git a/inc/classes/interfaces/template/class_CompileableTemplate.php b/inc/classes/interfaces/template/class_CompileableTemplate.php index 2b3499e..3aef610 100644 --- a/inc/classes/interfaces/template/class_CompileableTemplate.php +++ b/inc/classes/interfaces/template/class_CompileableTemplate.php @@ -25,8 +25,8 @@ interface CompileableTemplate extends FrameworkInterface { /** * Assign variables for templates * - * @param $var The "variable" we want to assign - * @param $value The value we want to store in the variable + * @param $var The "variable" we want to assign + * @param $value The value we want to store in the variable * @return void */ function assignVariable ($var, $value); @@ -44,7 +44,7 @@ interface CompileableTemplate extends FrameworkInterface { * Load a specified code template into the engine for later compilation * with other code/web/email templates. * - * @param $template The code template we shall load which is + * @param $template The code template we shall load which is * located in "html" by default * @return void */ @@ -53,7 +53,7 @@ interface CompileableTemplate extends FrameworkInterface { /** * Load a specified email template into the engine * - * @param $template The email template we shall load which is + * @param $template The email template we shall load which is * located in "emails" by default * @return void */ diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 3b0a939..132d5be 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -256,9 +256,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } elseif (is_null($arg)) { // Null $argsString .= "(null)"; + } elseif (is_resource($arg)) { + // Resource + $argsString .= "(resource)"; } else { // Unknown type (please report!) - $argsString .= $arg."(unknown!)"; + $argsString .= $arg."(unknown!)"; } // Add comma @@ -266,7 +269,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // Remove last comma - if (substr($argsString, -2, 1) === ",") $argsString = substr($argsString, 0, -2); + if (substr($argsString, -2, 1) === ",") { + $argsString = substr($argsString, 0, -2); + } // END - if } else { // Invalid arguments! $argsString = sprintf("!INVALID:%s!", $args); @@ -880,7 +885,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Prepare the template engine (TemplateEngine by default) for a given + * Prepare the template engine (WebTemplateEngine by default) for a given * application helper instance (ApplicationHelper by default). * * @param $appInstance An application helper instance or diff --git a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php index 6dcf0aa..d40a1ba 100644 --- a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php +++ b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php @@ -133,7 +133,17 @@ class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha { * @return void */ public function renderCode () { - $this->partialStub("Please implement this method."); + // Load a template for this CAPTCHA + $this->getTemplateInstance()->loadCodeTemplate("captch_graphic_code"); + + // Assign variable + $this->getTemplateInstance()->assignVariable('encrypted_code', urlencode(base64_encode($this->encryptedString))); + + // Compile the template + $this->getTemplateInstance()->compileTemplate(); + + // Get the content back + $this->addContent($this->getTemplateInstance()->getRawTemplateData()); } } diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index 1a48194..d266d5b 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -22,6 +22,10 @@ * along with this program. If not, see . */ class BaseHelper extends BaseFrameworkSystem { + // Exception constants + const EXCEPTION_XML_PARSER_ERROR = 0x0d0; + const EXCEPTION_XML_NODE_UNKNOWN = 0x0d1; + /** * Template engine instance */ diff --git a/inc/classes/main/helper/images/.htaccess b/inc/classes/main/helper/images/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/helper/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/images/class_ImageHelper.php b/inc/classes/main/helper/images/class_ImageHelper.php new file mode 100644 index 0000000..5490a40 --- /dev/null +++ b/inc/classes/main/helper/images/class_ImageHelper.php @@ -0,0 +1,253 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageHelper extends BaseHelper implements HelpableTemplate { + /** + * The image type + */ + private $imageType = "png"; + + /** + * Width of the image in pixel + */ + private $width = 0; + + /** + * Height of the image in pixel + */ + private $height = 0; + + /** + * Array for background color values + */ + private $backgroundColor = array( + 'red' => 0, + 'green' => 0, + 'blue' => 0 + ); + + /** + * Array for foreground color values + */ + private $foregroundColor = array( + 'red' => 0, + 'green' => 0, + 'blue' => 0 + ); + + /** + * Image message string + */ + private $imageString = "No message set!"; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("A image helper class"); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $imageType Type of the image + * @return $helperInstance A preparedf instance of this class + */ + public final static function createImageHelper (CompileableTemplate $templateInstance, $imageType) { + // Get new instance + $helperInstance = new ImageHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set image type (blindly) + $helperInstance->setImageType($imageType); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Setter for image type + * + * @param $imageType Type of the image + * @return void + */ + protected final function setImageType ($imageType) { + $this->imageType = (string) $imageType; + } + + /** + * Getter for image type + * + * @return $imageType Type of the image + */ + public final function getImageType () { + return $this->imageType; + } + + /** + * Setter for image width + * + * @param $width Width of the image + * @return void + */ + public final function setWidth ($width) { + $this->width = (int) $width; + } + + /** + * Getter for image width + * + * @return $width Width of the image + */ + public final function getWidth () { + return $this->width; + } + + /** + * Setter for image height + * + * @param $height Height of the image + * @return void + */ + public final function setHeight ($height) { + $this->height = (int) $height; + } + + /** + * Getter for image height + * + * @return $height Height of the image + */ + public final function getHeight () { + return $this->height; + } + + /** + * Setter for RGB of background color + * + * @param $red Color value for red + * @param $green Color value for green + * @param $blue Color value for blue + * @return void + */ + public final function setBackgroundColorRedGreenBlue ($red, $green, $blue) { + $this->backgroundColor['red'] = (int) $red; + $this->backgroundColor['green'] = (int) $green; + $this->backgroundColor['blue'] = (int) $blue; + } + + /** + * Setter for RGB of foreground color + * + * @param $red Color value for red + * @param $green Color value for green + * @param $blue Color value for blue + * @return void + */ + public final function setForegroundColorRedGreenBlue ($red, $green, $blue) { + $this->foregroundColor['red'] = (int) $red; + $this->foregroundColor['green'] = (int) $green; + $this->foregroundColor['blue'] = (int) $blue; + } + + /** + * Setter for image message string + * + * @param $imageString A message to display in the image + * @return void + */ + public final function setImageString ($imageString) { + $this->imageString = (string) $imageString; + } + + /** + * Getter for image message string + * + * @return $imageString A message to display in the image + */ + public final function getImageString () { + return $this->imageString; + } + + /** + * Setter for base image + * + * @param $baseImage A base image template + * @return void + */ + public final function setBaseImage ($baseImage) { + $this->baseImage = (string) $baseImage; + } + + /** + * Getter for base image + * + * @return $baseImage A base image template + */ + public final function getBaseImage () { + return $this->baseImage; + } + + /** + * Flushs the content out + * + * @return void + */ + public function flushContent () { + // Get a template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the base image + $templateInstance->loadCodeTemplate($this->getBaseImage()); + + // Assign all the image values with the template + $templateInstance->assignVariable("image_type" , $this->getImageType()); + $templateInstance->assignVariable("image_width" , $this->getWidth()); + $templateInstance->assignVariable("image_height" , $this->getHeight()); + $templateInstance->assignVariable("image_bg_red" , $this->backgroundColor['red']); + $templateInstance->assignVariable("image_bg_green", $this->backgroundColor['green']); + $templateInstance->assignVariable("image_bg_blue" , $this->backgroundColor['blue']); + $templateInstance->assignVariable("image_fg_red" , $this->foregroundColor['red']); + $templateInstance->assignVariable("image_fg_green", $this->foregroundColor['green']); + $templateInstance->assignVariable("image_fg_blue" , $this->foregroundColor['blue']); + $templateInstance->assignVariable("image_string" , $this->getImageString()); + + // Get the raw content + $imageContent = $templateInstance->getRawTemplateData(); + + // Transfer all to the template engine + $templateInstance->renderImageContent($imageContent); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php index ddb10a8..8d20001 100644 --- a/inc/classes/main/helper/web/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/class_WebFormHelper.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class WebFormHelper extends BaseHelper { +class WebFormHelper extends BaseHelper implements HelpableTemplate { /** * Instance to the class which provides field values */ @@ -53,6 +53,11 @@ class WebFormHelper extends BaseHelper { */ private $subGroupName = ""; + /** + * Wether form tag is enabled (default: true) + */ + private $formEnabled = true; + // Class Constants const EXCEPTION_FORM_NAME_INVALID = 0x030; const EXCEPTION_CLOSED_FORM = 0x031; @@ -81,9 +86,10 @@ class WebFormHelper extends BaseHelper { * @param $templateInstance An instance of a valid template engine * @param $formName Name of the form * @param $formId Value for "id" attribute (default: $formName) + * @param $withForm Wether include the form tag * @return $helperInstance A preparedf instance of this class */ - public final static function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false) { + public final static function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false, $withForm = true) { // Get new instance $helperInstance = new WebFormHelper(); @@ -94,10 +100,18 @@ class WebFormHelper extends BaseHelper { if ($formId === false) { // Use form id from form name $formId = $formName; - } + } // END - if - // Create the form - $helperInstance->addFormTag($formName, $formId); + // Set form name + $helperInstance->setFormName($formName); + // A form-less field may say "false" here... + if ($withForm === true) { + // Create the form + $helperInstance->addFormTag($formName, $formId); + } else { + // Disable form + $helperInstance->enableForm(false); + } // Return the prepared instance return $helperInstance; @@ -141,7 +155,7 @@ class WebFormHelper extends BaseHelper { $formContent = ""; // Check wether we shall open or close the form - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Add HTML code $formContent = sprintf("
getConfigInstance()->readConfig('form_target') ); - // Is the form id set? - if ($formId !== false) { - // Then add it as well - $formContent .= sprintf(" id=\"%s_form\"", - $formId - ); - } + // Add form id as well + $formContent .= sprintf(" id=\"%s_form\"", + $formId + ); // Add close bracket $formContent .= ">"; // Open the form and remeber the form name $this->formOpened = true; - $this->formName = $formName; } else { // Add the hidden field required to identify safely this form - $this->addInputHiddenField('form', $this->formName); + $this->addInputHiddenField('form', $this->getFormName()); // Is a group open? if ($this->groupOpened === true) { @@ -194,7 +204,7 @@ class WebFormHelper extends BaseHelper { */ public function addInputTextField ($fieldName, $fieldValue = "") { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -236,7 +246,7 @@ class WebFormHelper extends BaseHelper { */ public function addInputPasswordField ($fieldName, $fieldValue = "") { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -263,7 +273,7 @@ class WebFormHelper extends BaseHelper { */ public function addInputHiddenField ($fieldName, $fieldValue = "") { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -320,7 +330,7 @@ class WebFormHelper extends BaseHelper { */ public function addInputCheckboxField ($fieldName, $fieldChecked = true) { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -350,14 +360,14 @@ class WebFormHelper extends BaseHelper { */ public function addInputResetButton ($buttonText) { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, "reset"), self::EXCEPTION_CLOSED_FORM); } // END - if // Generate the content $inputContent = sprintf("", - $this->formName, + $this->getFormName(), $buttonText ); @@ -375,15 +385,15 @@ class WebFormHelper extends BaseHelper { */ public function addInputSubmitButton ($buttonText) { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, "submit"), self::EXCEPTION_CLOSED_FORM); } // END - if // Generate the content $inputContent = sprintf("", - $this->formName, - $this->formName, + $this->getFormName(), + $this->getFormName(), $buttonText ); @@ -402,7 +412,7 @@ class WebFormHelper extends BaseHelper { */ public function addFormGroup ($groupName, $groupText) { // Is a form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw exception here throw new FormClosedException(array($this, $groupName), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -531,7 +541,7 @@ class WebFormHelper extends BaseHelper { */ public function addFieldText ($fieldName, $fieldText) { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -564,7 +574,7 @@ class WebFormHelper extends BaseHelper { */ public function addFormNote ($formNotes) { // Is the form opened? - if ($this->formOpened === false) { + if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM); } // END - if @@ -742,7 +752,7 @@ class WebFormHelper extends BaseHelper { * @return $isSecured Wether this form is secured by a CAPTCHA */ public function ifFormSecuredWithCaptcha () { - $isSecured = ($this->getConfigInstance()->readConfig($this->formName."_captcha_secured") == "Y"); + $isSecured = ($this->getConfigInstance()->readConfig($this->getFormName()."_captcha_secured") == "Y"); return $isSecured; } @@ -755,13 +765,13 @@ class WebFormHelper extends BaseHelper { */ public function flushContent () { // Is the form still open? - if ($this->formOpened === true) { + if (($this->formOpened === true) && ($this->formEnabled === true)) { // Close the form automatically $this->addFormTag(); } // END - if // Send content to template engine - $this->getTemplateInstance()->assignVariable($this->formName, $this->getContent()); + $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->getContent()); } /** @@ -788,7 +798,7 @@ class WebFormHelper extends BaseHelper { $extraInstance = Registry::getRegistry()->getInstance('extra'); // Get a configured instance - $captchaInstance = ObjectFactory::createObjectByConfiguredName("{$this->formName}_captcha", array($this->getTemplateInstance(), $extraInstance)); + $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName()."_captcha", array($this->getTemplateInstance(), $extraInstance)); // Initiate the CAPTCHA $captchaInstance->initiateCaptcha(); @@ -799,6 +809,35 @@ class WebFormHelper extends BaseHelper { // Get the content and add it to the helper $this->addContent($captchaInstance->getContent()); } + + /** + * Enables/disables the form tag usage + * + * @param $formEnabled Wether form is enabled or disabled + * @return void + */ + public final function enableForm ($formEnabled = true) { + $this->formEnabled = (bool) $formEnabled; + } + + /** + * Setter for form name + * + * @param $formName Name of this form + * @return void + */ + public final function setFormName ($formName) { + $this->formName = (string) $formName; + } + + /** + * Getter for form name + * + * @return $formName Name of this form + */ + public final function getFormName () { + return $this->formName; + } } // [EOF] diff --git a/inc/classes/main/images/.htaccess b/inc/classes/main/images/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/images/class_ b/inc/classes/main/images/class_ new file mode 100644 index 0000000..9a90092 --- /dev/null +++ b/inc/classes/main/images/class_ @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Image extends BaseImage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this image class + * + * @return $imageInstance An instance of this image class + */ + public final static function create???Image() { + // Get a new instance + $imageInstance = new ???Image(); + + // Return the instance + return $imageInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/images/class_BaseImage.php b/inc/classes/main/images/class_BaseImage.php new file mode 100644 index 0000000..2273945 --- /dev/null +++ b/inc/classes/main/images/class_BaseImage.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseImage extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/images/extended/.htaccess b/inc/classes/main/images/extended/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/images/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/images/extended/class_PngImage.php b/inc/classes/main/images/extended/class_PngImage.php new file mode 100644 index 0000000..4693a3d --- /dev/null +++ b/inc/classes/main/images/extended/class_PngImage.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PngImage extends BaseImage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this image class + * + * @return $imageInstance An instance of this image class + */ + public final static function createPngImage() { + // Get a new instance + $imageInstance = new PngImage(); + + // Return the instance + return $imageInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php index fe6b058..c81db57 100644 --- a/inc/classes/main/io/class_FrameworkFileInputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -81,7 +81,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { throw new FileIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } elseif (!file_exists($fileName)) { // File does not exist! - throw new FileIsMissingException($fileName, self::EXCEPTION_FILE_NOT_FOUND); + throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_NOT_FOUND); } elseif (!is_readable($fileName)) { // File does not exist! throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); diff --git a/inc/classes/main/response/class_ImageResponse.php b/inc/classes/main/response/class_ImageResponse.php new file mode 100644 index 0000000..2e2fd09 --- /dev/null +++ b/inc/classes/main/response/class_ImageResponse.php @@ -0,0 +1,376 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class ImageResponse extends BaseFrameworkSystem implements Responseable { + /** + * Response status + */ + private $responseStatus = "200 OK"; + + /** + * Array with all headers + */ + private $responseHeaders = array(); + + /** + * Cookies we shall sent out + */ + private $cookies = array(); + + /** + * Body of the response + */ + private $responseBody = ""; + + /** + * Instance of the template engine + */ + private $templateEngine = null; + + /** + * Fatal resolved messages from filters and so on + */ + private $fatalMessages = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("HTTP response"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an object of this class + * + * @param $appInstance An instance of a manageable application + * @return $responseInstance A prepared instance of this class + */ + public final static function createImageResponse (ManageableApplication $appInstance) { + // Get a new instance + $responseInstance = new ImageResponse(); + + // Set the application instance + $responseInstance->setApplicationInstance($appInstance); + + // Initialize the template engine here + $responseInstance->initTemplateEngine($appInstance); + + // Return the prepared instance + return $responseInstance; + } + + /** + * Setter for status + * + * @param $status New response status + * @return void + */ + public final function setResponseStatus ($status) { + $this->responseStatus = (string) $status; + } + + /** + * Add header element + * + * @param $name Name of header element + * @param $value Value of header element + * @return void + */ + public final function addHeader ($name, $value) { + $this->responseHeaders[$name] = $value; + } + + /** + * Reset the header array + * + * @return void + */ + public final function resetResponseHeaders () { + $this->responseHeaders = array(); + } + + /** + * "Writes" data to the response body + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + public function writeToBody ($output) { + $this->responseBody .= $output; + } + + /** + * Sets the response body to something new + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + public function setResponseBody ($output) { + $this->responseBody = $output; + } + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Wether we shall force the output or abort if headers are + * already sent with an exception + * @return void + * @throws ResponseHeadersAlreadySentException Thrown if headers are + * already sent + */ + public function flushBuffer ($force=false) { + if ((headers_sent()) && (!$force)) { + // Headers are already sent! + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } elseif (!headers_sent()) { + // Send headers out + header("HTTP/1.1 {$this->responseStatus}"); + + // Used later + $now = gmdate('D, d M Y H:i:s') . ' GMT'; + + // General header for no caching + $this->addHeader('Expired', $now); // rfc2616 - Section 14.21 + $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 + + // Define the charset to be used + //$this->addHeader('Content-Type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset'))); + + foreach ($this->responseHeaders as $name=>$value) { + header("{$name}: {$value}"); + } // END - foreach + + // Send cookies out? + if (count($this->cookies) > 0) { + // Send all cookies + $cookieString = implode(" ", $this->cookies); + header("Set-Cookie: {$cookieString}"); + + // Remove them all + $this->cookies = array(); + } // END - if + } + + // Are there some error messages? + if (count($this->fatalMessages) == 0) { + // Flush the output to the world + $this->getWebOutputInstance()->output($this->responseBody); + } else { + // Display all error messages + $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages); + + // Send the error messages out to the world + $this->getWebOutputInstance()->output($this->responseBody); + } + + // Clear response header and body + $this->setResponseBody(""); + $this->resetResponseHeaders(); + } + + /** + * Initializes the template engine instance + * + * @param $appInstance An instance of a manageable application + * @return void + */ + public final function initTemplateEngine (ManageableApplication $appInstance) { + // Get config instance + $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"); + + // 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; + } + + /** + * Adds a fatal message id to the response. The added messages can then be + * processed and outputed to the world + * + * @param $messageId The message id we shall add + * @return void + */ + public final function addFatalMessage ($messageId) { + // Adds the resolved message id to the fatal message list + $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId); + } + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @param $expires Timestamp of expiration (default: configured) + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + * @todo Encryption of cookie data not yet supported. + * @todo Why are these parameters conflicting? + * @todo If the return statement is removed and setcookie() commented out, + * @todo this will send only one cookie out, the first one. + */ + public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) { + // Are headers already sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Shall we encrypt the cookie? + if ($encrypted === true) { + } // END - if + + // For slow browsers set the cookie array element first + $_COOKIE[$cookieName] = $cookieValue; + + // Get all config entries + if (is_null($expires)) { + $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire')); + } // END - if + + $path = $this->getConfigInstance()->readConfig('cookie_path'); + $domain = $this->getConfigInstance()->readConfig('cookie_domain'); + + setcookie($cookieName, $cookieValue, $expires); + //, $path, $domain, (isset($_SERVER['HTTPS'])) + return; + + // Now construct the full header + $cookieString = $cookieName . "=" . $cookieValue . "; "; + $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; + // $cookieString .= "; path=".$path."; domain=".$domain; + + // Set the cookie as a header + $this->cookies[$cookieName] = $cookieString; + } + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function redirectToConfiguredUrl ($configEntry) { + // Is the header not yet sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Get the url from config + $url = $this->getConfigInstance()->readConfig($configEntry); + + // 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); + + // No, then extend it with our base URL + $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url; + } // END - if + + // Add redirect header + $this->addHeader("Location", $url); + + // Set correct response status + $this->setResponseStatus("301 Moved Permanently"); + + // Clear the body + $this->setResponseBody(""); + + // Flush the result + $this->flushBuffer(); + + // All done here... + exit(); + } + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + public function expireCookie ($cookieName) { + // Is the cookie there? + if (isset($_COOKIE[$cookieName])) { + // Then expire it with 20 minutes past + $this->addCookie($cookieName, "", false, (time() - 1200)); + + // Remove it from array + unset($_COOKIE[$cookieName]); + } // END - if + } + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + public function refreshCookie ($cookieName) { + // Only update existing cookies + if (isset($_COOKIE[$cookieName])) { + // Update the cookie + $this->addCookie($cookieName, $_COOKIE[$cookieName], false); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php index 1e702c9..15f4373 100644 --- a/inc/classes/main/rng/class_RandomNumberGenerator.php +++ b/inc/classes/main/rng/class_RandomNumberGenerator.php @@ -122,7 +122,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { } // One-way data we need for "extra-salting" the random number - $this->extraSalt = sha1($this->fixedSalt . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key')); + $this->extraSalt = sha1($this->fixedSalt . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . $this->getConfigInstance()->readConfig('base_url')); // Get config entry for max salt length $this->rndStrLen = $this->getConfigInstance()->readConfig('rnd_str_length'); diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php similarity index 90% rename from inc/classes/main/template/class_TemplateEngine.php rename to inc/classes/main/template/class_BaseTemplateEngine.php index 23ac8b4..7188fda 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -1,7 +1,6 @@ * @version 0.0.0 @@ -22,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate { +class BaseTemplateEngine extends BaseFrameworkSystem { /** * The local path name where all templates and sub folders for special * templates are stored. We will internally determine the language plus @@ -30,6 +29,11 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate */ private $basePath = ""; + /** + * Template type + */ + private $templateType = "html"; + /** * The extension for web and email templates (not compiled templates) */ @@ -113,88 +117,36 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x021; const EXCEPTION_INVALID_VIEW_HELPER = 0x022; + /** + * Initialize the variable stack. This holds all variables for later + * compilation. + * + * @return void + */ + public final function initVariableStack () { + $this->varStack = new FrameworkArrayObject("FakedVariableStack"); + } + /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct () { + protected function __construct ($className) { // Call parent constructor - parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Web template engine"); - - // Create unique ID number - $this->generateUniqueId(); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); } - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @param $basePath The local base path for all templates - * @param $langInstance An instance of LanguageSystem (default) - * @param $ioInstance An instance of FileIoHandler (default, middleware!) - * @return $tplInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $basePath is empty - * @throws InvalidBasePathStringException If $basePath is no string - * @throws BasePathIsNoDirectoryException If $basePath is no - * directory or not found - * @throws BasePathReadProtectedException If $basePath is - * read-protected - */ - public final static function createTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { - // Get a new instance - $tplInstance = new TemplateEngine(); - - // Is the base path valid? - if (empty($basePath)) { - // Base path is empty - throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($basePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($basePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($basePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Get configuration instance - $cfgInstance = FrameworkConfiguration::getInstance(); - - // Set the base path - $tplInstance->setBasePath($basePath); - - // Initialize the variable stack - $tplInstance->initVariableStack(); - - // Set the language and IO instances - $tplInstance->setLanguageInstance($langInstance); - $tplInstance->setFileIoInstance($ioInstance); - - // Set template extensions - $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); - $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); - - // Absolute output path for compiled templates - $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path')); - - // Return the prepared instance - return $tplInstance; - } - /** * Search for a variable in the stack * - * @param $var The variable we are looking for - * @return $idx FALSE means not found, >=0 means found on a specific index + * @param $var The variable we are looking for + * @return $idx FALSE means not found, >=0 means found on a specific index */ private function isVariableAlreadySet ($var) { // First everything is not found @@ -247,8 +199,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate /** * Add a variable to the stack * - * @param $var The variable we are looking for - * @param $value The value we want to store in the variable + * @param $var The variable we are looking for + * @param $value The value we want to store in the variable * @return void */ private function addVariable ($var, $value) { @@ -262,8 +214,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate /** * Modify an entry on the stack * - * @param $var The variable we are looking for - * @param $value The value we want to store in the variable + * @param $var The variable we are looking for + * @param $value The value we want to store in the variable * @return void */ private function modifyVariable ($var, $value) { @@ -319,16 +271,6 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate return $this->lastTemplate; } - /** - * Initialize the variable stack. This holds all variables for later - * compilation. - * - * @return void - */ - public final function initVariableStack () { - $this->varStack = new FrameworkArrayObject("FakedVariableStack"); - } - /** * Setter for base path * @@ -511,7 +453,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) { // Switch over to the code-template extension $ext = $this->getCodeTemplateExtension(); - } + } // END - if // Construct the FQFN for the template by honoring the current language $fqfn = sprintf("%s%s/%s/%s%s", @@ -552,6 +494,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate throw new MissingMethodException(array($ioInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD); } + /* DEBUG: */ echo __METHOD__.": FQFN=".$fqfn."
\n"; + // Load the raw template $rawTemplateData = $ioInstance->loadFileContents($fqfn); @@ -649,7 +593,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Remember this template for recursion detection // RECURSIVE PROTECTION! $this->loadedTemplates[] = $template; - } catch (FileIsMissingException $e) { + } catch (FileNotFoundException $e) { // Even this is not done... :/ $this->rawTemplates[] = $template; } catch (FilePointerNotOpenedException $e) { @@ -657,10 +601,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate $this->rawTemplates[] = $template; } } - - } // if ((!isset( ... - - } // for ($templateMatches ... + } // END - if + } // END - foreach // Restore the raw template data $this->setRawTemplateData($backup); @@ -755,7 +697,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Remember this template for recursion detection // RECURSIVE PROTECTION! $this->loadedTemplates[] = $template; - } catch (FileIsMissingException $e) { + } catch (FileNotFoundException $e) { // This template was never found. We silently ignore it unset($this->rawTemplates[$key]); } catch (FilePointerNotOpenedException $e) { @@ -769,7 +711,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate /** * Assign all found template variables * - * @param $varMatches An array full of variable/value pairs. + * @param $varMatches An array full of variable/value pairs. * @return void * @todo Unfinished work or don't die here. */ @@ -1122,8 +1064,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate default: // Unknown type found // Construct message - $msg = sprintf("[%s:] Unknown/unsupported template type %s detected.", + $msg = sprintf("[%s->%s] Unknown/unsupported template type %s detected.", $this->__toString(), + __FUNCTION__, $this->getTemplateType() ); @@ -1215,6 +1158,26 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Get version number and assign it $this->assignVariable("app_version" , $appInstance->getAppVersion()); } + + /** + * "Compiles" a variable by replacing {?var?} with it's content + * + * @param $rawCode Raw code to compile + * @return $rawCode Compile code with inserted variable value + */ + protected function compileRawCode ($rawCode) { + // Find the variables + preg_match_all($this->regExpVarValue, $rawCode, $varMatches); + + // Compile all variables + foreach ($varMatches[0] as $match) { + // Replace the variable with it's value, if found + $rawCode = str_replace("{?".$match."?}", $this->readVariable($match), $rawCode); + } // END - foreach + + // Return the compiled data + return $rawCode; + } } // [EOF] diff --git a/inc/classes/main/template/image/.htaccess b/inc/classes/main/template/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/template/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php new file mode 100644 index 0000000..6e80fd1 --- /dev/null +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -0,0 +1,210 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree ("image" is ignored) + */ + private $mainNodes = array("type", "resolution", "background-color", "foreground-color", "image-string"); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array("width", "height", "red", "green", "blue", "text"); + + /** + * Image instance + */ + private $imageInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("Image template engine"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $basePath The local base path for all templates + * @param $langInstance An instance of LanguageSystem (default) + * @param $ioInstance An instance of FileIoHandler (default, middleware!) + * @return $tplInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $basePath is empty + * @throws InvalidBasePathStringException If $basePath is no string + * @throws BasePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws BasePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createImageTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { + // Get a new instance + $tplInstance = new ImageTemplateEngine(); + + // Is the base path valid? + if (empty($basePath)) { + // Base path is empty + throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Get configuration instance + $cfgInstance = FrameworkConfiguration::getInstance(); + + // Set the base path + $tplInstance->setBasePath($basePath); + + // Initialize the variable stack + $tplInstance->initVariableStack(); + + // Set the language and IO instances + $tplInstance->setLanguageInstance($langInstance); + $tplInstance->setFileIoInstance($ioInstance); + + // Set template extensions + $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); + $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); + + // Absolute output path for compiled templates + $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } + + /** + * Renders the given image content + * + * @param $imageContent A valid XML image content + * @return void + * @throws XmlParserException If an XML error was found + */ + public function renderImageContent ($imageContent) { + // Get an XML parser + $xmlParser = xml_parser_create(); + + // Force case-folding to on + xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true); + + // Set object + xml_set_object($xmlParser, $this); + + // Set handler call-backs + xml_set_element_handler($xmlParser, "startElement", "endElement"); + xml_set_character_data_handler($xmlParser, "characterHandler"); + + // Now parse the XML tree + if (!xml_parse($xmlParser, $imageContent)) { + // Error found in XML! + throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR); + } // END - if + + // Free the parser + xml_parser_free($xmlParser); + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = "initImage"; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + if (in_array($element, $this->mainNodes)) { + // Okay, main node found! + $methodName = "setImage" . $this->convertToClassName($element); + } elseif (in_array($element, $this->subNodes)) { + // Sub node found + $methodName = "setImageProperty" . $this->convertToClassName($element); + } elseif ($element != "image") { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), self::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
\n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Intializes the image + * + * @return void + * @todo Add cache creation here + */ + private function initImage () { + // Unfinished work! + } + + /** + * Set the image type + * + * @param $imageType Code fragment or direct value holding the image type + * @return void + */ + private function setImageType ($imageType) { + // Try to compile it first to get the value from variable stack + $imageType = $this->compileRawCode($imageType); + + // Now make a class name of it + $className = $this->convertToClassName($imageType."_image"); + + // And try to initiate it + $this->imageInstance = ObjectFactory::createObjectByName($className); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/web/.htaccess b/inc/classes/main/template/web/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/template/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/web/class_WebTemplateEngine.php b/inc/classes/main/template/web/class_WebTemplateEngine.php new file mode 100644 index 0000000..8c9c408 --- /dev/null +++ b/inc/classes/main/template/web/class_WebTemplateEngine.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("Web template engine"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $basePath The local base path for all templates + * @param $langInstance An instance of LanguageSystem (default) + * @param $ioInstance An instance of FileIoHandler (default, middleware!) + * @return $tplInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $basePath is empty + * @throws InvalidBasePathStringException If $basePath is no string + * @throws BasePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws BasePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createWebTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { + // Get a new instance + $tplInstance = new WebTemplateEngine(); + + // Is the base path valid? + if (empty($basePath)) { + // Base path is empty + throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Get configuration instance + $cfgInstance = FrameworkConfiguration::getInstance(); + + // Set the base path + $tplInstance->setBasePath($basePath); + + // Initialize the variable stack + $tplInstance->initVariableStack(); + + // Set the language and IO instances + $tplInstance->setLanguageInstance($langInstance); + $tplInstance->setFileIoInstance($ioInstance); + + // Set template extensions + $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); + $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); + + // Absolute output path for compiled templates + $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } + +// [EOF] +?> diff --git a/inc/config.php b/inc/config.php index 145761f..a9e567f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -90,7 +90,7 @@ $cfg->setConfigEntry('application_path', "application"); $cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH! // CFG: TEMPLATE-ENGINE -$cfg->setConfigEntry('template_class', "TemplateEngine"); +$cfg->setConfigEntry('template_class', "WebTemplateEngine"); // CFG: DEBUG-ENGINE $cfg->setConfigEntry('debug_class', "DebugWebOutput"); diff --git a/templates/images/.htaccess b/templates/images/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/templates/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/de/.htaccess b/templates/images/de/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/templates/images/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/de/image/.htaccess b/templates/images/de/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/templates/images/de/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/de/image/base_image.img b/templates/images/de/image/base_image.img new file mode 100644 index 0000000..39781ef --- /dev/null +++ b/templates/images/de/image/base_image.img @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/templates/images/de/image/emergency_exit.img b/templates/images/de/image/emergency_exit.img new file mode 100644 index 0000000..b46b738 --- /dev/null +++ b/templates/images/de/image/emergency_exit.img @@ -0,0 +1,22 @@ +setBaseImage("base_image"); + +// Set image dimensions +$helper->setWidth(400); +$helper->setHeight(200); + +// Background and foreground color +$helper->setBackgroundColorRedGreenBlue(0xFF, 0xAA, 0xAA); +$helper->setForegroundColorRedGreenBlue(0x00, 0x00, 0x00); + +// Add error message +$helper->setImageString("Genereller Fehler!"); + +// Flush content to the template engine +$helper->flushContent(); + +// Comment this out if image is done +//$this->debugInstance(); +?> -- 2.39.2