* The simulator system class is the super class of all other classes. This
* class handles saving of games etc.
*
- * @author Roland Haeder <webmaster@ship-simu.org>
+ * @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
* @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
+ * @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
$this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
} // END - if
- // Is the startup time set? (0 cannot be true anymore)
+ // Is the startup time set? (0 cannot be TRUE anymore)
if (self::$startupTime == 0) {
// Then set it
- self::$startupTime = microtime(true);
+ self::$startupTime = microtime(TRUE);
} // END - if
}
} else {
// Do not call this twice
trigger_error(__METHOD__ . ': Called twice.');
+ exit;
}
}
// .. or size if array
$argsString .= ', ' . count($arg);
} elseif ($arg === TRUE) {
- // ... is boolean 'true'
- $argsString .= ', true';
+ // ... is boolean 'TRUE'
+ $argsString .= ', TRUE';
} elseif ($arg === FALSE) {
- // ... is boolean 'true'
- $argsString .= ', false';
+ // ... is boolean 'FALSE'
+ $argsString .= ', FALSE';
}
// Closing bracket
$content .= sprintf('<pre>%s</pre>',
trim(
htmlentities(
- print_r($this, true)
+ print_r($this, TRUE)
)
)
);
} else {
// Trigger an error
trigger_error($stubMessage);
+ exit;
}
}
* Outputs a debug backtrace and stops further script execution
*
* @param $message An optional message to output
- * @param $doExit Whether exit the program (true is default)
+ * @param $doExit Whether exit the program (TRUE is default)
* @return void
*/
public function debugBackTrace ($message = '', $doExit = TRUE) {
* @return $debugInstance An instance of a debugger class
*/
public final static function createDebugInstance ($className) {
- // Init debug instance
- $debugInstance = NULL;
+ // Is the instance set?
+ if (!Registry::getRegistry()->instanceExists('debug')) {
+ // Init debug instance
+ $debugInstance = NULL;
+
+ // Try it
+ try {
+ // Get a debugger instance
+ $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
+ } catch (NullPointerException $e) {
+ // Didn't work, no instance there
+ exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
+ }
- // Try it
- try {
- // Get a debugger instance
- $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
- } catch (NullPointerException $e) {
- // Didn't work, no instance there
- exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
- }
+ // Empty string should be ignored and used for testing the middleware
+ DebugMiddleware::getSelfInstance()->output('');
- // Empty string should be ignored and used for testing the middleware
- DebugMiddleware::getSelfInstance()->output('');
+ // Set it in its own class. This will set it in the registry
+ $debugInstance->setDebugInstance($debugInstance);
+ } else {
+ // Get instance from registry
+ $debugInstance = Registry::getRegistry()->getDebugInstance();
+ }
// Return it
return $debugInstance;
*
* @param $message Message we shall send out...
* @param $doPrint Whether print or die here (default: print)
- * @paran $stripTags Whether to strip tags (default: false)
+ * @paran $stripTags Whether to strip tags (default: FALSE)
* @return void
*/
public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) {
// Get current array
$fieldArray = $resultInstance->current();
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, true).'</pre>');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
// Convert dashes to underscore
$fieldName = $this->convertDashesToUnderscores($fieldName);
} else {
// Trigger an error
trigger_error($message . "<br />\n");
+ exit;
}
} else {
// @TODO Finish this part!
*/
public function getMilliTime () {
// Get the time of day as float
- $milliTime = gettimeofday(true);
+ $milliTime = gettimeofday(TRUE);
// Return it
return $milliTime;
*/
protected function isBase64Encoded ($encodedData) {
// Determine it
- $isBase64 = (@base64_decode($encodedData, true) !== FALSE);
+ $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE);
// Return it
return $isBase64;
*/
protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) {
// Generate it
- $cacheKey = sprintf("%s@%s",
+ $cacheKey = sprintf('%s@%s',
$this->__toString(),
$criteriaInstance->getCacheKey($onlyKeys)
);
*/
protected function getPrintableExecutionTime () {
// Caculate the execution time
- $executionTime = microtime(true) - $this->getStartupTime();
+ $executionTime = microtime(TRUE) - $this->getStartupTime();
// Pack it in nice braces
$executionTime = sprintf('[ %01.5f ] ', $executionTime);
if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
// No, then abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+ exit;
} // END - if
// Debug message
if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) {
// Already initialized
trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.');
+ exit;
} // END - if
// Initialize it
if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
// Already initialized
trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
+ exit;
} // END - if
// Initialize it
if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) {
// Already initialized
trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.');
+ exit;
} // END - if
// Initialize it
if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Not found
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
+ exit;
} // END - if
// Then "pop" it
if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Not found
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
+ exit;
} // END - if
// Then "shift" it
if (!isset($this->genericArray[$keyGroup])) {
// Abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
+ exit;
} // END - if
// Then count it
if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
// Abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+ exit;
} // END - if
// Then count it
if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+ exit;
} elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
// Not valid
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.');
+ exit;
}
// Then count it
if (!isset($this->genericArray[$keyGroup])) {
// Then abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
+ exit;
} // END - if
// Return it
if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Then abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
+ exit;
} // END - if
// Return it
if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
// Then abort here
trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
+ exit;
} // END - if
// Return it