private $wrapperInstance = NULL;
/**
- * Thousands seperator
+ * Thousands separator
*/
private $thousands = '.'; // German
/**
- * Decimal seperator
+ * Decimal separator
*/
private $decimals = ','; // German
const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x040;
- // Hexadecimal->Decimal translation array
+ /**
+ * Hexadecimal->Decimal translation array
+ */
private static $hexdec = array(
'0' => 0,
'1' => 1,
'f' => 15
);
- // Decimal->hexadecimal translation array
+ /**
+ * Decimal->hexadecimal translation array
+ */
private static $dechex = array(
0 => '0',
1 => '1',
15 => 'f'
);
+ /**
+ * Startup time in miliseconds
+ */
+ private static $startupTime = 0;
+
/**
* Protected super constructor
*
// Set configuration instance if no registry ...
if (!$this instanceof Register) {
// ... because registries doesn't need to be configured
- $this->setConfigInstance(FrameworkConfiguration::getInstance());
+ $this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
+ } // END - if
+
+ // Is the startup time set? (0 cannot be true anymore)
+ if (self::$startupTime == 0) {
+ // Then set it
+ self::$startupTime = microtime(true);
} // END - if
}
/**
- * Destructor reached...
+ * Destructor for all classes
*
* @return void
*/
// Add the type
$argsString .= $this->replaceControlCharacters($arg) . ' (' . gettype($arg);
- // Add length if type is string
if (is_string($arg)) {
+ // Add length for strings
$argsString .= ', '.strlen($arg);
- } // END - if
+ } elseif (is_array($arg)) {
+ // .. or size if array
+ $argsString .= ', '.count($arg);
+ } elseif ($arg === true) {
+ // ... is boolean 'true'
+ $argsString .= ', true';
+ } elseif ($arg === false) {
+ // ... is boolean 'true'
+ $argsString .= ', false';
+ }
// Closing bracket
$argsString .= '), ';
/**
* Formats computer generated price values into human-understandable formats
- * with thousand and decimal seperators.
+ * with thousand and decimal separators.
*
* @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
+ * @throws MissingDecimalsThousandsSeparatorException If decimals or
+ * thousands separator
* is missing
*/
public function formatCurrency ($value, $currency = '€', $decNum = 2) {
// Are all required attriutes set?
if ((!isset($this->decimals)) || (!isset($this->thousands))) {
// Throw an exception
- throw new MissingDecimalsThousandsSeperatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING);
+ throw new MissingDecimalsThousandsSeparatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING);
} // END - if
// Cast the number
ApplicationEntryPoint::app_die(sprintf("<div class=\"debug_header\">%s debug output:</div><div class=\"debug_content\">%s</div>\nLoaded includes: <div class=\"debug_include_list\">%s</div>",
$this->__toString(),
$content,
- ClassLoader::getInstance()->getPrintableIncludeList()
+ ClassLoader::getSelfInstance()->getPrintableIncludeList()
));
}
protected function replaceControlCharacters ($str) {
// Replace them
$str = str_replace(
- "\r", '[r]', str_replace(
- "\n", '[n]', str_replace(
- "\t", '[t]',
+ chr(13), '[r]', str_replace(
+ chr(10), '[n]', str_replace(
+ chr(9) , '[t]',
$str
)));
} else {
// Put directly out
if ($doPrint === true) {
- print($message);
+ // Are debug times enabled?
+ if ($this->getConfigInstance()->getConfigEntry('debug_output_timings') == 'Y') {
+ // Output it first
+ print($this->getPrintableExecutionTime());
+ } // END - if
+
+ // Print message
+ print($message . chr(10));
} else {
// DO NOT REWRITE THIS TO app_die() !!!
die($message);
} // END - if
// Add line number to the code
- foreach (explode("\n", $phpCode) as $lineNo => $code) {
+ foreach (explode(chr(10), $phpCode) as $lineNo => $code) {
// Add line numbers
$markedCode .= sprintf("<span id=\"code_line\">%s</span>: %s\n",
($lineNo + 1),
// Return it
return $responseType;
}
+
+ /**
+ * Gets a cache key from Criteria instance
+ *
+ * @param $criteriaInstance An instance of a Criteria class
+ * @param $onlyKeys Only use these keys for a cache key
+ * @return $cacheKey A cache key suitable for lookup/storage purposes
+ */
+ protected function getCacheKeyByCriteria (Criteria $criteriaInstance, $onlyKeys = array()) {
+ // Generate it
+ $cacheKey = sprintf("%s@%s",
+ $this->__toString(),
+ $criteriaInstance->getCacheKey($onlyKeys)
+ );
+
+ // And return it
+ //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
+ return $cacheKey;
+ }
+
+ /**
+ * Getter for startup time in miliseconds
+ *
+ * @return $startupTime Startup time in miliseconds
+ */
+ protected function getStartupTime () {
+ return self::$startupTime;
+ }
+
+ /**
+ * "Getter" for a printable currently execution time in nice braces
+ *
+ * @return $executionTime Current execution time in nice braces
+ */
+ protected function getPrintableExecutionTime () {
+ // Caculate the execution time
+ $executionTime = microtime(true) - $this->getStartupTime();
+
+ // Pack it in nice braces
+ $executionTime = sprintf('[ %01.5f ] ', $executionTime);
+
+ // And return it
+ return $executionTime;
+ }
}
// [EOF]