application/ship-simu/main/class_BaseSimulator.php -text
application/ship-simu/main/class_Merchant.php -text
application/ship-simu/main/class_WorksContract.php -text
+application/ship-simu/main/commands/.htaccess -text
+application/ship-simu/main/commands/web/.htaccess -text
+application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php -text
application/ship-simu/main/companies/.htaccess -text
application/ship-simu/main/companies/class_ShippingCompany.php -text
application/ship-simu/main/constructions/.htaccess -text
$app->setAppShortName(FrameworkConfiguration::getInstance()->readConfig("selector_name"));
// Initialize output system
-require(PATH . "inc/output.php");
+require(PATH . 'inc/output.php');
// Initialize file i/o system
-require(PATH . "inc/file_io.php");
+require(PATH . 'inc/file_io.php');
// Include the language sub-system
-require(PATH . "inc/language.php");
+require(PATH . 'inc/language.php');
// [EOF]
?>
$resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
// Get a new controller instance as well
- $controllerInstance = $resolverInstance->resolveDefaultController();
+ $controllerInstance = $resolverInstance->resolveCommandController();
// Handle the request
$controllerInstance->handleRequest($requestInstance, $responseInstance);
$cfg = FrameworkConfiguration::getInstance();
// CFG: DEFAULT-COMMAND
-$cfg->setConfigEntry("default_command", "home");
+$cfg->setConfigEntry('default_command', "home");
// CFG: HOME-WITH-NEWS
-$cfg->setConfigEntry("home_with_news", "Y");
+$cfg->setConfigEntry('home_with_news', "Y");
// CFG: FORM-ACTION
-$cfg->setConfigEntry("form_action", "index.php?app={?app_short_name?}&page=do_form");
+$cfg->setConfigEntry('form_action', "index.php?app={?app_short_name?}&page=do_form");
// CFG: FORM-METHOD
-$cfg->setConfigEntry("form_method", "post");
+$cfg->setConfigEntry('form_method', "post");
// CFG: FORM-TARGET
-$cfg->setConfigEntry("form_target", "_self");
+$cfg->setConfigEntry('form_target', "_self");
// CFG: REGISTRATION-REQUIRES-EMAIL
-$cfg->setConfigEntry("register_requires_email", "Y");
+$cfg->setConfigEntry('register_requires_email', "Y");
// CFG: REGISTRATION-INCLUDES-PROFILE
-$cfg->setConfigEntry("register_includes_profile", "Y");
+$cfg->setConfigEntry('register_includes_profile', "Y");
// CFG: REGISTRATION-PERSONAL-DATA
-$cfg->setConfigEntry("register_personal_data", "Y");
+$cfg->setConfigEntry('register_personal_data', "Y");
// CFG: CHAT-ENABLED-ICQ
-$cfg->setConfigEntry("chat_enabled_icq", "Y");
+$cfg->setConfigEntry('chat_enabled_icq', "Y");
// CFG: CHAT-ENABLED-JABBER
-$cfg->setConfigEntry("chat_enabled_jabber", "Y");
+$cfg->setConfigEntry('chat_enabled_jabber', "Y");
// CFG: CHAT-ENABLED-YAHOO
-$cfg->setConfigEntry("chat_enabled_yahoo", "Y");
+$cfg->setConfigEntry('chat_enabled_yahoo', "Y");
// CFG: CHAT-ENABLED-AOL
-$cfg->setConfigEntry("chat_enabled_aol", "Y");
+$cfg->setConfigEntry('chat_enabled_aol', "Y");
// CFG: CHAT-ENABLED-MSN
-$cfg->setConfigEntry("chat_enabled_msn", "Y");
+$cfg->setConfigEntry('chat_enabled_msn', "Y");
// CFG: COMMAND-PARAMETER
-$cfg->setConfigEntry("command_parameter", "page");
+$cfg->setConfigEntry('command_parameter', "page");
// [EOF]
?>
$app->setAppShortName("ship-simu");
// Initialize output system
-require(PATH . "inc/output.php");
+require(PATH . 'inc/output.php');
// Initialize file i/o system
-require(PATH . "inc/file_io.php");
+require(PATH . 'inc/file_io.php');
$app->setFileIoInstance($io);
// Include the language sub-system
-require(PATH . "inc/language.php");
+require(PATH . 'inc/language.php');
$app->setLanguageInstance($lang);
// This application needs a database connection then we have to simply include
// the inc/database.php script
-require(PATH . "inc/database.php");
+require(PATH . 'inc/database.php');
// [EOF]
?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command for registration handling
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebShipsimuRegisterCommand extends BaseCommand implements Commandable {
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Registration handling command for Ship-Simu");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * 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 final static function createWebShipsimuRegisterCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new WebShipsimuRegisterCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Get the controller instance from the resolver (breaks MVC pattern again)
+ $controllerInstance = $resolverInstance->getControllerInstance();
+
+ // @TODO Add some more pre/post filters to the controller
+ $controllerInstance->addPreFilter(UserNameValidatorFilter::createUserNameValidatorFilter());
+
+ // 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->partialStub();
+ }
+}
+
+// [EOF]
+?>
* @return $headerValue Value of the header or 'null' if not found
*/
function getHeader ($headerName);
+
+ /**
+ * Sets wether the request was valid (default: true)
+ *
+ * @param $isValid Wether the request is valid
+ * @return void
+ */
+ function requestIsValid ($isValid = true);
}
//
*
* @return $controllerInstance A controller instance for the default command
*/
- function resolveDefaultController ();
+ function resolveCommandController ();
}
//
* already sent
*/
function flushBuffer($force=false);
+
+ /**
+ * Adds a fatal message id to the response. The added messages can then be
+ * processed and outputed to the world
+ *
+ * @param $messageId The message id we shall add
+ * @return void
+ */
+ function addFatalMessage ($messageId);
}
//
}
return $className;
}
+
+ /**
+ * Outputs a debug backtrace and stops further script execution
+ *
+ * @return void
+ */
+ public function debugBacktrace () {
+ // Sorry, there is no other way getting this nice backtrace
+ print "<pre>\n";
+ debug_print_backtrace();
+ print "</pre>";
+ exit;
+ }
}
// [EOF]
parent::__construct(__CLASS__);
// Set special description
- $this->setObjectDescription("Home-Command");
+ $this->setObjectDescription("DoForm-Command");
// Create unique ID number
$this->createUniqueID();
* @return void
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- die(__METHOD__.": Stub!");
+ // Should never be executed...
+ echo "<strong>This should never be executed!</strong><pre>";
+ debug_print_backtrace();
+ die("</pre>Good bye...");
}
}
<?php
/**
- * A generic controller class
+ * A generic controller class. You should extend this base class if you want to
+ * write your own controller. You get the advantage that you can use the pre and
+ * post filters.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Getter for a command resolver instance
*
- * @
* @return $resolverInstance An instance of a command resolver class
*/
public final function getResolverInstance () {
* @return void
*/
protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ // Execute all pre filters
$this->preFilterChain->processFilters($requestInstance, $responseInstance);
}
* @return void
*/
protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ // Execute all post filters
$this->postFilterChain->processFilters($requestInstance, $responseInstance);
}
}
// Get the command instance
$commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
+
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
// Load the news here
$this->loadNewsByRequest($requestInstance);
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
+
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
// Set resolver instance
$controllerInstance->setResolverInstance($resolverInstance);
- // Generate some pre/post filters
- $controllerInstance->addDoFormPrePostFilters();
+ // We need the controller instance in the resolver class so set it here
+ $resolverInstance->setControllerInstance($controllerInstance);
// Return the prepared instance
return $controllerInstance;
* @return void
*/
public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
- // Run all pre filters
- $this->executePreFilters($requestInstance, $responseInstance);
- $requestInstance->debugInstance();
+ // Get the "form action"
+ $formAction = $requestInstance->getRequestElement('form');
// Get command instance from resolver
- $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
+ $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
+
+ // Execute *very* generic pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
- // Run all post filters
+ // Execute *very* generic ppost filters
$this->executePostFilters($requestInstance, $responseInstance);
- // Do something more here
- die("OK");
- }
-
- /**
- * Add some default pre/post filters for this controller to the matching
- * filter chains
- *
- * @return void
- */
- protected function addDoFormPrePostFilters () {
- // Add a filter to check for missing user name
- $this->addPreFilter(UserNameValidatorFilter::createUserNameValidatorFilter());
+ // Flush the buffer out
+ $responseInstance->flushBuffer();
}
}
*/
public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Run all filters
+ //* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
foreach ($this->filters as $filterInstance) {
// Execute this filter
//* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get username from request
- $userName = $requestInstance->getRequestElement("username");
+ $userName = $requestInstance->getRequestElement('username');
// Is the username set?
if (is_null($userName)) {
}
/**
- * Initialize the array-object for all later language strings
+ * Setter for base path
*
+ * @param $basePath The local base path for all templates
* @return void
*/
- public function initLanguageStrings () {
- $this->langStrings = new FrameworkArrayObject();
+ protected final function setBasePath ($basePath) {
+ // And set it
+ $this->basePath = (string) $basePath;
}
/**
- * Setter for base path
+ * Setter for language code
*
- * @param $basePath The local base path for all templates
+ * @param $langCode The language code for the current application
* @return void
*/
- public final function setBasePath ($basePath) {
+ protected final function setLanguageCode ($langCode) {
// Cast it
- $basePath = (string) $basePath;
+ $langCode = (string) $langCode;
- // And set it
- $this->basePath = $basePath;
+ // And set it (only 2 chars)
+ $this->langCode = substr($langCode, 0, 2);
}
/**
- * Getter for language code
+ * Initialize the array-object for all later language strings
*
- * @return $langCode The language code for the current application
+ * @return void
*/
- public final function getLanguageCode () {
- return $this->langCode;
+ public function initLanguageStrings () {
+ $this->langStrings = new FrameworkArrayObject();
}
/**
- * Setter for language code
+ * Getter for language code
*
- * @param $langCode The language code for the current application
- * @return void
+ * @return $langCode The language code for the current application
*/
- public final function setLanguageCode ($langCode) {
- // Cast it
- $langCode = (string) $langCode;
-
- // And set it (only 2 chars)
- $this->langCode = substr($langCode, 0, 2);
+ public final function getLanguageCode () {
+ return $this->langCode;
}
}
*/
private $requestData = array();
+ /**
+ * Wether this request is valid and can be further processed
+ */
+ private $requestIsValid = false;
+
/**
* Protected constructor
*
public final function getRequestMethod () {
return $_SERVER['REQUEST_METHOD'];
}
+
+ /**
+ * Sets wether the request was valid (default: true)
+ *
+ * @param $isValid Wether the request is valid
+ * @return void
+ */
+ public final function requestIsValid ($isValid = true) {
+ $this->requestIsValid = (bool) $isValid;
+ }
}
// [EOF]
*/
private $commandPrefix = "";
+ /**
+ * A controller instance
+ */
+ private $controllerInstance = null;
+
/**
* Protected constructor
*
parent::__construct($class);
// Clean up a little
+ $this->removeNumberFormaters();
$this->removeSystemArray();
}
+ /**
+ * Setter for controller instance (this surely breaks a bit the MVC patterm)
+ *
+ * @param $controllerInstance An instance of the controller
+ * @return void
+ */
+ public final function setControllerInstance (Controller $controllerInstance) {
+ $this->controllerInstance = $controllerInstance;
+ }
+
+ /**
+ * Getter for controller instance (this surely breaks a bit the MVC patterm)
+ *
+ * @return $controllerInstance An instance of the controller
+ */
+ public final function getControllerInstance () {
+ return $this->controllerInstance;
+ }
+
/**
* Setter for command name
*
// Create unique ID number
$this->createUniqueID();
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
-
// Set prefix to "Web"
$this->setCommandPrefix("Web");
}
return $commandInstance;
}
+ /**
+ * Resolves the command by its direct name and returns an instance of its class
+ *
+ * @param $commandName The direct command name we shall resolve
+ * @return $commandInstance An instance of the command class
+ * @throws InvalidCommandException Thrown if $commandName is invalid
+ */
+ public function resolveCommand ($commandName) {
+ // Initiate the instance variable
+ $commandInstance = null;
+
+ // Is the command empty? Then fall back to default command
+ if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
+
+ // Check if the command is valid
+ if (!$this->isCommandValid($commandName)) {
+ // This command is invalid!
+ throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Get the command
+ $commandInstance = $this->loadCommand($commandName);
+
+ // Return the instance
+ return $commandInstance;
+ }
+
/**
* "Loads" a given command and instances it if not yet cached
*
$commandInstance = null;
// Create command class name
- $class = sprintf("Web%sCommand",
+ $className = sprintf("Web%sCommand",
$this->convertToClassName($commandName)
);
// Is this class loaded?
- if (!class_exists($class)) {
+ if (!class_exists($className)) {
// Class not found, so try the default one or throw exception
if ($commandName != $defaultCommand) {
// Try the default command
// Initiate the command
$eval = sprintf("\$commandInstance = %s::create%s(\$this);",
- $class,
- $class
+ $className,
+ $className
);
// Run the command
// Create unique ID number
$this->createUniqueID();
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
-
// Set prefix to "Web"
$this->setCommandPrefix("Web");
}
* @throws InvalidControllerInstanceException Thrown if $commandInstance
* is invalid
*/
- public function resolveDefaultController () {
+ public function resolveCommandController () {
// Init variables
$commandName = "";
$controllerInstance = null;
*/
private $templateEngine = null;
+ /**
+ * Fatal resolved messages from filters and so on
+ */
+ private $fatalMessages = array();
+
/**
* Protected constructor
*
// Get a new instance
$responseInstance = new HttpResponse();
+ // Set the application instance
+ $responseInstance->setApplicationInstance($appInstance);
+
// Initialize the template engine here
$responseInstance->initTemplateEngine($appInstance);
public final function getTemplateEngine () {
return $this->templateEngine;
}
+
+ /**
+ * Adds a fatal message id to the response. The added messages can then be
+ * processed and outputed to the world
+ *
+ * @param $messageId The message id we shall add
+ * @return void
+ */
+ public final function addFatalMessage ($messageId) {
+ // Adds the resolved message id to the fatal message list
+ $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
+ }
}
// [EOF]
*/
// Load the class from inc/config direktory
-@require_once(dirname(__FILE__) . "/config/class_FrameworkConfiguration.php");
+@require_once(dirname(__FILE__) . '/config/class_FrameworkConfiguration.php');
// Get a new configuration instance
$cfg = FrameworkConfiguration::createFrameworkConfiguration();
// CFG: SERVER-PATH
-$cfg->definePath(dirname(dirname(__FILE__)) . "/"); // DON'T MISS THE TRAILING SLASH!!!
+$cfg->definePath(dirname(dirname(__FILE__)) . '/'); // DON'T MISS THE TRAILING SLASH!!!
// CFG: DATABASE-TYPE
-$cfg->defineDatabaseType("local");
+$cfg->defineDatabaseType('local');
// CFG: TIME-ZONE
$cfg->setDefaultTimezone("Europe/Berlin");
$cfg->setMagicQuotesRuntime(false);
// CFG: PHP-SCRIPT-EXTENSION
-$cfg->setConfigEntry("php_extension", ".php");
+$cfg->setConfigEntry('php_extension', ".php");
// CFG: CLASS-PREFIX
-$cfg->setConfigEntry("class_prefix", "class_");
+$cfg->setConfigEntry('class_prefix', "class_");
// CFG: CLASS-SUFFIX
-$cfg->setConfigEntry("class_suffix", ".php");
+$cfg->setConfigEntry('class_suffix', ".php");
// CFG: RAW-TEMPLATE-EXTENSION
-$cfg->setConfigEntry("raw_template_extension", ".tpl");
+$cfg->setConfigEntry('raw_template_extension', ".tpl");
// CFG: CODE-TEMPLATE-EXTENSION
-$cfg->setConfigEntry("code_template_extension", ".ctp");
+$cfg->setConfigEntry('code_template_extension', ".ctp");
// CFG: SELECTOR-GET
-$cfg->setConfigEntry("app_selector_get", "app");
+$cfg->setConfigEntry('app_selector_get', "app");
// CFG: APPLICATION-HELPER
-$cfg->setConfigEntry("app_helper_class", "ApplicationHelper");
+$cfg->setConfigEntry('app_helper_class', "ApplicationHelper");
// CFG: SELECTOR-PATH
-$cfg->setConfigEntry("selector_path", "selector");
+$cfg->setConfigEntry('selector_path', "selector");
// CFG: TEMPLATE-BASE-PATH
-$cfg->setConfigEntry("tpl_base_path", "templates/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('tpl_base_path', "templates/"); // DON'T MISS THE TRAILING SLASH!
// CFG: LANGUAGE-BASE-PATH
-$cfg->setConfigEntry("lang_base_path", "inc/language/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('lang_base_path', "inc/language/"); // DON'T MISS THE TRAILING SLASH!
// CFG: COMPRESSOR-BASE-PATH
-$cfg->setConfigEntry("compressor_base_path", "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
// CFG: APPLICATION-PATH
-$cfg->setConfigEntry("application_path", "application");
+$cfg->setConfigEntry('application_path', "application");
// CFG: COMPILE-OUTPUT-PATH
-$cfg->setConfigEntry("compile_output_path", "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
// CFG: TEMPLATE-ENGINE
-$cfg->setConfigEntry("tpl_engine", "TemplateEngine");
+$cfg->setConfigEntry('tpl_engine', "TemplateEngine");
// CFG: DEBUG-ENGINE
-$cfg->setConfigEntry("debug_engine", "DebugWebOutput");
+$cfg->setConfigEntry('debug_engine', "DebugWebOutput");
// CFG: DEFAULT-LANGUAGE
-$cfg->setConfigEntry("default_lang", "de"); // A two-char language string: de for german, en for english and so on
+$cfg->setConfigEntry('default_lang', "de"); // A two-char language string: de for german, en for english and so on
// CFG: WEB-TEMPLATE-TYPE
-$cfg->setConfigEntry("web_template_type", "html");
+$cfg->setConfigEntry('web_template_type', "html");
// CFG: EMAIL-TEMPLATE-TYPE
-$cfg->setConfigEntry("email_template_type", "emails");
+$cfg->setConfigEntry('email_template_type', "emails");
// CFG: CODE-TEMPLATE-TYPE
-$cfg->setConfigEntry("code_template_type", "code");
+$cfg->setConfigEntry('code_template_type', "code");
// CFG: WEB-ENGINE
-$cfg->setConfigEntry("web_engine", "WebOutput");
+$cfg->setConfigEntry('web_engine', "WebOutput");
// CFG: SELECTOR-TEMPLATE-PREFIX
-$cfg->setConfigEntry("tpl_selector_prefix", "selector");
+$cfg->setConfigEntry('tpl_selector_prefix', "selector");
// CFG: WEB-CONTENT-TYPE
-$cfg->setConfigEntry("web_content_type", "text/html");
+$cfg->setConfigEntry('web_content_type', "text/html");
// CFG: VALID-TEMPLATE-VARIABLE
-$cfg->setConfigEntry("tpl_valid_var", "content");
+$cfg->setConfigEntry('tpl_valid_var', "content");
// CFG: META-AUTHOR
-$cfg->setConfigEntry("meta_author", "Roland Häder");
+$cfg->setConfigEntry('meta_author', "Roland Häder");
// CFG: META-PUBLISHER
-$cfg->setConfigEntry("meta_publisher", "Roland Häder");
+$cfg->setConfigEntry('meta_publisher', "Roland Häder");
// CFG: META-KEYWORDS
-$cfg->setConfigEntry("meta_keywords", "test,test,test");
+$cfg->setConfigEntry('meta_keywords', "test,test,test");
// CFG: META-DESCRIPTION
-$cfg->setConfigEntry("meta_description", "A lame description for an application framework");
+$cfg->setConfigEntry('meta_description', "A lame description for an application framework");
// CFG: LAUNCH-METHOD
-$cfg->setConfigEntry("entry_method", "entryPoint");
+$cfg->setConfigEntry('entry_method', "entryPoint");
// CFG: SELECTOR-MAIN-TEMPLATE
-$cfg->setConfigEntry("selector_main_tpl", "selector_main");
+$cfg->setConfigEntry('selector_main_tpl', "selector_main");
// CFG: SELECTOR-APPS-TEMPLATE
-$cfg->setConfigEntry("selector_apps_tpl", "selector_apps");
+$cfg->setConfigEntry('selector_apps_tpl', "selector_apps");
// CFG: SELECTOR-NAME
-$cfg->setConfigEntry("selector_name", "selector");
+$cfg->setConfigEntry('selector_name', "selector");
// CFG: DEFAULT-APPLICATION
-$cfg->setConfigEntry("default_application", "selector");
+$cfg->setConfigEntry('default_application', "selector");
// CFG: VERBOSE-LEVEL
-$cfg->setConfigEntry("verbose_level", 0);
+$cfg->setConfigEntry('verbose_level', 0);
// [EOF]
?>
$cfg = FrameworkConfiguration::getInstance();
// CFG: HUB-LISTEN-ADDR
-$cfg->setConfigEntry("hub_listen_addr", "0.0.0.0");
+$cfg->setConfigEntry('hub_listen_addr', "0.0.0.0");
// CFG: HUB-LISTEN-PORT (zero = auto-choose)
-$cfg->setConfigEntry("hub_listen_port", 9060);
+$cfg->setConfigEntry('hub_listen_port', 9060);
// CFG: HUB-MAX-AUTH-TRIES
-$cfg->setConfigEntry("hub_max_auth_tries", 3);
+$cfg->setConfigEntry('hub_max_auth_tries', 3);
// CFG: HUB-MSG-AUTH-TRIES
-$cfg->setConfigEntry("hub_msg_auth_tries", "AUTH_MAX_TRIES");
+$cfg->setConfigEntry('hub_msg_auth_tries', "AUTH_MAX_TRIES");
// CFG: HUB-MSG-SPOOFING
-$cfg->setConfigEntry("hub_msg_spoofing", "SPOOFING");
+$cfg->setConfigEntry('hub_msg_spoofing', "SPOOFING");
// CFG: HUB-MSG-AUTH-REPLY
-$cfg->setConfigEntry("hub_msg_auth_reply_timeout", "TIMEOUT_AUTH");
+$cfg->setConfigEntry('hub_msg_auth_reply_timeout', "TIMEOUT_AUTH");
// CFG: HUB-MSG-BYE
-$cfg->setConfigEntry("hub_msg_bye", "BYE");
+$cfg->setConfigEntry('hub_msg_bye', "BYE");
// CFG: HUB-MASTER-IP
-$cfg->setConfigEntry("hub_master_ip", "192.168.1.17");
+$cfg->setConfigEntry('hub_master_ip', "192.168.1.17");
// CFG: HUB-MASTER-PORT
-$cfg->setConfigEntry("hub_master_port", 9060);
+$cfg->setConfigEntry('hub_master_port', 9060);
// CFG: HUB-AUTH-REQUEST
-$cfg->setConfigEntry("hub_auth_request", "AUTH");
+$cfg->setConfigEntry('hub_auth_request', "AUTH");
// CFG: HUB-AUTH-REQUEST-TIMEOUT (5 seconds for whole auth procedure shall be fine)
-$cfg->setConfigEntry("hub_auth_request_timeout", 5);
+$cfg->setConfigEntry('hub_auth_request_timeout', 5);
// CFG: HUB-PEER-HELLO
-$cfg->setConfigEntry("hub_peer_hello", "HELLO");
+$cfg->setConfigEntry('hub_peer_hello', "HELLO");
// CFG: HUB-HELLO-REPLY
-$cfg->setConfigEntry("hub_hello_reply", "ELHO");
+$cfg->setConfigEntry('hub_hello_reply', "ELHO");
// CFG: HUB-HELLO-TIMEOUT
-$cfg->setConfigEntry("hub_hello_timeout", 30);
+$cfg->setConfigEntry('hub_hello_timeout', 30);
// CFG: HUB-HELLO-RETRIES
-$cfg->setConfigEntry("hub_hello_retires", 3);
+$cfg->setConfigEntry('hub_hello_retires', 3);
// CFG: HUB-PEER-PING
-$cfg->setConfigEntry("hub_peer_ping", "PING");
+$cfg->setConfigEntry('hub_peer_ping', "PING");
// CFG: HUB-PING-REPLY
-$cfg->setConfigEntry("hub_ping_reply", "PONG");
+$cfg->setConfigEntry('hub_ping_reply', "PONG");
// CFG: HUB-PING-TIMEOUT
-$cfg->setConfigEntry("hub_ping_timeout", 10);
+$cfg->setConfigEntry('hub_ping_timeout', 10);
// CFG: HUB-PING-MAXDROPS
-$cfg->setConfigEntry("hub_ping_maxdrops", 3);
+$cfg->setConfigEntry('hub_ping_maxdrops', 3);
// CFG: HUB-PEER-MISS-PONG
-$cfg->setConfigEntry("hub_peer_miss_pong", "PONG_MISS");
+$cfg->setConfigEntry('hub_peer_miss_pong', "PONG_MISS");
// [EOF]
?>
}
// Generate FQFN for the database layer
-$INC = sprintf("%sinc/database/lib-%s%s", PATH, _DB_TYPE, FrameworkConfiguration::getInstance()->readConfig("php_extension"));
+$INC = sprintf("%sinc/database/lib-%s%s",
+ PATH,
+ _DB_TYPE,
+ FrameworkConfiguration::getInstance()->readConfig('php_extension')
+);
// Load the database layer include
if ((file_exists($INC)) && (is_file($INC)) && (is_readable($INC))) {
// Zum Testen speichern wir in lokale Dateien (LocalFileDatabase)
try {
- $layer = LocalFileDatabase::createLocalFileDatabase(PATH . "db/", FileIoHandler::getInstance());
+ $layer = LocalFileDatabase::createLocalFileDatabase(PATH . 'db/', FileIoHandler::getInstance());
} catch (SavePathIsEmptyException $e) {
ApplicationEntryPoint::app_die(sprintf("[Main:] Debug-Instanz konnte nicht gesetzt werden. Reason: <strong>%s</strong><br />\n",
$e->getMessage()
*/
// Include the class loader function
-require(sprintf("%sinc/loader/class_ClassLoader%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
+require(sprintf("%sinc/loader/class_ClassLoader%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
/**
* Is the devel package included?
/**
* Load all development includes
*/
- ClassLoader::getInstance()->loadClasses("devel");
+ ClassLoader::getInstance()->loadClasses('devel');
}
// Shall we include additional configs where you can configure some things? Then
try {
$lang = LanguageSystem::createLanguageSystem(sprintf("%s%s",
PATH,
- FrameworkConfiguration::getInstance()->readConfig("lang_base_path")
+ FrameworkConfiguration::getInstance()->readConfig('lang_base_path')
));
} catch (LanguagePathIsEmptyException $e) {
ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
*/
// Get a debugger instance
-$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig("debug_engine"));
+$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig('debug_engine'));
// Empty string should be ignored and used for testing the middleware
DebugMiddleware::getInstance()->output("");
*/
// Does the user has an application specified?
-if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")])) {
+if (!empty($_GET[FrameworkConfiguration::getInstance()->readConfig('app_selector_get')])) {
// Set the application from string
- $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig("app_selector_get")];
+ $application = (string) $_GET[FrameworkConfiguration::getInstance()->readConfig('app_selector_get')];
} elseif (!empty($_SERVER['argv'][1])) {
// Set the application from string
$application = (string) $_SERVER['argv'][1];
- $app = explode("=", trim($application));
- if ($app[0] == FrameworkConfiguration::getInstance()->readConfig("app_selector_get")) {
+ $app = explode('=', trim($application));
+ if ($app[0] == FrameworkConfiguration::getInstance()->readConfig('app_selector_get')) {
// Application is valid!
$application = trim($app[1]);
} else {
// Invalid entry found, first must be "app"!
- $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
+ $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
}
} else {
// Set the "application selector" application
- $application = FrameworkConfiguration::getInstance()->readConfig("default_application");
+ $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
}
// Secure it, by keeping out tags
// Generate a FQFN for the helper class
$fqfn = sprintf("%s%s/%s/%s%s",
PATH,
- FrameworkConfiguration::getInstance()->readConfig("application_path"),
+ FrameworkConfiguration::getInstance()->readConfig('application_path'),
$application,
$inc,
- FrameworkConfiguration::getInstance()->readConfig("php_extension")
+ FrameworkConfiguration::getInstance()->readConfig('php_extension')
);
// Does the include file exists?
if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) {
// Load it
require_once($fqfn);
- } elseif (FrameworkConfiguration::getInstance()->readConfig("verbose_level") > 0) {
+ } elseif (FrameworkConfiguration::getInstance()->readConfig('verbose_level') > 0) {
// File is missing
trigger_error(sprintf("Cannot load application script %s! File is missing or read-protected.",
- $inc . FrameworkConfiguration::getInstance()->readConfig("php_extension")
+ $inc . FrameworkConfiguration::getInstance()->readConfig('php_extension')
));
}
}
}
// Get some instances
- $tpl = FrameworkConfiguration::getInstance()->readConfig("tpl_engine");
+ $tpl = FrameworkConfiguration::getInstance()->readConfig('tpl_engine');
$lang = LanguageSystem::getInstance();
$io = FileIoHandler::getInstance();
// Use the template engine for putting out (nicer look) the message
try {
$eval = sprintf("\$tplEngine = %s::create%s(\"%s%s\", \$lang, \$io);",
- FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
- FrameworkConfiguration::getInstance()->readConfig("tpl_engine"),
+ FrameworkConfiguration::getInstance()->readConfig('tpl_engine'),
+ FrameworkConfiguration::getInstance()->readConfig('tpl_engine'),
PATH,
- FrameworkConfiguration::getInstance()->readConfig("tpl_base_path")
+ FrameworkConfiguration::getInstance()->readConfig('tpl_base_path')
);
eval($eval);
} catch (BasePathIsEmptyException $e) {
}
// Assign variables
- $tplEngine->assignVariable("message", $message);
- $tplEngine->assignVariable("backtrace", $backtrace);
+ $tplEngine->assignVariable('message', $message);
+ $tplEngine->assignVariable('backtrace', $backtrace);
// Load the template
- $tplEngine->loadCodeTemplate("emergency_exit");
+ $tplEngine->loadCodeTemplate('emergency_exit');
// Compile the template
$tplEngine->compileTemplate();
global $_SERVER;
// Load config file
- require(dirname(__FILE__) . "/inc/config.php");
+ require(dirname(__FILE__) . '/inc/config.php');
// Load all include files
- require(PATH . "inc/includes.php");
+ require(PATH . 'inc/includes.php');
// Load all framework classes
- require(PATH . "inc/classes.php");
+ require(PATH . 'inc/classes.php');
// Include the application selector
- require(PATH . "inc/selector.php");
+ require(PATH . 'inc/selector.php');
} // END - main()
@chdir("..");
// Load config file
-require(dirname(dirname(__FILE__)) . "/inc/config.php");
+require(dirname(dirname(__FILE__)) . '/inc/config.php');
// Load all include files
-require(PATH . "inc/includes.php");
+require(PATH . 'inc/includes.php');
// Load all game classes
-require(PATH . "inc/classes.php");
+require(PATH . 'inc/classes.php');
// Set default application
-FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "ship-simu");
+FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
// Set testing mode (no starter.php will be loaded!)
define('TEST_MODE', true);
// Load the PHPUnit framework
-require_once("PHPUnit/Framework.php");
+require_once('PHPUnit/Framework.php');
/**
* A test case for the configuration sub system
$cfg = FrameworkConfiguration::getInstance();
// Now find a configuration variable that does not exist
- $dummy = $cfg->readConfig("does_not_exist");
+ $dummy = $cfg->readConfig('does_not_exist');
} catch (ConfigEntryNotFoundException $expected) {
// This exception was expected, so it is fine
$testPassed = true;
$cfg = FrameworkConfiguration::getInstance();
// Try to read an empty configuration variable
- $cfg->setConfigEntry("", "will_never_be_set");
+ $cfg->setConfigEntry("", 'will_never_be_set');
} catch (ConfigEntryIsEmptyException $expected) {
// This exception was expected, so it is fine
$testPassed = true;
$cfg = FrameworkConfiguration::getInstance();
// Try to read an empty configuration variable
- $cfg->setConfigEntry("test_key", "{$value}");
+ $cfg->setConfigEntry('test_key', "{$value}");
// Read the config entry we have just written
- $readValue = $cfg->readConfig("test_key");
+ $readValue = $cfg->readConfig('test_key');
// Now test the values
$this->assertEquals($value, $readValue);
require(dirname(dirname(dirname(__FILE__))) . "/inc/config.php");
// Load all include files
-require(PATH . "inc/includes.php");
+require(PATH . 'inc/includes.php');
// Load all game classes
-require(PATH . "inc/classes.php");
+require(PATH . 'inc/classes.php');
// Load file I/O handler
-require(PATH . "inc/file_io.php");
+require(PATH . 'inc/file_io.php');
// Load database layer
-require(PATH . "inc/database.php");
+require(PATH . 'inc/database.php');
// Set default application
-FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "ship-simu");
-$application = "ship-simu";
+FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
+$application = 'ship-simu';
// Load more includes
-require(PATH . "application/ship-simu/loader.php");
+require(PATH . 'application/ship-simu/loader.php');
// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen
// jetzt die Personalliste wiederherstellen
try {
- $personell = SimulatorPersonell::createSimulatorPersonellByID("SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98");
+ $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98');
} catch (InvalidIDFormatException $e) {
die(sprintf("[Main:] Could not create personal list for follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
require(dirname(dirname(dirname(__FILE__))) . "/inc/config.php");
// Load all include files
-require(PATH . "inc/includes.php");
+require(PATH . 'inc/includes.php');
// Load all game classes
-require(PATH . "inc/classes.php");
+require(PATH . 'inc/classes.php');
// Load file I/O handler
-require(PATH . "inc/file_io.php");
+require(PATH . 'inc/file_io.php');
// Load database layer
-require(PATH . "inc/database.php");
+require(PATH . 'inc/database.php');
// Set default application
-FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "ship-simu");
-$application = "ship-simu";
+FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
+$application = 'ship-simu';
// Load more includes
-require(PATH . "application/ship-simu/loader.php");
+require(PATH . 'application/ship-simu/loader.php');
// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen
// jetzt die Personalliste wiederherstellen
try {
- $personell = SimulatorPersonell::createSimulatorPersonellByID("SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98");
+ $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98');
} catch (InvalidIDFormatException $e) {
die(sprintf("[Main:] Could not create personal list for follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
require(dirname(dirname(dirname(__FILE__))) . "/inc/config.php");
// Load all include files
-require(PATH . "inc/includes.php");
+require(PATH . 'inc/includes.php');
// Load all game classes
-require(PATH . "inc/classes.php");
+require(PATH . 'inc/classes.php');
// Load file I/O handler
-require(PATH . "inc/file_io.php");
+require(PATH . 'inc/file_io.php');
// Load database layer
-require(PATH . "inc/database.php");
+require(PATH . 'inc/database.php');
// Set default application
-FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "ship-simu");
-$application = "ship-simu";
+FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
+$application = 'ship-simu';
// Load more includes
-require(PATH . "application/ship-simu/loader.php");
+require(PATH . 'application/ship-simu/loader.php');
// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen
// jetzt die Personalliste wiederherstellen
try {
- $personell = SimulatorPersonell::createSimulatorPersonellByID("SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98");
+ $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98');
} catch (InvalidIDFormatException $e) {
die(sprintf("[Main:] Could not create personal list for follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()