X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=0b5ce31099294001468444eda7f8daac25122f09;hp=fafe6b0310e0d9dcfe400acb403d4409e1870167;hb=9ea7c80cda1d4b8018ddc61a0d1a2f9e5eedbdf1;hpb=114ddb6dfaf2be44a8d61ebd609cc05302ac702e diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index fafe6b03..0b5ce310 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -73,10 +73,20 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $controllerInstance = null; + /** + * Instance of a RNG + */ + private $rngInstance = null; + + /** + * Instance of an Iterator class + */ + private $iteratorInstance = null; + /** * The real class name */ - private $realClass = 'FrameworkSystem'; + private $realClass = 'BaseFrameworkSystem'; /** * Thousands seperator @@ -270,19 +280,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->setConfigInstance(FrameworkConfiguration::getInstance()); // Add application helper to our class - $this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class'); + $this->systemclasses[] = $this->getConfigInstance()->getConfigEntry('app_helper_class'); // Set debug instance - $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_class'))); + $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->getConfigEntry('debug_class'))); // Get output instance and set it - $outputInstance = ObjectFactory::createObjectByConfiguredName('web_engine', array($this->getConfigInstance()->readConfig('web_content_type'))); + $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($this->getConfigInstance()->getConfigEntry('web_content_type'))); $this->setWebOutputInstance($outputInstance); // Set the compressor channel $this->setCompressorChannel(CompressorChannel::createCompressorChannel( - $this->getConfigInstance()->readConfig('base_path'). - $this->getConfigInstance()->readConfig('compressor_base_path') + $this->getConfigInstance()->getConfigEntry('base_path'). + $this->getConfigInstance()->getConfigEntry('compressor_base_path') )); // Initialization done! :D @@ -590,27 +600,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return ($this->__toString() == $className); } - /** - * Stub method (only real cabins shall override it) - * - * @return boolean false = is no cabin, true = is a cabin - * @deprecated - */ - public function isCabin () { - return false; - } - - /** - * Stub method for tradeable objects - * - * @return boolean false = is not tradeable by the Merchant class, - * true = is a tradeable object - * @deprecated - */ - public function isTradeable () { - return false; - } - /** * Formats computer generated price values into human-understandable formats * with thousand and decimal seperators. @@ -740,13 +729,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - if } // END - if - // Generate FQFN for all application templates - $fqfn = sprintf("%s%s/%s", - $this->getConfigInstance()->readConfig('application_path'), - strtolower($appInstance->getAppShortName()), - $this->getConfigInstance()->readConfig('tpl_base_path') - ); - // Are both instances set? if ($appInstance->getLanguageInstance() === null) { // Invalid language instance @@ -757,7 +739,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // Initialize the template engine - $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance())); + $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($appInstance)); // Return the prepared instance return $templateInstance; @@ -867,7 +849,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if ($doPrint === false) die(); // Die here if not printed } else { // Put directly out - if ($doPrint) { + if ($doPrint === true) { print($message); } else { // DO NOT REWRITE THIS TO app_die() !!! @@ -975,7 +957,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $timeArray = explode(':', $dateTime[1]); // Construct the timestamp - $readable = sprintf($this->getConfigInstance()->readConfig('german_date_time'), + $readable = sprintf($this->getConfigInstance()->getConfigEntry('german_date_time'), $dateArray[0], $dateArray[1], $dateArray[2], @@ -1119,6 +1101,93 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $wrapperInstance->doUpdateByResult($this->getResultInstance()); } // END - if } + + /** + * Outputs a deprecation warning to the developer. + * + * @param $message The message we shall output to the developer + * @return void + * @todo Write a logging mechanism for productive mode + */ + public function deprecationWarning ($message) { + // Is developer mode active? + if (defined('DEVELOPER')) { + // Debug instance is there? + if (!is_null($this->getDebugInstance())) { + // Output stub message + $this->debugOutput($message); + } else { + // Trigger an error + trigger_error($message."
\n"); + } + } else { + // @TODO Finish this part! + $this->partialStub('Developer mode inactive. Message:' . $message); + } + } + + /** + * Generates a generic hash code of this class. You should really overwrite + * this method with your own hash code generator code. But keep KISS in mind. + * + * @return $hashCode A generic hash code respresenting this whole class + */ + public function hashCode () { + // Simple hash code + return crc32($this->__toString()); + } + + /** + * Checks wether the given PHP extension is loaded + * + * @param $phpExtension The PHP extension we shall check + * @return $isLoaded Wether the PHP extension is loaded + */ + public final function isPhpExtensionLoaded ($phpExtension) { + // Is it loaded? + $isLoaded = in_array($phpExtension, get_loaded_extensions()); + + // Return result + return $isLoaded; + } + + /** + * Setter for RNG instance + * + * @param $rngInstance An instance of a random number generator (RNG) + * @return void + */ + protected final function setRngInstance (RandomNumberGenerator $rngInstance) { + $this->rngInstance = $rngInstance; + } + + /** + * Getter for RNG instance + * + * @return $rngInstance An instance of a random number generator (RNG) + */ + public final function getRngInstance () { + return $this->rngInstance; + } + + /** + * Setter for Iterator instance + * + * @param $iteratorInstance An instance of an Iterator + * @return void + */ + protected final function setIteratorInstance (Iterator $iteratorInstance) { + $this->iteratorInstance = $iteratorInstance; + } + + /** + * Getter for Iterator instance + * + * @return $iteratorInstance An instance of an Iterator + */ + public final function getIteratorInstance () { + return $this->iteratorInstance; + } } // [EOF]