From: Roland Haeder Date: Sun, 5 Apr 2015 23:42:07 +0000 (+0200) Subject: Renamed a lot more stuff from 'web' to 'html'. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=32702da3e7035c52f9124720310b797e05fd7410;p=core.git Renamed a lot more stuff from 'web' to 'html'. Signed-off-by: Roland Häder --- diff --git a/inc/classes/interfaces/template/class_CompileableTemplate.php b/inc/classes/interfaces/template/class_CompileableTemplate.php index b35a750c..4cdd7422 100644 --- a/inc/classes/interfaces/template/class_CompileableTemplate.php +++ b/inc/classes/interfaces/template/class_CompileableTemplate.php @@ -32,13 +32,13 @@ interface CompileableTemplate extends FrameworkInterface { function assignVariable ($variableName, $value); /** - * Load a specified web template into the engine + * Load a specified HTML template into the engine * * @param $template The web template we shall load which is located in * "html" by default * @return void */ - function loadWebTemplate ($template); + function loadHtmlTemplate ($template); /** * Load a specified code template into the engine for later compilation diff --git a/inc/classes/main/actions/html/.htaccess b/inc/classes/main/actions/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/actions/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/actions/html/class_HtmlLoginProfileAction.php b/inc/classes/main/actions/html/class_HtmlLoginProfileAction.php new file mode 100644 index 00000000..55ff8cee --- /dev/null +++ b/inc/classes/main/actions/html/class_HtmlLoginProfileAction.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginProfileAction extends BaseAction implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @param $resolverInstance An instance of an action resolver + * @return $actionInstance An instance of this action class + */ + public static final function createHtmlLoginProfileAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new HtmlLoginProfileAction(); + + // Set the resolver instance + $actionInstance->setResolverInstance($resolverInstance); + + // Return the instance + return $actionInstance; + } + + /** + * 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 + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Dummy method + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add user status filter here + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/actions/web/.htaccess b/inc/classes/main/actions/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/actions/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/actions/web/class_WebLoginProfileAction.php b/inc/classes/main/actions/web/class_WebLoginProfileAction.php deleted file mode 100644 index faa5d181..00000000 --- a/inc/classes/main/actions/web/class_WebLoginProfileAction.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebLoginProfileAction extends BaseAction implements Commandable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this action - * - * @param $resolverInstance An instance of an action resolver - * @return $actionInstance An instance of this action class - */ - public static final function createWebLoginProfileAction (ActionResolver $resolverInstance) { - // Get a new instance - $actionInstance = new WebLoginProfileAction(); - - // Set the resolver instance - $actionInstance->setResolverInstance($resolverInstance); - - // Return the instance - return $actionInstance; - } - - /** - * 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 - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Dummy method - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add user status filter here - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlConfirmCommand.php b/inc/classes/main/commands/html/class_HtmlConfirmCommand.php index 0ca3f7ea..7500fead 100644 --- a/inc/classes/main/commands/html/class_HtmlConfirmCommand.php +++ b/inc/classes/main/commands/html/class_HtmlConfirmCommand.php @@ -38,9 +38,9 @@ class HtmlConfirmCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebConfirmCommand (CommandResolver $resolverInstance) { + public static final function createHtmlConfirmCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebConfirmCommand(); + $commandInstance = new HtmlConfirmCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlDoFormCommand.php b/inc/classes/main/commands/html/class_HtmlDoFormCommand.php index 5c38e15d..05ece9ea 100644 --- a/inc/classes/main/commands/html/class_HtmlDoFormCommand.php +++ b/inc/classes/main/commands/html/class_HtmlDoFormCommand.php @@ -38,9 +38,9 @@ class HtmlDoFormCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebDoFormCommand (CommandResolver $resolverInstance) { + public static final function createHtmlDoFormCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebDoFormCommand(); + $commandInstance = new HtmlDoFormCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlHomeCommand.php b/inc/classes/main/commands/html/class_HtmlHomeCommand.php index bca92ae2..b422cb73 100644 --- a/inc/classes/main/commands/html/class_HtmlHomeCommand.php +++ b/inc/classes/main/commands/html/class_HtmlHomeCommand.php @@ -38,9 +38,9 @@ class HtmlHomeCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebHomeCommand (CommandResolver $resolverInstance) { + public static final function createHtmlHomeCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebHomeCommand(); + $commandInstance = new HtmlHomeCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php b/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php index 5ab4d807..c75c59c2 100644 --- a/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php +++ b/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php @@ -43,9 +43,9 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebLoginAreaCommand (CommandResolver $resolverInstance) { + public static final function createHtmlLoginAreaCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebLoginAreaCommand(); + $commandInstance = new HtmlLoginAreaCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); @@ -186,7 +186,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); // Get a resolver - $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance); + $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance); // Resolve the action $actionInstance = $actionResolver->resolveAction(); diff --git a/inc/classes/main/commands/html/class_HtmlLoginCommand.php b/inc/classes/main/commands/html/class_HtmlLoginCommand.php index c1d71c90..f5221504 100644 --- a/inc/classes/main/commands/html/class_HtmlLoginCommand.php +++ b/inc/classes/main/commands/html/class_HtmlLoginCommand.php @@ -38,9 +38,9 @@ class HtmlLoginCommand extends BaseCommand implements Commandable, Registerable * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebLoginCommand (CommandResolver $resolverInstance) { + public static final function createHtmlLoginCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebLoginCommand(); + $commandInstance = new HtmlLoginCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php b/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php index 960ce7b0..af50192a 100644 --- a/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php +++ b/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php @@ -38,9 +38,9 @@ class HtmlLoginFailedCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebLoginFailedCommand (CommandResolver $resolverInstance) { + public static final function createHtmlLoginFailedCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebLoginFailedCommand(); + $commandInstance = new HtmlLoginFailedCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlLogoutCommand.php b/inc/classes/main/commands/html/class_HtmlLogoutCommand.php index 4725d184..47c8fd12 100644 --- a/inc/classes/main/commands/html/class_HtmlLogoutCommand.php +++ b/inc/classes/main/commands/html/class_HtmlLogoutCommand.php @@ -38,9 +38,9 @@ class HtmlLogoutCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebLogoutCommand (CommandResolver $resolverInstance) { + public static final function createHtmlLogoutCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebLogoutCommand(); + $commandInstance = new HtmlLogoutCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php b/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php index ccac0789..9149de16 100644 --- a/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php +++ b/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php @@ -38,9 +38,9 @@ class HtmlLogoutDoneCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebLogoutDoneCommand (CommandResolver $resolverInstance) { + public static final function createHtmlLogoutDoneCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebLogoutDoneCommand(); + $commandInstance = new HtmlLogoutDoneCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlProblemCommand.php b/inc/classes/main/commands/html/class_HtmlProblemCommand.php index 500789d9..1c18dc62 100644 --- a/inc/classes/main/commands/html/class_HtmlProblemCommand.php +++ b/inc/classes/main/commands/html/class_HtmlProblemCommand.php @@ -38,9 +38,9 @@ class HtmlProblemCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebProblemCommand (CommandResolver $resolverInstance) { + public static final function createHtmlProblemCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebProblemCommand(); + $commandInstance = new HtmlProblemCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlRegisterCommand.php b/inc/classes/main/commands/html/class_HtmlRegisterCommand.php index c78dc805..a293bed4 100644 --- a/inc/classes/main/commands/html/class_HtmlRegisterCommand.php +++ b/inc/classes/main/commands/html/class_HtmlRegisterCommand.php @@ -38,9 +38,9 @@ class HtmlRegisterCommand extends BaseCommand implements Commandable, Registerab * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebRegisterCommand (CommandResolver $resolverInstance) { + public static final function createHtmlRegisterCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebRegisterCommand(); + $commandInstance = new HtmlRegisterCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php b/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php index fedd4e79..05f66f93 100644 --- a/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php +++ b/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php @@ -38,9 +38,9 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebResendLinkCommand (CommandResolver $resolverInstance) { + public static final function createHtmlResendLinkCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebResendLinkCommand(); + $commandInstance = new HtmlResendLinkCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/commands/html/class_HtmlStatusCommand.php b/inc/classes/main/commands/html/class_HtmlStatusCommand.php index 2ded5a41..eb280138 100644 --- a/inc/classes/main/commands/html/class_HtmlStatusCommand.php +++ b/inc/classes/main/commands/html/class_HtmlStatusCommand.php @@ -38,9 +38,9 @@ class HtmlStatusCommand extends BaseCommand implements Commandable { * @param $resolverInstance An instance of a command resolver class * @return $commandInstance An instance a prepared command class */ - public static final function createWebStatusCommand (CommandResolver $resolverInstance) { + public static final function createHtmlStatusCommand (CommandResolver $resolverInstance) { // Get new instance - $commandInstance = new WebStatusCommand(); + $commandInstance = new HtmlStatusCommand(); // Set the application instance $commandInstance->setResolverInstance($resolverInstance); diff --git a/inc/classes/main/controller/captcha/.htaccess b/inc/classes/main/controller/captcha/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/captcha/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php b/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php deleted file mode 100644 index 99b044e9..00000000 --- a/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageCodeCaptchaController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createImageCodeCaptchaController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new ImageCodeCaptchaController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add filter for checking the "encrypt" string - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_filter')); - - // 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) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/form/.htaccess b/inc/classes/main/controller/form/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/form/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php deleted file mode 100644 index d109dfb8..00000000 --- a/inc/classes/main/controller/form/class_WebDoFormController.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebDoFormController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createWebDoFormController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new WebDoFormController(); - - // Set resolver instance - $controllerInstance->setResolverInstance($resolverInstance); - - // We need the controller instance in 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); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Try to run the pre filters, if auth exceptions come through redirect here - try { - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - } catch (UserAuthorizationException $e) { - // Redirect to main page - $responseInstance->redirectToConfiguredUrl('login_failed'); - - // Exit here - exit(); - } - - // 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] -?> diff --git a/inc/classes/main/controller/html/form/.htaccess b/inc/classes/main/controller/html/form/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/html/form/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/html/form/class_HtmlDoFormController.php b/inc/classes/main/controller/html/form/class_HtmlDoFormController.php new file mode 100644 index 00000000..38ae3c2a --- /dev/null +++ b/inc/classes/main/controller/html/form/class_HtmlDoFormController.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlDoFormController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlDoFormController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlDoFormController(); + + // Set resolver instance + $controllerInstance->setResolverInstance($resolverInstance); + + // We need the controller instance in 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); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed'); + + // Exit here + exit(); + } + + // 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] +?> diff --git a/inc/classes/main/controller/html/login/.htaccess b/inc/classes/main/controller/html/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/html/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php b/inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php new file mode 100644 index 00000000..0c7725c0 --- /dev/null +++ b/inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php @@ -0,0 +1,106 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginAreaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some morer filters to this controller + */ + public static final function createHtmlLoginAreaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlLoginAreaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // User auth filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); + + // User update filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter')); + + // News fetcher filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + + // News proccess/display-preparation + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // 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 command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed'); + + // Exit here + exit(); + } + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/image/captcha/.htaccess b/inc/classes/main/controller/image/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/image/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/image/captcha/class_ImageCodeCaptchaController.php b/inc/classes/main/controller/image/captcha/class_ImageCodeCaptchaController.php new file mode 100644 index 00000000..99b044e9 --- /dev/null +++ b/inc/classes/main/controller/image/captcha/class_ImageCodeCaptchaController.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createImageCodeCaptchaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ImageCodeCaptchaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filter for checking the "encrypt" string + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_filter')); + + // 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) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/login/.htaccess b/inc/classes/main/controller/login/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/login/class_WebLoginAreaController.php b/inc/classes/main/controller/login/class_WebLoginAreaController.php deleted file mode 100644 index 83ebfd4c..00000000 --- a/inc/classes/main/controller/login/class_WebLoginAreaController.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebLoginAreaController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some morer filters to this controller - */ - public static final function createWebLoginAreaController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new WebLoginAreaController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // User auth filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); - - // User update filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter')); - - // News fetcher filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); - - // News proccess/display-preparation - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); - - // 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 command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Try to run the pre filters, if auth exceptions come through redirect here - try { - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - } catch (UserAuthorizationException $e) { - // Redirect to main page - $responseInstance->redirectToConfiguredUrl('login_failed'); - - // Exit here - exit(); - } - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php b/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php index 13e07abd..9aad65d8 100644 --- a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php +++ b/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php @@ -194,15 +194,15 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT } /** - * Load a specified web template into the engine + * Load a specified HTML template into the engine * * @param $template The web template we shall load which is located in * 'html' by default * @return void */ - public function loadWebTemplate ($template) { + public function loadHtmlTemplate ($template) { // Call the inner class' method - $this->getTemplateInstance()->loadWebTemplate($template); + $this->getTemplateInstance()->loadHtmlTemplate($template); } /** diff --git a/inc/classes/main/factories/html/.htaccess b/inc/classes/main/factories/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/factories/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/factories/html/class_HtmlNewsFactory.php b/inc/classes/main/factories/html/class_HtmlNewsFactory.php new file mode 100644 index 00000000..2cb7ec78 --- /dev/null +++ b/inc/classes/main/factories/html/class_HtmlNewsFactory.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlNewsFactory extends BaseFactory { + /** + * Instance of a request class + */ + private $requestInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * 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 HtmlNewsFactory class + */ + public static final function createFactoryByRequest (Requestable $requestInstance) { + // Set default news reader class + $configEntry = 'news_reader_class'; + + // Get "page" + $page = $requestInstance->getRequestElement('page'); + + // Is 'page' used? + if (!empty($page)) { + // Then add it + $configEntry = sprintf('news_reader_%s_class', $page); + + // Get 'action' + $action = $requestInstance->getRequestElement('action'); + + // Is it also there? + if (!empty($action)) { + // Then use both for config entry + $configEntry = sprintf('news_reader_%s_%s_class', $page, $action); + } // END - if + } // END - if + + // Get the news reader class name from config + $className = $requestInstance->getConfigInstance()->getConfigEntry($configEntry); + + // Once we have that name, try to load initialize it + $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); + + // Initialize the reader + $newsInstance->initializeReader(); + + // Return the prepared factory instance + return $newsInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/factories/web/.htaccess b/inc/classes/main/factories/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/web/class_WebNewsFactory.php b/inc/classes/main/factories/web/class_WebNewsFactory.php deleted file mode 100644 index 35546fbd..00000000 --- a/inc/classes/main/factories/web/class_WebNewsFactory.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebNewsFactory extends BaseFactory { - /** - * Instance of a request class - */ - private $requestInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * 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 static final function createFactoryByRequest (Requestable $requestInstance) { - // Set default news reader class - $configEntry = 'news_reader_class'; - - // Get "page" - $page = $requestInstance->getRequestElement('page'); - - // Is 'page' used? - if (!empty($page)) { - // Then add it - $configEntry = sprintf('news_reader_%s_class', $page); - - // Get 'action' - $action = $requestInstance->getRequestElement('action'); - - // Is it also there? - if (!empty($action)) { - // Then use both for config entry - $configEntry = sprintf('news_reader_%s_%s_class', $page, $action); - } // END - if - } // END - if - - // Get the news reader class name from config - $className = $requestInstance->getConfigInstance()->getConfigEntry($configEntry); - - // Once we have that name, try to load initialize it - $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); - - // Initialize the reader - $newsInstance->initializeReader(); - - // Return the prepared factory instance - return $newsInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/news/class_NewsDownloadFilter.php b/inc/classes/main/filter/news/class_NewsDownloadFilter.php index 9f79e76f..2e1fb8df 100644 --- a/inc/classes/main/filter/news/class_NewsDownloadFilter.php +++ b/inc/classes/main/filter/news/class_NewsDownloadFilter.php @@ -56,7 +56,7 @@ class NewsDownloadFilter extends BaseFilter implements Filterable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get a news instance - $newsInstance = WebNewsFactory::createFactoryByRequest($requestInstance); + $newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance); // Store the news instance in registry Registry::getRegistry()->addInstance('news', $newsInstance); diff --git a/inc/classes/main/helper/html/.htaccess b/inc/classes/main/helper/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/html/blocks/.htaccess b/inc/classes/main/helper/html/blocks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/html/blocks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/html/blocks/class_HtmlBlockHelper.php b/inc/classes/main/helper/html/blocks/class_HtmlBlockHelper.php new file mode 100644 index 00000000..b0fc6605 --- /dev/null +++ b/inc/classes/main/helper/html/blocks/class_HtmlBlockHelper.php @@ -0,0 +1,151 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlBlockHelper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Name of the block + */ + private $blockName = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $blockName Name of the block we shall generate + * @return $helperInstance A prepared instance of this helper + */ + public static final function createHtmlBlockHelper (CompileableTemplate $templateInstance, $blockName) { + // Get new instance + $helperInstance = new HtmlBlockHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set block name + $helperInstance->setBlockName($blockName); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Setter for block name + * + * @param $blockName Name of the block we shall generate + * @return void + */ + protected final function setBlockName ($blockName) { + $this->blockName = (string) $blockName; + } + + /** + * Getter for block name + * + * @return $blockName Name of the block we shall generate + */ + public final function getBlockName () { + return $this->blockName; + } + + /** + * Checks whether include registration date in this block + * + * @return $withRegistration Whether with registration date + */ + public function ifIncludeRegistrationStamp () { + $withRegistration = ($this->getConfigInstance()->getConfigEntry('block_shows_registration') == 'Y'); + return $withRegistration; + } + + /** + * Assignes a template variable with a message from a given message id + * + * @param $templateVariable Template variable to assign + * @param $messageId Message id to load an assign + * @return void + */ + public function assignMessageField ($templateVariable, $messageId) { + // Get message + $message = $this->getLanguageInstance()->getMessage($messageId); + + // And assign it + $this->getTemplateInstance()->assignVariable($templateVariable, $message); + } + + /** + * Assigns a link field with a given value + * + * @param $linkField "Link field" (variable) to assign + * @param $actionValue Action value to assign + * @return void + */ + public function assignLinkFieldWithAction ($linkField, $actionValue) { + $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); + } + + /** + * "Filter" method for translating the raw user status into something human-readable + * + * @param $userStatus Raw user status from database layer + * @return $translated Translated user status + */ + protected function doFilterUserStatusTranslator ($userStatus) { + // Generate message id + $messageId = 'user_status_' . strtolower($userStatus); + + // Get that message + $translated = $this->getLanguageInstance()->getMessage($messageId); + + // Return it + return $translated; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + public function flushContent () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the template named like this block + $templateInstance->loadCodeTemplate('block_' . $this->getBlockName()); + + // Transfer it to the template instance + $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/html/class_ b/inc/classes/main/helper/html/class_ new file mode 100644 index 00000000..09466e18 --- /dev/null +++ b/inc/classes/main/helper/html/class_ @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Html???Helper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Name of the ??? + */ + private $???Name = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $???Name Name of the ??? we shall generate + * @return $helperInstance A prepared instance of this helper + */ + public final static function createHtml???Helper (CompileableTemplate $templateInstance, $???Name) { + // Get new instance + $helperInstance = new Html???Helper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set ??? name + $helperInstance->set???Name($???Name); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo 0% done + */ + public function flushContent () { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/html/class_BaseHtmlHelper.php b/inc/classes/main/helper/html/class_BaseHtmlHelper.php new file mode 100644 index 00000000..02497dde --- /dev/null +++ b/inc/classes/main/helper/html/class_BaseHtmlHelper.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHtmlHelper extends BaseHelper { + /** + * Protected constructor + * + * @param $className The real class name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/html/forms/.htaccess b/inc/classes/main/helper/html/forms/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/html/forms/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/html/forms/class_HtmlFormHelper.php b/inc/classes/main/helper/html/forms/class_HtmlFormHelper.php new file mode 100644 index 00000000..10b152e3 --- /dev/null +++ b/inc/classes/main/helper/html/forms/class_HtmlFormHelper.php @@ -0,0 +1,938 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Whether the form tag is opened (keep at FALSE or else your forms will + * never work!) + */ + private $formOpened = FALSE; + + /** + * Name of the form + */ + private $formName = ''; + + /** + * Whether form tag is enabled (default: TRUE) + */ + private $formEnabled = TRUE; + + // Class Constants + const EXCEPTION_FORM_NAME_INVALID = 0x120; + const EXCEPTION_CLOSED_FORM = 0x121; + const EXCEPTION_OPENED_FORM = 0x122; + const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * 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) + * @param $withForm Whether include the form tag + * @return $helperInstance A preparedf instance of this helper + */ + public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) { + // Get new instance + $helperInstance = new HtmlFormHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Is the form id not set? + if ($formId === FALSE) { + // Use form id from form name + $formId = $formName; + } // END - if + + // Set form name + $helperInstance->setFormName($formName); + + // A form-less field may say 'FALSE' here... + if ($withForm === TRUE) { + // Create the form + $helperInstance->addFormTag($formName, $formId); + } else { + // Disable form + $helperInstance->enableForm(FALSE); + } + + // Return the prepared instance + return $helperInstance; + } + + /** + * 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) + * @todo Add some unique PIN here to bypass problems with some browser and/or extensions + */ + 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); + } // END - if + + // Close the form is default + $formContent = ''; + + // Check whether we shall open or close the form + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Add HTML code + $formContent = sprintf("
getConfigInstance()->getConfigEntry('base_url'), + $this->getConfigInstance()->getConfigEntry('form_action'), + $this->getConfigInstance()->getConfigEntry('form_method'), + $this->getConfigInstance()->getConfigEntry('form_target') + ); + + // Add form id as well + $formContent .= sprintf(" id=\"%s_form\"", + $formId + ); + + // Add close bracket + $formContent .= '>'; + + // Open the form and remeber the form name + $this->formOpened = TRUE; + + // Add it to the content + $this->addHeaderContent($formContent); + } else { + // Add the hidden field required to identify safely this form + $this->addInputHiddenField('form', $this->getFormName()); + + // Is a group open? + if ($this->ifGroupOpenedPreviously()) { + // Then automatically close it here + $this->addFormGroup(); + } // END - if + + // Simply close it + $this->formOpened = FALSE; + + // Add it to the content + $this->addFooterContent($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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $fieldValue + ); + + // And add it maybe with a 'li' tag + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a text input tag to the form with pre-loaded default value + * + * @param $fieldName Input field name + * @return void + */ + public function addInputTextFieldWithDefault ($fieldName) { + // Get the value from instance + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; + + // Add the text field + $this->addInputTextField($fieldName, $fieldValue); + } + + /** + * 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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $fieldValue + ); + + // And add it + $this->addContentToPreviousGroup($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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldValue + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a hidden input tag to the form with pre-loaded default value + * + * @param $fieldName Input field name + * @return void + */ + public function addInputHiddenFieldWithDefault ($fieldName) { + // Get the value from instance + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; + + // Add the text field + $this->addInputHiddenField($fieldName, $fieldValue); + } + + /** + * Add a hidden input tag to the form with configuration value + * + * @param $fieldName Input field name + * @param $prefix Prefix for configuration without trailing _ + * @return void + */ + public function addInputHiddenConfiguredField ($fieldName, $prefix) { + // Get the value from instance + $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}"); + //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; + + // Add the text field + $this->addInputHiddenField($fieldName, $fieldValue); + } + + /** + * 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 Whether 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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Set whether the check box is checked... + $checked = " checked=\"checked\""; + if ($fieldChecked === FALSE) $checked = ' '; + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $checked + ); + + // And add it + $this->addContentToPreviousGroup($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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $this->getFormName(), + $buttonText + ); + + // And add it + $this->addContentToPreviousGroup($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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $this->getFormName(), + $this->getFormName(), + $buttonText + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a form group or close an already opened and open a new one + * + * @param $groupId Name of the group or last opened if empty + * @param $groupText Text including HTML to show above this group + * @return void + * @throws FormClosedException If no form has been opened before + * @throws EmptyVariableException If $groupId is not set + */ + public function addFormGroup ($groupId = '', $groupText = '') { + // Is a form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw exception here + throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // At least the group name should be set + if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($groupId)) { + // Close the last opened + $groupId = $this->getPreviousGroupId(); + } + + // Same group to open? + if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) { + // Abort here silently + return FALSE; + } // END - if + + // Initialize content with closing div by default + $content = " \n"; + + // Is this group opened? + if ($this->ifGroupOpenedPreviously() === FALSE) { + // Begin the div/span blocks + $content = sprintf(" +
+ + %s + +
", + $groupId, + $groupId, + $groupId, + $groupText, + $groupId + ); + + // Switch the state + $this->openGroupByIdContent($groupId, $content, "div"); + } else { + // Is a sub group opened? + if ($this->ifSubGroupOpenedPreviously()) { + // Close it here + $this->addFormSubGroup(); + } // END - if + + // Get previous group id + $prevGroupId = $this->getPreviousGroupId(); + + // Switch the state + $this->closePreviousGroupByContent($content); + + // All call it again if group name is not empty + if ((!empty($groupId)) && ($groupId != $prevGroupId)) { + //* DEBUG: */ echo $groupId.'/'.$prevGroupId."
\n"; + $this->addFormGroup($groupId, $groupText); + } // END - if + } + } + + /** + * 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 sub group + * name is empty. + * + * @param $subGroupId Name of the group or last opened if empty + * @param $subGroupText Text including HTML to show above this group + * @return void + * @throws FormFormClosedException If no group has been opened before + * @throws EmptyVariableException If $subGroupId is not set + */ + public function addFormSubGroup ($subGroupId = '', $subGroupText = '') { + // Is a group opened? + if ($this->ifGroupOpenedPreviously() === FALSE) { + // Throw exception here + throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP); + } // END - if + + // At least the sub group name should be set + if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($subGroupId)) { + // Close the last opened + $subGroupId = $this->getPreviousSubGroupId(); + } + + // Same sub group to open? + if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($subGroupId == $this->getPreviousSubGroupId())) { + // Abort here silently + return FALSE; + } // END - if + + // Initialize content with closing div by default + $content = "
\n
"; + + // Is this group opened? + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Begin the span block + $content = sprintf(" +
+ + %s + +
", + $subGroupId, + $subGroupId, + $subGroupId, + $subGroupText, + $subGroupId + ); + + // Switch the state and remeber the name + $this->openSubGroupByIdContent($subGroupId, $content, "div"); + } else { + // Get previous sub group id + $prevSubGroupId = $this->getPreviousSubGroupId(); + + // Switch the state + $this->closePreviousSubGroupByContent($content); + + // All call it again if sub group name is not empty + if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) { + $this->addFormSubGroup($subGroupId, $subGroupText); + } // END - if + } + } + + /** + * 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) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Set the block type + $block = 'div'; + if ($this->ifGroupOpenedPreviously()) $block = 'span'; + + // Generate the content + $inputContent = sprintf(" <%s id=\"%s_text\"> + %s + ", + $block, + $fieldName, + $fieldText, + $block + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add text (notes) surrounded by a div block. Still opened groups or sub + * groups will be automatically closed. + * + * @param $noteId Id for this note + * @param $formNotes The form notes we shell addd + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addFormNote ($noteId, $formNotes) { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("
+ %s +
", + $noteId, + $formNotes + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Adds a selection box as a sub group to the form. Do not box this into + * another sub group. Sub-sub groups are not (yet) supported. + * + * @param $selectId Id of the selection box + * @param $firstEntry Content to be added as first non-selectable entry + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputSelectField ($selectId, $firstEntry) { + // Is the form group opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Shall we close or open the sub group? + if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) { + // Initialize first entry (which might be non-selectable if content is provided + if (!empty($firstEntry)) { + // Add selection around it + $firstEntry = sprintf("\n", + $firstEntry + ); + } // END - if + + // Construct the opening select tag + $content = sprintf(""); + } + } + + /** + * Adds a non-selectable sub option to a previously added selection box. + * This method does *not* validate if there is already a sub option added + * with the same name. We need to finish this here! + * + * @param $subName Name of the sub action + * @param $subValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectSubOption ($subName, $subValue) { + // Is there a sub group (shall be a selection box!) + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $subName, + $subValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a selectable option to a previously added selection box. This method + * does *not* validate if there is already a sub option added with the same + * name. We need to finish this here! + * + * @param $optionName Name of the sub action + * @param $optionValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectOption ($optionName, $optionValue) { + // Is there a sub group (shall be a selection box!) + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $optionName, + $optionName, + $optionValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a pre-configured CAPTCHA + * + * @return void + */ + public function addCaptcha () { + // Init instance + $extraInstance = NULL; + + try { + // Get last executed pre filter + $extraInstance = Registry::getRegistry()->getInstance('extra'); + } catch (NullPointerException $e) { + // Instance in registry is not set (NULL) + // @TODO We need to log this later + } + + // Get a configured instance + $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha', array($this, $extraInstance)); + + // Initiate the CAPTCHA + $captchaInstance->initiateCaptcha(); + + // Render the CAPTCHA code + $captchaInstance->renderCode(); + + // Get the content and add it to the helper + $this->addContentToPreviousGroup($captchaInstance->renderContent()); + } + + /** + * Enables/disables the form tag usage + * + * @param $formEnabled Whether form is enabled or disabled + * @return void + */ + public final function enableForm ($formEnabled = TRUE) { + $this->formEnabled = (bool) $formEnabled; + } + + /** + * Setter for form name + * + * @param $formName Name of this form + * @return void + */ + public final function setFormName ($formName) { + $this->formName = (string) $formName; + } + + /** + * Getter for form name + * + * @return $formName Name of this form + */ + public final function getFormName () { + return $this->formName; + } + + /** + * Checks whether the registration requires a valid email address + * + * @return $required Whether the email address is required + */ + public function ifRegisterRequiresEmailVerification () { + $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y'); + return $required; + } + + /** + * Checks whether profile data shall be asked + * + * @return $required Whether profile data shall be asked + */ + public function ifRegisterIncludesProfile () { + $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y'); + return $required; + } + + /** + * Checks whether this form is secured by a CAPTCHA + * + * @return $isSecured Whether this form is secured by a CAPTCHA + */ + public function ifFormSecuredWithCaptcha () { + $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y'); + return $isSecured; + } + + /** + * Checks whether personal data shall be asked + * + * @return $required Whether personal data shall be asked + */ + public function ifRegisterIncludesPersonaData () { + $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y'); + return $required; + } + + /** + * Checks whether for birthday shall be asked + * + * @return $required Whether birthday shall be asked + */ + public function ifProfileIncludesBirthDay () { + $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y'); + return $required; + } + + /** + * Checks whether email addresses can only be once used + * + * @return $isUnique + */ + public function ifEmailMustBeUnique () { + $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y'); + return $isUnique; + } + + /** + * Checks whether the specified chat protocol is enabled in this form + * + * @return $required Whether the specified chat protocol is enabled + */ + public function ifChatEnabled ($chatProtocol) { + $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y'); + return $required; + } + + /** + * Checks whether login is enabled or disabled + * + * @return $isEnabled Whether the login is enabled or disabled + */ + public function ifLoginIsEnabled () { + $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y'); + return $isEnabled; + } + + /** + * Checks whether login shall be done by username + * + * @return $isEnabled Whether the login shall be done by username + */ + public function ifLoginWithUsername () { + $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username"); + return $isEnabled; + } + + /** + * Checks whether login shall be done by email + * + * @return $isEnabled Whether the login shall be done by email + */ + public function ifLoginWithEmail () { + $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email"); + return $isEnabled; + } + + /** + * Checks whether guest login is allowed + * + * @return $isAllowed Whether guest login is allowed + */ + public function ifGuestLoginAllowed () { + $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y'); + return $isAllowed; + } + + /** + * Checks whether the email address change must be confirmed + * + * @return $requireConfirm Whether email change must be confirmed + */ + public function ifEmailChangeRequireConfirmation () { + $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y'); + return $requireConfirm; + } + + /** + * Checks whether the rules has been updated + * + * @return $rulesUpdated Whether rules has been updated + * @todo Implement check if rules have been changed + */ + public function ifRulesHaveChanged () { + return FALSE; + } + + /** + * Checks whether email change is allowed + * + * @return $emailChange Whether changing email address is allowed + */ + public function ifEmailChangeAllowed () { + $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y'); + return $emailChange; + } + + /** + * Checks whether the user account is unconfirmed + * + * @return $isUnconfirmed Whether the user account is unconfirmed + */ + public function ifUserAccountUnconfirmed () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed')); + return $isUnconfirmed; + } + + /** + * Checks whether the user account is locked + * + * @return $isUnconfirmed Whether the user account is locked + */ + public function ifUserAccountLocked () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked')); + return $isUnconfirmed; + } + + /** + * Checks whether the user account is a guest + * + * @return $isUnconfirmed Whether the user account is a guest + */ + public function ifUserAccountGuest () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest')); + return $isUnconfirmed; + } + + /** + * Checks whether the refill page is active which should be not the default + * on non-web applications. + * + * @return $refillActive Whether the refill page is active + */ + public function ifRefillPageActive () { + $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y'); + return $refillActive; + } + + /** + * Flushs the content out (not yet secured against open forms, etc.!) or + * close the form automatically + * + * @return void + * @throws FormOpenedException If the form is still open + */ + public function flushContent () { + // Is the form still open? + if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) { + // Close the form automatically + $this->addFormTag(); + } elseif ($this->formEnabled === FALSE) { + if ($this->ifSubGroupOpenedPreviously()) { + // Close sub group + $this->addFormSubGroup(); + } elseif ($this->ifGroupOpenedPreviously()) { + // Close group + $this->addFormGroup(); + } + } + + // Send content to template engine + //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."
\n"; + $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/html/links/.htaccess b/inc/classes/main/helper/html/links/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/html/links/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/html/links/class_HtmlLinkHelper.php b/inc/classes/main/helper/html/links/class_HtmlLinkHelper.php new file mode 100644 index 00000000..09121d59 --- /dev/null +++ b/inc/classes/main/helper/html/links/class_HtmlLinkHelper.php @@ -0,0 +1,343 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Name of the link + */ + private $linkName = ''; + + /** + * Base of the link + */ + private $linkBase = ''; + + /** + * First parameter separator + */ + const FIRST_PARAMETER_SEPARATOR = '?'; + + /** + * SEPARATOR for more paraemters + */ + const EXTRA_PARAMETER_SEPARATOR = '&'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $linkName Name of the link we shall generate + * @param $linkBase Link base for the link. This parameter is deprecated. + * @return $helperInstance A prepared instance of this helper + * @throws NoConfigEntryException A deprecated exception at this point + */ + public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = NULL) { + // Get new instance + $helperInstance = new HtmlLinkHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set link name + $helperInstance->setLinkName($linkName); + + // Get the application instance + $applicationInstance = Registry::getRegistry()->getInstance('application'); + + // Get the request instance + $requestInstance = $applicationInstance->getRequestInstance(); + + // Sanity-check on it + if (is_null($requestInstance)) { + // Throw an exception here + throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get page (this will throw an exception if not set) + $page = $helperInstance->convertDashesToUnderscores($requestInstance->getRequestElement('page')); + + // Construct config entry + $configEntry = $page . '_' . $linkName . '_action_url'; + + // Is the deprecated parameter set? + if (!is_null($linkBase)) { + // Then output a deprecation message + $helperInstance->deprecationWarning('[' . __METHOD__ . ':' . __LINE__ . ']: linkBase is deprecated. Please remove it from your templates and add a config entry ' . $configEntry . ' in your config.php file.'); + } // END - if + + // Determine link base from config now and 'page' request + try { + $newLinkBase = $helperInstance->getConfigInstance()->getConfigEntry($configEntry); + $linkBase = $newLinkBase; + } catch (NoConfigEntryException $e) { + // Is the deprecated linkBase not set? + if (is_null($linkBase)) { + // Then throw again the exception + throw new NoConfigEntryException(array(__CLASS__, ($configEntry)), FrameworkConfiguration::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); + } // END - if + } + + // Set link base + $helperInstance->setLinkBase($linkBase); + + // Add default group + $helperInstance->openGroupByIdContent('main', '', ''); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Renders the link content (HTML code) with given link text and optional + * extra content + * + * @param $linkText Link text to set in link + * @param $linkTitle Link title to set in link + * @param $extraContent Optional extra HTML content + * @return $linkContent Rendered text link content + */ + private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') { + // Construct link content + $linkContent = sprintf("%s", + $this->getLinkBase(), + $extraContent, + $linkTitle, + $linkText + ); + + // Return it + return $linkContent; + } + + /** + * Setter for link name + * + * @param $linkName Name of the link we shall generate + * @return void + */ + protected final function setLinkName ($linkName) { + $this->linkName = (string) $linkName; + } + + /** + * Getter for link name + * + * @return $linkName Name of the link we shall generate + */ + public final function getLinkName () { + return $this->linkName; + } + + /** + * Setter for link base + * + * @param $linkBase Base of the link we shall generate + * @return void + */ + protected final function setLinkBase ($linkBase) { + $this->linkBase = (string) $linkBase; + } + + /** + * Getter for link base + * + * @return $linkBase Base of the link we shall generate + */ + public final function getLinkBase () { + return $this->linkBase; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo Completely unimplemented + */ + public function flushContent () { + // Is a previous opened group still open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it + $this->closePreviousGroupByContent(''); + } // END - if + + // Get the content + $content = $this->renderContent(); + + // Get template engine + $templateInstance = $this->getTemplateInstance(); + + // Add content to variable + $templateInstance->assignVariable($this->getLinkName(), $content); + } + + /** + * Adds a link group (like the form group is) with some raw language to the + * helper. + * + * @param $groupId Id string of the group + * @param $groupText Text for this group to add + * @param $groupCode Code to open and close groups + * @return void + */ + public function addLinkGroup ($groupId, $groupText, $groupCode = "div") { + // Is a group with that name open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it here + $this->closePreviousGroupByContent(''); + } // END - if + + // Generate the group content + $content = sprintf("<{$groupCode} id=\"group_%s_%s\">%s", + $this->getLinkName(), + $groupId, + $groupText + ); + + // Open the new group + $this->openGroupByIdContent($groupId, $content, $groupCode); + } + + /** + * Adds text (note) to the previously opened group or throws an exception + * if no previous group was opened. + * + * @param $groupId Group id to set + * @param $groupNote Note to be added to a group + * @param $groupCode Code to open and close groups + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + public function addLinkNote ($groupId, $groupNote, $groupCode = "div") { + // Check if a previous group was opened + if ($this->ifGroupOpenedPreviously() === FALSE) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Is a previous sub group open? + if ($this->ifSubGroupOpenedPreviously()) { + // Then close it + $this->closePreviousSubGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("<{$groupCode} id=\"subgroup_%s_%s\">%s", + $this->getLinkName(), + $groupId, + $groupNote + ); + + // Open the sub group + $this->openSubGroupByIdContent($groupId, $content, $groupCode); + } + + /** + * Adds a link to the previously opened group or throws an exception if no group has been opened + * + * @param $linkAction Action (action=xxx) value for the link + * @param $linkText Link text and title (title="xxx") for the link + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + protected function addActionLink ($linkAction, $linkText, $linkTitle) { + // Check if a previous group was opened + if ($this->ifGroupOpenedPreviously() === FALSE) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $linkAction . '(' . $linkText . ')'), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Default parameter SEPARATOR is & + $separator = self::EXTRA_PARAMETER_SEPARATOR; + + // Is there a question mark in? + $linkArray = explode(self::FIRST_PARAMETER_SEPARATOR, $this->getLinkBase()); + if (count($linkArray) == 0) { + // No question mark + $separator = self::FIRST_PARAMETER_SEPARATOR; + } // END - if + + // Prepare action + $action = sprintf('%saction=%s', + $separator, + $linkAction + ); + + // Renders the link content + $linkContent = $this->renderLinkContentWithTextExtraContent($linkText, $linkTitle, $action); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } + + /** + * Adds a link to the previously opened group with a text from language system + * + * @param $linkAction Action (action=xxx) value for the link + * @param $languageId Language id string to use + * @return void + */ + public function addActionLinkById ($linkAction, $languageId) { + // Resolve the language string + $languageResolvedText = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_text"); + + // Resolve the language string + $languageResolvedTitle = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_title"); + + // Add the action link + $this->addActionLink($linkAction, $languageResolvedText, $languageResolvedTitle); + } + + /** + * Adds a default link (no extra parameters) to the content with specified + * language id string. + * + * @param $languageId Language id string to use + * @return void + */ + public function addLinkWithTextById ($languageId) { + // Resolve the language string + $languageResolvedText = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_text"); + + // Resolve the language string + $languageResolvedTitle = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_title"); + + // Now add the link + $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolvedText, $languageResolvedTitle); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/.htaccess b/inc/classes/main/helper/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/web/blocks/.htaccess b/inc/classes/main/helper/web/blocks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/web/blocks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php deleted file mode 100644 index 1b20fd36..00000000 --- a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebBlockHelper extends BaseWebHelper implements HelpableTemplate { - /** - * Name of the block - */ - private $blockName = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $blockName Name of the block we shall generate - * @return $helperInstance A prepared instance of this helper - */ - public static final function createWebBlockHelper (CompileableTemplate $templateInstance, $blockName) { - // Get new instance - $helperInstance = new WebBlockHelper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set block name - $helperInstance->setBlockName($blockName); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Setter for block name - * - * @param $blockName Name of the block we shall generate - * @return void - */ - protected final function setBlockName ($blockName) { - $this->blockName = (string) $blockName; - } - - /** - * Getter for block name - * - * @return $blockName Name of the block we shall generate - */ - public final function getBlockName () { - return $this->blockName; - } - - /** - * Checks whether include registration date in this block - * - * @return $withRegistration Whether with registration date - */ - public function ifIncludeRegistrationStamp () { - $withRegistration = ($this->getConfigInstance()->getConfigEntry('block_shows_registration') == 'Y'); - return $withRegistration; - } - - /** - * Assignes a template variable with a message from a given message id - * - * @param $templateVariable Template variable to assign - * @param $messageId Message id to load an assign - * @return void - */ - public function assignMessageField ($templateVariable, $messageId) { - // Get message - $message = $this->getLanguageInstance()->getMessage($messageId); - - // And assign it - $this->getTemplateInstance()->assignVariable($templateVariable, $message); - } - - /** - * Assigns a link field with a given value - * - * @param $linkField "Link field" (variable) to assign - * @param $actionValue Action value to assign - * @return void - */ - public function assignLinkFieldWithAction ($linkField, $actionValue) { - $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); - } - - /** - * "Filter" method for translating the raw user status into something human-readable - * - * @param $userStatus Raw user status from database layer - * @return $translated Translated user status - */ - protected function doFilterUserStatusTranslator ($userStatus) { - // Generate message id - $messageId = 'user_status_' . strtolower($userStatus); - - // Get that message - $translated = $this->getLanguageInstance()->getMessage($messageId); - - // Return it - return $translated; - } - - /** - * Flush the content out,e g. to a template variable - * - * @return void - */ - public function flushContent () { - // Get template instance - $templateInstance = $this->getTemplateInstance(); - - // Get the template named like this block - $templateInstance->loadCodeTemplate('block_' . $this->getBlockName()); - - // Transfer it to the template instance - $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/web/class_ b/inc/classes/main/helper/web/class_ deleted file mode 100644 index ae99b2cd..00000000 --- a/inc/classes/main/helper/web/class_ +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Web???Helper extends BaseWebHelper implements HelpableTemplate { - /** - * Name of the ??? - */ - private $???Name = ""; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription(""); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $???Name Name of the ??? we shall generate - * @return $helperInstance A prepared instance of this helper - */ - public final static function createWeb???Helper (CompileableTemplate $templateInstance, $???Name) { - // Get new instance - $helperInstance = new Web???Helper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set ??? name - $helperInstance->set???Name($???Name); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Flush the content out,e g. to a template variable - * - * @return void - * @todo 0% done - */ - public function flushContent () { - $this->partialStub("Please implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/web/class_BaseWebHelper.php b/inc/classes/main/helper/web/class_BaseWebHelper.php deleted file mode 100644 index 14ce3982..00000000 --- a/inc/classes/main/helper/web/class_BaseWebHelper.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseWebHelper extends BaseHelper { - /** - * Protected constructor - * - * @param $className The real class name - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/web/forms/.htaccess b/inc/classes/main/helper/web/forms/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/web/forms/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php deleted file mode 100644 index f7c8fa1d..00000000 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ /dev/null @@ -1,938 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebFormHelper extends BaseWebHelper implements HelpableTemplate { - /** - * Whether the form tag is opened (keep at FALSE or else your forms will - * never work!) - */ - private $formOpened = FALSE; - - /** - * Name of the form - */ - private $formName = ''; - - /** - * Whether form tag is enabled (default: TRUE) - */ - private $formEnabled = TRUE; - - // Class Constants - const EXCEPTION_FORM_NAME_INVALID = 0x120; - const EXCEPTION_CLOSED_FORM = 0x121; - const EXCEPTION_OPENED_FORM = 0x122; - const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * 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) - * @param $withForm Whether include the form tag - * @return $helperInstance A preparedf instance of this helper - */ - public static final function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) { - // 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; - } // END - if - - // Set form name - $helperInstance->setFormName($formName); - - // A form-less field may say 'FALSE' here... - if ($withForm === TRUE) { - // Create the form - $helperInstance->addFormTag($formName, $formId); - } else { - // Disable form - $helperInstance->enableForm(FALSE); - } - - // Return the prepared instance - return $helperInstance; - } - - /** - * 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) - * @todo Add some unique PIN here to bypass problems with some browser and/or extensions - */ - 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); - } // END - if - - // Close the form is default - $formContent = ''; - - // Check whether we shall open or close the form - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Add HTML code - $formContent = sprintf("
getConfigInstance()->getConfigEntry('base_url'), - $this->getConfigInstance()->getConfigEntry('form_action'), - $this->getConfigInstance()->getConfigEntry('form_method'), - $this->getConfigInstance()->getConfigEntry('form_target') - ); - - // Add form id as well - $formContent .= sprintf(" id=\"%s_form\"", - $formId - ); - - // Add close bracket - $formContent .= '>'; - - // Open the form and remeber the form name - $this->formOpened = TRUE; - - // Add it to the content - $this->addHeaderContent($formContent); - } else { - // Add the hidden field required to identify safely this form - $this->addInputHiddenField('form', $this->getFormName()); - - // Is a group open? - if ($this->ifGroupOpenedPreviously()) { - // Then automatically close it here - $this->addFormGroup(); - } // END - if - - // Simply close it - $this->formOpened = FALSE; - - // Add it to the content - $this->addFooterContent($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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldName, - $fieldValue - ); - - // And add it maybe with a 'li' tag - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a text input tag to the form with pre-loaded default value - * - * @param $fieldName Input field name - * @return void - */ - public function addInputTextFieldWithDefault ($fieldName) { - // Get the value from instance - $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; - - // Add the text field - $this->addInputTextField($fieldName, $fieldValue); - } - - /** - * 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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldName, - $fieldValue - ); - - // And add it - $this->addContentToPreviousGroup($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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldValue - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a hidden input tag to the form with pre-loaded default value - * - * @param $fieldName Input field name - * @return void - */ - public function addInputHiddenFieldWithDefault ($fieldName) { - // Get the value from instance - $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; - - // Add the text field - $this->addInputHiddenField($fieldName, $fieldValue); - } - - /** - * Add a hidden input tag to the form with configuration value - * - * @param $fieldName Input field name - * @param $prefix Prefix for configuration without trailing _ - * @return void - */ - public function addInputHiddenConfiguredField ($fieldName, $prefix) { - // Get the value from instance - $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}"); - //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; - - // Add the text field - $this->addInputHiddenField($fieldName, $fieldValue); - } - - /** - * 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 Whether 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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Set whether the check box is checked... - $checked = " checked=\"checked\""; - if ($fieldChecked === FALSE) $checked = ' '; - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldName, - $checked - ); - - // And add it - $this->addContentToPreviousGroup($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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $this->getFormName(), - $buttonText - ); - - // And add it - $this->addContentToPreviousGroup($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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $this->getFormName(), - $this->getFormName(), - $buttonText - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a form group or close an already opened and open a new one - * - * @param $groupId Name of the group or last opened if empty - * @param $groupText Text including HTML to show above this group - * @return void - * @throws FormClosedException If no form has been opened before - * @throws EmptyVariableException If $groupId is not set - */ - public function addFormGroup ($groupId = '', $groupText = '') { - // Is a form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw exception here - throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // At least the group name should be set - if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) { - // Throw exception here - throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (empty($groupId)) { - // Close the last opened - $groupId = $this->getPreviousGroupId(); - } - - // Same group to open? - if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) { - // Abort here silently - return FALSE; - } // END - if - - // Initialize content with closing div by default - $content = "
\n
"; - - // Is this group opened? - if ($this->ifGroupOpenedPreviously() === FALSE) { - // Begin the div/span blocks - $content = sprintf(" -
- - %s - -
", - $groupId, - $groupId, - $groupId, - $groupText, - $groupId - ); - - // Switch the state - $this->openGroupByIdContent($groupId, $content, "div"); - } else { - // Is a sub group opened? - if ($this->ifSubGroupOpenedPreviously()) { - // Close it here - $this->addFormSubGroup(); - } // END - if - - // Get previous group id - $prevGroupId = $this->getPreviousGroupId(); - - // Switch the state - $this->closePreviousGroupByContent($content); - - // All call it again if group name is not empty - if ((!empty($groupId)) && ($groupId != $prevGroupId)) { - //* DEBUG: */ echo $groupId.'/'.$prevGroupId."
\n"; - $this->addFormGroup($groupId, $groupText); - } // END - if - } - } - - /** - * 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 sub group - * name is empty. - * - * @param $subGroupId Name of the group or last opened if empty - * @param $subGroupText Text including HTML to show above this group - * @return void - * @throws FormFormClosedException If no group has been opened before - * @throws EmptyVariableException If $subGroupId is not set - */ - public function addFormSubGroup ($subGroupId = '', $subGroupText = '') { - // Is a group opened? - if ($this->ifGroupOpenedPreviously() === FALSE) { - // Throw exception here - throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP); - } // END - if - - // At least the sub group name should be set - if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) { - // Throw exception here - throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (empty($subGroupId)) { - // Close the last opened - $subGroupId = $this->getPreviousSubGroupId(); - } - - // Same sub group to open? - if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($subGroupId == $this->getPreviousSubGroupId())) { - // Abort here silently - return FALSE; - } // END - if - - // Initialize content with closing div by default - $content = "
\n
"; - - // Is this group opened? - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Begin the span block - $content = sprintf(" -
- - %s - -
", - $subGroupId, - $subGroupId, - $subGroupId, - $subGroupText, - $subGroupId - ); - - // Switch the state and remeber the name - $this->openSubGroupByIdContent($subGroupId, $content, "div"); - } else { - // Get previous sub group id - $prevSubGroupId = $this->getPreviousSubGroupId(); - - // Switch the state - $this->closePreviousSubGroupByContent($content); - - // All call it again if sub group name is not empty - if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) { - $this->addFormSubGroup($subGroupId, $subGroupText); - } // END - if - } - } - - /** - * 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) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Set the block type - $block = 'div'; - if ($this->ifGroupOpenedPreviously()) $block = 'span'; - - // Generate the content - $inputContent = sprintf(" <%s id=\"%s_text\"> - %s - ", - $block, - $fieldName, - $fieldText, - $block - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add text (notes) surrounded by a div block. Still opened groups or sub - * groups will be automatically closed. - * - * @param $noteId Id for this note - * @param $formNotes The form notes we shell addd - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addFormNote ($noteId, $formNotes) { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("
- %s -
", - $noteId, - $formNotes - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Adds a selection box as a sub group to the form. Do not box this into - * another sub group. Sub-sub groups are not (yet) supported. - * - * @param $selectId Id of the selection box - * @param $firstEntry Content to be added as first non-selectable entry - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputSelectField ($selectId, $firstEntry) { - // Is the form group opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Shall we close or open the sub group? - if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) { - // Initialize first entry (which might be non-selectable if content is provided - if (!empty($firstEntry)) { - // Add selection around it - $firstEntry = sprintf("\n", - $firstEntry - ); - } // END - if - - // Construct the opening select tag - $content = sprintf(""); - } - } - - /** - * Adds a non-selectable sub option to a previously added selection box. - * This method does *not* validate if there is already a sub option added - * with the same name. We need to finish this here! - * - * @param $subName Name of the sub action - * @param $subValue Value of the sub action - * @return void - * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found - * @todo Add checking if sub option is already added - */ - public function addSelectSubOption ($subName, $subValue) { - // Is there a sub group (shall be a selection box!) - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Then throw an exception here - throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); - } // END - if - - // Render the content - $content = sprintf("\n", - $subName, - $subValue - ); - - // Add the content to the previously opened sub group - $this->addContentToPreviousGroup($content); - } - - /** - * Adds a selectable option to a previously added selection box. This method - * does *not* validate if there is already a sub option added with the same - * name. We need to finish this here! - * - * @param $optionName Name of the sub action - * @param $optionValue Value of the sub action - * @return void - * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found - * @todo Add checking if sub option is already added - */ - public function addSelectOption ($optionName, $optionValue) { - // Is there a sub group (shall be a selection box!) - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Then throw an exception here - throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); - } // END - if - - // Render the content - $content = sprintf("\n", - $optionName, - $optionName, - $optionValue - ); - - // Add the content to the previously opened sub group - $this->addContentToPreviousGroup($content); - } - - /** - * Adds a pre-configured CAPTCHA - * - * @return void - */ - public function addCaptcha () { - // Init instance - $extraInstance = NULL; - - try { - // Get last executed pre filter - $extraInstance = Registry::getRegistry()->getInstance('extra'); - } catch (NullPointerException $e) { - // Instance in registry is not set (NULL) - // @TODO We need to log this later - } - - // Get a configured instance - $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha', array($this, $extraInstance)); - - // Initiate the CAPTCHA - $captchaInstance->initiateCaptcha(); - - // Render the CAPTCHA code - $captchaInstance->renderCode(); - - // Get the content and add it to the helper - $this->addContentToPreviousGroup($captchaInstance->renderContent()); - } - - /** - * Enables/disables the form tag usage - * - * @param $formEnabled Whether form is enabled or disabled - * @return void - */ - public final function enableForm ($formEnabled = TRUE) { - $this->formEnabled = (bool) $formEnabled; - } - - /** - * Setter for form name - * - * @param $formName Name of this form - * @return void - */ - public final function setFormName ($formName) { - $this->formName = (string) $formName; - } - - /** - * Getter for form name - * - * @return $formName Name of this form - */ - public final function getFormName () { - return $this->formName; - } - - /** - * Checks whether the registration requires a valid email address - * - * @return $required Whether the email address is required - */ - public function ifRegisterRequiresEmailVerification () { - $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y'); - return $required; - } - - /** - * Checks whether profile data shall be asked - * - * @return $required Whether profile data shall be asked - */ - public function ifRegisterIncludesProfile () { - $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y'); - return $required; - } - - /** - * Checks whether this form is secured by a CAPTCHA - * - * @return $isSecured Whether this form is secured by a CAPTCHA - */ - public function ifFormSecuredWithCaptcha () { - $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y'); - return $isSecured; - } - - /** - * Checks whether personal data shall be asked - * - * @return $required Whether personal data shall be asked - */ - public function ifRegisterIncludesPersonaData () { - $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y'); - return $required; - } - - /** - * Checks whether for birthday shall be asked - * - * @return $required Whether birthday shall be asked - */ - public function ifProfileIncludesBirthDay () { - $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y'); - return $required; - } - - /** - * Checks whether email addresses can only be once used - * - * @return $isUnique - */ - public function ifEmailMustBeUnique () { - $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y'); - return $isUnique; - } - - /** - * Checks whether the specified chat protocol is enabled in this form - * - * @return $required Whether the specified chat protocol is enabled - */ - public function ifChatEnabled ($chatProtocol) { - $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y'); - return $required; - } - - /** - * Checks whether login is enabled or disabled - * - * @return $isEnabled Whether the login is enabled or disabled - */ - public function ifLoginIsEnabled () { - $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y'); - return $isEnabled; - } - - /** - * Checks whether login shall be done by username - * - * @return $isEnabled Whether the login shall be done by username - */ - public function ifLoginWithUsername () { - $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username"); - return $isEnabled; - } - - /** - * Checks whether login shall be done by email - * - * @return $isEnabled Whether the login shall be done by email - */ - public function ifLoginWithEmail () { - $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email"); - return $isEnabled; - } - - /** - * Checks whether guest login is allowed - * - * @return $isAllowed Whether guest login is allowed - */ - public function ifGuestLoginAllowed () { - $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y'); - return $isAllowed; - } - - /** - * Checks whether the email address change must be confirmed - * - * @return $requireConfirm Whether email change must be confirmed - */ - public function ifEmailChangeRequireConfirmation () { - $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y'); - return $requireConfirm; - } - - /** - * Checks whether the rules has been updated - * - * @return $rulesUpdated Whether rules has been updated - * @todo Implement check if rules have been changed - */ - public function ifRulesHaveChanged () { - return FALSE; - } - - /** - * Checks whether email change is allowed - * - * @return $emailChange Whether changing email address is allowed - */ - public function ifEmailChangeAllowed () { - $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y'); - return $emailChange; - } - - /** - * Checks whether the user account is unconfirmed - * - * @return $isUnconfirmed Whether the user account is unconfirmed - */ - public function ifUserAccountUnconfirmed () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed')); - return $isUnconfirmed; - } - - /** - * Checks whether the user account is locked - * - * @return $isUnconfirmed Whether the user account is locked - */ - public function ifUserAccountLocked () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked')); - return $isUnconfirmed; - } - - /** - * Checks whether the user account is a guest - * - * @return $isUnconfirmed Whether the user account is a guest - */ - public function ifUserAccountGuest () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest')); - return $isUnconfirmed; - } - - /** - * Checks whether the refill page is active which should be not the default - * on non-web applications. - * - * @return $refillActive Whether the refill page is active - */ - public function ifRefillPageActive () { - $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y'); - return $refillActive; - } - - /** - * Flushs the content out (not yet secured against open forms, etc.!) or - * close the form automatically - * - * @return void - * @throws FormOpenedException If the form is still open - */ - public function flushContent () { - // Is the form still open? - if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) { - // Close the form automatically - $this->addFormTag(); - } elseif ($this->formEnabled === FALSE) { - if ($this->ifSubGroupOpenedPreviously()) { - // Close sub group - $this->addFormSubGroup(); - } elseif ($this->ifGroupOpenedPreviously()) { - // Close group - $this->addFormGroup(); - } - } - - // Send content to template engine - //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."
\n"; - $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/web/links/.htaccess b/inc/classes/main/helper/web/links/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/web/links/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php deleted file mode 100644 index ff0b7083..00000000 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ /dev/null @@ -1,343 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { - /** - * Name of the link - */ - private $linkName = ''; - - /** - * Base of the link - */ - private $linkBase = ''; - - /** - * First parameter separator - */ - const FIRST_PARAMETER_SEPARATOR = '?'; - - /** - * SEPARATOR for more paraemters - */ - const EXTRA_PARAMETER_SEPARATOR = '&'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $linkName Name of the link we shall generate - * @param $linkBase Link base for the link. This parameter is deprecated. - * @return $helperInstance A prepared instance of this helper - * @throws NoConfigEntryException A deprecated exception at this point - */ - public static final function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = NULL) { - // Get new instance - $helperInstance = new WebLinkHelper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set link name - $helperInstance->setLinkName($linkName); - - // Get the application instance - $applicationInstance = Registry::getRegistry()->getInstance('application'); - - // Get the request instance - $requestInstance = $applicationInstance->getRequestInstance(); - - // Sanity-check on it - if (is_null($requestInstance)) { - // Throw an exception here - throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get page (this will throw an exception if not set) - $page = $helperInstance->convertDashesToUnderscores($requestInstance->getRequestElement('page')); - - // Construct config entry - $configEntry = $page . '_' . $linkName . '_action_url'; - - // Is the deprecated parameter set? - if (!is_null($linkBase)) { - // Then output a deprecation message - $helperInstance->deprecationWarning('[' . __METHOD__ . ':' . __LINE__ . ']: linkBase is deprecated. Please remove it from your templates and add a config entry ' . $configEntry . ' in your config.php file.'); - } // END - if - - // Determine link base from config now and 'page' request - try { - $newLinkBase = $helperInstance->getConfigInstance()->getConfigEntry($configEntry); - $linkBase = $newLinkBase; - } catch (NoConfigEntryException $e) { - // Is the deprecated linkBase not set? - if (is_null($linkBase)) { - // Then throw again the exception - throw new NoConfigEntryException(array(__CLASS__, ($configEntry)), FrameworkConfiguration::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); - } // END - if - } - - // Set link base - $helperInstance->setLinkBase($linkBase); - - // Add default group - $helperInstance->openGroupByIdContent('main', '', ''); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Renders the link content (HTML code) with given link text and optional - * extra content - * - * @param $linkText Link text to set in link - * @param $linkTitle Link title to set in link - * @param $extraContent Optional extra HTML content - * @return $linkContent Rendered text link content - */ - private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') { - // Construct link content - $linkContent = sprintf("%s", - $this->getLinkBase(), - $extraContent, - $linkTitle, - $linkText - ); - - // Return it - return $linkContent; - } - - /** - * Setter for link name - * - * @param $linkName Name of the link we shall generate - * @return void - */ - protected final function setLinkName ($linkName) { - $this->linkName = (string) $linkName; - } - - /** - * Getter for link name - * - * @return $linkName Name of the link we shall generate - */ - public final function getLinkName () { - return $this->linkName; - } - - /** - * Setter for link base - * - * @param $linkBase Base of the link we shall generate - * @return void - */ - protected final function setLinkBase ($linkBase) { - $this->linkBase = (string) $linkBase; - } - - /** - * Getter for link base - * - * @return $linkBase Base of the link we shall generate - */ - public final function getLinkBase () { - return $this->linkBase; - } - - /** - * Flush the content out,e g. to a template variable - * - * @return void - * @todo Completely unimplemented - */ - public function flushContent () { - // Is a previous opened group still open? - if ($this->ifGroupOpenedPreviously()) { - // Then close it - $this->closePreviousGroupByContent(''); - } // END - if - - // Get the content - $content = $this->renderContent(); - - // Get template engine - $templateInstance = $this->getTemplateInstance(); - - // Add content to variable - $templateInstance->assignVariable($this->getLinkName(), $content); - } - - /** - * Adds a link group (like the form group is) with some raw language to the - * helper. - * - * @param $groupId Id string of the group - * @param $groupText Text for this group to add - * @param $groupCode Code to open and close groups - * @return void - */ - public function addLinkGroup ($groupId, $groupText, $groupCode = "div") { - // Is a group with that name open? - if ($this->ifGroupOpenedPreviously()) { - // Then close it here - $this->closePreviousGroupByContent(''); - } // END - if - - // Generate the group content - $content = sprintf("<{$groupCode} id=\"group_%s_%s\">%s", - $this->getLinkName(), - $groupId, - $groupText - ); - - // Open the new group - $this->openGroupByIdContent($groupId, $content, $groupCode); - } - - /** - * Adds text (note) to the previously opened group or throws an exception - * if no previous group was opened. - * - * @param $groupId Group id to set - * @param $groupNote Note to be added to a group - * @param $groupCode Code to open and close groups - * @return void - * @throws NoGroupOpenedException If no previous group was opened - */ - public function addLinkNote ($groupId, $groupNote, $groupCode = "div") { - // Check if a previous group was opened - if ($this->ifGroupOpenedPreviously() === FALSE) { - // No group was opened before! - throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); - } // END - if - - // Is a previous sub group open? - if ($this->ifSubGroupOpenedPreviously()) { - // Then close it - $this->closePreviousSubGroupByContent(""); - } // END - if - - // Generate the group content - $content = sprintf("<{$groupCode} id=\"subgroup_%s_%s\">%s", - $this->getLinkName(), - $groupId, - $groupNote - ); - - // Open the sub group - $this->openSubGroupByIdContent($groupId, $content, $groupCode); - } - - /** - * Adds a link to the previously opened group or throws an exception if no group has been opened - * - * @param $linkAction Action (action=xxx) value for the link - * @param $linkText Link text and title (title="xxx") for the link - * @return void - * @throws NoGroupOpenedException If no previous group was opened - */ - protected function addActionLink ($linkAction, $linkText, $linkTitle) { - // Check if a previous group was opened - if ($this->ifGroupOpenedPreviously() === FALSE) { - // No group was opened before! - throw new NoGroupOpenedException(array($this, $linkAction . '(' . $linkText . ')'), self::EXCEPTION_GROUP_NOT_OPENED); - } // END - if - - // Default parameter SEPARATOR is & - $separator = self::EXTRA_PARAMETER_SEPARATOR; - - // Is there a question mark in? - $linkArray = explode(self::FIRST_PARAMETER_SEPARATOR, $this->getLinkBase()); - if (count($linkArray) == 0) { - // No question mark - $separator = self::FIRST_PARAMETER_SEPARATOR; - } // END - if - - // Prepare action - $action = sprintf('%saction=%s', - $separator, - $linkAction - ); - - // Renders the link content - $linkContent = $this->renderLinkContentWithTextExtraContent($linkText, $linkTitle, $action); - - // Add the content to the previous group - $this->addContentToPreviousGroup($linkContent); - } - - /** - * Adds a link to the previously opened group with a text from language system - * - * @param $linkAction Action (action=xxx) value for the link - * @param $languageId Language id string to use - * @return void - */ - public function addActionLinkById ($linkAction, $languageId) { - // Resolve the language string - $languageResolvedText = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_text"); - - // Resolve the language string - $languageResolvedTitle = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_title"); - - // Add the action link - $this->addActionLink($linkAction, $languageResolvedText, $languageResolvedTitle); - } - - /** - * Adds a default link (no extra parameters) to the content with specified - * language id string. - * - * @param $languageId Language id string to use - * @return void - */ - public function addLinkWithTextById ($languageId) { - // Resolve the language string - $languageResolvedText = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_text"); - - // Resolve the language string - $languageResolvedTitle = $this->getLanguageInstance()->getMessage("link_" . $languageId . "_title"); - - // Now add the link - $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolvedText, $languageResolvedTitle); - - // Add the content to the previous group - $this->addContentToPreviousGroup($linkContent); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/action/html/.htaccess b/inc/classes/main/resolver/action/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/action/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/action/html/class_HtmlActionResolver.php b/inc/classes/main/resolver/action/html/class_HtmlActionResolver.php new file mode 100644 index 00000000..e6d8bb37 --- /dev/null +++ b/inc/classes/main/resolver/action/html/class_HtmlActionResolver.php @@ -0,0 +1,151 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlActionResolver extends BaseActionResolver implements ActionResolver { + /** + * Last successfull resolved action + */ + private $lastActionInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'html' + $this->setClassPrefix('html'); + } + + /** + * Creates an instance of a Html action resolver with a given default action + * + * @param $actionName The default action we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws InvalidActionException Thrown if default action is invalid + */ + public static final function createHtmlActionResolver ($actionName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HtmlActionResolver(); + + // Is the variable $actionName set and the action is valid? + if (empty($actionName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isActionValid($actionName) === FALSE) { + // Invalid action found + throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $actionInstance An instance of the resolved action + * @throws InvalidActionException Thrown if $actionName is + * invalid + * @throws InvalidActionInstanceException Thrown if $actionInstance + * is an invalid instance + */ + public function resolveActionByRequest (Requestable $requestInstance) { + // Init variables + $actionName = ''; + $actionInstance = NULL; + + // This goes fine so let's resolve the action + $actionName = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($actionName)) { + $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->isActionValid($actionName) === FALSE) { + // This action is invalid! + throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $actionInstance = $this->loadAction(); + + // And validate it + if ((!is_object($actionInstance)) || (!$actionInstance instanceof Actionable)) { + // This action has an invalid instance! + throw new InvalidActionInstanceException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->setResolvedInstance($actionInstance); + + // Return the resolved action instance + return $actionInstance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $actionInstance An instance of the action class + * @throws InvalidActionException Thrown if $actionName is invalid + */ + public function resolveAction () { + // Initiate the instance variable + $actionInstance = NULL; + + // Get action name + $actionName = $this->getActionName(); + + // Is the action empty? Then fall back to default action + if (empty($actionName)) { + $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->isActionValid($actionName) === FALSE) { + // This action is invalid! + throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $actionInstance = $this->loadAction(); + + // Return the instance + return $actionInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/action/web/.htaccess b/inc/classes/main/resolver/action/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/action/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/action/web/class_WebActionResolver.php b/inc/classes/main/resolver/action/web/class_WebActionResolver.php deleted file mode 100644 index a5e9a0ca..00000000 --- a/inc/classes/main/resolver/action/web/class_WebActionResolver.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebActionResolver extends BaseActionResolver implements ActionResolver { - /** - * Last successfull resolved action - */ - private $lastActionInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "Web" - $this->setClassPrefix('web'); - } - - /** - * Creates an instance of a Web action resolver with a given default action - * - * @param $actionName The default action we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws InvalidActionException Thrown if default action is invalid - */ - public static final function createWebActionResolver ($actionName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new WebActionResolver(); - - // Is the variable $actionName set and the action is valid? - if (empty($actionName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isActionValid($actionName) === FALSE) { - // Invalid action found - throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $actionInstance An instance of the resolved action - * @throws InvalidActionException Thrown if $actionName is - * invalid - * @throws InvalidActionInstanceException Thrown if $actionInstance - * is an invalid instance - */ - public function resolveActionByRequest (Requestable $requestInstance) { - // Init variables - $actionName = ''; - $actionInstance = NULL; - - // This goes fine so let's resolve the action - $actionName = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($actionName)) { - $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->isActionValid($actionName) === FALSE) { - // This action is invalid! - throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $actionInstance = $this->loadAction(); - - // And validate it - if ((!is_object($actionInstance)) || (!$actionInstance instanceof Actionable)) { - // This action has an invalid instance! - throw new InvalidActionInstanceException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($actionInstance); - - // Return the resolved action instance - return $actionInstance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $actionInstance An instance of the action class - * @throws InvalidActionException Thrown if $actionName is invalid - */ - public function resolveAction () { - // Initiate the instance variable - $actionInstance = NULL; - - // Get action name - $actionName = $this->getActionName(); - - // Is the action empty? Then fall back to default action - if (empty($actionName)) { - $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->isActionValid($actionName) === FALSE) { - // This action is invalid! - throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $actionInstance = $this->loadAction(); - - // Return the instance - return $actionInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/class_ b/inc/classes/main/resolver/class_ index 33ce259e..5cdfd089 100644 --- a/inc/classes/main/resolver/class_ +++ b/inc/classes/main/resolver/class_ @@ -37,7 +37,7 @@ class ???Resolver extends BaseResolver implements Resolver { } /** - * Creates an instance of a Web action resolver with a given default action + * Creates an instance of a Html action resolver with a given default action * * @param $!!!Name The default action we shall execute * @param $appInstance An instance of a manageable application helper class @@ -181,7 +181,7 @@ class ???Resolver extends BaseResolver implements Resolver { } /** - * Creates an instance of a Web action resolver with a given default action + * Creates an instance of a Html action resolver with a given default action * * @param $!!!Name The default action we shall execute * @param $appInstance An instance of a manageable application helper class @@ -325,7 +325,7 @@ class ???Resolver extends BaseResolver implements Resolver { } /** - * Creates an instance of a Web action resolver with a given default action + * Creates an instance of a Html action resolver with a given default action * * @param $!!!Name The default action we shall execute * @param $appInstance An instance of a manageable application helper class @@ -469,7 +469,7 @@ class ???Resolver extends BaseResolver implements Resolver { } /** - * Creates an instance of a Web action resolver with a given default action + * Creates an instance of a ??? resolver with a given default action * * @param $!!!Name The default action we shall execute * @param $appInstance An instance of a manageable application helper class diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index e4f3130d..68be4dcb 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -704,7 +704,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $this->loadRawTemplateData($fqfn); } catch (FileIoException $e) { // If we shall load a code-template we need to switch the file extension - if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('web_template_type')) && (empty($extOther))) { + if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) { // Switch over to the code-template extension and try it again $ext = $this->getCodeTemplateExtension(); @@ -934,7 +934,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { foreach ($this->rawTemplates as $key => $template) { try { // Load the template - $this->loadWebTemplate($template); + $this->loadHtmlTemplate($template); // Remember it's contents $this->rawTemplates[$template] = $this->getRawTemplateData(); @@ -1086,15 +1086,15 @@ class BaseTemplateEngine extends BaseFrameworkSystem { } /** - * Load a specified web template into the engine + * Load a specified HTML template into the engine * * @param $template The web template we shall load which is located in * 'html' by default * @return void */ - public function loadWebTemplate ($template) { + public function loadHtmlTemplate ($template) { // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('web_template_type')); + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('html_template_type')); // Load the special template $this->loadTemplate($template); diff --git a/inc/config.php b/inc/config.php index 77db3c02..276e5579 100644 --- a/inc/config.php +++ b/inc/config.php @@ -104,8 +104,8 @@ $cfg->setConfigEntry('debug_console_class', 'DebugConsoleOutput'); // CFG: DEFAULT-LANGUAGE $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: HTML-TEMPLATE-TYPE +$cfg->setConfigEntry('html_template_type', 'html'); // CFG: EMAIL-TEMPLATE-TYPE $cfg->setConfigEntry('email_template_type', 'emails'); @@ -246,10 +246,10 @@ $cfg->setConfigEntry('user_db_wrapper_class', 'UserDatabaseWrapper'); $cfg->setConfigEntry('news_db_wrapper_class', 'NewsDatabaseWrapper'); // CFG: HTML-CMD-RESOLVER-CLASS -$cfg->setConfigEntry('html_cmd_resolver_class', 'WebCommandResolver'); +$cfg->setConfigEntry('html_cmd_resolver_class', 'HtmlCommandResolver'); // CFG: HTML-CMD-LOGIN-RESOLVER-CLASS -$cfg->setConfigEntry('html_cmd_login_resolver_class', 'WebCommandResolver'); +$cfg->setConfigEntry('html_cmd_login_resolver_class', 'HtmlCommandResolver'); // CFG: IMAGE-CMD-RESOLVER-CLASS $cfg->setConfigEntry('image_cmd_resolver_class', 'ImageCommandResolver');