// Insert all application templates
$selInstance->insertApplicationTemplates();
}
+
+ /**
+ * Handle the indexed array of fatal messages and puts them out in an
+ * acceptable fasion
+ *
+ * @param $messageList An array of fatal messages
+ * @return void
+ */
+ public function handleFatalMessages (array $messageList) {
+ die("<pre>".print_r($messageList, true)."</pre>");
+ }
}
// [EOF]
} elseif (!is_object($app)) {
// Not an object
throw new NoObjectException($app, self::EXCEPTION_IS_NO_OBJECT);
- } elseif (!method_exists($app, $this->getConfigInstance()->readConfig("entry_method"))) {
+ } elseif (!method_exists($app, $this->getConfigInstance()->readConfig('entry_method'))) {
// Method not found!
- throw new MissingMethodException(array($app, $this->getConfigInstance()->readConfig("entry_method")), self::EXCEPTION_MISSING_METHOD);
+ throw new MissingMethodException(array($app, $this->getConfigInstance()->readConfig('entry_method')), self::EXCEPTION_MISSING_METHOD);
}
// Add the current instance to the list
* @return $shortName This selector's short name
*/
public function getAppShortName() {
- $shortName = $this->getConfigInstance()->readConfig("selector_path");
+ $shortName = $this->getConfigInstance()->readConfig('selector_path');
return $shortName;
}
// Generate the base path for all applications
$appBasePath = sprintf("%s%s/",
PATH,
- $this->getConfigInstance()->readConfig("application_path")
+ $this->getConfigInstance()->readConfig('application_path')
);
// Add the selector path to the ignore list
- $this->addDirIgnoreList($this->getConfigInstance()->readConfig("selector_path"));
+ $this->addDirIgnoreList($this->getConfigInstance()->readConfig('selector_path'));
// Get a directory pointer for the application path
$dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($appBasePath);
// Is this a readable directory? (files will be ignored silently)
if ((is_dir($fqfn)) && (is_readable($fqfn))) {
// Then get the init.php script for analyzing
- $initScript = sprintf("%s/init%s", $fqfn, $this->getConfigInstance()->readConfig("php_extension"));
+ $initScript = sprintf("%s/init%s", $fqfn, $this->getConfigInstance()->readConfig('php_extension'));
// Load the application's init.php script and append the
// application to the ArrayObject
// Try to load the web template
$tplEngine->loadWebTemplate(sprintf("%s_%s",
- $this->getConfigInstance()->readConfig("tpl_selector_prefix"),
+ $this->getConfigInstance()->readConfig('tpl_selector_prefix'),
strtolower($appInstance->getAppShortName())
));
$tplEngine = $this->prepareTemplateEngine($this);
// Load the selector's template
- $tplEngine->loadCodeTemplate($this->getConfigInstance()->readConfig("selector_main_tpl"));
+ $tplEngine->loadCodeTemplate($this->getConfigInstance()->readConfig('selector_main_tpl'));
// Now store it in the class
$this->setSelectorTemplateEngine($tplEngine);
$tplEngine = $this->prepareTemplateEngine($this);
// Load template which shall later hold all application templates
- $tplEngine->loadCodeTemplate($this->getConfigInstance()->readConfig("selector_apps_tpl"));
+ $tplEngine->loadCodeTemplate($this->getConfigInstance()->readConfig('selector_apps_tpl'));
// Add all loaded application templates together
$dummy = "";
} // END - for
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
}
// [EOF]
//
// Get an instance of the initializer
$eval = sprintf("\$app = %s::getInstance();",
- FrameworkConfiguration::getInstance()->readConfig("app_helper_class")
+ FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
);
eval($eval);
// Set application name and version
$app->setAppName("Applikationsauswähler");
$app->setAppVersion("0.1a");
-$app->setAppShortName(FrameworkConfiguration::getInstance()->readConfig("selector_name"));
+$app->setAppShortName(FrameworkConfiguration::getInstance()->readConfig('selector_name'));
// Initialize output system
require(PATH . 'inc/output.php');
}
// Load all classes
-ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/", FrameworkConfiguration::getInstance()->readConfig("application_path"), $application));
+ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/", FrameworkConfiguration::getInstance()->readConfig('application_path'), $application));
// Include all classes
ClassLoader::getInstance()->includeAllClasses();
// Something went wrong!
ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched because the helper class <strong>%s</strong> is not loaded.",
$application,
- FrameworkConfiguration::getInstance()->readConfig("app_helper_class")
+ FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
));
} elseif (!is_object($app)) {
// No object!
ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched because 'app' is not an object.",
$application
));
-} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig("entry_method"))) {
+} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig('entry_method'))) {
// Method not found!
ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched because the method <strong>%s</strong> is missing.",
$application,
- FrameworkConfiguration::getInstance()->readConfig("entry_method")
+ FrameworkConfiguration::getInstance()->readConfig('entry_method')
));
}
// Call the entry point method
try {
$eval = sprintf("%s::getInstance()->%s();",
- FrameworkConfiguration::getInstance()->readConfig("app_helper_class"),
- FrameworkConfiguration::getInstance()->readConfig("entry_method")
+ FrameworkConfiguration::getInstance()->readConfig('app_helper_class'),
+ FrameworkConfiguration::getInstance()->readConfig('entry_method')
);
eval($eval);
} catch (FrameworkException $e) {
*/
private $masterTemplate = "shipsimu_main";
+ /**
+ * An instance of a controller
+ */
+ private $controllerInstance = null;
+
/**
* An instance of this class
*/
private static $thisInstance = null;
-
/**
* Protected constructor
*
$responseInstance = HttpResponse::createHttpResponse($this);
// Get command parameter
- $commandPara = $this->getConfigInstance()->readConfig("command_parameter");
+ $commandPara = $this->getConfigInstance()->readConfig('command_parameter');
// Get the parameter from the request
$commandName = $requestInstance->getRequestElement($commandPara);
// If it is null then get default command
if (is_null($commandName)) {
- $commandName = $this->getConfigInstance()->readConfig("default_command");
+ $commandName = $this->getConfigInstance()->readConfig('default_command');
}
// Get a resolver
$resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
// Get a new controller instance as well
- $controllerInstance = $resolverInstance->resolveCommandController();
+ $this->controllerInstance = $resolverInstance->resolveCommandController();
// Handle the request
- $controllerInstance->handleRequest($requestInstance, $responseInstance);
+ $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
+ }
+
+ /**
+ * Handle the indexed array of fatal messages and puts them out in an
+ * acceptable fasion
+ *
+ * @param $messageList An array of fatal messages
+ * @return void
+ */
+ public function handleFatalMessages (array $messageList) {
+ die("<pre>".print_r($messageList, true)."</pre>");
}
}
// Get an instance of the helper
$eval = sprintf("\$app = %s::getInstance();",
- FrameworkConfiguration::getInstance()->readConfig("app_helper_class")
+ FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
);
eval($eval);
foreach ($lowerClasses as $class) {
// Try to load the application classes
try {
- ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", FrameworkConfiguration::getInstance()->readConfig("application_path"), $application, $class));
+ ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", FrameworkConfiguration::getInstance()->readConfig('application_path'), $application, $class));
} catch (PathIsNoDirectoryException $e) {
ApplicationEntryPoint::app_die(sprintf("[Main:%s] Kann Applikationsklassen im Pfad <strong>%s</strong> nicht laden. Grund: <strong>%s</strong>",
$application,
// Return price
return $price;
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
}
// [EOF]
// Return total price
return $totalPrice;
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
}
// [EOF]
// Set the merchant in the contract (for getting prices)
$contractInstance->setMerchantInstance($merchantInstance);
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Generate unique ID number
$this->createUniqueID();
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Generate unique ID number
$this->createUniqueID();
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Werft generieren und in die Werftliste aufnehmen
$this->shipyardList->append(Shipyard::createShipyard($this, $shipyardName));
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Generate unique ID number
$this->createUniqueID();
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Add new personell
public function addNewPersonell ($personell) {
- if (is_null($this->staffList)) {
- // Opps, not initialized!
- ApplicationEntryPoint::app_die("New personell: <pre>".print_r($this, true)."</pre>");
- }
-
// Add to list
$this->staffList->append($personell);
}
// Return result
return $result;
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Instanz zurueckgeben
return $roomInstance;
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
}
/**
- * Stub!
+ * Reduces the volume of a processed object.
+ *
+ * @param $limitInstance An instance to ObjectLimits which holds
+ * attribute names that we want to include in the processing
+ * phase. Other attributes except $uniqueID and $realClass will
+ * be ignored and keept out.
+ * @return void
*/
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
+ function limitObject (ObjectLimits $limitInstance) {
+ // Work in progress
+ $this->partialStub("Unfinished method called.");
}
}
public final function isCabin () {
return ($this->isClass("BaseCabin"));
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Set description
$this->setObjectDescription("Allgemeines Deck");
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Stub!
- */
- public function saveObjectToDatabase () {
- $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
- $this->__toString(),
- __FUNCTION__
- ));
- }
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
// Something went wrong!
ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched because the helper class <strong>%s</strong> is not loaded.",
$application,
- FrameworkConfiguration::getInstance()->readConfig("app_helper_class")
+ FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
));
} elseif (!is_object($app)) {
// No object!
ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched because 'app' is not an object.",
$application
));
-} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig("entry_method"))) {
+} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig('entry_method'))) {
// Method not found!
ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> could not be launched because the method <strong>%s</strong> is missing.",
$application,
- FrameworkConfiguration::getInstance()->readConfig("entry_method")
+ FrameworkConfiguration::getInstance()->readConfig('entry_method')
));
}
// Call the entry point method
try {
$eval = sprintf("%s::getInstance()->%s();",
- FrameworkConfiguration::getInstance()->readConfig("app_helper_class"),
- FrameworkConfiguration::getInstance()->readConfig("entry_method")
+ FrameworkConfiguration::getInstance()->readConfig('app_helper_class'),
+ FrameworkConfiguration::getInstance()->readConfig('entry_method')
);
eval($eval);
} catch (FrameworkException $e) {
$this->getLine(),
basename($classArray[1]),
$classArray[2],
- $classArray[3]->readConfig("tpl_valid_var")
+ $classArray[3]->readConfig('tpl_valid_var')
);
// Call parent constructor
* @return void
*/
function entryPoint ();
+
+ /**
+ * Handle the indexed array of fatal messages and puts them out in an
+ * acceptable fasion
+ *
+ * @param $messageList An array of fatal messages
+ * @return void
+ */
+ function handleFatalMessages (array $messageList);
}
// [EOF]
// Initialize debug instance
if (is_null($this->getDebugInstance())) {
// Set the debug output system if it is not debug class ;)
- $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig("debug_engine")));
+ $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_engine')));
}
// Initialize web instance
if (is_null($this->getWebOutputInstance())) {
// Generate the eval() command
$eval = sprintf("\$this->setWebOutputInstance(%s::create%s(\"%s\"));",
- $this->getConfigInstance()->readConfig("web_engine"),
- $this->getConfigInstance()->readConfig("web_engine"),
- $this->getConfigInstance()->readConfig("web_content_type")
+ $this->getConfigInstance()->readConfig('web_engine'),
+ $this->getConfigInstance()->readConfig('web_engine'),
+ $this->getConfigInstance()->readConfig('web_content_type')
);
// Debug message
// Set the compressor channel
$this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s",
PATH,
- $this->getConfigInstance()->readConfig("compressor_base_path")
+ $this->getConfigInstance()->readConfig('compressor_base_path')
)));
}
// Generate FQFN for all application templates
$fqfn = sprintf("%s%s/%s/%s",
PATH,
- $this->getConfigInstance()->readConfig("application_path"),
+ $this->getConfigInstance()->readConfig('application_path'),
strtolower($appInstance->getAppShortName()),
- $this->getConfigInstance()->readConfig("tpl_base_path")
+ $this->getConfigInstance()->readConfig('tpl_base_path')
);
// Are both instances set?
\$appInstance->getLanguageInstance(),
\$appInstance->getFileIoInstance()
);",
- $this->getConfigInstance()->readConfig("tpl_engine"),
- $this->getConfigInstance()->readConfig("tpl_engine"),
+ $this->getConfigInstance()->readConfig('tpl_engine'),
+ $this->getConfigInstance()->readConfig('tpl_engine'),
$fqfn
);
*/
public final function debugInstance () {
// Generate the output
- $content = "<pre>".trim(print_r($this, true))."</pre>";
+ $content = sprintf("<pre>%s</pre>",
+ trim(print_r($this, true))
+ );
// Output it
- ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$content);
+ ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong>%s", $this->__toString(), $content));
}
/**
$templateInstance->loadCodeTemplate($masterTemplate);
// Set title
- $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter")));
+ $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter')));
if (empty($title)) $title = "Home";
- $templateInstance->assignVariable("title", $title);
+ $templateInstance->assignVariable('title', $title);
// ... and all variables. This should be merged together in a pattern
// to make things easier. A cache mechanism should be added between
$templateInstance->loadCodeTemplate($masterTemplate);
// Set title
- $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter")));
+ $title = ucfirst($requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter')));
if (empty($title)) $title = "Register";
- $templateInstance->assignVariable("title", $title);
+ $templateInstance->assignVariable('title', $title);
// ... and all variables. This should be merged together in a pattern
// to make things easier. A cache mechanism should be added between
// Execute *very* generic pre filters
$this->executePreFilters($requestInstance, $responseInstance);
- // This request was valid! :-D
- $requestInstance->requestIsValid();
+ // 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 the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Execute *very* generic ppost filters
- $this->executePostFilters($requestInstance, $responseInstance);
+ // Execute *very* generic ppost filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+ }
// Flush the buffer out
$responseInstance->flushBuffer();
$factoryInstance = new NewsFactory();
// Get the element name from configuration
- $element = FrameworkConfiguration::getInstance()->readConfig("app_selector_get");
+ $element = FrameworkConfiguration::getInstance()->readConfig('app_selector_get');
// Analyze the request, first get the Uni* application name (short one from URL)
$appName = $requestInstance->getRequestElement($element);
// Add HTML code
$formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s\" method=\"%s\" target=\"%s\"",
$formName,
- $this->getConfigInstance()->readConfig("form_action"),
- $this->getConfigInstance()->readConfig("form_method"),
- $this->getConfigInstance()->readConfig("form_target")
+ $this->getConfigInstance()->readConfig('form_action'),
+ $this->getConfigInstance()->readConfig('form_method'),
+ $this->getConfigInstance()->readConfig('form_target')
);
// Is the form id set?
$this->formName = $formName;
} else {
// Add the hidden field required to identify safely this form
- $this->addInputHiddenField("form", $this->formName);
+ $this->addInputHiddenField('form', $this->formName);
// Is a group open?
if ($this->groupOpened === true) {
* @return $required Wether the email address is required
*/
public function ifRegisterRequiresEmailVerification () {
- $required = ($this->getConfigInstance()->readConfig("register_requires_email") == "Y");
+ $required = ($this->getConfigInstance()->readConfig('register_requires_email') == "Y");
return $required;
}
* @return $required Wether profile shall be asked
*/
public function ifRegisterIncludesProfile () {
- $required = ($this->getConfigInstance()->readConfig("register_includes_profile") == "Y");
+ $required = ($this->getConfigInstance()->readConfig('register_includes_profile') == "Y");
return $required;
}
* @return $required Wether personal data shall be asked
*/
public function ifRegisterIncludesPersonaData () {
- $required = ($this->getConfigInstance()->readConfig("register_personal_data") == "Y");
+ $required = ($this->getConfigInstance()->readConfig('register_personal_data') == "Y");
return $required;
}
$langInstance->initLanguageStrings();
// Set language code from default config
- $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig("default_lang"));
+ $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang'));
// Remember this instance
self::$thisInstance = $langInstance;
public final function getLanguageCode () {
return $this->langCode;
}
+
+ /**
+ * Get the plain message from the cache variable for the given message id
+ *
+ * @param $messageId The message id we shall find in the cache variable
+ * @return $messageText The plain message text
+ */
+ public function getMessage ($messageId) {
+ // Default is missing message text
+ $messageText = sprintf("!%s!",
+ $messageId
+ );
+
+ // Try to look it up in the cache variable
+ if ($this->langStrings->offsetExists($messageId)) {
+ // Return the message string
+ $messageText = $this->langStrings->offsetGet($messageId);
+ }
+
+ // Return the text
+ return $messageText;
+ }
}
// [EOF]
*/
public final static function getInstance() {
if (is_null(self::$consoleInstance)) {
- $contentType = FrameworkConfiguration::getInstance()->readConfig("web_content_type");
+ $contentType = FrameworkConfiguration::getInstance()->readConfig('web_content_type');
self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
}
return self::$consoleInstance;
private $requestData = array();
/**
- * Wether this request is valid and can be further processed
+ * Wether this request is valid and can be further processed. The default is
+ * valid so make sure your intercepting filters sets this attribute to false
+ * when they need to intercept the data flow.
*/
- private $requestIsValid = false;
+ private $requestIsValid = true;
/**
* Protected constructor
public final function requestIsValid ($isValid = true) {
$this->requestIsValid = (bool) $isValid;
}
+
+ /**
+ * Returns wether this request is valid
+ *
+ * @return $requestIsValid Wether this request is valid
+ */
+ public final function isRequestValid () {
+ return $this->requestIsValid;
+ }
}
// [EOF]
// Test if the required parameter is set
try {
// This goes fine so let's resolv the command
- $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig("command_parameter"));
+ $commandName = $requestInstance->getRequestElement($this->getConfigInstance()->readConfig('command_parameter'));
// Is the command empty? Then fall back to default command
- if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
+ if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_command');
// Check if the command is valid
if (!$this->isCommandValid($commandName)) {
$commandInstance = null;
// Is the command empty? Then fall back to default command
- if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig("default_command");
+ if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_command');
// Check if the command is valid
if (!$this->isCommandValid($commandName)) {
*/
private function loadCommand ($commandName) {
// Cache default command
- $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+ $defaultCommand = $this->getConfigInstance()->readConfig('default_command');
// Init command instance
$commandInstance = null;
//
// Cache default command
- $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+ $defaultCommand = $this->getConfigInstance()->readConfig('default_command');
// Init controller instance
$controllerInstance = null;
$class = sprintf("Web%sController",
$this->convertToClassName($commandName)
);
- } elseif ($this->getConfigInstance()->readConfig("home_with_news") == "Y") {
+ } elseif ($this->getConfigInstance()->readConfig('home_with_news') == "Y") {
// Yes, display news in home then set default controller with news
$class = "WebDefaultNewsController";
} else {
$this->responseHeaders[$name] = $value;
}
+ /**
+ * Reset the header array
+ *
+ * @return void
+ */
+ public final function resetResponseHeaders () {
+ $this->responseHeaders = array();
+ }
+
/**
* "Writes" data to the response body
*
$this->responseBody .= $output;
}
+ /**
+ * Sets the response body to something new
+ *
+ * @param $output Output we shall sent in the HTTP response
+ * @return void
+ */
+ public function setReponseBody ($output) {
+ $this->responseBody = $output;
+ }
+
/**
* Flushs the cached HTTP response to the outer world
*
throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
} elseif (!headers_sent()) {
// Send headers out
- header("HTTP/1.0 {$this->responseStatus}");
+ header("HTTP/1.1 {$this->responseStatus}");
// Used later
$now = gmdate('D, d M Y H:i:s') . ' GMT';
}
}
- // Flush the output to the world
- $this->getWebOutputInstance()->output($this->responseBody);
- $this->reponseBody = "";
- $this->responseHeaders = array();
+ // Are there some error messages?
+ if (count($this->fatalMessages) == 0) {
+ // Flush the output to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ } else {
+ // Display all error messages
+ $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
+
+ // Send the error messages out to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ }
+
+ // Clear response header and body
+ $this->setReponseBody("");
+ $this->resetResponseHeaders();
}
/**
$tplInstance->setFileIoInstance($ioInstance);
// Set template extensions
- $tplInstance->setRawTemplateExtension($cfgInstance->readConfig("raw_template_extension"));
- $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig("code_template_extension"));
+ $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension'));
+ $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension'));
// Absolute output path for compiled templates
- $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig("compile_output_path"));
+ $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path'));
// Return the prepared instance
return $tplInstance;
$ext = $this->getRawTemplateExtension();
// If we shall load a code-template we need to switch the file extension
- if ($this->getTemplateType() == $this->getConfigInstance()->readConfig("code_template_type")) {
+ if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) {
// Switch over to the code-template extension
$ext = $this->getCodeTemplateExtension();
}
*/
public final function loadWebTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("web_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('web_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function loadEmailTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("email_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('email_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function loadCodeTemplate ($template) {
// Set template type
- $this->setTemplateType($this->getConfigInstance()->readConfig("code_template_type"));
+ $this->setTemplateType($this->getConfigInstance()->readConfig('code_template_type'));
// Load the special template
$this->loadTemplate($template);
*/
public final function compileVariables () {
// Initialize the $content array
- $validVar = $this->getConfigInstance()->readConfig("tpl_valid_var");
+ $validVar = $this->getConfigInstance()->readConfig('tpl_valid_var');
$dummy = array();
// Iterate through all variables
*/
public final function compileTemplate () {
// We will only work with template type "code" from configuration
- if ($this->getTemplateType() != $this->getConfigInstance()->readConfig("code_template_type")) {
+ if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('code_template_type')) {
// Abort here
- throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig("code_template_type")), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
+ throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig('code_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
} // END - if
// Get the raw data.
// Read all directories but no sub directories
while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess"))) {
// Is this a class file?
- if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig("php_extension"))) {
+ if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig('php_extension'))) {
// Get the compressor's name. That's why you must name
// your files like your classes and also that's why you
// must keep on class in one file.
$this->dirList = new ArrayObject();
// Set suffix and prefix from configuration
- $this->suffix = $cfgInstance->readConfig("class_suffix");
- $this->prefix = $cfgInstance->readConfig("class_prefix");
+ $this->suffix = $cfgInstance->readConfig('class_suffix');
+ $this->prefix = $cfgInstance->readConfig('class_prefix');
// Estimate length of prefix and suffix for substr() function (cache)
$this->sufLen = strlen($this->suffix);
}
// Initial load of core classes and the FrameworkDirectoryPointer class
-require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
-require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
-require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig("php_extension")));
+require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
+require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
+require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
// Initialize the class loader
$loader = new ClassLoader(FrameworkConfiguration::getInstance());
// Try to load these includes in the given order
$configAppIncludes = array(
- sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig("app_helper_class")), // The ApplicationHelper class
+ sprintf("class_%s", FrameworkConfiguration::getInstance()->readConfig('app_helper_class')), // The ApplicationHelper class
"config", // The application's own configuration
"init", // The application initializer
"loader", // The application's class loader