inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php -text
inc/classes/exceptions/container/class_ContainerItemIsNullException.php -text
inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php -text
+inc/classes/exceptions/controller/.htaccess -text
+inc/classes/exceptions/controller/class_DefaultControllerException.php -text
inc/classes/exceptions/database/.htaccess -text
inc/classes/exceptions/database/local_file/.htaccess -text
inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php -text
inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php -text
inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php -text
inc/classes/exceptions/main/class_DimNotFoundInArrayException.php -text
+inc/classes/exceptions/main/class_EmptyVariableException.php -text
inc/classes/exceptions/main/class_ExceptionNotChangedException.php -text
inc/classes/exceptions/main/class_ExceptionNotFoundException.php -text
inc/classes/exceptions/main/class_GetterNotFoundException.php -text
inc/classes/exceptions/main/class_InvalidArrayCountException.php -text
+inc/classes/exceptions/main/class_InvalidCommandException.php -text
+inc/classes/exceptions/main/class_InvalidCommandInstanceException.php -text
+inc/classes/exceptions/main/class_InvalidControllerException.php -text
inc/classes/exceptions/main/class_InvalidObjectException.php -text
inc/classes/exceptions/main/class_MissingArrayElementsException.php -text
inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php -text
inc/classes/exceptions/main/class_NoArrayException.php -text
inc/classes/exceptions/main/class_NoObjectException.php -text
inc/classes/exceptions/main/class_NullPointerException.php -text
+inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php -text
inc/classes/exceptions/main/class_VariableIsNotSetException.php -text
inc/classes/exceptions/template/.htaccess -text
inc/classes/exceptions/template/class_BasePathIsEmptyException.php -text
inc/classes/interfaces/.htaccess -text
inc/classes/interfaces/application/.htaccess -text
inc/classes/interfaces/application/class_ManageableApplication.php -text
+inc/classes/interfaces/class_ -text
inc/classes/interfaces/class_FrameworkInterface.php -text
+inc/classes/interfaces/commands/.htaccess -text
+inc/classes/interfaces/commands/class_Commandable.php -text
inc/classes/interfaces/compressor/.htaccess -text
inc/classes/interfaces/compressor/class_Compressor.php -text
+inc/classes/interfaces/controller/.htaccess -text
+inc/classes/interfaces/controller/class_Controller.php -text
inc/classes/interfaces/database/.htaccess -text
inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php -text
inc/classes/interfaces/database/frontend/.htaccess -text
inc/classes/interfaces/io/output/class_OutputStreamer.php -text
inc/classes/interfaces/language/.htaccess -text
inc/classes/interfaces/language/class_ManageableLanguage.php -text
+inc/classes/interfaces/request/.htaccess -text
+inc/classes/interfaces/request/class_Requestable.php -text
+inc/classes/interfaces/resolver/.htaccess -text
+inc/classes/interfaces/resolver/class_CommandResolver.php -text
+inc/classes/interfaces/resolver/class_ControllerResolver.php -text
+inc/classes/interfaces/response/.htaccess -text
+inc/classes/interfaces/response/class_Responseable.php -text
inc/classes/interfaces/template/.htaccess -text
inc/classes/interfaces/template/class_CompileableTemplate.php -text
inc/classes/interfaces/template/view/class_ViewHelper.php -text
inc/classes/main/.htaccess -text
+inc/classes/main/class_ -text
inc/classes/main/class_BaseFrameworkSystem.php -text
inc/classes/main/class_FrameworkArrayObject.php -text
+inc/classes/main/commands/.htaccess -text
+inc/classes/main/commands/class_BaseCommand.php -text
+inc/classes/main/commands/local/.htaccess -text
+inc/classes/main/commands/local/class_LocalHomeCommand.php -text
inc/classes/main/compressor/.htaccess -text
inc/classes/main/compressor/class_Bzip2Compressor.php -text
inc/classes/main/compressor/class_GzipCompressor.php -text
inc/classes/main/compressor/class_NullCompressor.php -text
inc/classes/main/console/.htaccess -text
inc/classes/main/console/class_ConsoleTools.php -text
+inc/classes/main/controller/.htaccess -text
+inc/classes/main/controller/class_ -text
+inc/classes/main/controller/class_BaseController.php -text
+inc/classes/main/controller/default/.htaccess -text
+inc/classes/main/controller/default/class_LocalDefaultController.php -text
+inc/classes/main/controller/default/class_LocalDefaultNewsController.php -text
+inc/classes/main/controller/registration/.htaccess -text
+inc/classes/main/controller/registration/class_DefaultRegistrationController.php -text
inc/classes/main/database/.htaccess -text
inc/classes/main/database/class_BaseDatabaseFrontend.php -text
inc/classes/main/database/classes/.htaccess -text
inc/classes/main/output/.htaccess -text
inc/classes/main/output/class_ConsoleOutput.php -text
inc/classes/main/output/class_WebOutput.php -text
+inc/classes/main/request/.htaccess -text
+inc/classes/main/request/class_HttpRequest.php -text
+inc/classes/main/resolver/.htaccess -text
+inc/classes/main/resolver/class_BaseResolver.php -text
+inc/classes/main/resolver/local/.htaccess -text
+inc/classes/main/resolver/local/class_LocalCommandResolver.php -text
+inc/classes/main/resolver/local/class_LocalControllerResolver.php -text
+inc/classes/main/response/.htaccess -text
+inc/classes/main/response/class_HttpResponse.php -text
inc/classes/main/template/.htaccess -text
inc/classes/main/template/class_TemplateEngine.php -text
inc/classes/middleware/.htaccess -text
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * This exception is thrown when the default controller is missing
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class DefaultControllerException extends FrameworkException {
+ /**
+ * The super constructor for all exceptions
+ *
+ * @param $resolverInstance An instance of a resolver class
+ * @param $code An optional code for better debugging
+ * @return void
+ */
+ public function __construct(ControllerResolver $resolverInstance, $code) {
+ // Prepare the message
+ $message = sprintf("[%s:%d] Cannot resolv default controller. Maybe missing?",
+ $resolverInstance->__toString(),
+ $this->getLine()
+ );
+
+ // Call parent contructor with message
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a variable is unexpected empty
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class EmptyVariableException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $msgArray Message array holding all needed data
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (array $msgArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Variable <u>%s</u> is not set.",
+ $msgArray[0]->__toString(),
+ $this->getLine(),
+ $msgArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a command is invalid
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class InvalidCommandException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $message Message from the exception
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (array $msgArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Invalid command <u>%s</u> detected.",
+ $msgArray[0]->__toString(),
+ $this->getLine(),
+ htmlentities(strip_tags($msgArray[1]), ENT_QUOTES)
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a command instance is invalid
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class InvalidCommandInstanceException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $message Message from the exception
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (array $msgArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Invalid command <u>%s</u> detected.",
+ $msgArray[0]->__toString(),
+ $this->getLine(),
+ $msgArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a controller instance is invalid
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class InvalidControllerInstanceException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $msgArray Array with data from the exception point
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (array $msgArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Invalid controller <u>%s</u> detected.",
+ $msgArray[0]->__toString(),
+ $this->getLine(),
+ $msgArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when an object instance is null
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ResponseHeadersAlreadySentException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $message Message from the exception
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (BaseFrameworkSystem $class, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Headers are already sent!",
+ $class->__toString(),
+ $this->getLine()
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface extends FrameworkInterface {
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for commands for the front controller
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface Commandable extends FrameworkInterface {
+ /**
+ * Executes the given command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ function execute (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for controller
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface Controller extends FrameworkInterface {
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ function handleRequest (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for requests
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface Requestable extends FrameworkInterface {
+ /**
+ * Prepares the HTTP request data for usage by currently copying
+ * $_REQUEST into a private attribute. Later on we can add more
+ * things for initialization here.
+ *
+ * @return void
+ */
+ function prepareRequestData ();
+
+ /**
+ * Checks wether a request element is set
+ * @param $element Name of the request element we want to check
+ * @return $isSet Wether the request element is set
+ * @throws MissingArrayElementsException Thrown if a request element is not set
+ */
+ function isRequestElementSet ($element);
+
+ /**
+ * Getter for request element or 'null' if the element was not found
+ *
+ * @param $element Name of the request element we want to check
+ * @return $value Value of the found request element or 'null' if the
+ * element was not found
+ */
+ function getRequestElement ($element);
+
+ /**
+ * Wrapper method for array_key() function for the request data array
+ *
+ * @return $array An array containing all array keys to return
+ */
+ function getParameterNames ();
+
+ /**
+ * Getter for a header element or 'null' if the header was not found
+ *
+ * @param $headerName Name of the header
+ * @return $headerValue Value of the header or 'null' if not found
+ */
+ function getHeader ($headerName);
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An instance for command resolver classes
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface CommandResolver extends FrameworkInterface {
+ /**
+ * Returns an command instance for a given request class
+ *
+ * @param $requestInstance An instance of a request class
+ * @return $commandInstance An instance of the resolved command
+ */
+ function resolvCommandByRequest (Requestable $requestInstance);
+
+ /**
+ * Checks wether the given command is valid
+ *
+ * @param $commandName The default command we shall execute
+ * @return $isValid Wether the given command is valid
+ * @throws EmptyVariableException Thrown if the given command is not set
+ */
+ function isCommandValid ($commandName);
+}
+
+//
+?>
--- /dev/null
+<?php
+/**
+ * An instance for controller resolver classes
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface ControllerResolver extends FrameworkInterface {
+ /**
+ * Resolves the default controller of the given command
+ *
+ * @return $controllerInstance A controller instance for the default command
+ */
+ function resolveDefaultController ();
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for responses
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface Responseable extends FrameworkInterface {
+ /**
+ * Setter for status
+ *
+ * @param $status New response status
+ * @return void
+ */
+ function setResponseStatus ($status);
+
+ /**
+ * Add header element
+ *
+ * @param $name Name of header element
+ * @param $value Value of header element
+ * @return void
+ */
+ function addHeader ($name, $value);
+
+ /**
+ * "Writes" data to the response body
+ *
+ * @param $output Output we shall sent in the HTTP response
+ * @return void
+ */
+ function writeToBody ($output);
+
+ /**
+ * Flushs the cached HTTP response to the outer world
+ *
+ * @param $foce 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
+ */
+ function flushResponse($force=false);
+}
+
+//
+?>
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class extends BaseFrameworkSystem {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A general (base) command
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class BaseCommand extends BaseFrameworkSystem {
+ /**
+ * The controller we need for this command
+ */
+ private $controllerName = "";
+
+ /**
+ * Resolver instance
+ */
+ private $resolverInstance = null;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct ($class) {
+ // Call parent constructor
+ parent::__construct($class);
+ }
+
+ /**
+ * Setter for controller name
+ *
+ * @param $controllerName Name of the controller assigned with this command
+ * @return void
+ */
+ public final function setControllerName ($controllerName) {
+ $this->controllerName = (string) $controllerName;
+ }
+
+ /**
+ * Getter for controller name
+ *
+ * @return $controllerName Name of the controller assigned with this command
+ */
+ public final function getControllerName () {
+ return $this->controllerName;
+ }
+
+ /**
+ * Setter for resolver instance
+ *
+ * @param $resolverInstance Instance of a command resolver class
+ * @return void
+ */
+ public final function setResolverInstance (CommandResolver $resolverInstance) {
+ $this->resolverInstance = $resolverInstance;
+ }
+
+ /**
+ * Getter for resolver instance
+ *
+ * @return $resolverInstance Instance of a command resolver class
+ */
+ public final function getResolverInstance () {
+ return $this->resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command for the "home" page
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalHomeCommand extends BaseCommand implements Commandable {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set special description
+ $this->setObjectDescription("Home-Command");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $commandInstance An instance a prepared command class
+ */
+ public final static function createLocalHomeCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new LocalHomeCommand();
+
+ // Set the application instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the given command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the application instance
+ $appInstance = $this->getResolverInstance()->getApplicationInstance();
+
+ // Prepare a template instance
+ $templateInstance = $this->prepareTemplateEngine($appInstance);
+
+ // Load the master template
+ $masterTemplate = $appInstance->getMasterTemplate();
+
+ // Load header template
+ $templateInstance->loadCodeTemplate("header");
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable("header", "header");
+
+ // Load footer template
+ $templateInstance->loadCodeTemplate("footer");
+
+ // Compile and assign it with a variable
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable("footer", "footer");
+
+ // Load the home template
+ $templateInstance->loadWebTemplate("home");
+
+ // Assign the home template with the master template as a content ... ;)
+ $templateInstance->assignTemplateWithVariable("home", "content");
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter")));
+ if (empty($title)) $title = "Home";
+ $templateInstance->assignVariable("title", $title);
+
+ // ... and all variables. This should be merged together in a pattern
+ // to make things easier. A cache mechanism should be added between
+ // these two calls to cache compiled templates.
+ $templateInstance->compileVariables();
+
+ // Get the content back from the template engine and put it in the response class
+ $templateInstance->transferToResponse($responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class Controller extends BaseController {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Ein spezieller Controller");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A generic controller class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class BaseController extends BaseFrameworkSystem {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct ($class) {
+ // Call parent constructor
+ parent::__construct($class);
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * The default controller for all other requests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalLocalDefaultController extends BaseController implements Controller {
+ /**
+ * Instance of a CommandResolver class
+ */
+ private $resolverInstance = null;
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Standart-Controller für alle übrigen Anfragen");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public final static function createLocalDefaultController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new LocalDefaultController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $controllerInstance;
+ }
+
+ /**
+ * Setter for a command resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return void
+ */
+ public final function setResolverInstance (CommandResolver $resolverInstance) {
+ $this->resolverInstance = $resolverInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the command instance
+ $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Flush the response out
+ $responseInstance->flushResponse();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Instance of a CommandResolver class
+ */
+ private $resolverInstance = null;
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Standart-Controller mit News-Auflistung");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public final static function createLocalDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new LocalDefaultNewsController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $controllerInstance;
+ }
+
+ /**
+ * Setter for a command resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return void
+ */
+ public final function setResolverInstance (CommandResolver $resolverInstance) {
+ $this->resolverInstance = $resolverInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the command instance
+ $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+
+ // Get the news page variable from the request instance
+ $newsPage = $requestInstance->getRequestElement("news_page");
+
+ // Load the news here
+ $this->loadNews($newsPage);
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Flush the response out
+ $responseInstance->flushResponse();
+ }
+
+ /**
+ * Loads news from the connected database for later usage
+ *
+ * @param $newsPage Page of listed news we want to read
+ * @return void
+ */
+ private function loadNews ($newsPage) {
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A default registration controller which is suitable for most applications
+ * with a registration form.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class DefaultRegistrationController extends BaseController implements Controller {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Ein Standart-Anmelde-Controller");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public final static function createDefaultRegistrationController () {
+ // Create the instance
+ $controllerInstance = new DefaultRegistrationController();
+
+ // Return the prepared instance
+ return $controllerInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ die(__METHOD__.": Stub!");
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A concrete HTTP request class to make HTTP requests more abstract
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class HttpRequest extends BaseFrameworkSystem implements Requestable {
+ /**
+ * Array for the request data
+ */
+ private $requestData = array();
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("HTTP-Anfrage");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class and prepares it a little
+ *
+ * @return $httpInstance An instance of this class
+ */
+ public final static function createHttpRequest () {
+ // Create an instance
+ $httpInstance = new HttpRequest();
+
+ // Prepare the HTTP request data for usage
+ $httpInstance->prepareRequestData();
+
+ // Return the prepared instance
+ return $httpInstance;
+ }
+
+ /**
+ * Prepares the HTTP request data for usage by currently copying
+ * $_REQUEST into a private attribute. Later on we can add more
+ * things for initialization here.
+ *
+ * @return void
+ */
+ public function prepareRequestData () {
+ // Copy the $_REQUEST array
+ $this->requestData = $_REQUEST;
+ }
+
+ /**
+ * Checks wether a request element is set
+ * @param $element Name of the request element we want to check
+ * @return $isSet Wether the request element is set
+ * @throws MissingArrayElementsException Thrown if a request element is not set
+ */
+ public function isRequestElementSet ($element) {
+ // Is this element found?
+ if (!isset($this->requestData[$element])) {
+ // Then throw an exception
+ throw new MissingArrayElementsException(array($this, 'requestData', $element), self::EXCEPTION_MISSING_ELEMENT);
+ }
+
+ // All clear
+ return true;
+ }
+
+ /**
+ * Getter for request element or 'null' if the element was not found
+ *
+ * @param $element Name of the request element we want to check
+ * @return $value Value of the found request element or 'null' if the
+ * element was not found
+ */
+ public function getRequestElement ($element) {
+ // Initialize value
+ $value = null;
+
+ try {
+ if ($this->isRequestElementSet($element)) {
+ $value = $this->requestData[$element];
+ }
+ } catch (MissingArrayElementsException $e) {
+ // Do nothing here
+ }
+
+ // Return the element's value
+ return $value;
+ }
+
+ /**
+ * Wrapper method for array_key() function for the request data array
+ *
+ * @return $array An array containing all array keys to return
+ */
+ public function getParameterNames () {
+ return array_keys($this->requestData);
+ }
+
+ /**
+ * Getter for a header element or 'null' if the header was not found
+ *
+ * @param $headerName Name of the header
+ * @return $headerValue Value of the header or 'null' if not found
+ */
+ public function getHeader ($headerName) {
+ // Default return value on error
+ $headerValue = null;
+
+ // Construct the name
+ $name = 'HTTP_' . strtolower(str_replace('-', '_', $headerName));
+
+ // Does this header exist?
+ if (isset($_SERVER[$name])) {
+ $headerValue = $_SERVER[$name];
+ }
+
+ // Return the value
+ return $headerValue;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A generic resolver class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class BaseResolver extends BaseFrameworkSystem {
+ /**
+ * Validated command name
+ */
+ private $commandName = "";
+
+ /**
+ * Prefix for local, remote or other resolver
+ */
+ private $commandPrefix = "";
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct ($class) {
+ // Call parent constructor
+ parent::__construct($class);
+
+ // Clean up a little
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Setter for command name
+ *
+ * @param $commandName Last validated command name
+ * @return void
+ */
+ protected final function setCommandName ($commandName) {
+ $this->commandName = $commandName;
+ }
+
+ /**
+ * Getter for command name
+ *
+ * @return $commandName Last validated command name
+ */
+ protected final function getCommandName () {
+ return $this->commandName;
+ }
+
+ /**
+ * Setter for command prefix
+ *
+ * @param $commandPrefix Last validated commandPrefix
+ * @return void
+ */
+ protected final function setCommandPrefix ($commandPrefix) {
+ $this->commandPrefix = $commandPrefix;
+ }
+
+ /**
+ * Checks wether the given command is valid
+ *
+ * @param $commandName The default command we shall execute
+ * @return $isValid Wether the given command is valid
+ * @throws EmptyVariableException Thrown if the given command is not set
+ */
+ public function isCommandValid ($commandName) {
+ // By default nothing shall be valid
+ $isValid = false;
+
+ // Is a command set?
+ if (empty($commandName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ }
+
+ // Now, let us create the full name of the command class
+ $class = sprintf("%s%sCommand",
+ $this->commandPrefix,
+ ucfirst(strtolower($commandName))
+ );
+
+ // Is this class already loaded?
+ if (class_exists($class)) {
+ // This class does exist. :-)
+ $isValid = true;
+ }
+
+ // Set command name
+ $this->setCommandName($commandName);
+
+ // Return the result
+ return $isValid;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command resolver for local (non-hubbed) commands
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalCommandResolver extends BaseResolver implements CommandResolver {
+ /**
+ * Last successfull resolved command
+ */
+ private $lastCommandInstance = "";
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Lokaler Kommandoauflöser");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+
+ // Set prefix to "Local"
+ $this->setCommandPrefix("Local");
+ }
+
+ /**
+ * Creates an instance of a local command resolver with a given default command
+ *
+ * @param $defaultCommand The default command we shall execute
+ * @param $appInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared command resolver instance
+ * @throws EmptyVariableException Thrown if the default command is not set
+ * @throws InvalidCommandException Thrown if the default command is invalid
+ */
+ public final static function createLocalCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
+ // Create the new instance
+ $resolverInstance = new LocalCommandResolver();
+
+ // Is the variable $defaultCommand set and the command is valid?
+ if (empty($defaultCommand)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
+ // Invalid command found
+ throw new InvalidCommandException(array($resolverInstance, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($appInstance);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+ /**
+ * Returns an command instance for a given request class or null if
+ * MissingArrayElementsException was thrown
+ *
+ * @param $requestInstance An instance of a request class
+ * @return $commandInstance An instance of the resolved command
+ * @throws InvalidCommandException Thrown if $commandName is
+ * invalid
+ * @throws InvalidCommandInstanceException Thrown if $commandInstance
+ * is an invalid instance
+ */
+ public function resolvCommandByRequest (Requestable $requestInstance) {
+ // Init variables
+ $commandName = "";
+ $commandInstance = null;
+
+ // Test if the required parameter is set
+ try {
+ // This goes fine so let's resolv the command
+ $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter"));
+
+ // Is the command empty? Then fall back to default command
+ if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
+
+ // Check if the command is valid
+ if (!$this->isCommandValid($commandName)) {
+ // This command is invalid!
+ throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Get the command
+ $commandInstance = $this->loadCommand($commandName);
+
+ // And validate it
+ if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
+ // This command has an invalid instance!
+ throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Set last command
+ $this->lastCommandInstance = $commandInstance;
+ } catch (MissingArrayElementsException $e) {
+ // Just catch it here...
+ }
+
+ // Return the resolved command instance
+ return $commandInstance;
+ }
+
+ /**
+ * "Loads" a given command and instances it if not yet cached
+ *
+ * @param $commandName A command name we shall look for
+ * @return $commandInstance A loaded command instance
+ * @throws InvalidCommandException Thrown if even the default
+ * command class is missing (bad!)
+ */
+ private function loadCommand ($commandName) {
+ // Cache default command
+ $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+
+ // Init command instance
+ $commandInstance = null;
+
+ // Create command class name
+ $class = sprintf("Local%sCommand",
+ ucfirst(strtolower($commandName))
+ );
+
+ // Is this class loaded?
+ if (!class_exists($class)) {
+ // Class not found, so try the default one or throw exception
+ if ($commandName != $defaultCommand) {
+ // Try the default command
+ return $this->loadCommand($defaultCommand);
+ } else {
+ // Still not found?
+ throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+ }
+ }
+
+ // Initiate the command
+ $eval = sprintf("\$commandInstance = %s::create%s(\$this);",
+ $class,
+ $class
+ );
+
+ // Run the command
+ eval($eval);
+
+ // Is the instance valid?
+ if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
+ // Something is wrong
+ $commandInstance = null;
+ }
+
+ // Return the result
+ return $commandInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalControllerResolver extends BaseResolver implements ControllerResolver {
+ /**
+ * Last successfull resolved controller
+ */
+ private $lastControllerName = "";
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+
+ // Set prefix to "Local"
+ $this->setCommandPrefix("Local");
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given command
+ *
+ * @param $commandName The default command we shall execute
+ * @param $appInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared command resolver instance
+ * @throws EmptyVariableException Thrown if the default command is not set
+ * @throws InvalidCommandException Thrown if the default command is invalid
+ */
+ public final static function createLocalControllerResolver ($commandName, ManageableApplication $appInstance) {
+ // Create the new instance
+ $resolverInstance = new LocalControllerResolver();
+
+ // Is the variable $commandName set and the command is valid?
+ if (empty($commandName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (!$resolverInstance->isCommandValid($commandName)) {
+ // Invalid command found
+ throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($appInstance);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+ /**
+ * Resolves the default controller of the given command
+ *
+ * @return $controllerInstance A controller instance for the default
+ * command
+ * @throws InvalidCommandException Thrown if $commandName is
+ * invalid
+ * @throws InvalidControllerInstanceException Thrown if $commandInstance
+ * is invalid
+ */
+ public function resolveDefaultController () {
+ // Init variables
+ $commandName = "";
+ $controllerInstance = null;
+
+ // Try to resolv the command
+ try {
+ // Get the command name
+ $commandName = $this->getCommandName();
+
+ // Check if the command is valid
+ if (!$this->isCommandValid($commandName)) {
+ // This command is invalid!
+ throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Get the command
+ $controllerInstance = $this->loadController($commandName);
+
+ // And validate it
+ if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
+ // This command has an invalid instance!
+ throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set last command
+ $this->lastCommandInstance = $controllerInstance;
+ } catch (MissingArrayElementsException $e) {
+ // Just catch it here...
+ }
+
+ // Return the maybe resolved instance
+ return $controllerInstance;
+ }
+
+ /**
+ * "Loads" a given controller and instances it if not yet cached
+ *
+ * @param $commandName A controller name we shall look for
+ * @return $controllerInstance A loaded controller instance
+ * @throws DefaultControllerException Thrown if even the default
+ * controller class is missing (bad!)
+ */
+ private function loadController ($commandName) {
+ // Cache default command
+ $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+
+ // Init controller instance
+ $controllerInstance = null;
+
+ // Default controller
+ $class = "LocalDefaultController";
+
+ // Generate the class name
+ if ($commandName != $defaultCommand) {
+ // Create controller class name
+ $class = sprintf("Local%sController",
+ ucfirst(strtolower($commandName))
+ );
+ } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
+ // Yes, display news in home then set default controller with news
+ $class = "LocalDefaultNewsController";
+ }
+
+ // Is this class loaded?
+ if (!class_exists($class)) {
+ // Class not found, so try the default one or throw exception
+ if ($commandName != $defaultCommand) {
+ // Try the default controller
+ return $this->loadController($defaultCommand);
+ } else {
+ // Still not found?
+ throw new DefaultControllerException($this, self::EXCEPTION_DEFAUL_CONTROLLER_GONE);
+ }
+ }
+
+ // Initiate the controller
+ $eval = sprintf("\$controllerInstance = %s::create%s(LocalCommandResolver::createLocalCommandResolver(\$commandName, \$this->getApplicationInstance()));",
+ $class,
+ $class
+ );
+
+ // Run the command
+ eval($eval);
+
+ // Is the instance valid?
+ if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
+ // Something is wrong
+ $controllerInstance = null;
+ }
+
+ // Return the result
+ return $controllerInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for an HTTP response on an HTTP request
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class HttpResponse extends BaseFrameworkSystem implements Responseable {
+ /**
+ * Response status
+ */
+ private $responseStatus = "200 OK";
+
+ /**
+ * Array with all headers
+ */
+ private $responseHeaders = array();
+
+ /**
+ * Body of the response
+ */
+ private $responseBody = "";
+
+ /**
+ * Instance of the template engine
+ */
+ private $templateEngine = null;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("HTTP-Antwort");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // 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 createHttpResponse (ManageableApplication $appInstance) {
+ // Get a new instance
+ $responseInstance = new HttpResponse();
+
+ // 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;
+ }
+
+ /**
+ * "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;
+ }
+
+ /**
+ * Flushs the cached HTTP response to the outer world
+ *
+ * @param $foce 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 flushResponse ($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.0 {$this->responseStatus}");
+ foreach ($this->responseHeaders as $name=>$value) {
+ header("{$name}: {$value}");
+ }
+ }
+
+ // Flush the output to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ $this->reponseBody = "";
+ $this->responseHeaders = array();
+ }
+
+ /**
+ * Initializes the template engine instance
+ *
+ * @param $appInstance An instance of a manageable application
+ * @return void
+ */
+ public final function initTemplateEngine (ManageableApplication $appInstance) {
+ $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;
+ }
+}
+
+// [EOF]
+?>