inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php -text
inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php -text
inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php -text
+inc/classes/exceptions/helper/.htaccess -text
+inc/classes/exceptions/helper/class_FormClosedException.php -text
+inc/classes/exceptions/helper/class_FormGroupClosedException.php -text
+inc/classes/exceptions/helper/class_FormOpenedException.php -text
+inc/classes/exceptions/helper/class_InvalidFormNameException.php -text
inc/classes/exceptions/io/.htaccess -text
inc/classes/exceptions/io/class_DirPointerNotOpenedException.php -text
inc/classes/exceptions/io/class_FilePointerNotOpenedException.php -text
inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php -text
inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php -text
inc/classes/exceptions/template/class_ViewHelperNotFoundException.php -text
+inc/classes/exceptions/user/.htaccess -text
+inc/classes/exceptions/user/class_UsernameMissingException.php -text
inc/classes/interfaces/.htaccess -text
inc/classes/interfaces/application/.htaccess -text
inc/classes/interfaces/application/class_ManageableApplication.php -text
inc/classes/interfaces/debug/class_Debugger.php -text
inc/classes/interfaces/extended/.htaccess -text
inc/classes/interfaces/extended/class_LimitableObject.php -text
+inc/classes/interfaces/filter/.htaccess -text
+inc/classes/interfaces/filter/class_Filterable.php -text
inc/classes/interfaces/io/.htaccess -text
inc/classes/interfaces/io/class_Streamable.php -text
inc/classes/interfaces/io/file/.htaccess -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/interfaces/user/.htaccess -text
+inc/classes/interfaces/user/class_ManageableUser.php -text
inc/classes/main/.htaccess -text
inc/classes/main/class_ -text
inc/classes/main/class_BaseFrameworkSystem.php -text
inc/classes/main/class_FrameworkArrayObject.php -text
inc/classes/main/commands/.htaccess -text
+inc/classes/main/commands/class_ -text
inc/classes/main/commands/class_BaseCommand.php -text
inc/classes/main/commands/web/.htaccess -text
+inc/classes/main/commands/web/class_WebDoFormCommand.php -text
inc/classes/main/commands/web/class_WebHomeCommand.php -text
+inc/classes/main/commands/web/class_WebRegisterCommand.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/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/form/.htaccess -text
+inc/classes/main/controller/form/class_WebDoFormController.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/factories/objects/class_ObjectFactory.php -text
inc/classes/main/factories/web/.htaccess -text
inc/classes/main/factories/web/class_NewsFactory.php -text
+inc/classes/main/factories/web/class_WebNewsFactory.php -text
+inc/classes/main/filter/.htaccess -text
+inc/classes/main/filter/class_ -text
+inc/classes/main/filter/class_AbstractFilterDecorator.php -text
+inc/classes/main/filter/class_FilterChain.php -text
+inc/classes/main/filter/validator/.htaccess -text
+inc/classes/main/filter/validator/class_UserNameValidatorFilter.php -text
+inc/classes/main/helper/.htaccess -text
+inc/classes/main/helper/class_ -text
+inc/classes/main/helper/class_BaseHelper.php -text
+inc/classes/main/helper/web/.htaccess -text
+inc/classes/main/helper/web/class_WebFormHelper.php -text
inc/classes/main/io/.htaccess -text
inc/classes/main/io/class_FileIOStream.php -text
+inc/classes/main/io/class_FileIoStream.php -text
inc/classes/main/io/class_FrameworkDirectoryPointer.php -text
inc/classes/main/io/class_FrameworkFileInputPointer.php -text
inc/classes/main/io/class_FrameworkFileOutputPointer.php -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/main/user/.htaccess -text
+inc/classes/main/user/class_User.php -text
inc/classes/middleware/.htaccess -text
inc/classes/middleware/class_BaseMiddleware.php -text
inc/classes/middleware/compressor/.htaccess -text
inc/classes/middleware/debug/class_DebugMiddleware.php -text
inc/classes/middleware/io/.htaccess -text
inc/classes/middleware/io/class_FileIOHandler.php -text
+inc/classes/middleware/io/class_FileIoHandler.php -text
inc/config.php -text
inc/config/.htaccess -text
inc/config/class_FrameworkConfiguration.php -text
*/
private static $thisInstance = null;
+ /**
+ * Master template
+ */
+ private $masterTemplate = "mxchange_main";
+
/**
* Private constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Application-Helper");
// Not yet implemented
trigger_error(__METHOD__.": Not yet implemented!");
}
+
+ /**
+ * Getter for master template name
+ *
+ * @return $masterTemplate Name of the master template
+ */
+ public final function getMasterTemplate () {
+ return $this->masterTemplate;
+ }
+
+ /**
+ * Handle the indexed array of fatal messages and puts them out in an
+ * acceptable fasion
+ *
+ * @param $messageList An array of fatal messages
+ * @return void
+ */
+ public function handleFatalMessages (array $messageList) {
+ // Walk through all messages
+ foreach ($messageList as $message) {
+ die("MSG:".$message);
+ }
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An exception thrown when the form is still closed but input field shall be
+ * added to it. This should normally not happen, but well, who knows?
+ *
+ * @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 FormClosedException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $classArray Class throwing the exception
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (array $classArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Could not add form element <u>%s</u> because form is closed.",
+ $classArray[0]->__toString(),
+ $this->getLine(),
+ $classArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when a form group is still closed.
+ *
+ * @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 FormGroupClosedException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $classArray Class throwing the exception
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (array $classArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Could not add sub group <u>%s</u> because no form group has been opened before.",
+ $classArray[0]->__toString(),
+ $this->getLine(),
+ $classArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when the form is still opened but we e.g. shall flush
+ * the content.
+ *
+ * @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 FormOpenedException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $class Class throwing 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] Form is not yet closed. Close it with method <u>%s::addFormTag()</u> and add no parameters.",
+ $class->__toString(),
+ $this->getLine(),
+ $class->__toString()
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when the form name is invalid (set to false)
+ *
+ * @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 InvalidFormNameException extends FrameworkException {
+ /**
+ * The constructor
+ *
+ * @param $class Class throwing 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] Form name not set.",
+ $class->__toString(),
+ $this->getLine()
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
* An exception thrown when a file pointer is not opened
*
* @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 FilePointerNotOpenedException extends FrameworkException {
/**
* The constructor
*
- * @param $message Message from the exception
+ * @param $fqfn Full-qualified file name of (maybe) missing file
* @param $code Code number for the exception
* @return void
*/
- public function __construct ($path, $code) {
+ public function __construct ($fqfn, $code) {
// Add a message around the missing class
- $message = sprintf("Für die Datei <u>%s</u> konnte kein Pointer initialisiert werden. Möglicherweise ist die Datei nicht lesbar oder fehlt!", $path);
+ $message = sprintf("Not able to initialize a pointer for the file <u>%s</u>. Maybe the file is missing.", $fqfn);
// Call parent constructor
parent::__construct($message, $code);
* An exception thrown when a template variable name is invalid
*
* @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
+ * @deprecated
*
* 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 InvalidTemplateVariableNameException extends FrameworkException {
/**
* The constructor
*
- * @param $class An array holding our informations
- * @param $code Code number for the exception
+ * @param $classArray An array holding our informations
+ * @param $code Code number for the exception
* @return void
*/
- public function __construct (BaseFrameworkSystem $class, $code) {
+ public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Die im Template <u>%s</u> gefundene Variable <u>%s</u> ist nicht gültig! Gültige Variablennamen sind nur <u>%s</strong>.",
- $class[0]->__toString(),
+ $message = sprintf("[%s:%d] The template <u>%s</u> contains an invalid variable called <u>%s</u>. Valid variable names are only <u>%s</u>.",
+ $classArray[0]->__toString(),
$this->getLine(),
- basename($class[1]),
- $class[2],
- $class[3]->readConfig("tpl_valid_var")
+ basename($classArray[1]),
+ $classArray[2],
+ $classArray[3]->readConfig('tpl_valid_var')
);
// Call parent constructor
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for non-existing usernames
+ *
+ * @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 UsernameMissingException extends FrameworkException {
+ /**
+ * The super constructor for all exceptions
+ *
+ * @param $msgArray The non-optional message for the exception
+ * @param $code An optional code for better debugging
+ * @return void
+ */
+ public function __construct(array $msgArray, $code = 0) {
+ // Create the message
+ $message = sprintf("[%s:%d] Username <u>%s</u> was not found.",
+ $msgArray[0]->__toString(),
+ $this->getLine(),
+ $msgArray[1]
+ );
+
+ // Make sure everything is assigned properly
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
* - And many more...
*
* @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/>.
*/
interface ManageableApplication extends FrameworkInterface {
/**
*/
function setAppShortName ($shortName);
+ /**
+ * Getter for master template name
+ *
+ * @return $masterTemplate Name of the master template
+ */
+ function getMasterTemplate ();
+
/**
* Launches the application
*
* @return void
*/
function entryPoint ();
+
+ /**
+ * Handle the indexed array of fatal messages and puts them out in an
+ * acceptable fasion
+ *
+ * @param $messageList An array of fatal messages
+ * @return void
+ */
+ function handleFatalMessages (array $messageList);
}
// [EOF]
*/
interface Commandable extends FrameworkInterface {
/**
- * Executes the given command with given request and response objects
+ * Executes the 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
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for pre and post filters
+ *
+ * @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 Filterable extends FrameworkInterface {
+ /**
+ * Executes the filter 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);
+}
+
+//
+?>
* An interface for requests
*
* @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/>.
*/
interface Requestable extends FrameworkInterface {
/**
* @return $headerValue Value of the header or 'null' if not found
*/
function getHeader ($headerName);
+
+ /**
+ * Sets wether the request was valid (default: true)
+ *
+ * @param $isValid Wether the request is valid
+ * @return void
+ */
+ function requestIsValid ($isValid = true);
}
//
*
* @return $controllerInstance A controller instance for the default command
*/
- function resolveDefaultController ();
+ function resolveCommandController ();
}
//
* already sent
*/
function flushBuffer($force=false);
+
+ /**
+ * Adds a fatal message id to the response. The added messages can then be
+ * processed and outputed to the world
+ *
+ * @param $messageId The message id we shall add
+ * @return void
+ */
+ function addFatalMessage ($messageId);
}
//
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for manageable users
+ *
+ * @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 ManageableUser extends FrameworkInterface {
+}
+
+//
+?>
const EXCEPTION_INVALID_CONTROLLER = 0x032;
const EXCEPTION_HEADERS_ALREADY_SENT = 0x033;
const EXCEPTION_DEFAUL_CONTROLLER_GONE = 0x034;
+ const EXCEPTION_CLASS_NOT_FOUND = 0x035;
/**
* In the super constructor these system classes shall be ignored or else
*/
public final function __call ($methodName, $args) {
// Implode all given arguments
- $argsString = implode("|", $args);
- if (empty($argsString)) $argsString = "NULL";
+ $argsString = "";
+ if (empty($args)) {
+ // No arguments
+ $argsString = "NULL";
+ } elseif (is_array($args)) {
+ // Some arguments are there
+ foreach ($args as $arg) {
+ // Check the type
+ if (is_bool($arg)) {
+ // Boolean!
+ if ($arg) $argsString .= "true(bool)"; else $argsString .= "false(bool)";
+ } elseif (is_int($arg)) {
+ // Integer
+ $argsString .= $arg."(int)";
+ } elseif (is_float($arg)) {
+ // Floating point
+ $argsString .= $arg."(float)";
+ } elseif ($arg instanceof BaseFramework) {
+ // Own object instance
+ $argsString .= $arg->__toString()."(Object)";
+ } elseif (is_object($arg)) {
+ // External object
+ $argsString .= "unknown object(!)";
+ } elseif (is_array($arg)) {
+ // Array
+ $argsString .= "Array(array)";
+ } elseif (is_string($arg)) {
+ // String
+ $argsString .= "\"".$arg."\"(string)";
+ } else {
+ // Unknown type (please report!)
+ $argsString .= $arg."(unknown!)";
+ }
+
+ // Add comma
+ $argsString .= ", ";
+ }
+
+ // Remove last comma
+ if (substr($argsString, -2, 1) === ",") $argsString = substr($argsString, 0, -2);
+ } else {
+ // Invalid arguments!
+ $argsString = sprintf("!INVALID:%s!", $args);
+ }
$this->getDebugInstance()->output(sprintf("[%s::%s] Stub! Args: %s",
$this->__toString(),
// Initialize debug instance
if (is_null($this->getDebugInstance())) {
// Set the debug output system if it is not debug class ;)
- $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig("debug_engine")));
+ $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_engine')));
}
// Initialize web instance
if (is_null($this->getWebOutputInstance())) {
// Generate the eval() command
$eval = sprintf("\$this->setWebOutputInstance(%s::create%s(\"%s\"));",
- $this->getConfigInstance()->readConfig("web_engine"),
- $this->getConfigInstance()->readConfig("web_engine"),
- $this->getConfigInstance()->readConfig("web_content_type")
+ $this->getConfigInstance()->readConfig('web_engine'),
+ $this->getConfigInstance()->readConfig('web_engine'),
+ $this->getConfigInstance()->readConfig('web_content_type')
);
// Debug message
// Set the compressor channel
$this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s",
PATH,
- $this->getConfigInstance()->readConfig("compressor_base_path")
+ $this->getConfigInstance()->readConfig('compressor_base_path')
)));
}
*
* @return $cfhInstance - Configuration instance
*/
- public final function getConfigInstance () {
+ protected final function getConfigInstance () {
return self::$cfgInstance;
}
*
* @return $fileIOInstance An instance to the file I/O sub-system
*/
- protected final function getFileIOInstance () {
+ protected final function getFileIoInstance () {
return $this->fileIOInstance;
}
* @param $fileIOInstance An instance to the file I/O sub-system
* @return void
*/
- public final function setFileIOInstance (FileIOHandler $fileIOInstance) {
+ public final function setFileIoInstance (FileIoHandler $fileIOInstance) {
$this->fileIOInstance = $fileIOInstance;
}
// Generate FQFN for all application templates
$fqfn = sprintf("%s%s/%s/%s",
PATH,
- $this->getConfigInstance()->readConfig("application_path"),
+ $this->getConfigInstance()->readConfig('application_path'),
strtolower($appInstance->getAppShortName()),
- $this->getConfigInstance()->readConfig("tpl_base_path")
+ $this->getConfigInstance()->readConfig('tpl_base_path')
);
// Are both instances set?
if ($appInstance->getLanguageInstance() === null) {
// Invalid language instance
throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER);
- } elseif ($appInstance->getFileIOInstance() === null) {
+ } elseif ($appInstance->getFileIoInstance() === null) {
// Invalid language instance
throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER);
}
$eval = sprintf("\$tplEngine = %s::create%s(
\"%s\",
\$appInstance->getLanguageInstance(),
- \$appInstance->getFileIOInstance()
+ \$appInstance->getFileIoInstance()
);",
- $this->getConfigInstance()->readConfig("tpl_engine"),
- $this->getConfigInstance()->readConfig("tpl_engine"),
+ $this->getConfigInstance()->readConfig('tpl_engine'),
+ $this->getConfigInstance()->readConfig('tpl_engine'),
$fqfn
);
*/
public final function debugInstance () {
// Generate the output
- $content = "<pre>".trim(print_r($this, true))."</pre>";
+ $content = sprintf("<pre>%s</pre>",
+ trim(print_r($this, true))
+ );
// Output it
- ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$content);
+ ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong>%s", $this->__toString(), $content));
+ }
+
+ /**
+ * Output a partial stub message for the caller method
+ *
+ * @param $message An optional message to display
+ * @return void
+ */
+ protected function partialStub ($message = "") {
+ // Get the backtrace
+ $backtrace = debug_backtrace();
+
+ // Generate the class::method string
+ $methodName = "UnknownClass::unknownMethod";
+ if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
+ $methodName = $backtrace[1]['class']."::".$backtrace[1]['function'];
+ }
+
+ // Construct the full message
+ $stubMessage = sprintf("[%s:] Partial stub!",
+ $methodName
+ );
+
+ // Is the extra message given?
+ if (!empty($message)) {
+ // Then add it as well
+ $stubMessage .= sprintf(" Message: <u>%s</u>", $message);
+ }
+
+ // Debug instance is there?
+ if (!is_null($this->getDebugInstance())) {
+ // Output stub message
+ $this->getDebugInstance()->output($stubMessage);
+ } else {
+ // Trigger an error
+ trigger_error($stubMessage."<br />\n");
+ }
+ }
+
+ /**
+ * Converts e.g. a command from URL to a valid class by keeping out bad characters
+ *
+ * @param $str The string, what ever it is needs to be converted
+ * @return $className Generated class name
+ */
+ public function convertToClassName ($str) {
+ $className = "";
+ foreach (explode("_", $str) as $strPart) {
+ $className .= ucfirst(strtolower($strPart));
+ }
+ return $className;
+ }
+
+ /**
+ * Outputs a debug backtrace and stops further script execution
+ *
+ * @return void
+ */
+ public function debugBacktrace () {
+ // Sorry, there is no other way getting this nice backtrace
+ print "<pre>\n";
+ debug_print_backtrace();
+ print "</pre>";
+ exit;
}
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class FrameworkArrayObject extends ArrayObject {
- /**
- * Constructor for smooth coding style ;-)
- *
- * @param $class The class's real name
- * @return void
- */
- public function constructor ($class) {
- // $class will be ignored for backward compatiblity
- }
-
/**
* Get real class' name back
*
--- /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/>.
+ */
+class ???Command extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set special description
+ $this->setObjectDescription("");
+
+ // 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 create???Command (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new ???Command();
+
+ // 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) {
+ }
+}
+
+// [EOF]
+?>
--- /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 WebDoFormCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set special description
+ $this->setObjectDescription("Command for handling forms on a centralized place");
+
+ // 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 createWebDoFormCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new WebDoFormCommand();
+
+ // 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) {
+ // Should never be executed...
+ echo "<strong>This should never be executed!</strong><pre>";
+ debug_print_backtrace();
+ die("</pre>Good bye...");
+ }
+}
+
+// [EOF]
+?>
*/
class WebHomeCommand extends BaseCommand implements Commandable {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
parent::__construct(__CLASS__);
// Set special description
- $this->setObjectDescription("Home-Command");
+ $this->setObjectDescription("Command for the "home" page");
// Create unique ID number
$this->createUniqueID();
$templateInstance->assignTemplateWithVariable("footer", "footer");
// Load the home template
- $templateInstance->loadWebTemplate("home");
+ $templateInstance->loadCodeTemplate("home");
// Assign the home template with the master template as a content ... ;)
$templateInstance->assignTemplateWithVariable("home", "content");
$templateInstance->loadCodeTemplate($masterTemplate);
// Set title
- $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter")));
+ $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter')));
if (empty($title)) $title = "Home";
- $templateInstance->assignVariable("title", $title);
+ $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
--- /dev/null
+<?php
+/**
+ * A command class for the registration form
+ *
+ * @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 WebRegisterCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set special description
+ $this->setObjectDescription("Command for the registration form");
+
+ // 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 createWebRegisterCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new WebRegisterCommand();
+
+ // 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);
+
+ // Assign all the application's data with template variables
+ $templateInstance->assignApplicationData($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 register template
+ $templateInstance->loadCodeTemplate("register");
+
+ // Assign the register template with the master template as a content ... ;)
+ $templateInstance->compileTemplate();
+ $templateInstance->assignTemplateWithVariable("register", "content");
+
+ // Load the master template
+ $templateInstance->loadCodeTemplate($masterTemplate);
+
+ // Set title
+ $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter')));
+ if (empty($title)) $title = "Register";
+ $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]
+?>
parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("BZIP2-Kompressor");
+ $this->setObjectDescription("BZIP2 compressor");
// Create an unique ID
$this->createUniqueID();
parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("GZIP-Kompressor");
+ $this->setObjectDescription("GZIP compressor");
// Create an unique ID
$this->createUniqueID();
parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Null-Kompressor");
+ $this->setObjectDescription("Null compressor");
// Create an unique ID
$this->createUniqueID();
* This class contains static helper functions for console applications
*
* @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 ConsoleTools extends BaseFrameworkSystem {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Console-Tools");
+ $this->setObjectDescription("General console tools");
// Create an unique ID
$this->createUniqueID();
<?php
/**
- * A generic controller class
+ * A generic controller class. You should extend this base class if you want to
+ * write your own controller. You get the advantage that you can use the pre and
+ * post filters.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseController extends BaseFrameworkSystem {
+ /**
+ * Instance of a CommandResolver class
+ */
+ private $resolverInstance = null;
+
+ /**
+ * Pre filter chain instance
+ */
+ private $preFilterChain = null;
+
+ /**
+ * Post filter chain instance
+ */
+ private $postFilterChain = null;
+
/**
* Protected constructor
*
// Clean up a little
$this->removeNumberFormaters();
+ $this->removeSystemArray();
+
+ // Initialize both filter chains
+ $this->preFilterChain = FilterChain::createFilterChain();
+ $this->postFilterChain = FilterChain::createFilterChain();
+ }
+
+ /**
+ * Getter for a command resolver instance
+ *
+ * @return $resolverInstance An instance of a command resolver class
+ */
+ public final function getResolverInstance () {
+ return $this->resolverInstance;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Adds a filter to the pre filter chain
+ *
+ * @param $filterInstance An instance of a filter
+ * @return void
+ */
+ public function addPreFilter (Filterable $filterInstance) {
+ // Add the pre filter
+ $this->preFilterChain->addFilter($filterInstance);
+ }
+
+ /**
+ * Adds a filter to the post filter chain
+ *
+ * @param $filterInstance An instance of a filter
+ * @return void
+ */
+ public function addPostFilter (Filterable $filterInstance) {
+ // Add the post filter
+ $this->postFilterChain->addFilter($filterInstance);
+ }
+
+ /**
+ * Executes all pre filters
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ // Execute all pre filters
+ $this->preFilterChain->processFilters($requestInstance, $responseInstance);
+ }
+
+ /**
+ * Executes all post filters
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ // Execute all post filters
+ $this->postFilterChain->processFilters($requestInstance, $responseInstance);
}
}
*/
class WebWebDefaultController extends BaseController implements Controller {
/**
- * Instance of a CommandResolver class
- */
- private $resolverInstance = null;
-
- /**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Standart-Controller für alle übrigen Anfragen");
+ $this->setObjectDescription("Default controller for all other requests");
// Create unique ID number
$this->createUniqueID();
-
- // Clean up a little
- $this->removeSystemArray();
}
/**
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
*
*/
public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
// Get the command instance
- $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+ $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
*/
class WebDefaultNewsController extends BaseController implements Controller {
/**
- * Instance of a CommandResolver class
- */
- private $resolverInstance = null;
-
- /**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Standart-Controller mit News-Auflistung");
+ $this->setObjectDescription("Default controller with news");
// Create unique ID number
$this->createUniqueID();
-
- // Clean up a little
- $this->removeSystemArray();
}
/**
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
*
*/
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");
+ $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
// Load the news here
- $this->loadNews($newsPage);
+ $this->loadNewsByRequest($requestInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
}
/**
- * Loads news from the connected database for later usage
+ * Loads news by a given request
*
- * @param $newsPage Page of listed news we want to read
+ * @param $requestInstance An instance of a request class
* @return void
*/
- private function loadNews ($newsPage) {
+ private function loadNewsByRequest (Requestable $requestInstance) {
+ // Generate a new news object but not carring about which concrete we have
+ $newsInstance = WebNewsFactory::createFactoryByRequest($requestInstance)->createNewsObject();
}
}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A controller for handling sent forms
+ *
+ * @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 WebDoFormController extends BaseController implements Controller {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Controller for handling forms");
+
+ // Create unique ID number
+ $this->createUniqueID();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public final static function createWebDoFormController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new WebDoFormController();
+
+ // Set resolver instance
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // We need the controller instance in the resolver class so set it here
+ $resolverInstance->setControllerInstance($controllerInstance);
+
+ // 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) {
+ // Get the "form action"
+ $formAction = $requestInstance->getRequestElement('form');
+
+ // Get command instance from resolver
+ $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
+
+ // Execute *very* generic pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
+ // Is the request still valid? Post filters shall only be executed of
+ // the request is valid
+ if ($requestInstance->isRequestValid()) {
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Execute *very* generic ppost filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+ }
+
+ // Flush the buffer out
+ $responseInstance->flushBuffer();
+ }
+}
+
+// [EOF]
+?>
parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Dateidatenbankschicht");
+ $this->setObjectDescription("Class for local file databases");
// Create unique ID
$this->createUniqueID();
*
* @param $savePath The local file path string
* @param $ioInstance The input/output handler. This
- * should be FileIOHandler
+ * should be FileIoHandler
* @return $dbInstance An instance of LocalFileDatabase
* @throws SavePathIsEmptyException If the given save path is an
* empty string
* @throws SavePathWriteProtectedException If the save path is write-
* protected
*/
- public final static function createLocalFileDatabase ($savePath, FileIOHandler $ioInstance) {
+ public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) {
// Get an instance
$dbInstance = new LocalFileDatabase();
// Set save path and IO instance
$dbInstance->setSavePath($savePath);
- $dbInstance->setFileIOInstance($ioInstance);
+ $dbInstance->setFileIoInstance($ioInstance);
// Return database instance
return $dbInstance;
// Save the file to disc we don't care here if the path is there,
// this must be done in later methods.
- $this->getFileIOInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized));
+ $this->getFileIoInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized));
}
/**
$this->setLastFile($fqfn);
// Get instance for file handler
- $inputHandler = $this->getFileIOInstance();
+ $inputHandler = $this->getFileIoInstance();
// Try to read from it. This makes it sure that the file is
// readable and a valid database file
*/
public final function getObjectFromCachedData ($uniqueID) {
// Get instance for file handler
- $inputHandler = $this->getFileIOInstance();
+ $inputHandler = $this->getFileIoInstance();
// Get last file's name and contents
$fqfn = $this->repairFQFN($this->getLastFile(), $uniqueID);
* A debug output class for the console (e.g. hub software)
*
* @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 DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Debug-Ausgabe auf Konsole");
+ $this->setObjectDescription("Debug output for the console");
// Create an unique ID
$this->createUniqueID();
* A debug output class for PHP's error_log() command
*
* @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 DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Debug-Ausgabe in error_log()");
+ $this->setObjectDescription("Debug output to error_log()");
// Create an unique ID
$this->createUniqueID();
* A debug output class for the web browser
*
* @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 DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Debug-Ausgabe auf Konsole");
+ $this->setObjectDescription("Debug output for webpages");
// Create an unique ID
$this->createUniqueID();
* objects to the datatabase connection or else a lot heap would be saved.
*
* @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 ObjectLimits extends BaseFrameworkSystem {
/**
private $limitArray = null;
/**
- * 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("Limitierungsobjekt");
+ $this->setObjectDescription("Class for "limiting" other classes. See description for details.");
// Create unique ID number
$this->createUniqueID();
* @return $containerInstance An instance of SerializationContainer
* @throws GetterNotFoundException If a getter was not found
*/
- public final static function createSerializationContainer (ObjectLimits $limitInstance, $object) {
+ public final static function createSerializationContainer (ObjectLimits $limitInstance, FrameworkInterface $object) {
// Get an instance
$containerInstance = new SerializationContainer();
parent::__construct(__CLASS__);
// Set object description
- $this->setObjectDescription("Objekte-Fabrik");
+ $this->setObjectDescription("Simple generic object factory");
}
/**
--- /dev/null
+<?php
+/**
+ * A news factory for web pages
+ *
+ * @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 WebNewsFactory extends BaseFactory {
+ /**
+ * Instance of a request class
+ */
+ private $requestInstance = null;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Factory for webpages with news");
+ }
+
+ /**
+ * Singleton getter for a special factory instance depending on the given
+ * request
+ *
+ * @param $requestInstance An instance of a request class
+ * @return $factoryInstance An instance of a WebNewsFactory class
+ */
+ public final static function createFactoryByRequest (Requestable $requestInstance) {
+ // Generate the new instance
+ $factoryInstance = new WebNewsFactory();
+
+ // Get the element name from configuration
+ $element = FrameworkConfiguration::getInstance()->readConfig('app_selector_get');
+
+ // Analyze the request, first get the Uni* application name (short one from URL)
+ $appName = $requestInstance->getRequestElement($element);
+
+ // Initialize some variables
+ $className = "";
+ $className2 = $appName;
+
+ // Then construct the class name
+ foreach (array("_", "-") as $exp) {
+ $array = explode($exp, $className2);
+ foreach ($array as $el) {
+ $className .= ucfirst(strtolower($el));
+ }
+
+ // Copy it back and clear the class name
+ $className2 = $className;
+ $className = "";
+ }
+
+ // After all is done, copy it back and add this class' name
+ $className = $className2 . $factoryInstance->__toString();
+
+ // Once we have that name, try to load initialize it
+ $realFactoryInstance = ObjectFactory::createObjectByName($className);
+
+ // And assign it with the factory
+ $factoryInstance->setRealFactoryInstance($realFactoryInstance);
+
+ // Remember the request we have used for later usage
+ $factoryInstance->setRequestInstance($requestInstance);
+
+ // Return the prepared factory instance
+ return $factoryInstance;
+ }
+
+ /**
+ * Setter for the request instance
+ *
+ * @param $requestInstance An instance of a request object
+ * @return void
+ */
+ public final function setRequestInstance (Requestable $requestInstance) {
+ $this->requestInstance = $requestInstance;
+ }
+
+ /**
+ * Creates a new object instance and returns it
+ *
+ * @return $newsInstance An instance of a news object
+ */
+ public function createNewsObject () {
+ // Ask the real factory class for doing this
+ $newsInstance = $this->getRealFactoryInstance()->createNewObject($this->requestInstance);
+
+ // And return it
+ return $newsInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Filter extends BaseFrameworkSystem implements Filterable {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A concrete filter");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function create???Filter () {
+ // Get a new instance
+ $filterInstance = new ???Filter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter 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) {
+ // Implement this!
+ $this->partialStub("Please implement this method.");
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An abstract filter decorator for decorating filters with other filters
+ *
+ * @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/>.
+ */
+abstract class AbstractFilterDecorator extends BaseFrameworkSystem implements Filterable {
+ /**
+ * The decorated filter instance
+ */
+ private $filterInstance = null;
+
+ /**
+ * Private constructor
+ *
+ * @param $className Name of the real class' name
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Setter for the decorated filter instance
+ *
+ * @param $filterInstance An instance of a filter
+ * @return void
+ */
+ protected final function setFilterInstance (Filterable $filterInstance) {
+ $this->filterInstance = $filterInstance;
+ }
+
+ /**
+ * Getter for the decorated filter instance
+ *
+ * @return $filterInstance An instance of a filter
+ */
+ protected final function getFilterInstance () {
+ return $this->filterInstance;
+ }
+
+ /**
+ * Execute the inner filter
+ *
+ * @param<->$requestInstance<-->An instance of a request class
+ * @param<->$responseInstance<->An instance of a response class
+ * @return void
+ */
+ public final function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->getFilterInstance()->execute($requestInstance, $responseInstance);
+ }
+
+
+ /**
+ * Do the execution of the filter
+ *
+ * @param<->$requestInstance<-->An instance of a request class
+ * @param<->$responseInstance<->An instance of a response class
+ * @return void
+ */
+ abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance);
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A filter chain for pre and post filters
+ *
+ * @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 FilterChain extends BaseFrameworkSystem {
+ /**
+ * All filters together
+ */
+ private $filters = array();
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A filter chain class");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $chainInstance An instance of this class
+ */
+ public final static function createFilterChain () {
+ // Get a new instance
+ $chainInstance = new FilterChain();
+
+ // Return the prepared instance
+ return $chainInstance;
+ }
+
+ /**
+ * Add a new filter
+ *
+ * @param $filerInstance An instance of a filter class
+ * @return void
+ */
+ public final function addFilter (Filterable $filterInstance) {
+ $this->filters[] = $filterInstance;
+ }
+
+ /**
+ * Process all added filters
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ // Run all filters
+ //* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
+ foreach ($this->filters as $filterInstance) {
+ // Execute this filter
+ //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
+ $filterInstance->execute($requestInstance, $responseInstance);
+ //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
+ }
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A concrete filter for validating the username. This filter may intercept the
+ * filter chain if no username is given or if the supplied username has an
+ * invalid form. It could also intercept the filter chain if the username is
+ * already taken.
+ *
+ * @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 UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A filter for username validation");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createUserNameValidatorFilter () {
+ // Get a new instance
+ $filterInstance = new UserNameValidatorFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter 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 username from request
+ $userName = $requestInstance->getRequestElement('username');
+
+ // Is the username set?
+ if (is_null($userName)) {
+ // Not found in form so stop the filtering process
+ $requestInstance->requestIsValid(false);
+
+ // Set a message for the response
+ $responseInstance->addFatalMessage('username_unset');
+
+ // Abort here
+ return false;
+ } elseif (empty($userName)) {
+ // Empty field!
+ $requestInstance->requestIsValid(false);
+
+ // Set a message for the response
+ $responseInstance->addFatalMessage('username_empty');
+
+ // Abort here
+ return false;
+ } elseif ($this->ifUserNameIsTaken($userName)) {
+ // Username is already taken
+ $requestInstance->requestIsValid(false);
+
+ // Set a message for the response
+ $responseInstance->addFatalMessage('username_taken');
+
+ // Abort here
+ return false;
+ }
+ }
+
+ /**
+ * Check wether the username as already been taken
+ *
+ * @param $userName Username to check for existence
+ * @return $alreadyTaken Wether the username has been taken
+ */
+ private function ifUserNameIsTaken ($userName) {
+ // Default is already taken
+ $alreadyTaken = true;
+
+ // Try to create a user instance
+ try {
+ // If this instance is created then the username *does* exist
+ $userInstance = User::createUserByUsername($userName);
+ } catch (UsernameMissingException $e) {
+ // Okay, this user is missing!
+ $alreadyTaken = false;
+ } catch (FrameworkException $e) {
+ // Something bad happend
+ ApplicationEntryPoint::app_die(sprintf("Exception: %s", $e->__toString()));
+ }
+
+ // Return the result
+ return $alreadyTaken;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class extends BaseHelper {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("");
+ }
+
+ /**
+ * Creates the helper class
+ *
+ * @return $helperInstance A preparedf instance of this class
+ */
+ public final static function createHelper () {
+ // Get new instance
+ $helperInstance = new Helper();
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A generic helper class with generic methods
+ *
+ * @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 BaseHelper extends BaseFrameworkSystem {
+ /**
+ * Template engine instance
+ */
+ private $templateInstance = null;
+
+ /**
+ * Rendered content created by the helper class
+ */
+ private $content = "";
+
+ /**
+ * Private constructor
+ *
+ * @param $className Real name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Setter for template engine instances
+ *
+ * @param $templateInstance An instance of a template engine class
+ * @return void
+ */
+ protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
+ $this->templateInstance = $templateInstance;
+ }
+
+ /**
+ * Getter for template engine instances
+ *
+ * @return $templateInstance An instance of a template engine class
+ */
+ protected final function getTemplateInstance () {
+ return $this->templateInstance;
+ }
+
+ /**
+ * Add content
+ *
+ * @param $newContent New content to add
+ * @return void
+ */
+ protected final function addContent ($newContent) {
+ $this->content .= (string) trim($newContent)."\r\n";
+ }
+
+ /**
+ * Getter for content
+ *
+ * @return $content The rendered content by this helper
+ */
+ protected final function getContent () {
+ return $this->content;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A helper for constructing web forms
+ *
+ * @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 WebFormHelper extends BaseHelper {
+ /**
+ * Wether the form tag is opened (keep at false or else your forms will
+ * never work!)
+ */
+ private $formOpened = false;
+
+ /**
+ * Name of the form
+ */
+ private $formName = "";
+
+ /**
+ * Wether the group is opened or not
+ */
+ private $groupOpened = false;
+
+ /**
+ * Wether the sub group is opened or not
+ */
+ private $subGroupOpened = false;
+
+ /**
+ * Name of the sub group
+ */
+ private $subGroupName = "";
+
+ // Class Constants
+ const EXCEPTION_FORM_NAME_INVALID = 0xb00;
+ const EXCEPTION_CLOSED_FORM = 0xb01;
+ const EXCEPTION_OPENED_FORM = 0xb02;
+ const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0xb03;
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Helper class for HTML forms");
+
+ // Create unique ID number
+ $this->createUniqueID();
+ }
+
+ /**
+ * Creates the helper class with the given template engine instance and form name
+ *
+ * @param $templateInstance An instance of a valid template engine
+ * @param $formName Name of the form
+ * @param $formId Value for "id" attribute (default: $formName)
+ * @return $helperInstance A preparedf instance of this class
+ */
+ public final static function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false) {
+ // Get new instance
+ $helperInstance = new WebFormHelper();
+
+ // Set template instance
+ $helperInstance->setTemplateInstance($templateInstance);
+
+ // Is the form id not set?
+ if ($formId === false) {
+ // Use form id from form name
+ $formId = $formName;
+ }
+
+ // Create the form
+ $helperInstance->addFormTag($formName, $formId);
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+
+ /**
+ * Add the form tag or close it an already opened form tag
+ *
+ * @param $formName Name of the form (default: false)
+ * @param $formId Id of the form (attribute "id"; default: false)
+ * @return void
+ * @throws InvalidFormNameException If the form name is invalid (=false)
+ */
+ public function addFormTag ($formName = false, $formId = false) {
+ // When the form is not yet opened at least form name must be valid
+ if (($this->formOpened === false) && ($formName === false)) {
+ // Thrown an exception
+ throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
+ }
+
+ // Close the form is default
+ $formContent = "</form>";
+
+ // Check wether we shall open or close the form
+ if ($this->formOpened === false) {
+ // Add HTML code
+ $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s\" method=\"%s\" target=\"%s\"",
+ $formName,
+ $this->getConfigInstance()->readConfig('form_action'),
+ $this->getConfigInstance()->readConfig('form_method'),
+ $this->getConfigInstance()->readConfig('form_target')
+ );
+
+ // Is the form id set?
+ if ($formId !== false) {
+ // Then add it as well
+ $formContent .= sprintf(" id=\"%s_form\"",
+ $formId
+ );
+ }
+
+ // Add close bracket
+ $formContent .= ">";
+
+ // Open the form and remeber the form name
+ $this->formOpened = true;
+ $this->formName = $formName;
+ } else {
+ // Add the hidden field required to identify safely this form
+ $this->addInputHiddenField('form', $this->formName);
+
+ // Is a group open?
+ if ($this->groupOpened === true) {
+ // Then automatically close it here
+ $this->addFormGroup("", "");
+ }
+
+ // @TODO Add some unique PIN here to bypass problems with some browser and/or extensions
+ // Simply close it
+ $this->formOpened = false;
+ }
+
+ // Add it to the content
+ $this->addContent($formContent);
+ }
+
+ /**
+ * Add a text input tag to the form or throw an exception if it is not yet
+ * opened. The field's name will be set as id.
+ *
+ * @param $fieldName Input field name
+ * @param $fieldValue Input default value (default: empty)
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addInputTextField ($fieldName, $fieldValue = "") {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Generate the content
+ $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+ $fieldName,
+ $fieldName,
+ $fieldValue
+ );
+
+ // And add it maybe with a "li" tag
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add a password input tag to the form or throw an exception if it is not
+ * yet opened. The field's name will be set as id.
+ *
+ * @param $fieldName Input field name
+ * @param $fieldValue Input default value (default: empty)
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addInputPasswordField ($fieldName, $fieldValue = "") {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Generate the content
+ $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+ $fieldName,
+ $fieldName,
+ $fieldValue
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add a hidden input tag to the form or throw an exception if it is not
+ * yet opened. The field's name will be set as id.
+ *
+ * @param $fieldName Input field name
+ * @param $fieldValue Input default value (default: empty)
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addInputHiddenField ($fieldName, $fieldValue = "") {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Generate the content
+ $inputContent = sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />",
+ $fieldName,
+ $fieldValue
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add a checkbox input tag to the form or throw an exception if it is not
+ * yet opened. The field's name will be set as id.
+ *
+ * @param $fieldName Input field name
+ * @param $fieldChecked Wether the field is checked (defaut: checked)
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addInputCheckboxField ($fieldName, $fieldChecked = true) {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Set wether the check box is checked...
+ $checked = " checked=\"checked\"";
+ if ($fieldChecked === false) $checked = " ";
+
+ // Generate the content
+ $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox\" id=\"%s\" value=\"1\"%s/>",
+ $fieldName,
+ $fieldName,
+ $checked
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add a reset input tag to the form or throw an exception if it is not
+ * yet opened. The field's name will be set as id.
+ *
+ * @param $buttonText Text displayed on the button
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addInputResetButton ($buttonText) {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, "reset"), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Generate the content
+ $inputContent = sprintf("<input type=\"reset\" class=\"reset_button\" id=\"%s_reset\" value=\"%s\" />",
+ $this->formName,
+ $buttonText
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add a reset input tag to the form or throw an exception if it is not
+ * yet opened. The field's name will be set as id.
+ *
+ * @param $buttonText Text displayed on the button
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addInputSubmitButton ($buttonText) {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, "submit"), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Generate the content
+ $inputContent = sprintf("<input type=\"submit\" class=\"submit_button\" id=\"%s_submit\" name=\"%s_button\" value=\"%s\" />",
+ $this->formName,
+ $this->formName,
+ $buttonText
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add a form group or close an already opened and open a new one
+ *
+ * @param $groupName Name of the group
+ * @param $groupText Text including HTML to show above this group
+ * @return void
+ * @throws FormClosedException If no form has been opened before
+ * @throws EmptyVariableException If $groupName is not set
+ */
+ public function addFormGroup ($groupName, $groupText) {
+ // Is a form opened?
+ if ($this->formOpened === false) {
+ // Throw exception here
+ throw new FormClosedException(array($this, $groupName), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // At least the group name should be set
+ if ((empty($groupName)) && ($this->groupOpened === false)) {
+ // Throw exception here
+ throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ }
+
+ // Initialize content with closing div by default
+ $content = " </div>\n</div><!-- Group - CLOSE //-->";
+
+ // Is this group opened?
+ if ($this->groupOpened === false) {
+ // Begin the div/span blocks
+ $content = sprintf("<!-- Group %s - OPEN //-->
+<div class=\"group_box\" id=\"%s_group_box\">
+ <span class=\"group_text\" id=\"%s_group_text\">
+ %s
+ </span>
+ <div class=\"group_field\" id=\"%s_group_field\">",
+ $groupName,
+ $groupName,
+ $groupName,
+ $groupText,
+ $groupName
+ );
+
+ // Add the content
+ $this->addContent($content);
+
+ // Switch the state
+ $this->groupOpened = true;
+ } else {
+ // Is a sub group opened?
+ if ($this->subGroupOpened === true) {
+ // Close it here
+ $this->addFormSubGroup("", "");
+ }
+
+ // Add the content
+ $this->addContent($content);
+
+ // Switch the state
+ $this->groupOpened = false;
+
+ // All call it again if the group name is not empty
+ if (!empty($groupName)) {
+ $this->addFormGroup($groupName, $groupText);
+ }
+ }
+ }
+
+ /**
+ * Add a form sub group or close an already opened and open a new one or
+ * throws an exception if no group has been opened before or if the sub
+ * group name is empty.
+ *
+ * @param $subGroupName Name of the group
+ * @param $subGroupText Text including HTML to show above this group
+ * @return void
+ * @throws FormGroupClosedException If no group has been opened before
+ * @throws EmptyVariableException If $subGroupName is not set
+ */
+ public function addFormSubGroup ($subGroupName, $subGroupText) {
+ // Is a group opened?
+ if ($this->groupOpened === false) {
+ // Throw exception here
+ throw new FormGroupClosedException(array($this, $subGroupName), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
+ }
+
+ // At least the sub group name should be set
+ if ((empty($subGroupName)) && ($this->subGroupOpened === false)) {
+ // Throw exception here
+ throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ }
+
+ // Initialize content with closing div by default
+ $content = " </div>\n</div><!-- Sub group- CLOSE //-->";
+
+ // Is this group opened?
+ if ($this->subGroupOpened === false) {
+ // Begin the span block
+ $content = sprintf("<!-- Sub group %s - OPEN //-->
+<div class=\"subgroup_box\" id=\"%s_subgroup_box\">
+ <span class=\"subgroup_text\" id=\"%s_subgroup_text\">
+ %s
+ </span>
+ <div class=\"subgroup_field\" id=\"%s_subgroup_field\">",
+ $subGroupName,
+ $subGroupName,
+ $subGroupName,
+ $subGroupText,
+ $subGroupName
+ );
+
+ // Add the content
+ $this->addContent($content);
+
+ // Switch the state and remeber the name
+ $this->subGroupOpened = true;
+ $this->subGroupName = $subGroupName;
+ } else {
+ // Add the content
+ $this->addContent($content);
+
+ // Switch the state
+ $this->subGroupOpened = false;
+
+ // All call it again if sub group name is not empty
+ if (!empty($subGroupName)) {
+ $this->addFormSubGroup($subGroupName, $subGroupText);
+ }
+ }
+ }
+
+ /**
+ * Add text surrounded by a span block when there is a group opened before
+ * or else by a div block.
+ *
+ * @param $fieldName Field name
+ * @param $fieldText Text for the field
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addFieldText ($fieldName, $fieldText) {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Set the block type
+ $block = "div";
+ if ($this->groupOpened === true) $block = "span";
+
+ // Generate the content
+ $inputContent = sprintf(" <%s id=\"%s_text\">
+ %s
+ </%s>",
+ $block,
+ $fieldName,
+ $fieldText,
+ $block
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Add text (notes) surrounded by a div block. Still opened groups or sub
+ * groups will be automatically closed.
+ *
+ * @param $formNotes The form notes we shell addd
+ * @return void
+ * @throws FormClosedException If the form is not yet opened
+ */
+ public function addFormNote ($formNotes) {
+ // Is the form opened?
+ if ($this->formOpened === false) {
+ // Throw an exception
+ throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM);
+ }
+
+ // Is a group open?
+ if ($this->groupOpened === true) {
+ // Then automatically close it here
+ $this->addFormGroup("unknown", "");
+ }
+
+ // Generate the content
+ $inputContent = sprintf(" <div id=\"form_note\">
+ %s
+ </div>",
+ $formNotes
+ );
+
+ // And add it
+ $this->addContent($inputContent);
+ }
+
+ /**
+ * Checks wether the registration requires a valid email address
+ *
+ * @return $required Wether the email address is required
+ */
+ public function ifRegisterRequiresEmailVerification () {
+ $required = ($this->getConfigInstance()->readConfig('register_requires_email') == "Y");
+ return $required;
+ }
+
+ /**
+ * Checks wether profile data shall be asked
+ *
+ * @return $required Wether profile shall be asked
+ */
+ public function ifRegisterIncludesProfile () {
+ $required = ($this->getConfigInstance()->readConfig('register_includes_profile') == "Y");
+ return $required;
+ }
+
+ /**
+ * Checks wether personal data shall be asked
+ *
+ * @return $required Wether personal data shall be asked
+ */
+ public function ifRegisterIncludesPersonaData () {
+ $required = ($this->getConfigInstance()->readConfig('register_personal_data') == "Y");
+ return $required;
+ }
+
+ /**
+ * Checks wether email addresses can only be once used
+ *
+ * @return $isUnique
+ */
+ public function ifEmailMustBeUnique () {
+ $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') == "Y");
+ return $isUnique;
+ }
+
+ /**
+ * Checks wether the specified chat protocol is enabled in this form
+ *
+ * @return $required Wether the specified chat protocol is enabled
+ */
+ public function ifChatEnabled ($chatProtocol) {
+ $required = ($this->getConfigInstance()->readConfig(sprintf("chat_enabled_%s", $chatProtocol)) == "Y");
+ return $required;
+ }
+
+ /**
+ * Flushs the content out (not yet secured against open forms, etc.!) or
+ * throw an exception if it is not yet closed
+ *
+ * @return void
+ * @throws FormOpenedException If the form is still open
+ */
+ public function flushContent () {
+ // Is the form still open?
+ if ($this->formOpened === true) {
+ // Throw an exception
+ throw new FormOpenedException ($this, self::EXCEPTION_OPENED_FORM);
+ }
+
+ // Send content to template engine
+ $this->getTemplateInstance()->assignVariable($this->formName, $this->getContent());
+ }
+}
+
+// [EOF]
+?>
/**
* Private constructor
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set part description
$this->setObjectDescription("Universal Datei-Ein-/Ausgabesystem");
--- /dev/null
+<?php
+/**
+ * An universal class for file input/output streams.
+ *
+ * @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 FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer {
+ /**
+ * Protected constructor
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Universal file I/O stream system");
+
+ // Create unique ID
+ $this->createUniqueID();
+
+ // Clean-up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Create a file IO stream. This is a class for performing all actions
+ * on files like creating, deleting and loading them.
+ *
+ * @return $ioInstance An instance of FileIoStream
+ */
+ public final static function createFileIoStream () {
+ // Create new instance
+ $ioInstance = new FileIoStream();
+
+ // Return the instance
+ return $ioInstance;
+ }
+
+ /**
+ * Saves data to a given local file
+ *
+ * @param $fileName The file name for the to be saved file
+ * @param $dataArray The data we shall store to the file
+ * @return void
+ * @see FileOutputStreamer
+ */
+ public final function saveFile ($fileName, $dataArray) {
+ // Try it five times
+ $dirName = ""; $fileInstance = null;
+ for ($idx = 0; $idx < 5; $idx++) {
+ // Get a file output pointer
+ try {
+ $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w');
+ } catch (FilePointerNotOpenedException $e) {
+ // Create missing directory
+ $dirName = dirname($fileName);
+ for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) {
+ $dirName = dirname($dirName);
+ }
+ // Try to create it
+ @mkdir($dirName);
+ }
+ }
+
+ // Write a header information for validation purposes
+ $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n",
+ $dataArray[0],
+ time(),
+ strlen($dataArray[1]),
+ md5($dataArray[1])
+ ));
+
+ // Encode the (maybe) binary stream with Base64
+ $b64Stream = base64_encode($dataArray[1]);
+
+ // write the data line by line
+ $line = str_repeat(" ", 50); $idx = 0;
+ while (strlen($line) == 50) {
+ // Get 50 chars or less
+ $line = substr($b64Stream, $idx, 50);
+
+ // Save it to the stream
+ $fileInstance->writeToFile(sprintf("@data^%s:%s\n",
+ $line,
+ md5($line)
+ ));
+
+ // Advance to the next 50-chars block
+ $idx += 50;
+ }
+
+ // Close the file
+ $fileInstance->closeFile();
+ }
+
+ /**
+ * Reads from a local file
+ *
+ * @param $fqfn The full-qualified file-name which we shall load
+ * @return $array An array with the element 'header' and 'data'
+ * @see FileInputStreamer
+ */
+ public final function loadFileContents ($fqfn) {
+ // Initialize some variables and arrays
+ $inputBuffer = "";
+ $lastBuffer = "";
+ $header = array();
+ $data = array();
+ $readData = ""; // This will contain our read data
+
+ // Get a file input handler
+ $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn);
+
+ // Read all it's contents (we very and transparently decompress it below)
+ while ($readRawLine = $fileInstance->readFromFile()) {
+ // Add the read line to the buffer
+ $inputBuffer .= $readRawLine;
+
+ // Break infinite loop maybe caused by the input handler
+ if ($lastBuffer == $inputBuffer) break;
+
+ // Remember last read line for avoiding possible infinite loops
+ $lastBuffer = $inputBuffer;
+ }
+
+ // Close directory handle
+ $fileInstance->closeFile();
+
+ // Convert it into an array
+ $inputBuffer = explode("\n", $inputBuffer);
+
+ // Now process the read lines and verify it's content
+ foreach ($inputBuffer as $rawLine) {
+ // Trim it a little but not the leading spaces/tab-stops
+ $rawLine = rtrim($rawLine);
+
+ // Analyze this line
+ if (substr($rawLine, 0, 5) == "@head") {
+ // Header found, so let's extract it
+ $header = explode("^", $rawLine);
+ $header = trim($header[1]);
+
+ // Now we must convert it again into an array
+ $header = explode(":", $header);
+
+ // Is the header (maybe) valid?
+ if (count($header) != 4) {
+ // Throw an exception
+ throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+ }
+ } elseif (substr($rawLine, 0, 5) == "@data") {
+ // Is a data line!
+ $data = explode("^", $rawLine);
+ $data = $data[1];
+
+ // First element is the data, second the MD5 checksum
+ $data = explode(":", $data);
+
+ // Validate the read line
+ if (count($data) == 2) {
+ if (md5($data[0]) != $data[1]) {
+ // MD5 hash did not match!
+ throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+ }
+ } else {
+ // Invalid count!
+ throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+ }
+
+ // Add this to the readData string
+ $readData .= $data[0];
+ } else {
+ // Other raw lines than header/data tagged lines and re-add the new-line char
+ $readData .= $rawLine."\n";
+ }
+ }
+
+ // Was raw lines read and no header/data?
+ if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
+ // Return raw lines back
+ return $readData;
+ }
+
+ // Was a header found?
+ if (count($header) != 4) {
+ // Throw an exception
+ throw new InvalidArrayCountException(array($this, "header", count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+ }
+
+ // Decode all from Base64
+ $readData = @base64_decode($readData);
+
+ // Does the size match?
+ if (strlen($readData) != $header[2]) {
+ // Size did not match
+ throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
+ }
+
+ // Validate the decoded data with the final MD5 hash
+ if (md5($readData) != $header[3]) {
+ // MD5 hash did not match!
+ throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+ }
+
+ // Return all in an array
+ return array(
+ 'header' => $header,
+ 'data' => $readData
+ );
+ }
+}
+
+// [EOF]
+?>
* A class for directory reading and getting its contents
*
* @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 FrameworkDirectoryPointer extends BaseFrameworkSystem {
/**
private $dirPointer = null;
/**
- * Private constructor
+ * Protected constructor
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Verzeichnis-Handler");
+ $this->setObjectDescription("Helper for handling directories");
// Create unique ID
$this->createUniqueID();
* A class for reading 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 FrameworkFileInputPointer extends BaseFrameworkSystem {
/**
private $filePointer = null;
/**
- * Private constructor
+ * Protected constructor
*/
- private final function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Dateiausgabe-Handler");
+ $this->setObjectDescription("Handler for reading from files");
// Create unique ID
$this->createUniqueID();
* A class for writing 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 FrameworkFileOutputPointer extends BaseFrameworkSystem {
/**
private $filePointer = null;
/**
- * Private constructor
+ * Protected constructor
*/
- private final function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Dateiausgabe-Handler");
+ $this->setObjectDescription("Handler for writing to files");
// Create unique ID
$this->createUniqueID();
* application and whole framework
*
* @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 LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
/**
private static $thisInstance = null;
/**
- * 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("Sprachsystem");
+ $this->setObjectDescription("Language sub-system");
// Create unique ID number
$this->createUniqueID();
/**
* Creates an instance of the class LanguageSystem and prepares it for usage
*
- * @param $basePath The local base path for all language strings
+ * @param $basePath The local base path for all language strings
* @return $langInstance An instance of LanguageSystem
* @throws LanguagePathIsEmptyException If the provided $basePath is empty
* @throws InvalidLanguagePathStringException If $basePath is no string
$langInstance->initLanguageStrings();
// Set language code from default config
- $langInstance->setLanguageCode($langInstance->getConfigInstance()->readConfig("default_lang"));
+ $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang'));
// Remember this instance
self::$thisInstance = $langInstance;
}
/**
- * Initialize the array-object for all later language strings
+ * Setter for base path
*
+ * @param $basePath The local base path for all templates
* @return void
*/
- public function initLanguageStrings () {
- $this->langStrings = new FrameworkArrayObject();
+ protected final function setBasePath ($basePath) {
+ // And set it
+ $this->basePath = (string) $basePath;
}
/**
- * Setter for base path
+ * Setter for language code
*
- * @param $basePath The local base path for all templates
+ * @param $langCode The language code for the current application
* @return void
*/
- public final function setBasePath ($basePath) {
+ protected final function setLanguageCode ($langCode) {
// Cast it
- $basePath = (string) $basePath;
+ $langCode = (string) $langCode;
- // And set it
- $this->basePath = $basePath;
+ // And set it (only 2 chars)
+ $this->langCode = substr($langCode, 0, 2);
+ }
+
+ /**
+ * Initialize the array-object for all later language strings
+ *
+ * @return void
+ */
+ public function initLanguageStrings () {
+ $this->langStrings = new FrameworkArrayObject();
}
/**
}
/**
- * Setter for language code
+ * Get the plain message from the cache variable for the given message id
*
- * @param $langCode The language code for the current application
- * @return void
+ * @param $messageId The message id we shall find in the cache variable
+ * @return $messageText The plain message text
*/
- public final function setLanguageCode ($langCode) {
- // Cast it
- $langCode = (string) $langCode;
+ public function getMessage ($messageId) {
+ // Default is missing message text
+ $messageText = sprintf("!%s!",
+ $messageId
+ );
+
+ // Try to look it up in the cache variable
+ if ($this->langStrings->offsetExists($messageId)) {
+ // Return the message string
+ $messageText = $this->langStrings->offsetGet($messageId);
+ }
- // And set it (only 2 chars)
- $this->langCode = substr($langCode, 0, 2);
+ // Return the text
+ return $messageText;
}
}
* for console output
*
* @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 ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
/**
private $vars = array();
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Console-Ausgabe-Handler");
+ $this->setObjectDescription("Console output class");
// Create an unique ID
$this->createUniqueID();
*/
public final static function getInstance() {
if (is_null(self::$consoleInstance)) {
- $contentType = FrameworkConfiguration::getInstance()->readConfig("web_content_type");
+ $contentType = FrameworkConfiguration::getInstance()->readConfig('web_content_type');
self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
}
return self::$consoleInstance;
* browser
*
* @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 WebOutput extends BaseFrameworkSystem implements OutputStreamer {
/**
private static $webInstance = null;
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Web-Ausgabe-Handler");
+ $this->setObjectDescription("Class for web output e.g. XHTML code");
// Create an unique ID
$this->createUniqueID();
*/
private $requestData = array();
+ /**
+ * Wether this request is valid and can be further processed. The default is
+ * valid so make sure your intercepting filters sets this attribute to false
+ * when they need to intercept the data flow.
+ */
+ private $requestIsValid = true;
+
/**
* Protected constructor
*
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("HTTP-Anfrage");
+ $this->setObjectDescription("HTTP request");
// Create unique ID number
$this->createUniqueID();
// Return the value
return $headerValue;
}
+
+ /**
+ * Getter for request method. This getter might be useful for security filters
+ *
+ * @return $requestMethod Used request method
+ */
+ public final function getRequestMethod () {
+ return $_SERVER['REQUEST_METHOD'];
+ }
+
+ /**
+ * Sets wether the request was valid (default: true)
+ *
+ * @param $isValid Wether the request is valid
+ * @return void
+ */
+ public final function requestIsValid ($isValid = true) {
+ $this->requestIsValid = (bool) $isValid;
+ }
+
+ /**
+ * Returns wether this request is valid
+ *
+ * @return $requestIsValid Wether this request is valid
+ */
+ public final function isRequestValid () {
+ return $this->requestIsValid;
+ }
}
// [EOF]
private $commandPrefix = "";
/**
- * Private constructor
+ * A controller instance
+ */
+ private $controllerInstance = null;
+
+ /**
+ * Protected constructor
*
* @return void
*/
parent::__construct($class);
// Clean up a little
+ $this->removeNumberFormaters();
$this->removeSystemArray();
}
+ /**
+ * Setter for controller instance (this surely breaks a bit the MVC patterm)
+ *
+ * @param $controllerInstance An instance of the controller
+ * @return void
+ */
+ public final function setControllerInstance (Controller $controllerInstance) {
+ $this->controllerInstance = $controllerInstance;
+ }
+
+ /**
+ * Getter for controller instance (this surely breaks a bit the MVC patterm)
+ *
+ * @return $controllerInstance An instance of the controller
+ */
+ public final function getControllerInstance () {
+ return $this->controllerInstance;
+ }
+
/**
* Setter for command name
*
// Now, let us create the full name of the command class
$class = sprintf("%s%sCommand",
$this->commandPrefix,
- ucfirst(strtolower($commandName))
+ $this->convertToClassName($commandName)
);
// Is this class already loaded?
$isValid = true;
}
+ // Debug output
+ //echo "<strong>----- ".__METHOD__." -----</strong><br />\n";
+ //print($class."<pre>");
+ //debug_print_backtrace();
+ //var_dump($isValid);
+ //print("</pre>");
+
// Set command name
$this->setCommandName($commandName);
private $lastCommandInstance = "";
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Lokaler Kommandoauflöser");
+ $this->setObjectDescription("Resolver for local web commands");
// 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 $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 createWebCommandResolver ($defaultCommand, ManageableApplication $appInstance) {
+ public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) {
// Create the new instance
$resolverInstance = new WebCommandResolver();
- // Is the variable $defaultCommand set and the command is valid?
- if (empty($defaultCommand)) {
+ // Is the variable $commandName set and the command is valid?
+ if (empty($commandName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'defaultCommand'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif (!$resolverInstance->isCommandValid($defaultCommand)) {
+ } elseif (!$resolverInstance->isCommandValid($commandName)) {
// Invalid command found
- throw new InvalidCommandException(array($resolverInstance, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
+ throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
// Set the application instance
// 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"));
+ $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");
+ if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_command');
// Check if the command is valid
if (!$this->isCommandValid($commandName)) {
return $commandInstance;
}
+ /**
+ * Resolves the command by its direct name and returns an instance of its class
+ *
+ * @param $commandName The direct command name we shall resolve
+ * @return $commandInstance An instance of the command class
+ * @throws InvalidCommandException Thrown if $commandName is invalid
+ */
+ public function resolveCommand ($commandName) {
+ // Initiate the instance variable
+ $commandInstance = null;
+
+ // 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);
+
+ // Return the instance
+ return $commandInstance;
+ }
+
/**
* "Loads" a given command and instances it if not yet cached
*
*/
private function loadCommand ($commandName) {
// Cache default command
- $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+ $defaultCommand = $this->getConfigInstance()->readConfig('default_command');
// Init command instance
$commandInstance = null;
// Create command class name
- $class = sprintf("Web%sCommand",
- ucfirst(strtolower($commandName))
+ $className = sprintf("Web%sCommand",
+ $this->convertToClassName($commandName)
);
// Is this class loaded?
- if (!class_exists($class)) {
+ if (!class_exists($className)) {
// Class not found, so try the default one or throw exception
if ($commandName != $defaultCommand) {
// Try the default command
// Initiate the command
$eval = sprintf("\$commandInstance = %s::create%s(\$this);",
- $class,
- $class
+ $className,
+ $className
);
// Run the command
*/
class WebControllerResolver extends BaseResolver implements ControllerResolver {
/**
- * Last successfull resolved controller
+ * Last successfull resolved controller (name)
*/
private $lastControllerName = "";
/**
- * Private constructor
+ * Last successfull resolved controller (instance)
+ */
+ private $lastControllerInstance = null;
+
+ /**
+ * Protected constructor
*
* @return void
*/
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("");
+ $this->setObjectDescription("Resolver for local web controllers");
// Create unique ID number
$this->createUniqueID();
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
-
// Set prefix to "Web"
$this->setCommandPrefix("Web");
}
* @throws InvalidControllerInstanceException Thrown if $commandInstance
* is invalid
*/
- public function resolveDefaultController () {
+ public function resolveCommandController () {
// Init variables
$commandName = "";
$controllerInstance = null;
throw new InvalidControllerInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_CONTROLLER);
}
- // Set last command
- $this->lastCommandInstance = $controllerInstance;
+ // Set last controller
+ $this->lastControllerInstance = $controllerInstance;
} catch (MissingArrayElementsException $e) {
// Just catch it here...
}
* controller class is missing (bad!)
*/
private function loadController ($commandName) {
+ // Debug message
+ //print("<strong>----- ".__METHOD__." -----</strong><pre>");
+ //debug_print_backtrace();
+ //print("</pre>");
+ //
+
// Cache default command
- $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+ $defaultCommand = $this->getConfigInstance()->readConfig('default_command');
// Init controller instance
$controllerInstance = null;
if ($commandName != $defaultCommand) {
// Create controller class name
$class = sprintf("Web%sController",
- ucfirst(strtolower($commandName))
+ $this->convertToClassName($commandName)
);
- } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
+ } elseif ($this->getConfigInstance()->readConfig('home_with_news') == "Y") {
// Yes, display news in home then set default controller with news
$class = "WebDefaultNewsController";
+ } else {
+ // No nes at "home" page
+ $class = "WebDefaultController";
}
// Is this class loaded?
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The extended headers are taken from phpMyAdmin setup tool, written by
+ * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
*/
class HttpResponse extends BaseFrameworkSystem implements Responseable {
/**
*/
private $templateEngine = null;
+ /**
+ * Fatal resolved messages from filters and so on
+ */
+ private $fatalMessages = array();
+
/**
* Protected constructor
*
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("HTTP-Antwort");
+ $this->setObjectDescription("HTTP response");
// Create unique ID number
$this->createUniqueID();
// Get a new instance
$responseInstance = new HttpResponse();
+ // Set the application instance
+ $responseInstance->setApplicationInstance($appInstance);
+
// Initialize the template engine here
$responseInstance->initTemplateEngine($appInstance);
$this->responseHeaders[$name] = $value;
}
+ /**
+ * Reset the header array
+ *
+ * @return void
+ */
+ public final function resetResponseHeaders () {
+ $this->responseHeaders = array();
+ }
+
/**
* "Writes" data to the response body
*
$this->responseBody .= $output;
}
+ /**
+ * Sets the response body to something new
+ *
+ * @param $output Output we shall sent in the HTTP response
+ * @return void
+ */
+ public function setReponseBody ($output) {
+ $this->responseBody = $output;
+ }
+
/**
* Flushs the cached HTTP response to the outer world
*
throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
} elseif (!headers_sent()) {
// Send headers out
- header("HTTP/1.0 {$this->responseStatus}");
+ header("HTTP/1.1 {$this->responseStatus}");
+
+ // Used later
+ $now = gmdate('D, d M Y H:i:s') . ' GMT';
+
+ // General header for no caching
+ $this->addHeader('Expired', $now); // rfc2616 - Section 14.21
+ $this->addHeader('Last-Modified', $now);
+ $this->addHeader('Cache-Control:', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+ $this->addHeader('Pragma:', 'no-cache'); // HTTP/1.0
+
+ // Define the charset to be used
+ $this->addHeader('Content-Type:', 'text/html; charset=utf-8');
+
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();
+ // Are there some error messages?
+ if (count($this->fatalMessages) == 0) {
+ // Flush the output to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ } else {
+ // Display all error messages
+ $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
+
+ // Send the error messages out to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ }
+
+ // Clear response header and body
+ $this->setReponseBody("");
+ $this->resetResponseHeaders();
}
/**
public final function getTemplateEngine () {
return $this->templateEngine;
}
+
+ /**
+ * Adds a fatal message id to the response. The added messages can then be
+ * processed and outputed to the world
+ *
+ * @param $messageId The message id we shall add
+ * @return void
+ */
+ public final function addFatalMessage ($messageId) {
+ // Adds the resolved message id to the fatal message list
+ $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
+ }
}
// [EOF]
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Template-Engine");
+ $this->setObjectDescription("Web template engine");
// Create unique ID number
$this->createUniqueID();
*
* @param $basePath The local base path for all templates
* @param $langInstance An instance of LanguageSystem (default)
- * @param $ioInstance An instance of FileIOHandler (default, middleware!)
+ * @param $ioInstance An instance of FileIoHandler (default, middleware!)
* @return $tplInstance An instance of TemplateEngine
* @throws BasePathIsEmptyException If the provided $basePath is empty
* @throws InvalidBasePathStringException If $basePath is no string
* @throws BasePathReadProtectedException If $basePath is
* read-protected
*/
- public final static function createTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIOHandler $ioInstance) {
+ public final static function createTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) {
// Get a new instance
$tplInstance = new TemplateEngine();
}
// Get configuration instance
- $cfgInstance = $tplInstance->getConfigInstance();
+ $cfgInstance = FrameworkConfiguration::getInstance();
// Set the base path
$tplInstance->setBasePath($basePath);
// Set the language and IO instances
$tplInstance->setLanguageInstance($langInstance);
- $tplInstance->setFileIOInstance($ioInstance);
+ $tplInstance->setFileIoInstance($ioInstance);
// Set template extensions
- $tplInstance->setRawTemplateExtension($cfgInstance->readConfig("raw_template_extension"));
- $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig("code_template_extension"));
+ $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension'));
+ $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension'));
// Absolute output path for compiled templates
- $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig("compile_output_path"));
+ $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path'));
// Return the prepared instance
return $tplInstance;
$ext = $this->getRawTemplateExtension();
// If we shall load a code-template we need to switch the file extension
- if ($this->getTemplateType() == $this->getConfigInstance()->readConfig("code_template_type")) {
+ if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) {
// Switch over to the code-template extension
$ext = $this->getCodeTemplateExtension();
}
*/
private function loadRawTemplateData ($fqfn) {
// Get a input/output instance from the middleware
- $ioInstance = $this->getFileIOInstance();
+ $ioInstance = $this->getFileIoInstance();
// Validate the instance
if (is_null($ioInstance)) {
*
* @param $rawData The raw template data we shall analyze
* @return void
- * @throws InvalidTemplateVariableNameException If a variable name
- * in a template is
- * invalid
*/
private function extractVariablesFromRawData ($rawData) {
// Cast to string
if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
// Initialize all missing variables
foreach ($variableMatches[3] as $key=>$var) {
- // Is the variable name valid?
- if (($variableMatches[1][$key] != $this->getConfigInstance()->readConfig("tpl_valid_var")) && ($variableMatches[1][$key] != "config")) {
- // Invalid variable name
- throw new InvalidTemplateVariableNameException(array($this, $this->getLastTemplate(), $variableMatches[1][$key], $this->getConfigInstance()), self::EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR);
- }
-
// Try to assign it, empty strings are being ignored
$this->assignTemplateVariable($variableMatches[1][$key], $var);
}
// RECURSIVE PROTECTION! BE CAREFUL HERE!
if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
- // Then try to search for code-templates first
- try {
- // Load the code template and remember it's contents
- $this->loadCodeTemplate($template);
- $this->loadedRawData[$template] = $this->getRawTemplateData();
+ // Template not found, but maybe variable assigned?
+ if ($this->isVariableAlreadySet($template) !== false) {
+ // Use that content here
+ $this->loadedRawData[$template] = $this->readVariable($template);
- // Remember this template for recursion detection
- // RECURSIVE PROTECTION!
+ // Recursive protection:
$this->loadedTemplates[] = $template;
- } catch (FilePointerNotOpenedException $e) {
- // Template not found, but maybe variable assigned?
- if ($this->isVariableAlreadySet($template) !== false) {
- // Use that content here
- $this->loadedRawData[$template] = $this->readVariable($template);
-
- // Recursive protection:
+ } else {
+ // Then try to search for code-templates
+ try {
+ // Load the code template and remember it's contents
+ $this->loadCodeTemplate($template);
+ $this->loadedRawData[$template] = $this->getRawTemplateData();
+
+ // Remember this template for recursion detection
+ // RECURSIVE PROTECTION!
$this->loadedTemplates[] = $template;
- } else {
+ } catch (FilePointerNotOpenedException $e) {
// Even this is not done... :/
$this->rawTemplates[] = $template;
}
*/
public final function loadWebTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("web_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('web_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function loadEmailTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("email_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('email_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function loadCodeTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("code_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('code_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function compileVariables () {
// Initialize the $content array
- $validVar = $this->getConfigInstance()->readConfig("tpl_valid_var");
+ $validVar = $this->getConfigInstance()->readConfig('tpl_valid_var');
$dummy = array();
// Iterate through all variables
unset($idx);
unset($currVariable);
- // Finalize the compilation of template variables
- $this->finalizeVariableCompilation();
+ // Run the compilation twice to get content from helper classes in
+ $cnt = 0;
+ while ($cnt < 3) {
+ // Finalize the compilation of template variables
+ $this->finalizeVariableCompilation();
- // Prepare the eval() command for comiling the template
- $eval = sprintf("\$result = \"%s\";",
- addslashes($this->getRawTemplateData())
- );
+ // Prepare the eval() command for comiling the template
+ $eval = sprintf("\$result = \"%s\";",
+ addslashes($this->getRawTemplateData())
+ );
- // Debug message
- 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)
- ));
+ // This loop does remove the backslashes (\) in PHP parameters
+ // @TODO Make this some nicer...
+ while (strpos($eval, "<?") !== false) {
+ // Get left part before "<?"
+ $evalLeft = substr($eval, 0, strpos($eval, "<?"));
+
+ // Get all from right of "<?"
+ $evalRight = substr($eval, (strpos($eval, "<?") + 2));
+
+ // Is this a full PHP tag?
+ if (substr(strtolower($evalRight), 0, 3) == "php") {
+ // Remove "php" string from full PHP tag
+ $evalRight = substr($evalRight, 3);
+ } // END - if
+
+ // Cut middle part out and remove escapes
+ $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, "?>")));
+ $evalMiddle = stripslashes($evalMiddle);
+
+ // Remove the middle part from right one
+ $evalRight = substr($evalRight, (strpos($evalRight, "?>") + 2));
+
+ // And put all together
+ $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight);
+ } // END - while
+
+ // Prepare PHP code for eval() command
+ $eval = str_replace(
+ "<%php", "\";",
+ str_replace(
+ "%>", "\$result .= \"", $eval
+ )
+ );
+
+ // Debug message
+ 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);
- // Run the constructed command. This will "compile" all variables in
- eval($eval);
+ // Set raw template data
+ $this->setRawTemplateData($result);
+ $cnt++;
+ }
// Set the new content
$this->setCompiledData($result);
*
* @return void
* @throws UnexpectedTemplateTypeException If the template type is
- * not "code"
+ * not "code"
* @throws InvalidArrayCountException If an unexpected array
- * count has been found
+ * count has been found
*/
public final function compileTemplate () {
// We will only work with template type "code" from configuration
- if ($this->getTemplateType() != $this->getConfigInstance()->readConfig("code_template_type")) {
+ 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);
+ 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.
// Get the content and set it in the response class
$responseInstance->writeToBody($this->getCompiledData());
}
+
+ /**
+ * Assigns all the application data with template variables
+ *
+ * @param $appInstance A manageable application instance
+ * @return void
+ */
+ public function assignApplicationData (ManageableApplication $appInstance) {
+ // Get long name and assign it
+ $this->assignVariable("app_full_name" , $appInstance->getAppName());
+
+ // Get short name and assign it
+ $this->assignVariable("app_short_name", $appInstance->getAppShortName());
+
+ // Get version number and assign it
+ $this->assignVariable("app_version" , $appInstance->getAppVersion());
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A generic class for handling users
+ *
+ * @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 User extends BaseFrameworkSystem implements ManageableUser {
+ /**
+ * Username
+ */
+ private $username = "";
+
+ // Exceptions
+ const EXCEPTION_USERNAME_NOT_FOUND = 0xd00;
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct ($class = "") {
+ // Is the class name empty? Then this is not a specialized user class
+ if (empty($class)) $class = __CLASS__;
+
+ // Call parent constructor
+ parent::__construct($class);
+
+ // Set part description
+ $this->setObjectDescription("Generic user class");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this user class by a provided username. This
+ * factory method will check if the username is already taken and if not
+ * so it will throw an exception.
+ *
+ * @param $username Username we need a class instance for
+ * @return $userInstance An instance of this user class
+ * @throws UsernameMissingException If the username does not exist
+ */
+ public final static function createUserByUsername ($userName) {
+ // Get a new instance
+ $userInstance = new User();
+
+ // Set the username
+ $userInstance->setUsername($userName);
+
+ // Check if the username exists
+ if (!$userInstance->ifUsernameExists()) {
+ // Throw an exception here
+ throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
+ }
+
+ // Return the instance
+ return $userInstance;
+ }
+
+ /**
+ * Setter for username
+ *
+ * @param $userName The username to set
+ * @return void
+ */
+ protected final function setUsername ($userName) {
+ $this->userNane = $userName;
+ }
+
+ /**
+ * Getter for username
+ *
+ * @return $userName The username to set
+ */
+ public final function getUsername () {
+ return $this->userNane;
+ }
+}
+
+// [EOF]
+?>
*
* @return void
*/
- private function __construct ($class) {
+ protected function __construct ($class) {
// Call parent constructor
- parent::constructor($class);
+ parent::__construct($class);
// Clean up a little
$this->removeNumberFormaters();
}
-
- /**
- * Public constructor
- *
- * @return void
- */
- public function constructor ($class) {
- // Just call the private constructor
- $this->__construct($class);
- }
}
// [EOF]
* Middleware class for selecting the right compressor channel
*
* @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 CompressorChannel extends BaseMiddleware {
// Output handler instance
private $compressor = null;
// Public constructor
- private function __construct () {
+ protected function __construct () {
// Call parent constructor!
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Komprimierungshandler");
// Read all directories but no sub directories
while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess"))) {
// Is this a class file?
- if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == $cInstance->getConfigInstance()->readConfig("php_extension"))) {
+ if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig('php_extension'))) {
// Get the compressor's name. That's why you must name
// your files like your classes and also that's why you
// must keep on class in one file.
private static $thisInstance = null;
// Private constructor
- private final function __construct() {
+ protected function __construct() {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Datenbank-Mittelschicht");
*
* @return void
*/
- private final function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Debug-Ausgabe-Handler");
*
* @return void
*/
- private function __construct () {
+ protected function __construct () {
// Call parent constructor
- parent::constructor(__CLASS__);
+ parent::__construct(__CLASS__);
// Set description
$this->setObjectDescription("Datei-Ein-/Ausgabe-Handler");
--- /dev/null
+<?php
+/**
+ * This is a file IO handler. It handles reading from and writing to files.
+ * Missing paths in writing process will be automatically created.
+ *
+ * @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 FileIoHandler extends BaseMiddleware {
+ /**
+ * The *real* file input class we shall use for reading data
+ */
+ private $inputStream = null;
+
+ /**
+ * The *real* file output class we shall use for reading data
+ */
+ private $outputStream = null;
+
+ /**
+ * An instance of this class
+ */
+ private static $thisInstance = null;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set description
+ $this->setObjectDescription("Datei-Ein-/Ausgabe-Handler");
+
+ // Create an unique ID
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+
+ // Set own instance
+ self::$thisInstance = $this;
+ }
+
+ /**
+ * Creates an instance of this class and prepares the IO system. This is
+ * being done by setting the default file IO class
+ *
+ * @return $ioInstance A prepared instance of FilIOHandler
+ */
+ public final static function createFileIoHandler () {
+ // Get instance
+ $ioHandler = new FileIoHandler();
+
+ // Set the *real* file IO instances (both the same)
+ $ioHandler->setInputStream(FileIoStream::createFileIoStream());
+ $ioHandler->setOutputStream(FileIoStream::createFileIoStream());
+
+ // Return instance
+ return $ioHandler;
+ }
+
+ /**
+ * Getter for an instance of this class
+ *
+ * @return $thisInstance An instance of this class
+ */
+ public final static function getInstance () {
+ return self::$thisInstance;
+ }
+
+ /**
+ * Setter for the *real* file input instance
+ *
+ * @param $inputStream The *real* file-input class
+ */
+ public final function setInputStream (FileInputStreamer $inputStream) {
+ $this->inputStream = $inputStream;
+ }
+
+ /**
+ * Getter for the *real* file input instance
+ *
+ * @return $inputStream The *real* file-input class
+ */
+ public final function getInputStream () {
+ return $this->inputStream;
+ }
+
+ /**
+ * Setter for the *real* file output instance
+ *
+ * @param $outputStream The *real* file-output class
+ */
+ public final function setOutputStream (FileOutputStreamer $outputStream) {
+ $this->outputStream = $outputStream;
+ }
+
+ /**
+ * Getter for the *real* file output instance
+ *
+ * @return $outputStream The *real* file-output class
+ */
+ public final function getOutputStream () {
+ return $this->outputStream;
+ }
+
+ /**
+ * Saves a file with data by using the current output stream
+ *
+ * @see FileOutputStreamer
+ */
+ public function saveFile ($fileName, $dataArray) {
+ // Get output stream
+ $outInstance = $this->getOutputStream();
+
+ // Is it a valid stream?
+ if (is_null($outInstance)) {
+ // No class returned
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } elseif (!is_object($outInstance)) {
+ // Not an object! ;-(
+ throw new NoObjectException($outInstance, self::EXCEPTION_IS_NO_OBJECT);
+ } elseif (!method_exists($outInstance, 'saveFile')) {
+ // Nope, so throw exception
+ throw new MissingMethodException(array($outInstance, 'saveFile'), self::EXCEPTION_MISSING_METHOD);
+ }
+
+ // Send the fileName and dataArray to the output handler
+ $outInstance->saveFile($fileName, $dataArray);
+ }
+
+ /** Loads data from a file over the input handler
+ *
+ * @see FileInputStreamer
+ */
+ public function loadFileContents ($fqfn) {
+ // Initialize the array
+ $array = array();
+
+ // Get output stream
+ $inInstance = $this->getInputStream();
+
+ // Is it a valid stream?
+ if (is_null($inInstance)) {
+ // No class returned
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } elseif (!is_object($inInstance)) {
+ // Not an object! ;-(
+ throw new NoObjectException($inInstance, self::EXCEPTION_IS_NO_OBJECT);
+ } elseif (!method_exists($inInstance, 'loadFileContents')) {
+ // Nope, so throw exception
+ throw new MissingMethodException(array($inInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD);
+ }
+
+ // Read from the input handler
+ return $inInstance->loadFileContents($fqfn);
+ }
+}
+
+// [EOF]
+?>
* configuration entries there.
*
* @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/>.
*/
// Load the class from inc/config direktory
-@require_once(dirname(__FILE__) . "/config/class_FrameworkConfiguration.php");
+@require_once(dirname(__FILE__) . '/config/class_FrameworkConfiguration.php');
// Get a new configuration instance
$cfg = FrameworkConfiguration::createFrameworkConfiguration();
// CFG: SERVER-PATH
-$cfg->definePath(dirname(dirname(__FILE__)) . "/"); // DON'T MISS THE TRAILING SLASH!!!
+$cfg->definePath(dirname(dirname(__FILE__)) . '/'); // DON'T MISS THE TRAILING SLASH!!!
// CFG: DATABASE-TYPE
-$cfg->defineDatabaseType("local");
+$cfg->defineDatabaseType('local');
+
+// CFG: LOCAL-DB-PATH
+$cfg->setConfigEntry('local_db_path', 'db/');
// CFG: TIME-ZONE
$cfg->setDefaultTimezone("Europe/Berlin");
$cfg->setMagicQuotesRuntime(false);
// CFG: PHP-SCRIPT-EXTENSION
-$cfg->setConfigEntry("php_extension", ".php");
+$cfg->setConfigEntry('php_extension', ".php");
// CFG: CLASS-PREFIX
-$cfg->setConfigEntry("class_prefix", "class_");
+$cfg->setConfigEntry('class_prefix', "class_");
// CFG: CLASS-SUFFIX
-$cfg->setConfigEntry("class_suffix", ".php");
+$cfg->setConfigEntry('class_suffix', ".php");
// CFG: RAW-TEMPLATE-EXTENSION
-$cfg->setConfigEntry("raw_template_extension", ".tpl");
+$cfg->setConfigEntry('raw_template_extension', ".tpl");
// CFG: CODE-TEMPLATE-EXTENSION
-$cfg->setConfigEntry("code_template_extension", ".ctp");
+$cfg->setConfigEntry('code_template_extension', ".ctp");
// CFG: SELECTOR-GET
-$cfg->setConfigEntry("app_selector_get", "app");
+$cfg->setConfigEntry('app_selector_get', "app");
+
+// CFG: SELECTOR-PATH
+$cfg->setConfigEntry('selector_path', "selector");
// CFG: APPLICATION-HELPER
-$cfg->setConfigEntry("app_helper_class", "ApplicationHelper");
+$cfg->setConfigEntry('app_helper_class', "ApplicationHelper");
-// CFG: SELECTOR-PATH
-$cfg->setConfigEntry("selector_path", "selector");
+// CFG: LAUNCH-METHOD
+$cfg->setConfigEntry('entry_method', "entryPoint");
// CFG: TEMPLATE-BASE-PATH
-$cfg->setConfigEntry("tpl_base_path", "templates/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('tpl_base_path', "templates/"); // DON'T MISS THE TRAILING SLASH!
// CFG: LANGUAGE-BASE-PATH
-$cfg->setConfigEntry("lang_base_path", "inc/language/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('lang_base_path', "inc/language/"); // DON'T MISS THE TRAILING SLASH!
// CFG: COMPRESSOR-BASE-PATH
-$cfg->setConfigEntry("compressor_base_path", "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
// CFG: APPLICATION-PATH
-$cfg->setConfigEntry("application_path", "application");
+$cfg->setConfigEntry('application_path', "application");
// CFG: COMPILE-OUTPUT-PATH
-$cfg->setConfigEntry("compile_output_path", "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
// CFG: TEMPLATE-ENGINE
-$cfg->setConfigEntry("tpl_engine", "TemplateEngine");
+$cfg->setConfigEntry('tpl_engine', "TemplateEngine");
// CFG: DEBUG-ENGINE
-$cfg->setConfigEntry("debug_engine", "DebugWebOutput");
+$cfg->setConfigEntry('debug_engine', "DebugWebOutput");
// CFG: DEFAULT-LANGUAGE
-$cfg->setConfigEntry("default_lang", "de"); // A two-char language string: de for german, en for english and so on
+$cfg->setConfigEntry('default_lang', "de"); // A two-char language string: de for german, en for english and so on
// CFG: WEB-TEMPLATE-TYPE
-$cfg->setConfigEntry("web_template_type", "html");
+$cfg->setConfigEntry('web_template_type', "html");
// CFG: EMAIL-TEMPLATE-TYPE
-$cfg->setConfigEntry("email_template_type", "emails");
+$cfg->setConfigEntry('email_template_type', "emails");
// CFG: CODE-TEMPLATE-TYPE
-$cfg->setConfigEntry("code_template_type", "code");
+$cfg->setConfigEntry('code_template_type', "code");
// CFG: WEB-ENGINE
-$cfg->setConfigEntry("web_engine", "WebOutput");
+$cfg->setConfigEntry('web_engine', "WebOutput");
// CFG: SELECTOR-TEMPLATE-PREFIX
-$cfg->setConfigEntry("tpl_selector_prefix", "selector");
+$cfg->setConfigEntry('tpl_selector_prefix', "selector");
// CFG: WEB-CONTENT-TYPE
-$cfg->setConfigEntry("web_content_type", "text/html");
+$cfg->setConfigEntry('web_content_type', "text/html");
// CFG: VALID-TEMPLATE-VARIABLE
-$cfg->setConfigEntry("tpl_valid_var", "content");
+$cfg->setConfigEntry('tpl_valid_var', "content");
// CFG: META-AUTHOR
-$cfg->setConfigEntry("meta_author", "Roland Häder");
+$cfg->setConfigEntry('meta_author', "Roland Häder");
// CFG: META-PUBLISHER
-$cfg->setConfigEntry("meta_publisher", "Roland Häder");
+$cfg->setConfigEntry('meta_publisher', "Roland Häder");
// CFG: META-KEYWORDS
-$cfg->setConfigEntry("meta_keywords", "test,test,test");
+$cfg->setConfigEntry('meta_keywords', "test,test,test");
// CFG: META-DESCRIPTION
-$cfg->setConfigEntry("meta_description", "A lame description for an application framework");
-
-// CFG: LAUNCH-METHOD
-$cfg->setConfigEntry("entry_method", "entryPoint");
+$cfg->setConfigEntry('meta_description', "A lame description for an application framework");
// CFG: SELECTOR-MAIN-TEMPLATE
-$cfg->setConfigEntry("selector_main_tpl", "selector_main");
+$cfg->setConfigEntry('selector_main_tpl', "selector_main");
// CFG: SELECTOR-APPS-TEMPLATE
-$cfg->setConfigEntry("selector_apps_tpl", "selector_apps");
+$cfg->setConfigEntry('selector_apps_tpl', "selector_apps");
// CFG: SELECTOR-NAME
-$cfg->setConfigEntry("selector_name", "selector");
+$cfg->setConfigEntry('selector_name', "selector");
// CFG: DEFAULT-APPLICATION
-$cfg->setConfigEntry("default_application", "selector");
+$cfg->setConfigEntry('default_application', "selector");
// CFG: VERBOSE-LEVEL
-$cfg->setConfigEntry("verbose_level", 0);
+$cfg->setConfigEntry('verbose_level', 0);
// [EOF]
?>
*
* @see ClassLoader
* @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 FrameworkConfiguration {
/**
const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0xc01;
/**
- * Private constructor
+ * Protected constructor
*/
- private function __construct () {
+ protected function __construct () {
// Empty for now
}
$cfg = FrameworkConfiguration::getInstance();
// CFG: HUB-LISTEN-ADDR
-$cfg->setConfigEntry("hub_listen_addr", "0.0.0.0");
+$cfg->setConfigEntry('hub_listen_addr', "0.0.0.0");
// CFG: HUB-LISTEN-PORT (zero = auto-choose)
-$cfg->setConfigEntry("hub_listen_port", 9060);
+$cfg->setConfigEntry('hub_listen_port', 9060);
// CFG: HUB-MAX-AUTH-TRIES
-$cfg->setConfigEntry("hub_max_auth_tries", 3);
+$cfg->setConfigEntry('hub_max_auth_tries', 3);
// CFG: HUB-MSG-AUTH-TRIES
-$cfg->setConfigEntry("hub_msg_auth_tries", "AUTH_MAX_TRIES");
+$cfg->setConfigEntry('hub_msg_auth_tries', "AUTH_MAX_TRIES");
// CFG: HUB-MSG-SPOOFING
-$cfg->setConfigEntry("hub_msg_spoofing", "SPOOFING");
+$cfg->setConfigEntry('hub_msg_spoofing', "SPOOFING");
// CFG: HUB-MSG-AUTH-REPLY
-$cfg->setConfigEntry("hub_msg_auth_reply_timeout", "TIMEOUT_AUTH");
+$cfg->setConfigEntry('hub_msg_auth_reply_timeout', "TIMEOUT_AUTH");
// CFG: HUB-MSG-BYE
-$cfg->setConfigEntry("hub_msg_bye", "BYE");
+$cfg->setConfigEntry('hub_msg_bye', "BYE");
// CFG: HUB-MASTER-IP
-$cfg->setConfigEntry("hub_master_ip", "192.168.1.17");
+$cfg->setConfigEntry('hub_master_ip', "192.168.1.17");
// CFG: HUB-MASTER-PORT
-$cfg->setConfigEntry("hub_master_port", 9060);
+$cfg->setConfigEntry('hub_master_port', 9060);
// CFG: HUB-AUTH-REQUEST
-$cfg->setConfigEntry("hub_auth_request", "AUTH");
+$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->setConfigEntry('hub_auth_request_timeout', 5);
// CFG: HUB-PEER-HELLO
-$cfg->setConfigEntry("hub_peer_hello", "HELLO");
+$cfg->setConfigEntry('hub_peer_hello', "HELLO");
// CFG: HUB-HELLO-REPLY
-$cfg->setConfigEntry("hub_hello_reply", "ELHO");
+$cfg->setConfigEntry('hub_hello_reply', "ELHO");
// CFG: HUB-HELLO-TIMEOUT
-$cfg->setConfigEntry("hub_hello_timeout", 30);
+$cfg->setConfigEntry('hub_hello_timeout', 30);
// CFG: HUB-HELLO-RETRIES
-$cfg->setConfigEntry("hub_hello_retires", 3);
+$cfg->setConfigEntry('hub_hello_retires', 3);
// CFG: HUB-PEER-PING
-$cfg->setConfigEntry("hub_peer_ping", "PING");
+$cfg->setConfigEntry('hub_peer_ping', "PING");
// CFG: HUB-PING-REPLY
-$cfg->setConfigEntry("hub_ping_reply", "PONG");
+$cfg->setConfigEntry('hub_ping_reply', "PONG");
// CFG: HUB-PING-TIMEOUT
-$cfg->setConfigEntry("hub_ping_timeout", 10);
+$cfg->setConfigEntry('hub_ping_timeout', 10);
// CFG: HUB-PING-MAXDROPS
-$cfg->setConfigEntry("hub_ping_maxdrops", 3);
+$cfg->setConfigEntry('hub_ping_maxdrops', 3);
// CFG: HUB-PEER-MISS-PONG
-$cfg->setConfigEntry("hub_peer_miss_pong", "PONG_MISS");
+$cfg->setConfigEntry('hub_peer_miss_pong', "PONG_MISS");
// [EOF]
?>
}
// Generate FQFN for the database layer
-$INC = sprintf("%sinc/database/lib-%s%s", PATH, _DB_TYPE, FrameworkConfiguration::getInstance()->readConfig("php_extension"));
+$INC = sprintf("%sinc/database/lib-%s%s",
+ PATH,
+ _DB_TYPE,
+ FrameworkConfiguration::getInstance()->readConfig('php_extension')
+);
// Load the database layer include
if ((file_exists($INC)) && (is_file($INC)) && (is_readable($INC))) {
* Initializes the local file database class
*
* @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/>.
*/
// Zum Testen speichern wir in lokale Dateien (LocalFileDatabase)
try {
- $layer = LocalFileDatabase::createLocalFileDatabase(PATH . "db/", FileIOHandler::getInstance());
+ $layer = LocalFileDatabase::createLocalFileDatabase(PATH . FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance());
} catch (SavePathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (SavePathNotFoundException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (SavePathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (SavePathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
} catch (SavePathWriteProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong><br />\n",
$e->getMessage()
));
}
* instances will we generated.
*
* @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/>.
*/
// Get the instance
-$io = FileIOHandler::createFileIOHandler();
+$io = FileIoHandler::createFileIoHandler();
// [EOF]
?>
* Loads more include files by using the generic class loader
*
* @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/>.
*/
// Include the class loader function
-require(sprintf("%sinc/loader/class_ClassLoader%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
+require(sprintf("%sinc/loader/class_ClassLoader%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
/**
* Is the devel package included?
/**
* Load all development includes
*/
- ClassLoader::getInstance()->loadClasses("devel");
+ ClassLoader::getInstance()->loadClasses('devel');
}
// Shall we include additional configs where you can configure some things? Then
try {
$lang = LanguageSystem::createLanguageSystem(sprintf("%s%s",
PATH,
- FrameworkConfiguration::getInstance()->readConfig("lang_base_path")
+ FrameworkConfiguration::getInstance()->readConfig('lang_base_path')
));
} catch (LanguagePathIsEmptyException $e) {
ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
* This class loads class include files with a specific prefix and suffix
*
* @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/>.
*
* ----------------------------------
* 1.1
$this->dirList = new ArrayObject();
// Set suffix and prefix from configuration
- $this->suffix = $cfgInstance->readConfig("class_suffix");
- $this->prefix = $cfgInstance->readConfig("class_prefix");
+ $this->suffix = $cfgInstance->readConfig('class_suffix');
+ $this->prefix = $cfgInstance->readConfig('class_prefix');
// Estimate length of prefix and suffix for substr() function (cache)
$this->sufLen = strlen($this->suffix);
}
// Initial load of core classes and the FrameworkDirectoryPointer class
-require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
-require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
-require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
+require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
+require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
+require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
// Initialize the class loader
$loader = new ClassLoader(FrameworkConfiguration::getInstance());
*/
// Get a debugger instance
-$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig("debug_engine"));
+$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig('debug_engine'));
// Empty string should be ignored and used for testing the middleware
DebugMiddleware::getInstance()->output("");
* The application selector main include file
*
* @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/>.
*/
// Does the user has an application specified?
-if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")])) {
+if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig('app_selector_get')])) {
// Set the application from string
- $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")];
+ $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig('app_selector_get')];
} elseif (!empty($_SERVER['argv'][1])) {
// Set the application from string
$application = (string) $_SERVER['argv'][1];
- $app = explode("=", trim($application));
- if ($app[0] == FrameworkConfiguration::getInstance()->readConfig("app_selector_get")) {
+ $app = explode('=', trim($application));
+ if ($app[0] == FrameworkConfiguration::getInstance()->readConfig('app_selector_get')) {
// Application is valid!
$application = trim($app[1]);
} else {
// Invalid entry found, first must be "app"!
- $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
+ $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
}
} else {
// Set the "application selector" application
- $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
+ $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
}
// Secure it, by keeping out tags
// Try to load these includes in the given order
$configAppIncludes = array(
- sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig("app_helper_class")), // The ApplicationHelper class
+ sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig('app_helper_class')), // The ApplicationHelper class
"config", // The application's own configuration
"init", // The application initializer
"loader", // The application's class loader
// Generate a FQFN for the helper class
$fqfn = sprintf("%s%s/%s/%s%s",
PATH,
- FrameworkConfiguration::getInstance()->readConfig("application_path"),
+ FrameworkConfiguration::getInstance()->readConfig('application_path'),
$application,
$inc,
- FrameworkConfiguration::getInstance()->readConfig("php_extension")
+ FrameworkConfiguration::getInstance()->readConfig('php_extension')
);
// Does the include file exists?
if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) {
// Load it
require_once($fqfn);
- } elseif (FrameworkConfiguration::getInstance()->readConfig("verbose_level") > 0) {
+ } elseif (FrameworkConfiguration::getInstance()->readConfig('verbose_level') > 0) {
// File is missing
trigger_error(sprintf("Cannot load application script %s! File is missing or read-protected.",
- $inc . FrameworkConfiguration::getInstance()->readConfig("php_extension")
+ $inc . FrameworkConfiguration::getInstance()->readConfig('php_extension')
));
}
}
$content[message]
</div>
+ <div id="emergency_exit backtrace_box">
+ <div id="backtrace_header">
+ Backtrace:
+ </div>
+ <div id="backtrace_content">
+ $content[backtrace]
+ </div>
+ </div>
+
{?footer_msg:footer_msg="Please contact the support and supply the full above message, if you think you are not qualified to fix this problem."?}
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>
$content[title]