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/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/web/.htaccess -text
+inc/classes/main/commands/web/class_WebHomeCommand.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_WebDefaultController.php -text
+inc/classes/main/controller/default/class_WebDefaultNewsController.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/web/.htaccess -text
+inc/classes/main/resolver/web/class_WebCommandResolver.php -text
+inc/classes/main/resolver/web/class_WebControllerResolver.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
inc/config.php -text
inc/config/.htaccess -text
inc/config/class_FrameworkConfiguration.php -text
+inc/config/config-hubmaster.php -text
inc/config/config-override.php -text
inc/database.php -text
inc/database/.htaccess -text
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Lower framework classes
try {
ClassLoader::getInstance()->loadClasses(sprintf("inc/classes/%s/", $class));
} catch (PathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Kann Framework-Klassen im Pfad <strong>%s</strong> nicht laden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
$class
));
} catch (PathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Kann Framework-Klassen im Pfad <strong>%s</strong> nicht laden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
$class
));
} catch (PathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Kann Framework-Klassen im Pfad <strong>%s</strong> nicht laden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
$class
));
} catch (DirPointerNotOpenedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Kann Framework-Klassen im Pfad <strong>%s</strong> nicht laden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
$class
));
}
--- /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]
+?>
* An exception thrown when the template type is not supported
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class UnexpectedTemplateTypeException extends FrameworkException {
/**
* The constructor
*
- * @param $class An array holding our informations
+ * @param $msgArray An array holding our informations
* @param $code Code number for the exception
* @return void
*/
- public function __construct (BaseFrameworkSystem $class, $code) {
+ public function __construct (array $msgArray, $code) {
// Add a message around the missing class
$message = sprintf("[%s:%d] Der Template-Typ <u>%s</u> entspricht nicht dem erwartetem Template-Typ <u>%s</u>.",
- $class[0]->__toString(),
+ $msgArray[0]->__toString(),
$this->getLine(),
- $class[1],
- $class[2]
+ $msgArray[1],
+ $msgArray[2]
);
// Call parent constructor
--- /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.3.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.mxchange.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 flushBuffer($force=false);
+}
+
+//
+?>
* class handles saving of games etc.
*
* @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
/**
*/
private $dbInstance = null;
+ /**
+ * Instance to an application helper class
+ */
+ private $applicationInstance = null;
+
/**
* The real class name
*/
const EXCEPTION_MISSING_LANGUAGE_HANDLER = 0x02e;
const EXCEPTION_MISSING_FILE_IO_HANDLER = 0x02f;
const EXCEPTION_MISSING_ELEMENT = 0x030;
+ const EXCEPTION_INVALID_COMMAND = 0x031;
+ const EXCEPTION_INVALID_CONTROLLER = 0x032;
+ const EXCEPTION_HEADERS_ALREADY_SENT = 0x033;
+ const EXCEPTION_DEFAUL_CONTROLLER_GONE = 0x034;
/**
* In the super constructor these system classes shall be ignored or else
*--------------------------------------------------------------------*
*/
private $systemClasses = array(
- "DebugMiddleware", // Debug middleware output sub-system
- "DebugWebOutput", // Debug web output sub-system
- "DebugConsoleOutput", // Debug console output sub-system
- "DebugErrorLogOutput", // Debug error_log() output sub-system
- "CompressorChannel", // Compressor sub-system
+ "DebugMiddleware", // Debug middleware output sub-system
+ "DebugWebOutput", // Debug web output sub-system
+ "DebugConsoleOutput", // Debug console output sub-system
+ "DebugErrorLogOutput", // Debug error_log() output sub-system
+ "CompressorChannel", // Compressor sub-system
"FrameworkDirectoryPointer", // Directory handler sub-system
- "NullCompressor", // Null compressor
- "Bzip2Compressor", // BZIP2 compressor
- "GzipCompressor", // GZIP compressor
- "WebOutput", // Web output sub-system
+ "NullCompressor", // Null compressor
+ "Bzip2Compressor", // BZIP2 compressor
+ "GzipCompressor", // GZIP compressor
+ "WebOutput", // Web output sub-system
);
/**
*
* @return void
*/
- private function __construct ($class) {
+ protected function __construct ($class) {
// Set real class
$this->setRealClass($class);
+
+ // Init this instance
+ $this->initInstance($class);
}
/**
}
/**
- * Public constructor (for initializing things, etc.)
+ * Initializes the instance
*
* @return void
*/
- public function constructor ($class) {
- // Call constructor
- $this->__construct($class);
-
+ public function initInstance ($class) {
// Get the current (singleton) configuration instance
$this->setConfigInstance(FrameworkConfiguration::createFrameworkConfiguration());
);
// Debug message
- if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
+ if (defined('DEBUG_EVAL')) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
$this->__toString(),
htmlentities($eval)
));
$this->setDatabaseInstance($db);
}
}
-
- // Debug output
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Alle Sub-Systeme sind initialisiert.<br />\n",
- $this->__toString()
- ));
}
}
/**
* Setter for language instance
*
- * @param $configInstance The configuration instance which shall
+ * @param $configInstance The configuration instance which shall
* be FrameworkConfiguration
* @return void
*/
public final function setConfigInstance (FrameworkConfiguration $configInstance) {
- $this->cfgInstance = $configInstance;
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Konfigurations-Handler auf <strong>%s</strong> gesetzt.<br />\n",
- $this->__toString(),
- $configInstance->__toString()
- ));
+ self::$cfgInstance = $configInstance;
}
/**
* @return $cfhInstance - Configuration instance
*/
public final function getConfigInstance () {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Konfigurations-Handler <strong>%s</strong> angefordert.<br />\n",
- $this->__toString(),
- $this->cfgInstance->__toString()
- ));
- return $this->cfgInstance;
+ return self::$cfgInstance;
}
/**
*/
public final function setDebugInstance (DebugMiddleware $debugInstance) {
self::$debug = $debugInstance;
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Debug-Handler auf <strong>%s</strong> gesetzt.<br />\n",
- $this->__toString(),
- $this->getDebugInstance()->__toString()
- ));
}
/**
*/
public final function setWebOutputInstance (OutputStreamer $webInstance) {
self::$webOutput = $webInstance;
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Web-Handler auf <strong>%s</strong> gesetzt.<br />\n",
- $this->__toString(),
- $this->getWebOutputInstance()->__toString()
- ));
}
/**
* @return void
*/
public final function setDatabaseInstance (DatabaseConnection $dbInstance) {
- if ((defined('DEBUG_SYSTEM')) && (is_object($dbInstance->getDebugInstance()))) $dbInstance->getDebugInstance()->output(sprintf("[%s:] Datenbankschicht gesetzt.<br />\n",
- $dbInstance->__toString()
- ));
$this->dbInstance = $dbInstance;
}
* @return $realClass The name of the real class (not BaseFrameworkSystem)
*/
public final function __toString () {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] __toString() erreicht.<br />\n",
- $this->realClass
- ));
return $this->realClass;
}
* @return void
*/
public final function createUniqueID () {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] createUniqueID aufgerufen.<br />\n",
- $this->__toString()
- ));
-
// Existiert noch keine?
if (empty($this->uniqueID)) {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] createUniqueID erzeugt neue Unique-ID.<br />\n",
- $this->__toString()
- ));
// Correct missing class name
$corrected = false;
// Abort the loop
break;
}
- }
-
- // Debug message
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] uniqueID ist auf <strong>%s</strong> gesetzt.<br />\n",
- $this->__toString(),
- $tempID
- ));
+ } // END - while
// Apply the new ID
$this->setUniqueID($tempID);
// Cast to string
$uniqueID = (string) $uniqueID;
- // Debug message
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Unique-ID gesetzt auf <u>%s</u>.<br />\n",
- $this->__toString(),
- $uniqueID
- ));
-
// Set the ID number
$this->uniqueID = $uniqueID;
}
* @return $uniqueID The unique ID of this class
*/
public final function getUniqueID () {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Unique-ID angefordert.<br />\n",
- $this->__toString()
- ));
return $this->uniqueID;
}
public final function resetUniqueID() {
// Sweet and simple... ;-)
$newUniqueID = $this->generateIdNumber();
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Unique-ID zurückgesetzt auf <u>%s</u>.<br />\n",
- $this->__toString(),
- $newUniqueID
- ));
$this->setUniqueID($newUniqueID);
}
* @return $objectDescription The description of this simulation part
*/
public final function getObjectDescription () {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] getObjectDescription erreicht.<br />\n",
- $this->__toString()
- ));
if (isset($this->objectDescription)) {
return $this->objectDescription;
} else {
*/
public final function setObjectDescription ($objectDescription) {
$this->objectDescription = (String) $objectDescription;
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Teilbeschreibung wird auf <strong>%s</strong> gesetzt.<br />\n",
- $this->__toString(),
- $this->objectDescription
- ));
}
/**
* @return boolean The result of comparing both class names
*/
public final function isClass ($class) {
- if ((defined('DEBUG_SYSTEM')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] <strong>%s</strong>=<strong>%s</strong>?<br />\n",
- $this->__toString(),
- $this->__toString(),
- $class
- ));
return ($this->__toString() == $class);
}
// Cast the number
$value = (float) $value;
- if (defined('DEBUG_CORE') && is_object($this->getDebugInstance())) $this->getDebugInstance()->output(sprintf("[%s:] <strong>%d</strong> wird umformatiert.<br />\n",
- $this->__toString(),
- $value
- ));
// Reformat the US number
$price = sprintf("%s %s",
* @return void
*/
public final function removeNumberFormaters () {
- if (defined('DEBUG_CORE') && is_object($this->getDebugInstance())) $this->getDebugInstance()->output(sprintf("[%s:] Zahlenumformatierungszeichen werden entfernt.<br />\n",
- $this->__toString()
- ));
unset($this->thousands);
unset($this->decimals);
}
* @return $dbInstance The database layer instance
*/
public final function getDatabaseInstance () {
- if (defined('DEBUG_CORE') && is_object($this->getDebugInstance())) $this->getDebugInstance()->output(sprintf("[%s:] Datenbank-Instanz <u>%s</u> angefordert.<br />\n",
- $this->__toString(),
- $this->dbInstance
- ));
return $this->dbInstance;
}
$this->fileIOInstance = $fileIOInstance;
}
+ /**
+ * Protected getter for a manageable application helper class
+ *
+ * @return $applicationInstance An instance of a manageable application helper class
+ */
+ protected final function getApplicationInstance () {
+ return $this->applicationInstance;
+ }
+
+ /**
+ * Setter for a manageable application helper class
+ *
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return void
+ */
+ public final function setApplicationInstance (ManageableApplication $applicationInstance) {
+ $this->applicationInstance = $applicationInstance;
+ }
+
/**
* Prepare the template engine (TemplateEngine by default) for a given
* application helper instance (ApplicationHelper by default).
*
- * @param $appInstance An application helper instance
+ * @param $appInstance An application helper instance or
+ * null if we shall use the default
* @return $tplEngine The template engine instance
* @throws NullPointerException If the template engine could not
* be initialized
* unsupported template engine
* @throws MissingLanguageHandlerException If the language sub-system
* is not yet initialized
- */
- protected function prepareTemplateEngine (BaseFrameworkSystem $appInstance) {
+ * @throws NullPointerException If the discovered application
+ * instance is still null
+ */
+ protected function prepareTemplateEngine (BaseFrameworkSystem $appInstance=null) {
+ // Is the application instance set?
+ if (is_null($appInstance)) {
+ // Get the current instance
+ $appInstance = $this->getApplicationInstance();
+
+ // Still null?
+ if (is_null($appInstance)) {
+ // Thrown an exception
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ }
+ }
+
// Generate FQFN for all application templates
$fqfn = sprintf("%s%s/%s/%s",
PATH,
// Debug message
if ((!is_null($this->getDebugInstance())) && (defined('DEBUG_EVAL'))) {
- $this->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
+ $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
$this->__toString(),
htmlentities($eval)
));
// Return the prepared instance
return $tplEngine;
}
+
+ /**
+ * Debugs this instance by putting out it's full content
+ *
+ * @return void
+ */
+ public final function debugInstance () {
+ // Generate the output
+ $content = "<pre>".trim(print_r($this, true))."</pre>";
+
+ // Output it
+ ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$content);
+ }
}
// [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 WebHomeCommand 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 createWebHomeCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new WebHomeCommand();
+
+ // 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]
+?>
* BZIP2 compression and decompression class
*
* @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class Bzip2Compressor extends BaseFrameworkSystem implements Compressor {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor!
- parent::constructor(__CLASS__);
-
- // Debug message
- if (((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
- $this->__toString()
- ));
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("BZIP2-Kompressor");
if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) {
// Compressor can maybe be used
$cInstance = new Bzip2Compressor();
-
- // Debug message
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $cInstance->getDebugInstance()->output(sprintf("[%s:] BZIP2-Kompression wird verwendet.<br />\n",
- $cInstance->__toString()
- ));
} else {
// Routines not found!
$cInstance = null;
-
- // Debug message
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $cInstance->getDebugInstance()->output(sprintf("[%s:] BZIP2-Kompressionsroutinen <strong>nicht</strong> gefunden.<br />\n",
- $cInstance->__toString()
- ));
}
// Return the compressor instance
* @return $string Returns always "bz2"
*/
public final function getCompressorExtension () {
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Dateierweiterung angefordert.<br />\n",
- $this->__toString()
- ));
return "bz2";
}
}
* GZIP compression and decompression class
*
* @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class GzipCompressor extends BaseFrameworkSystem implements Compressor {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor!
- parent::constructor(__CLASS__);
-
- // Debug message
- if (((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
- $this->__toString()
- ));
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("GZIP-Kompressor");
if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) {
// Compressor can maybe be used
$cInstance = new GzipCompressor();
-
- // Debug message
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $cInstance->getDebugInstance()->output(sprintf("[%s:] GZIP-Kompression wird verwendet.<br />\n",
- $cInstance->__toString()
- ));
} else {
// Routines not found!
$cInstance = null;
-
- // Debug message
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $cInstance->getDebugInstance()->output(sprintf("[%s:] GZIP-Kompressionsroutinen <strong>nicht</strong> gefunden.<br />\n",
- $cInstance->__toString()
- ));
}
// Return the compressor instance
* @return $string Returns always "gz"
*/
public final function getCompressorExtension () {
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Dateierweiterung angefordert.<br />\n",
- $this->__toString()
- ));
return "gz";
}
}
* Null compression and decompression class
*
* @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class NullCompressor extends BaseFrameworkSystem implements Compressor {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor!
- parent::constructor(__CLASS__);
-
- // Debug message
- if (((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
- $this->__toString()
- ));
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Null-Kompressor");
* @return $string Returns always "null"
*/
public final function getCompressorExtension () {
- if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Dateierweiterung angefordert.<br />\n",
- $this->__toString()
- ));
return "null";
}
}
--- /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 implements Controller {
+ /**
+ * 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 WebWebDefaultController 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 createWebDefaultController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new WebDefaultController();
+
+ // 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->flushBuffer();
+ }
+}
+
+// [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 WebDefaultNewsController 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 createWebDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new WebDefaultNewsController();
+
+ // 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 from the resolver by sending a request instance to the resolver
+ $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->flushBuffer();
+ }
+
+ /**
+ * 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]
+?>
*
* @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface, LimitableObject {
/**
private $limitInstance = null;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct($class) {
+ protected function __construct($class) {
// Call parent constructor
- parent::constructor($class);
-
- // Debug message
- if (((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
- $this->__toString()
- ));
+ parent::__construct($class);
// Clean up a little
$this->removeNumberFormaters();
}
- /**
- * The public constructor
- *
- * @return void
- */
- public function constructor ($class) {
- // Calls just the private one
- $this->__construct($class);
- }
-
/**
* Getter for limitation instance
*
* @return $limitInstance The instance to the object ObjectLimits
*/
public final function getLimitInstance () {
- if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> angefordert.<br />\n",
- $this->__toString(),
- $this->limitInstance->__toString()
- ));
return $this->limitInstance;
}
* @return void
*/
public final function limitObject (ObjectLimits $limitInstance) {
- // Debug message
- if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> soll verwendet werden.<br />\n",
- $this->__toString(),
- $limitInstance->__toString()
- ));
-
// Get limitArray for validation
$array = $limitInstance->getLimitArray();
if ($array->count() > 0) {
// Okay, there is enougth
$this->limitInstance = $limitInstance;
-
- // Debug message
- if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> wird verwendet und beinhaltet <strong>%s</strong> Einträge.<br />\n",
- $this->__toString(),
- $limitInstance->__toString(),
- $array->count()
- ));
}
}
}
* This class serializes objects and saves them to local files.
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface {
/**
*
* @return void
*/
- private function __construct() {
+ protected function __construct() {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Dateidatenbankschicht");
throw new SavePathWriteProtectedException($savePath, self::EXCEPTION_WRITE_PROTECED_PATH);
}
- // Debug output
- if (defined('DEBUG_DATABASE')) $dbInstance->getDebugInstance()->output(sprintf("[%s:] Es werden lokale Dateien zum Speichern von Objekten verwendet.<br />\n",
- $dbInstance->__toString()
- ));
-
// Set save path and IO instance
$dbInstance->setSavePath($savePath);
$dbInstance->setFileIOInstance($ioInstance);
// Secure string
$savePath = (string) $savePath;
- // Debug message
- if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Lokaler Speicherpfad <strong>%s</strong> wird verwendet.<br />\n",
- $this->__toString(),
- $savePath
- ));
-
// Set save path
$this->savePath = $savePath;
}
throw new MissingMethodException(array($object, '__toString'), self::EXCEPTION_MISSING_METHOD);
}
- // Debug message
- if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Das Objekt <strong>%s</strong> soll in eine lokale Datei gespeichert werden.<br />\n",
- $this->__toString(),
- $object->__toString()
- ));
-
// Get a string containing the serialized object. We cannot exchange
// $this and $object here because $object does not need to worry
// about it's limitations... ;-)
$serialized = $this->serializeObject($object);
- // Debug message
- if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Das Objekt <strong>%s</strong> ist nach der Serialisierung <strong>%s</strong> Byte gross.<br />\n",
- $this->__toString(),
- $object->__toString(),
- strlen($serialized)
- ));
-
// Get a path name plus file name and append the extension
$fqfn = $this->getSavePath() . $object->getPathFileNameFromObject() . "." . $this->getFileExtension();
* other classes
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class SerializationContainer extends FrameworkArrayObject {
/**
*/
public function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
-
- // Debug message
- if ((defined('DEBUG_CONTAINER')) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output("[SerializationContainer:] Konstruktor erreicht.<br />\n");
+ parent::__construct(__CLASS__);
}
/**
);
// Debug eval command
- if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $limitInstance->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
+ if (defined('DEBUG_EVAL')) $limitInstance->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
$this->__toString(),
htmlentities($eval)
));
// Run it
- @eval($eval);
+ eval($eval);
// Add this item to the container list
$containerInstance->append(array(
--- /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 WebCommandResolver 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 "Web"
+ $this->setCommandPrefix("Web");
+ }
+
+ /**
+ * Creates an instance of a Web 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 createWebCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
+ // Create the new instance
+ $resolverInstance = new WebCommandResolver();
+
+ // 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("Web%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 WebControllerResolver 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 "Web"
+ $this->setCommandPrefix("Web");
+ }
+
+ /**
+ * 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 createWebControllerResolver ($commandName, ManageableApplication $appInstance) {
+ // Create the new instance
+ $resolverInstance = new WebControllerResolver();
+
+ // 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 = "WebDefaultController";
+
+ // Generate the class name
+ if ($commandName != $defaultCommand) {
+ // Create controller class name
+ $class = sprintf("Web%sController",
+ ucfirst(strtolower($commandName))
+ );
+ } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
+ // Yes, display news in home then set default controller with news
+ $class = "WebDefaultNewsController";
+ }
+
+ // 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(WebCommandResolver::createWebCommandResolver(\$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 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.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]
+?>
* and emails.
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate {
/**
const EXCEPTION_INVALID_VIEW_HELPER = 0xa02;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private final function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set part description
$this->setObjectDescription("Template-Engine");
* 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
+ * @return $idx FALSE means not found, >=0 means found on a specific index
*/
private function isVariableAlreadySet ($var) {
// First everything is not found
return $found;
}
+ /**
+ * Return a content of a variable or null if not found
+ *
+ * @param $var The variable we are looking for
+ * @return $content Content of the variable or null if not found
+ */
+ private function readVariable ($var) {
+ // First everything is not found
+ $content = null;
+
+ // Now search for it
+ for ($idx = $this->varStack->getIterator(); $idx->valid(); $idx->next()) {
+ // Get current item
+ $currEntry = $idx->current();
+
+ // Is the entry found?
+ if ($currEntry['name'] == $var) {
+ // Found!
+ $content = $currEntry['value'];
+ break;
+ }
+ }
+
+ // Return the current position
+ return $content;
+ }
+
/**
* Add a variable to the stack
*
private function addVariable ($var, $value) {
// Add it to the stack
$this->varStack->append(array(
- 'name' => $var,
- 'value' => $value
+ 'name' => trim($var),
+ 'value' => trim($value)
));
}
* required method
*/
private function loadRawTemplateData ($fqfn) {
- // Debug message
- if ((defined('DEBUG_TEMPLATE')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Template <strong>%s</strong> vom Typ <strong>%s</strong> wird geladen.<br />\n",
- $this->__toString(),
- $template,
- $this->getTemplateType()
- ));
-
// Get a input/output instance from the middleware
$ioInstance = $this->getFileIOInstance();
// Load the raw template
$rawTemplateData = $ioInstance->loadFileContents($fqfn);
- // Debug message
- if ((defined('DEBUG_TEMPLATE')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] <strong>%s</strong> Byte Rohdaten geladen.<br />\n",
- $this->__toString(),
- strlen($rawTemplateData)
- ));
-
// Store the template's contents into this class
$this->setRawTemplateData($rawTemplateData);
* [2] => Array - An array with right part of a match including ":"
* [3] => Array - An array with right part of a match excluding ":"
*/
- private function analyzeTemplate ($templateMatches) {
+ private function analyzeTemplate (array $templateMatches) {
// Backup raw template data
$backup = $this->getRawTemplateData();
// RECURSIVE PROTECTION!
$this->loadedTemplates[] = $template;
} catch (FilePointerNotOpenedException $e) {
- // Template not found!
- $this->rawTemplates[] = $template;
+ // Template not found, but maybe variable assigned?
+ if ($this->isVariableAlreadySet($template) !== false) {
+ // Use that content here
+ $this->loadedRawData[$template] = $this->readVariable($template);
+
+ // Recursive protection:
+ $this->loadedTemplates[] = $template;
+ } else {
+ // Even this is not done... :/
+ $this->rawTemplates[] = $template;
+ }
}
} // if ((!isset( ...
* @param $templateMatches See method analyzeTemplate()
* @return void
*/
- private function insertAllTemplates ($templateMatches) {
+ private function insertAllTemplates (array $templateMatches) {
// Run through all loaded codes
- foreach ($this->loadedRawData as $template => $code) {
+ foreach ($this->loadedRawData as $template=>$code) {
// Search for the template
$foundIndex = array_search($template, $templateMatches[1]);
// Lookup the matching template replacement
- if (isset($templateMatches[0][$foundIndex])) {
+ if (($foundIndex !== false) && (isset($templateMatches[0][$foundIndex]))) {
// Get the current raw template
$rawData = $this->getRawTemplateData();
// Set the new raw data
$this->setRawTemplateData($rawData);
- }
- }
+
+ } // END - if
+
+ } // END - foreach
}
/**
* @param $varMatches An array full of variable/value pairs.
* @return void
*/
- private function assignAllVariables ($varMatches) {
+ private function assignAllVariables (array $varMatches) {
// Search for all variables
foreach ($varMatches[1] as $key=>$var) {
if ((substr($varMatches[2][$key], 0, 1) == "\"") && (substr($varMatches[2][$key], -1, 1) == "\"")) {
// Free string detected! Which we can assign directly
$this->assignVariable($var, $varMatches[3][$key]);
- } else {
+ } elseif (!empty($varMatches[2][$key])) {
// Non-string found so we need some deeper analysis...
// @TODO Unfinished work or don't die here.
die("Deeper analysis not yet implemented!");
* @param $templateMatches See method analyzeTemplate() for details
* @return void
*/
- private function compileRawTemplateData ($templateMatches) {
+ private function compileRawTemplateData (array $templateMatches) {
// Are some code-templates found which we need to compile?
if (count($this->loadedRawData) > 0) {
// Then compile all!
- foreach ($this->loadedRawData as $template => $code) {
+ foreach ($this->loadedRawData as $template=>$code) {
+
+ // Is this template already compiled?
+ if (in_array($template, $this->compiledTemplates)) {
+ // Then skip it
+ continue;
+ }
// Search for the template
$foundIndex = array_search($template, $templateMatches[1]);
// Lookup the matching variable data
- if (isset($templateMatches[3][$foundIndex])) {
+ if (($foundIndex !== false) && (isset($templateMatches[3][$foundIndex]))) {
// Split it up with another reg. exp. into variable=value pairs
- @preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches);
+ preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches);
// Assign all variables
$this->assignAllVariables($varMatches);
} // END - if (count($this->loadedRawData) ...
}
+ /**
+ * Inserts all raw templates into their respective variables
+ *
+ * @return void
+ */
+ private function insertRawTemplates () {
+ // Load all templates
+ foreach ($this->rawTemplates as $template=>$content) {
+ // Set the template as a variable with the content
+ $this->assignVariable($template, $content);
+ }
+ }
+
+ /**
+ * Finalizes the compilation of all template variables
+ *
+ * @return void
+ */
+ private function finalizeVariableCompilation () {
+ // Get the content
+ $content = $this->getRawTemplateData();
+
+ // Walk through all variables
+ for ($idx = $this->varStack->getIterator(); $idx->valid(); $idx->next()) {
+ // Get current entry
+ $currEntry = $idx->current();
+
+ // Replace all [$var] or {?$var?} with the content
+ //* DEBUG: */ echo "name=".$currEntry['name'].", value=<pre>".htmlentities($currEntry['value'])."</pre>\n";
+ $content = str_replace("\$content[".$currEntry['name']."]", $currEntry['value'], $content);
+ $content = str_replace("[".$currEntry['name']."]", $currEntry['value'], $content);
+ $content = str_replace("{?".$currEntry['name']."?}", $currEntry['value'], $content);
+ } // END - for
+
+ // Set the content back
+ $this->setRawTemplateData($content);
+ }
+
/**
* Getter for raw template data
*
// Iterate through all variables
for ($idx = $this->varStack->getIterator(); $idx->valid(); $idx->next()) {
+
// Get current variable from the stack
$currVariable = $idx->current();
// Transfer it's name/value combination to the $content array
+ //* DEBUG: */ echo $currVariable['name']."=<pre>".htmlentities($currVariable['value'])."</pre>\n";
$dummy[$currVariable['name']] = $currVariable['value'];
- }
+
+ }// END - if
+
+ // Set the new variable (don't remove the second dollar !)
$$validVar = $dummy;
// Prepare all configuration variables
unset($idx);
unset($currVariable);
+ // Finalize the compilation of template variables
+ $this->finalizeVariableCompilation();
+
// Prepare the eval() command for comiling the template
- $eval = sprintf("\$this->setCompiledData(\"%s\");",
+ $eval = sprintf("\$result = \"%s\";",
addslashes($this->getRawTemplateData())
);
// Debug message
- if (((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
+ if ((defined('DEBUG_EVAL')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
$this->__toString(),
htmlentities($eval)
));
// Run the constructed command. This will "compile" all variables in
eval($eval);
+
+ // Set the new content
+ $this->setCompiledData($result);
}
/**
if ($this->getTemplateType() != $this->getConfigInstance()->readConfig("code_template_type")) {
// Abort here
throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig("code_template_type")), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
- }
+ } // END - if
- // Get the raw data. Thanks to Flobee(R) for given me a hint using the
- // modifier "m" in regular expressions. I had implemented a regex here
- // like this: (\n|\r)
+ // Get the raw data.
$rawData = $this->getRawTemplateData();
// Remove double spaces and trim leading/trailing spaces
$this->extractVariablesFromRawData($rawData);
// Search for code-tags which are {? ?}
- @preg_match_all($this->regExpCodeTags, $rawData, $templateMatches);
+ preg_match_all($this->regExpCodeTags, $rawData, $templateMatches);
// Analyze the matches array
if ((is_array($templateMatches)) && (count($templateMatches) == 4) && (count($templateMatches[0]) > 0)) {
// Are some raw templates found and loaded?
if (count($this->rawTemplates) > 0) {
- die("NOT YET IMPLEMENTED");
- }
+
+ // Insert all raw templates
+ $this->insertRawTemplates();
+
+ // Remove the raw template content as well
+ $this->setRawTemplateData("");
+
+ } // END - if
+
} // END - if($templateMatches ...
}
break;
default: // Unknown type found
+ // Construct message
+ $msg = sprintf("[%s:] Unknown/unsupported template type <strong>%s</strong> detected.",
+ $this->__toString(),
+ $this->getTemplateType()
+ );
+
if ((is_object($this->getDebugInstance())) && (method_exists($this->getDebugInstance(), 'output'))) {
// Use debug output handler
- $this->getDebugInstance()->output(sprintf("[%s:] Unbekannter Template-Typ <strong>%s</strong> erkannt.",
- $this->__toString(),
- $this->getTemplateType()
- ));
+ $this->getDebugInstance()->output($msg);
die();
} else {
// Put directly out
// DO NOT REWRITE THIS TO app_die() !!!
- die(sprintf("[%s:] Unbekannter Template-Typ <strong>%s</strong> erkannt.",
- $this->__toString(),
- $this->getTemplateType()
- ));
+ die($msg);
}
break;
}
);
// Run the code
- @eval($eval);
+ eval($eval);
}
// Return the requested instance
return $this->helpers[$helperName];
}
+
+ /**
+ * Assigns the last loaded raw template content with a given variable
+ *
+ * @param $templateName Name of the template we want to assign
+ * @param $variableName Name of the variable we want to assign
+ * @return void
+ */
+ public function assignTemplateWithVariable ($templateName, $variableName) {
+ // Get the content from last loaded raw template
+ $content = $this->getRawTemplateData();
+
+ // Assign the variable
+ $this->assignVariable($variableName, $content);
+
+ // Purge raw content
+ $this->setRawTemplateData("");
+ }
+
+ /**
+ * Transfers the content of this template engine to a given response instance
+ *
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function transferToResponse (Responseable $responseInstance) {
+ // Get the content and set it in the response class
+ $responseInstance->writeToBody($this->getCompiledData());
+ }
}
// [EOF]
--- /dev/null
+<?php
+/**
+ * Configuration entries for connecting to the hub
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ *
+ * 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/>.
+ */
+
+// Get the configuration instance
+$cfg = FrameworkConfiguration::getInstance();
+
+// CFG: HUB-LISTEN-ADDR
+$cfg->setConfigEntry("hub_listen_addr", "0.0.0.0");
+
+// CFG: HUB-LISTEN-PORT (zero = auto-choose)
+$cfg->setConfigEntry("hub_listen_port", 9060);
+
+// CFG: HUB-MAX-AUTH-TRIES
+$cfg->setConfigEntry("hub_max_auth_tries", 3);
+
+// CFG: HUB-MSG-AUTH-TRIES
+$cfg->setConfigEntry("hub_msg_auth_tries", "AUTH_MAX_TRIES");
+
+// CFG: HUB-MSG-SPOOFING
+$cfg->setConfigEntry("hub_msg_spoofing", "SPOOFING");
+
+// CFG: HUB-MSG-AUTH-REPLY
+$cfg->setConfigEntry("hub_msg_auth_reply_timeout", "TIMEOUT_AUTH");
+
+// CFG: HUB-MSG-BYE
+$cfg->setConfigEntry("hub_msg_bye", "BYE");
+
+// CFG: HUB-MASTER-IP
+$cfg->setConfigEntry("hub_master_ip", "192.168.1.17");
+
+// CFG: HUB-MASTER-PORT
+$cfg->setConfigEntry("hub_master_port", 9060);
+
+// CFG: HUB-AUTH-REQUEST
+$cfg->setConfigEntry("hub_auth_request", "AUTH");
+
+// CFG: HUB-AUTH-REQUEST-TIMEOUT (5 seconds for whole auth procedure shall be fine)
+$cfg->setConfigEntry("hub_auth_request_timeout", 5);
+
+// CFG: HUB-PEER-HELLO
+$cfg->setConfigEntry("hub_peer_hello", "HELLO");
+
+// CFG: HUB-HELLO-REPLY
+$cfg->setConfigEntry("hub_hello_reply", "ELHO");
+
+// CFG: HUB-HELLO-TIMEOUT
+$cfg->setConfigEntry("hub_hello_timeout", 30);
+
+// CFG: HUB-HELLO-RETRIES
+$cfg->setConfigEntry("hub_hello_retires", 3);
+
+// CFG: HUB-PEER-PING
+$cfg->setConfigEntry("hub_peer_ping", "PING");
+
+// CFG: HUB-PING-REPLY
+$cfg->setConfigEntry("hub_ping_reply", "PONG");
+
+// CFG: HUB-PING-TIMEOUT
+$cfg->setConfigEntry("hub_ping_timeout", 10);
+
+// CFG: HUB-PING-MAXDROPS
+$cfg->setConfigEntry("hub_ping_maxdrops", 3);
+
+// CFG: HUB-PEER-MISS-PONG
+$cfg->setConfigEntry("hub_peer_miss_pong", "PONG_MISS");
+
+// [EOF]
+?>
* Initializes the database layer
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Initialize layer
try {
$db = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $layer);
} catch (NullPointerException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Datenbank-System nicht initialisiert. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (InvalidDirectoryResourceException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Datenbank-System nicht initialisiert. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (PathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Datenbank-System nicht initialisiert. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (PathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Datenbank-System nicht initialisiert. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (PathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Datenbank-System nicht initialisiert. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (DirPointerNotOpenedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Datenbank-System nicht initialisiert. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
}
// Datenbankobjekt debuggen
if (defined('DEBUG_DATABASE_OBJ')) {
- DebugMiddleware::getInstance()->output(sprintf("Die Datenbank-Schicht sieht wie folgt aus:<br />
+ DebugMiddleware::getInstance()->output(sprintf("The database sub-system does now look like this:<br />
<pre>%s</pre>\n",
print_r($db, true)
));
* Try to initializes the language system
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @version 0.0.0
* @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
*
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
try {
$lang = LanguageSystem::createLanguageSystem(sprintf("%s%s",
FrameworkConfiguration::getInstance()->readConfig("lang_base_path")
));
} catch (LanguagePathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Sprachsystem konnte nicht initialisiert werden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
$e->getMessage()
));
} catch (InvalidLanguagePathStringException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Sprachsystem konnte nicht initialisiert werden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
$e->getMessage()
));
} catch (LanguagePathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Sprachsystem konnte nicht initialisiert werden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
$e->getMessage()
));
} catch (LanguagePathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Sprachsystem konnte nicht initialisiert werden. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
$e->getMessage()
));
}
* Initializes the output middleware layer
*
* @author Roland Haeder <webmaster@mxchange.org>
- * @version 0.3.0
+ * @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.mxchange.org
+ * @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
* 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Debug-Ausgabe vorbereiten
+// Get a debugger instance
$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig("debug_engine"));
-// Leere Strings werden ignoriert und sollten zum Testen der Middleware genommen werden
+// Empty string should be ignored and used for testing the middleware
DebugMiddleware::getInstance()->output("");
// [EOF]