two pages are "ready": home and register.
Signed-off-by: Roland Haeder <roland@mxchange.org>
// CFG: DEFAULT-CITY-HTML-COMMAND
$cfg->setConfigEntry('default_city_html_command', 'home');
+// CFG: DEFAULT-HTML-CONTROLLER
+$cfg->setConfigEntry('default_html_controller', 'home');
+
+// CFG: DEFAULT-CITY-HTML-CONTROLLER
+$cfg->setConfigEntry('default_city_html_controller', 'home');
+
// CFG: CITY-HTML-CMD-HOME-RESOLVER-CLASS
$cfg->setConfigEntry('city_html_cmd_home_resolver_class', 'CityHtmlCommandResolver');
// CFG: CITY-HOME-MENU-CLASS
$cfg->setConfigEntry('city_home_menu_class', 'CityHomeMenu');
+// CFG: CITY-REGISTER-MENU-CLASS
+$cfg->setConfigEntry('city_register_menu_class', 'CityRegisterMenu');
+
// CFG: MENU-TEMPLATE-CLASS
$cfg->setConfigEntry('menu_template_class', 'MenuTemplateEngine');
// CFG: MENU-TEMPLATE-EXTENSION
$cfg->setConfigEntry('menu_template_extension', '.xml');
+// CFG: HTML-FORM-HELPER
+$cfg->setConfigEntry('html_form_helper', 'HtmlFormHelper');
+
+// CFG: FORM-ACTION
+$cfg->setConfigEntry('form_action', 'index.php?app={?app_short_name?}&command=do_form');
+
+// CFG: FORM-METHOD
+$cfg->setConfigEntry('form_method', 'post');
+
+// CFG: FORM-TARGET
+$cfg->setConfigEntry('form_target', '_self');
+
+// CFG: REGISTER-REQUIRES-EMAIL
+$cfg->setConfigEntry('register_requires_email', 'Y');
+
+// CFG: REGISTER-INCLUDES-PROFILE
+$cfg->setConfigEntry('register_includes_profile', 'Y');
+
+// CFG: REGISTER-PERSONAL-DATA
+$cfg->setConfigEntry('register_personal_data', 'Y');
+
+// CFG: REGISTER-EMAIL-UNIQUE
+$cfg->setConfigEntry('register_email_unique', 'Y');
+
+// CFG: PROFILE-INCLUDES-BIRTHDAY
+$cfg->setConfigEntry('profile_includes_birthday', 'Y');
+
+// CFG: CHAT-ENABLED-ICQ
+$cfg->setConfigEntry('chat_enabled_icq', 'Y');
+
+// CFG: CHAT-ENABLED-JABBER
+$cfg->setConfigEntry('chat_enabled_jabber', 'Y');
+
+// CFG: CHAT-ENABLED-YAHOO
+$cfg->setConfigEntry('chat_enabled_yahoo', 'Y');
+
+// CFG: CHAT-ENABLED-AOL
+$cfg->setConfigEntry('chat_enabled_aol', 'Y');
+
+// CFG: CHAT-ENABLED-MSN
+$cfg->setConfigEntry('chat_enabled_msn', 'Y');
+
+// CFG: CITY-REGISTER-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_register_captcha_secured', 'Y');
+
+// CFG: CITY-USER-LOGIN-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_user_login_captcha_secured', 'Y');
+
+// CFG: CITY-GUEST-LOGIN-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_guest_login_captcha_secured', 'Y');
+
+// CFG: CITY-PROFILE-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_profile_captcha_secured', 'Y');
+
+// CFG: CITY-REFILL-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_refill_captcha_secured', 'Y');
+
+// CFG: CITY-GOVERNMENT-STARTUP-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_government_startup_captcha_secured', 'Y');
+
+// CFG: CITY-GOVERNMENT-TRAINING-CAPTCHA-SECURED
+$cfg->setConfigEntry('city_government_training_captcha_secured', 'Y');
+
+// CFG: CITY-REGISTER-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_register_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CITY-USER-LOGIN-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_user_login_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CITY-GUEST-LOGIN-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_guest_login_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CITY-PROFILE-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_profile_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CITY-REFILL-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_refill_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CITY-GOVERNMENT-STARTUP-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_government_startup_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CITY-GOVERNMENT-TRAINING-CAPTCHA-CLASS
+$cfg->setConfigEntry('city_government_training_captcha_class', 'GraphicalCodeCaptcha');
+
+// CFG: CAPTCHA-STRING-LENGTH
+$cfg->setConfigEntry('captcha_string_length', 5);
+
+// CFG: CAPTCHA-SEARCH-CHARS
+$cfg->setConfigEntry('captcha_search_chars', '+/=');
+
+// CFG: RANDOM-STRING-LENGTH
+$cfg->setConfigEntry('random_string_length', 100);
+
+// CFG: IMAGE-TEMPLATE-CLASS
+$cfg->setConfigEntry('image_template_class', 'ImageTemplateEngine');
+
+// CFG: CAPTCHA-ENCRYPT-VALIDATOR-FILTER
+$cfg->setConfigEntry('captcha_encrypt_validator_filter', 'CaptchaEncryptFilter');
+
+// CFG: CITY-HTML-CMD-DO-FORM-RESOLVER-CLASS
+$cfg->setConfigEntry('city_html_cmd_do_form_resolver_class', 'HtmlCommandResolver');
+
+// CFG: CAPTCHA-GUEST-VERIFIER-FILTER
+$cfg->setConfigEntry('captcha_guest_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter');
+
+// CFG: CAPTCHA-USER-VERIFIER-FILTER
+$cfg->setConfigEntry('captcha_user_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter');
+
+// CFG: CAPTCHA-REGISTER-VERIFIER-FILTER
+$cfg->setConfigEntry('captcha_register_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter');
+
+// CFG: CAPTCHA-REFILL-VERFIER-FILTER
+$cfg->setConfigEntry('captcha_refill_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter');
+
+// CFG: CAPTCHA-GOVERNMENT-VERFIER-FILTER
+$cfg->setConfigEntry('captcha_government_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter');
+
+// CFG: CAPTCHA-PROFILE-VERFIER-FILTER
+$cfg->setConfigEntry('captcha_profile_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter');
+
+// CFG: CONFIRM-CODE-VERIFIER-FILTER
+$cfg->setConfigEntry('confirm_code_verifier_filter', 'ConfirmCodeVerifierFilter');
+
+// CFG: BIRTHDAY-REGISTER-VERIFIER-FILTER
+$cfg->setConfigEntry('birthday_register_verifier_filter', 'BirthdayVerifierFilter');
+
+// CFG: BIRTHDAY-PROFILE-VERIFIER-FILTER
+$cfg->setConfigEntry('birthday_profile_verifier_filter', 'BirthdayVerifierFilter');
+
/******************************************************************************
* Console client *
******************************************************************************/
);
// Set application name and version
-$app->setAppName('Simple City Grow Simulation');
+$app->setAppName('Simple City Growth Simulation');
$app->setAppVersion('0.0.0');
$app->setAppShortName('city');
--- /dev/null
+<?php
+/**
+ * A command for registration handling
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 Ship-Simu 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 <http://www.gnu.org/licenses/>.
+ */
+class CityHtmlRegisterCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createCityHtmlRegisterCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new CityHtmlRegisterCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * 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) {
+ /*
+ * This is a generic HTML request, this means that a regular page with
+ * header, menu, content and footer shall be send to the client.
+ */
+ $this->sendGenericGetResponse($requestInstance, $responseInstance, '_form');
+ }
+
+ /**
+ * 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
+ * @todo Add some more pre/post filters to the controller
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A command for registration form (POST) handling
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 Ship-Simu 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 <http://www.gnu.org/licenses/>.
+ */
+class HtmlCityRegisterCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createHtmlCityRegisterCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new HtmlCityRegisterCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * 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) {
+ // First get a UserRegistration instance
+ $registerInstance = ObjectFactory::createObjectByConfiguredName('user_registration_class');
+
+ // First set request and response instance
+ $registerInstance->setRequestInstance($requestInstance);
+ $registerInstance->setResponseInstance($responseInstance);
+
+ // Encrypt the password
+ $registerInstance->encryptPassword('pass1');
+
+ // Do things before registration
+ $registerInstance->doPreRegistration();
+
+ // Register the new user
+ $registerInstance->registerNewUser();
+
+ /*
+ * Do things after registration like notifying partner pages or queueing
+ * them for notification
+ */
+ $registerInstance->doPostRegistration();
+
+ // Redirect or login after registration
+ $registerInstance->doPostAction();
+ }
+
+ /**
+ * 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
+ * @todo Add some more pre/post filters to the controller
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Validate email address (if configured: check on double email addresses)
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter'));
+
+ // Validate username and check if it does not exist
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_filter'));
+
+ // Validate if username is "guest" and not taken
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_is_guest_filter'));
+
+ // Validate if password is set
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_filter'));
+
+ // Check if rules where accepted
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_filter'));
+
+ // Validate CAPTCHA input
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_register_verifier_filter'));
+
+ // Validate birthday
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('birthday_register_verifier_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * Controller for register form
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 <http://www.gnu.org/licenses/>.
+ */
+class CityHtmlRegisterController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * 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 filters to this controller
+ */
+ public static final function createCityHtmlRegisterController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlRegisterController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // 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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A controller for handling sent forms
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 <http://www.gnu.org/licenses/>.
+ */
+class CityHtmlDoFormController 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 createCityHtmlDoFormController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new CityHtmlDoFormController();
+
+ // 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);
+ } // END - if
+
+ // Flush the buffer out
+ $responseInstance->flushBuffer();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A menu class for City registration
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 <http://www.gnu.org/licenses/>.
+ */
+class CityRegisterMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createCityRegisterMenu () {
+ // Get a new instance
+ $menuInstance = new CityRegisterMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
}
/**
- * Creates an instance of a resolver class with a given command
+ * Creates an instance of a resolver class with a given controller
*
* @param $controllerName The controller we shall resolve
* @param $applicationInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if default command is not set
+ * @throws EmptyVariableException Thrown if default controller is not set
* @throws InvalidControllerException Thrown if default controller is invalid
*/
public static final function createCityConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
// Create the new instance
$resolverInstance = new CityConsoleControllerResolver();
- // Is the variable $controllerName set and the command is valid?
+ // Is the variable $controllerName set and the controller is valid?
if (empty($controllerName)) {
// Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
- // Invalid command found
+ // Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
// Set the application instance
$resolverInstance->setApplicationInstance($applicationInstance);
- // Set command name
+ // Set controller name
$resolverInstance->setControllerName($controllerName);
// Return the prepared instance
return $resolverInstance;
}
-
- /**
- * Resolves the default controller of the given command
- *
- * @return $controllerInstance A controller instance for the default
- * command
- * @throws InvalidControllerInstanceException Thrown if $controllerInstance
- * is invalid
- */
- public function resolveController () {
- // Init variables
- $controllerName = '';
- $controllerInstance = NULL;
-
- // Get the command name
- $controllerName = $this->getControllerName();
-
- // Get the command
- $controllerInstance = $this->loadController($controllerName);
-
- // And validate it
- if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
- // This command has an invalid instance!
- throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- } // END - if
-
- // Set last controller
- $this->setResolvedInstance($controllerInstance);
-
- // Return the maybe resolved instance
- return $controllerInstance;
- }
}
// [EOF]
}
/**
- * Creates an instance of a resolver class with a given command
+ * Creates an instance of a resolver class with a given controller
*
* @param $controllerName The controller we shall resolve
* @param $applicationInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if default command is not set
+ * @throws EmptyVariableException Thrown if default controller is not set
* @throws InvalidControllerException Thrown if default controller is invalid
*/
public static final function createCityHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
// Create the new instance
$resolverInstance = new CityHtmlControllerResolver();
- // Is the variable $controllerName set and the command is valid?
+ // Is the variable $controllerName set and the controller is valid?
if (empty($controllerName)) {
// Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
- // Invalid command found
+ // Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
// Set the application instance
$resolverInstance->setApplicationInstance($applicationInstance);
- // Set command name
+ // Set controller name
$resolverInstance->setControllerName($controllerName);
// Return the prepared instance
return $resolverInstance;
}
-
- /**
- * Resolves the default controller of the given command
- *
- * @return $controllerInstance A controller instance for the default
- * command
- * @throws InvalidControllerInstanceException Thrown if $controllerInstance
- * is invalid
- */
- public function resolveController () {
- // Init variables
- $controllerName = '';
- $controllerInstance = NULL;
-
- // Get the command name
- $controllerName = $this->getControllerName();
-
- // Get the command
- $controllerInstance = $this->loadController($controllerName);
-
- // And validate it
- if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
- // This command has an invalid instance!
- throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- } // END - if
-
- // Set last controller
- $this->setResolvedInstance($controllerInstance);
-
- // Return the maybe resolved instance
- return $controllerInstance;
- }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2015 City 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 <http://www.gnu.org/licenses/>.
+ */
+class CityImageControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to 'image'
+ $this->setClassPrefix('image');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given controller
+ *
+ * @param $controllerName The controller we shall resolve
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws EmptyVariableException Thrown if default controller is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createCityImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new CityImageControllerResolver();
+
+ // Is the variable $controllerName set and the controller is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ // Invalid controller found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($applicationInstance);
+
+ // Set controller name
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE: Has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
- // Set the city instance
- $stateInstance->setCityInstance($cityInstance);
-
// Return the prepared instance
return $stateInstance;
}
// Get new instance
$stateInstance = new CityInitState();
- // Set the city instance
- $stateInstance->setCityInstance($cityInstance);
-
// Return the prepared instance
return $stateInstance;
}
// Get new instance
$stateInstance = new CityVirginState();
- // Set the city instance
- $stateInstance->setCityInstance($cityInstance);
-
// Return the prepared instance
return $stateInstance;
}
--- /dev/null
+<?php
+// Get a helper instance without a form tag
+$captchaHelper = ObjectFactory::createObjectByConfiguredName('html_form_helper', array($this, 'captcha_code', false, false));
+
+// Add input field with text for CAPTCHA code
+$captchaHelper->addFieldText('captcha_code', "Bitte wiederhole den Code:");
+$captchaHelper->addInputTextField('c_code');
+
+// Add hidden field with validation hash
+$captchaHelper->addInputHiddenField('hash', $this->readVariable('captcha_hash'));
+
+// Flush content
+$captchaHelper->flushContent();
+
+// [EOC]
+?>
+<div class="captcha_image">
+ <img src="{?base_url?}/index.php?app={?app_short_name?}&command=code_captcha&encrypt={?encrypted_code?}&request=image"
+ alt="CAPTCHA-Bild" title="CAPTCHA-Bild" class="captcha_img" />
+</div>
+<div class="captcha_code">
+ {?captcha_code?}
+</div>
<div id="news_frame">
{?city_news?}
</div>
+
+<div id="welcome">
+ Hier wird der Gast zum Spiel begrüsst.
+</div>
--- /dev/null
+<?php
+// Get helper instance for web forms. This will add the opening form-tag to
+// the helper's render cache which is simply a small variable in the class
+// BaseHelper.
+$helperInstance = ObjectFactory::createObjectByConfiguredName('html_form_helper', array($this, 'city_register'));
+
+// Always ask at least for nickname and password
+$helperInstance->addFormGroup('login', "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein.");
+$helperInstance->addFormSubGroup('username', "Dein Nickname wird erst nach Absenden des Formulares geprüft. Später bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist.");
+$helperInstance->addFieldText('username', "Nickname im Spiel:");
+$helperInstance->addInputTextField('username');
+$helperInstance->addFormSubGroup('pass', "Dein Passwort sollte nicht zu leicht erratbar sein. Später bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortstärke anzeigt.");
+$helperInstance->addFieldText('pass1', "Passwort:");
+$helperInstance->addInputPasswordField('pass1');
+$helperInstance->addFieldText('pass2', "Passwortwiederholung:");
+$helperInstance->addInputPasswordField('pass2');
+
+// Does this registration require an email?
+if ($helperInstance->ifRegisterRequiresEmailVerification()) {
+ $helperInstance->addFormGroup('email', "Bitte gebe deine Email zweimal (ein zweites Mal zur Bestätigung) ein, damit wir dir deinen Freischaltlink zusenden können.");
+ $helperInstance->addFieldText('email1', "Email-Adresse:");
+ $helperInstance->addInputTextField('email1');
+ $helperInstance->addFieldText('email2', "Wiederholung Email-Adresse:");
+ $helperInstance->addInputTextField('email2');
+
+ // Must the email address be unique in this system?
+ if ($helperInstance->ifEmailMustBeUnique()) {
+ $helperInstance->addFormNote('email', "Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein.");
+ } // END - if
+} // END - if
+
+// Shall we also ask some personal data to complete the profile?
+if ($helperInstance->ifRegisterIncludesProfile()) {
+ $helperInstance->addFormGroup('profile', "Hier kannst du zusätzlich deine Profildaten vorweg eingeben, du kannst sie aber auch nach dem Login vervollständigen!");
+
+ if (!$helperInstance->ifRegisterRequiresEmailVerification()) {
+ $helperInstance->addFormSubGroup('email', "Die Angabe deiner Email-Adresse ist nur dann nötig, wenn du auch Email-Benachrichtigungen (<span id=\"add_note\">*1</span>) haben möchtest.");
+ $helperInstance->addFieldText('email1', "Email-Adresse:");
+ $helperInstance->addInputTextField('email1');
+
+ // Must the email address be unique in this system?
+ if ($helperInstance->ifEmailMustBeUnique()) {
+ $helperInstance->addFormNote('email', "Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein.");
+ } // END - if
+ } // END - if
+
+ // Persoenliche Daten mit in der Anmeldung abfragen?
+ if ($helperInstance->ifRegisterIncludesPersonaData()) {
+ $helperInstance->addFormSubGroup('persona', "Wenn du magst, dann vervollständige deine komplette Adresse mit deinem Namen.");
+ $helperInstance->addFieldText('surname', "Dein Vorname:");
+ $helperInstance->addInputTextField('surname');
+ $helperInstance->addFieldText('family', "Dein Nachname:");
+ $helperInstance->addInputTextField('family');
+ $helperInstance->addFieldText('street', "Strasse und Hausnummer:");
+ $helperInstance->addInputTextField('street');
+ $helperInstance->addFieldText('city', "Wohnort:");
+ $helperInstance->addInputTextField('city');
+
+ // Include birthday?
+ if ($helperInstance->ifProfileIncludesBirthDay()) {
+ $helperInstance->addFormSubGroup('birthday', "Verrate uns doch dein Geburtsdatum, als Dankeschön erhälst du interessante Prämien - ausschliesslich per Email - zum Geburtstag zugesandt! Gültiges Format: TT.MM.JJJJ");
+ $helperInstance->addInputTextField('birth_day');
+ $helperInstance->addFieldText('birth_day', ".");
+ $helperInstance->addInputTextField('birth_month');
+ $helperInstance->addFieldText('birth_day', ".");
+ $helperInstance->addInputTextField('birth_year');
+ } // END - if
+ } // END - if
+
+ $helperInstance->addFormSubGroup('zip', "Magst du uns auch deine Postleitzahl verraten?");
+ $helperInstance->addFieldText('zip', "Postleitzahl:");
+ $helperInstance->addInputTextField('zip');
+
+ $helperInstance->addFormSubGroup('chat', "Gebe hier deine Nicknames bzw. Nummern an:");
+
+ if ($helperInstance->ifChatEnabled('icq')) {
+ $helperInstance->addFieldText('icq', "ICQ-Nummer:");
+ $helperInstance->addInputTextField('icq');
+ } // END - if
+
+ if ($helperInstance->ifChatEnabled('jabber')) {
+ $helperInstance->addFieldText('jabber', "Jabber:");
+ $helperInstance->addInputTextField('jabber');
+ } // END - if
+
+ if ($helperInstance->ifChatEnabled('yahoo')) {
+ $helperInstance->addFieldText('yahoo', "Yahoo!:");
+ $helperInstance->addInputTextField('yahoo');
+ } // END - if
+
+ if ($helperInstance->ifChatEnabled('aol')) {
+ $helperInstance->addFieldText('aol', "AOL-Screenname:");
+ $helperInstance->addInputTextField('aol');
+ } // END - if
+
+ if ($helperInstance->ifChatEnabled('msn')) {
+ $helperInstance->addFieldText('msn', "MSN:");
+ $helperInstance->addInputTextField('msn');
+ } // END - if
+
+ if (!$helperInstance->ifRegisterRequiresEmailVerification()) {
+ $helperInstance->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst.");
+ } // END - Extra note
+
+} // END - ask profile data
+
+// Spielregeln abfragen
+$helperInstance->addFormGroup('rules', "Bitte lese dir die Spieleregeln gut durch und kreuze dann "Ja, ich akzeptiere die aktuellen Spielregeln" an.");
+$helperInstance->addFieldText('rules', "Ja, ich akzeptiere die aktuellen Spielregeln:");
+$helperInstance->addInputCheckboxField('rules', false);
+
+// Add CAPTCHA?
+if ($helperInstance->ifFormSecuredWithCaptcha()) {
+ $helperInstance->addFormGroup('captcha', "Bitte wiederhole den angezeigten Code damit die Anmeldung abgeschlossen werden kann.");
+ $helperInstance->addCaptcha();
+} // END - if
+
+// Final note and submit buttons
+$helperInstance->addFormGroup('buttons', "Wenn du alle benötigten Felder korrekt ausgefüt hast, kannst du die Anmeldung abschliessen.");
+
+$helperInstance->addInputResetButton("Alles nochmal eingeben");
+$helperInstance->addInputSubmitButton("Anmeldung zum Spiel abschliessen");
+$helperInstance->addFormNote('data_protection', "Deine Daten werden nach den gültigen Datenschutzgesetzen gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link "Datenschutz".");
+$helperInstance->flushContent();
+
+// [EOC]
+?>
+<div id="content_header">
+ Anmeldung bei <span class="app_name">{?app_full_name?}</span>
+</div>
+
+<div id="register_box">
+ {?city_register?}
+</div>
--- /dev/null
+Deny from all
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<image>
+ <type value="{?image_type?}" />
+ <base>
+ <name value="{?image_name?}" />
+ </base>
+ <resolution>
+ <width value="{?image_width?}" />
+ <height value="{?image_height?}" />
+ </resolution>
+ <background-color>
+ <red value="{?image_bg_red?}" />
+ <green value="{?image_bg_green?}" />
+ <blue value="{?image_bg_blue?}" />
+ </background-color>
+ <foreground-color>
+ <red value="{?image_fg_red?}" />
+ <green value="{?image_fg_green?}" />
+ <blue value="{?image_fg_blue?}" />
+ </foreground-color>
+ <image-string value="groupable">
+ <string-name value="{?image_string_name?}" />
+ <x value="{?image_x?}" />
+ <y value="{?image_y?}" />
+ <font-size value="{?image_size?}" />
+ <text value="{?image_string?}" />
+ </image-string>
+</image>
--- /dev/null
+<?php
+// Needed in every image template to initialy set the image type
+$helper = ImageHelper::createImageHelper($this, 'png');
+$helper->setImageName('code_captcha');
+$helper->setBaseImage('base_code');
+
+// Set image dimensions
+$helper->setWidth(100);
+$helper->setHeight(50);
+
+// Get random number
+$rand = $helper->getRngInstance()->randomNumber(0, 6);
+
+// Background and foreground color
+switch ($rand) {
+ case 1:
+ // First varriant
+ $helper->setBackgroundColorRedGreenBlue('rand', 0x90 , 0x00 );
+ $helper->setForegroundColorRedGreenBlue(0x00 , 0xff , 'rand');
+ break;
+
+ case 2:
+ // Second varriant
+ $helper->setBackgroundColorRedGreenBlue(0x90 , 'rand', 0x00 );
+ $helper->setForegroundColorRedGreenBlue(0xff , 0x00 , 'rand');
+ break;
+
+ case 3:
+ // Third varriant
+ $helper->setBackgroundColorRedGreenBlue('rand', 0x00 , 0x90 );
+ $helper->setForegroundColorRedGreenBlue(0x00 , 'rand', 0xff );
+ break;
+
+ case 4:
+ // Forth varriant
+ $helper->setBackgroundColorRedGreenBlue(0x00 , 0x90 , 'rand');
+ $helper->setForegroundColorRedGreenBlue(0x00 , 'rand', 0xa0 );
+ break;
+
+ case 5:
+ // Fith varriant
+ $helper->setBackgroundColorRedGreenBlue('rand', 0x00 , 0x90 );
+ $helper->setForegroundColorRedGreenBlue(0x00 , 0xe0 , 'rand');
+ break;
+
+ default:
+ // Last varriant
+ $helper->setBackgroundColorRedGreenBlue(0x00 , 'rand', 0x90 );
+ $helper->setForegroundColorRedGreenBlue(0xff , 0x00 , 'rand');
+ break;
+}
+
+// Random X/Y factors...
+$xRand = $helper->getRngInstance()->randomNumber(0, 45);
+$yRand = $helper->getRngInstance()->randomNumber(0, 25);
+
+// Add code
+$helper->addTextLine('code');
+$helper->setCoord((5 + $xRand), (5 + $yRand));
+$helper->setFontSize('rand');
+$helper->setImageString('{?decrypted_code?}');
+
+// Only for debug!
+/*
+$helper->addTextLine('debug');
+$helper->setCoord(90, 35);
+$helper->setFontSize(3);
+$helper->setImageString($rand);
+*/
+
+// Flush content to the template engine
+$helper->flushContent();
+
+// Comment this out if image is done
+//$this->debugInstance();
+
+// [EOF]
+?>
--- /dev/null
+<?php
+// Needed in every image template to initialy set the image type
+$helper = ImageHelper::createImageHelper($this, 'png');
+$helper->setImageName('emergency_exit');
+$helper->setBaseImage('base_exit');
+
+// Set image dimensions
+$helper->setWidth(100);
+$helper->setHeight(50);
+
+// Flush content to the template engine
+//$helper->flushContent();
+
+// Comment this out if image is done
+$this->debugInstance();
+
+// [EOF]
+?>
-Subproject commit 3b3947b86b38904aa1100b54846c14d3b31cb97d
+Subproject commit bbb4031b65beb69a02f8c476ae4cdc36da851d84
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all