X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=0d8213210adf2000e0592850a8902b8258cf1755;hb=dc97c9dc65dcbd007a4c5118674a03ff326a6dca;hp=f460986a655c35dac483daf9449a78037bf20b68;hpb=cc6ac14e62a0ba455caffae6870f6264141b0819;p=shipsimu.git diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index f460986..0d82132 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -150,6 +150,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_HEADERS_ALREADY_SENT = 0x033; const EXCEPTION_DEFAUL_CONTROLLER_GONE = 0x034; const EXCEPTION_CLASS_NOT_FOUND = 0x035; + const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x036; /** * In the super constructor these system classes shall be ignored or else @@ -236,7 +237,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } elseif (is_float($arg)) { // Floating point $argsString .= $arg."(float)"; - } elseif ($arg instanceof BaseFramework) { + } elseif ($arg instanceof BaseFrameworkSystem) { // Own object instance $argsString .= $arg->__toString()."(Object)"; } elseif (is_object($arg)) { @@ -248,6 +249,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } elseif (is_string($arg)) { // String $argsString .= "\"".$arg."\"(string)"; + } elseif (is_null($arg)) { + // Null + $argsString .= "(null)"; } else { // Unknown type (please report!) $argsString .= $arg."(unknown!)"; @@ -288,16 +292,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // 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 @@ -315,7 +319,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Set the compressor channel $this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s", PATH, - $this->getConfigInstance()->readConfig("compressor_base_path") + $this->getConfigInstance()->readConfig('compressor_base_path') ))); } @@ -628,10 +632,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * Formats computer generated price values into human-understandable formats * with thousand and decimal seperators. * - * @param $value The in computer format value for a price - * @param $currency The currency symbol (use HTML-valid characters!) - * @param $decNum Number of decimals after commata - * @return $price The for the current language formated price string + * @param $value The in computer format value for a price + * @param $currency The currency symbol (use HTML-valid characters!) + * @param $decNum Number of decimals after commata + * @return $price The for the current language formated price string * @throws MissingDecimalsThousandsSeperatorException If decimals or * thousands seperator * is missing @@ -839,9 +843,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // 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? @@ -860,8 +864,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { \$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 ); @@ -896,18 +900,21 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public final function debugInstance () { // Generate the output - $content = "
".trim(print_r($this, true))."
"; + $content = sprintf("
%s
", + trim(print_r($this, true)) + ); // Output it - ApplicationEntryPoint::app_die("Debug output:".$content); + ApplicationEntryPoint::app_die(sprintf("%s debug output:%s", $this->__toString(), $content)); } /** * Output a partial stub message for the caller method * + * @param $message An optional message to display * @return void */ - protected function partialStub () { + protected function partialStub ($message = "") { // Get the backtrace $backtrace = debug_backtrace(); @@ -917,16 +924,52 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $methodName = $backtrace[1]['class']."::".$backtrace[1]['function']; } + // Construct the full message + $stubMessage = sprintf("[%s:] Partial stub!", + $methodName + ); + + // Is the extra message given? + if (!empty($message)) { + // Then add it as well + $stubMessage .= sprintf(" Message: %s", $message); + } + // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - $this->getDebugInstance()->output(sprintf("[%s:] Partial stub!
\n", - $methodName - )); + $this->getDebugInstance()->output($stubMessage); } else { // Trigger an error - trigger_error(sprintf("[%s:] Partial stub!", $methodName)); + trigger_error($stubMessage."
\n"); + } + } + + /** + * Converts e.g. a command from URL to a valid class by keeping out bad characters + * + * @param $str The string, what ever it is needs to be converted + * @return $className Generated class name + */ + public function convertToClassName ($str) { + $className = ""; + foreach (explode("_", $str) as $strPart) { + $className .= ucfirst(strtolower($strPart)); } + 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 "
\n";
+		debug_print_backtrace();
+		print "
"; + exit; } }