* @param $dataArray Array containing the compressor's extension and streamed data
* @return void
*/
- function saveFile ($fileName, $dataArray);
+ function saveFile ($fileName, array $dataArray);
}
// [EOF]
// Is the offset there?
if ($this->offsetExists($offset)) {
// Purge only existing keys
- //* DEBUG: */ $this->debugOutput('CACHE: Unsetting cache ' . $offset);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CACHE: Unsetting cache ' . $offset);
$this->dataCache->offsetUnset($offset);
} // END - if
}
*
* @return void
*/
- public function __destruct() {
+ public function __destruct () {
// Flush any updated entries to the database
$this->flushPendingUpdates();
$this->setRealClass('DestructedObject');
} elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
// Already destructed object
- $this->debugOutput(sprintf("[%s:] The object <span class=\"object_name\">%s</span> is already destroyed.",
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf("[%s:] The object <span class=\"object_name\">%s</span> is already destroyed.",
__CLASS__,
$this->__toString()
));
* @return void
*/
public final function __call ($methodName, $args) {
+ return self::__callStatic($methodName, $args);
+ }
+
+ /**
+ * The __callStatic() method where all non-implemented static methods end up
+ *
+ * @param $methodName Name of the missing method
+ * @args $args Arguments passed to the method
+ * @return void
+ */
+ public static final function __callStatic ($methodName, $args) {
// Implode all given arguments
$argsString = '';
if (empty($args)) {
if (is_string($arg)) {
// Add length for strings
- $argsString .= ', '.strlen($arg);
+ $argsString .= ', ' . strlen($arg);
} elseif (is_array($arg)) {
// .. or size if array
- $argsString .= ', '.count($arg);
+ $argsString .= ', ' . count($arg);
} elseif ($arg === true) {
// ... is boolean 'true'
$argsString .= ', true';
}
// Output stub message
- $this->debugOutput(sprintf("[%s->%s] Stub! Args: %s",
- $this->__toString(),
+ // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf("[unknown::%s:] Stub! Args: %s",
$methodName,
$argsString
));
* @return void
*/
public final function setSocketResource ($socketResource) {
- //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
$this->socketResource = $socketResource;
}
* @return $socketResource A valid socket resource
*/
public final function getSocketResource () {
- //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
return $this->socketResource;
}
// Debug instance is there?
if (!is_null($this->getDebugInstance())) {
// Output stub message
- $this->debugOutput($stubMessage);
+ self::createDebugInstance(__CLASS__)->debugOutput($stubMessage);
} else {
// Trigger an error
trigger_error($stubMessage);
} // END - if
}
+ /**
+ * Creates an instance of a debugger instance
+ *
+ * @param $className Name of the class (currently unsupported)
+ * @return $debugInstance An instance of a debugger class
+ */
+ public final static function createDebugInstance ($className) {
+ // 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
+ die('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
+ }
+
+ // Empty string should be ignored and used for testing the middleware
+ DebugMiddleware::getSelfInstance()->output('');
+
+ // Return it
+ return $debugInstance;
+ }
+
/**
* Outputs a debug message whether to debug instance (should be set!) or
* dies with or ptints the message. Do NEVER EVER rewrite the die() call to
// Get current array
$fieldArray = $resultInstance->current();
- //* DEBUG: */ $this->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);
$fieldValue = $fieldArray[$fieldName];
} else {
// Missing field entry, may require debugging
- $this->debugOutput($this->__toString() . ':fieldname=' . $fieldName . ' not found!');
+ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ':fieldname=' . $fieldName . ' not found!');
}
// Return it
// Debug instance is there?
if (!is_null($this->getDebugInstance())) {
// Output stub message
- $this->debugOutput($message);
+ self::createDebugInstance(__CLASS__)->debugOutput($message);
} else {
// Trigger an error
trigger_error($message . "<br />\n");
*/
protected function hex2asc ($hex) {
// Check for length, it must be devideable by 2
- //* DEBUG: */ $this->debugOutput('hex='.$hex);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex);
assert((strlen($hex) % 2) == 0);
// Walk the string
// Cut it a little down
$prepend = substr($prepend, 0, $diff);
- //* DEBUG: */ $this->debugOutput('prepend('.strlen($prepend).')='.$prepend.',diff='.$diff.',length='.$length);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('prepend('.strlen($prepend).')='.$prepend.',diff='.$diff.',length='.$length);
// Construct the final prepended string
$strFinal = $prepend . $str;
);
// And return it
- //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
return $cacheKey;
}
* BZIP2 compression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The compressed stream data
+ * @return $streamData The compressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function compressStream ($streamData) {
* BZIP2 decompression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The decompressed stream data
+ * @return $streamData The decompressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function decompressStream ($streamData) {
throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
} // END - if
+ // Decompress it
+ $streamData = bzdecompress($streamData, true);
+
// Return the decompressed stream
- return bzdecompress($streamData);
+ return $streamData;
}
/**
* GZIP compression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The compressed stream data
+ * @return $streamData The compressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function compressStream ($streamData) {
* GZIP decompression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The decompressed stream data
+ * @return $streamData The decompressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function decompressStream ($streamData) {
* Null compression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The compressed stream data
+ * @return $streamData The compressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function compressStream ($streamData) {
* Null decompression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The decompressed stream data
+ * @return $streamData The decompressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function decompressStream ($streamData) {
* ZLIB compression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The compressed stream data
+ * @return $streamData The compressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function compressStream ($streamData) {
* ZLIB decompression stream
*
* @param $streamData Mixed non-object stream data
- * @return $streamData The decompressed stream data
+ * @return $streamData The decompressed stream data
* @throws InvalidObjectException If the stream is an object
*/
public function decompressStream ($streamData) {
*/
protected function resolveIpAddress ($hostname) {
// Debug message
- $this->debugOutput(sprintf('[%s:] Host name to resolve is: %s',
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s',
$this->__toString(),
$hostname
));
$ip = $ipResolved;
// Debug message
- $this->debugOutput(sprintf('[%s:] Resolved IP address is: %s',
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s',
$this->__toString(),
$ip
));
} else {
// Problem while resolving IP address
- $this->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.',
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.',
$this->__toString(),
$hostname
));
// Add last new-line
$proxyTunnel .= self::HTTP_EOL;
- //* DEBUG: */ $this->debugOutput('CONSOLE-TOOLS: proxyTunnel=' . $proxyTunnel);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS: proxyTunnel=' . $proxyTunnel);
// Write request
fwrite($socketResource, $proxyTunnel);
$packageData = $this->getPackageData();
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('SOCKET-CONTAINER: addressPort=' . $addressPort . ',packageData=' . print_r($packageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER: addressPort=' . $addressPort . ',packageData=' . print_r($packageData, true));
// So, does both match?
$matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $addressPort));
*/
public final function ifSocketResourceMatches ($socketResource) {
// Debug message
- /* NOISY-DEBUG: */ $this->debugOutput('SOCKET-CONTAINER: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource());
// So, does both match?
$matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource()));
* @return void
*/
protected function initFilterChain ($filterChain) {
- //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
$this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
- //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
}
/**
* @throws InvalidFilterChainException If the filter chain is invalid
*/
protected function addFilter ($filterChain, Filterable $filterInstance) {
- //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START');
// Test if the filter is there
if (!isset($this->filterChains[$filterChain])) {
// Add the filter
$this->filterChains[$filterChain]->addFilter($filterInstance);
- //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH');
}
/**
$criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . count($this->criteria));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . count($this->criteria));
// Default is not found
$value = NULL;
protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) {
// First get a key suitable for our cache and extend it with this class name
$cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
- //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
// Does this key exists in cache?
if ($this->cacheInstance->offsetExists($cacheKey)) {
protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) {
// First get a key suitable for our cache and extend it with this class name
$cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
- //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
// Does this key exists in cache?
if ($this->cacheInstance->offsetExists($cacheKey)) {
// Does this key exists in cache?
if ($this->cacheInstance->offsetExists($cacheKey)) {
// Debug message
- //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey);
// Then use this result
$result = $this->cacheInstance->offsetGet($cacheKey);
} else {
// Debug message
- //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
// Now it's time to ask the database layer for this select statement
$result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
$numRows = $resultInstance->getAffectedRows();
// Debug message
- //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
} // END - if
// Return the result
// Set the compressor channel
$databaseInstance->setCompressorChannel($compressorInstance);
+ // Get a file IO handler
+ $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
+
+ // ... and set it
+ $databaseInstance->setFileIoInstance($fileIoInstance);
+
// "Connect" to the database
$databaseInstance->connectToDatabase();
*/
private function getDataArrayFromFile ($fqfn) {
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...');
-
- // Get a file pointer
- $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...');
- // Get the raw data and BASE64-decode it
- $compressedData = base64_decode($fileInstance->readLinesFromFile());
+ // Init compressed data
+ $compressedData = $this->getFileIoInstance()->loadFileContents($fqfn);
+ $compressedData = $compressedData['data'];
// Close the file and throw the instance away
- $fileInstance->closeFile();
unset($fileInstance);
// Decompress it
$dataArray = unserialize($serializedData);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.');
// Finally return it
return $dataArray;
*/
private function writeDataArrayToFqfn ($fqfn, array $dataArray) {
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...');
-
- // Get a file pointer instance
- $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fqfn, 'w');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...');
// Serialize and compress it
$compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($dataArray));
- // Write this data BASE64 encoded to the file
- $fileInstance->writeToFile(base64_encode($compressedData));
+ // Write data
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...');
- // Close the file pointer
- $fileInstance->closeFile();
+ // Write this data BASE64 encoded to the file
+ $this->getFileIoInstance()->saveFile($fqfn, $compressedData);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.');
}
/**
// Read the file
$dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray,true));
// Is this an array?
if (is_array($dataArray)) {
$criteria = $criteriaInstance->getCriteriaElemnent($key);
// Is the criteria met or none set?
- //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: criteria[' . gettype($criteria) . ']=' . $criteria . ';()=' . strlen($criteria) . ',criteriaInstance()=' . $criteriaInstance->count() . ',value(' . strlen($value) . ')=' . $value);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: criteria[' . gettype($criteria) . ']=' . $criteria . ';()=' . strlen($criteria) . ',criteriaInstance()=' . $criteriaInstance->count() . ',value(' . strlen($value) . ')=' . $value);
if (((!is_null($criteria)) && ($criteria == $value)) || ($criteriaInstance->count() == 0)) {
// Shall we skip this entry?
if ($criteriaInstance->getSkip() > 0) {
$dataArray[$this->getIndexKey()] = $idx;
// Entry found!
- //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true));
$resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS][] = $dataArray;
// Count found entries up
// Does the extension match?
if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
// Debug message
- /* NOISY-DEBUG: */ $this->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!');
// Skip this file!
continue;
} // END - if
// Open this file for reading
$dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray,true));
// Is this an array?
if (is_array($dataArray)) {
foreach ($dataArray as $key => $value) {
// Get criteria element
$criteria = $searchInstance->getCriteriaElemnent($key);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',key=' . $key . ',criteria=' . $criteria);
// Is the criteria met?
if (((!is_null($criteria)) && ($criteria == $value)) || ($searchInstance->count() == 0)) {
// Entry found, so update it
foreach ($criteriaArray as $criteriaKey => $criteriaValue) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
$dataArray[$criteriaKey] = $criteriaValue;
} // END - foreach
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// Get result back
$resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ // Advanced to next entry
+ if (!$resultInstance->next()) {
+ // Not valid!
+ assert(false);
+ } // END - if
+
// Set the result instance
$this->setResultInstance($resultInstance);
}
*/
public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Run all filters
- //* DEBUG */ $this->debugOutput('COUNT=' . count($this->filters));
+ //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('COUNT=' . count($this->filters));
foreach ($this->getFilters() as $filterInstance) {
// Try to execute this filter
try {
- //* DEBUG */ $this->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing started.');
+ //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing started.');
$filterInstance->execute($requestInstance, $responseInstance);
- //* DEBUG */ $this->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing ended.');
+ //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing ended.');
} catch (FilterChainException $e) {
// This exception can be thrown to just skip any further processing
- $this->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage());
break;
}
} // END - foreach
public function assignFieldWithFilter ($fieldName, $filterMethod) {
// Get the value
$fieldValue = $this->getValueField($fieldName);
- //* DEBUG: */ $this->debugOutput($fieldName.'='.$fieldValue);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'='.$fieldValue);
// Now filter it through the value through the filter method
$filteredValue = call_user_func_array(array($this, 'doFilter' . $this->convertToClassName($filterMethod)), array($fieldValue));
* @throws NullPointerException If recovery of requested value instance failed
*/
public function prefetchValueInstance ($registryKey, $extraKey = NULL) {
- //* DEBUG: */ $this->debugOutput('O:'.$registryKey.'/'.$extraKey);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('O:'.$registryKey.'/'.$extraKey);
try {
// Get the required instance
$this->valueInstance = Registry::getRegistry()->getInstance($registryKey);
} catch (NullPointerException $e) {
// Not set in registry
// @TODO Try to log it here
- //* DEBUG: */ $this->debugOutput($registryKey.'=NULL!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($registryKey.'=NULL!');
}
// Shall we get an extra instance?
// Try to create it
$this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance));
}
- //* DEBUG: */ $this->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
} // END - if
// Is the value instance valid?
// Get the field value
$fieldValue = $this->getValueInstance()->getField($fieldName);
- //* DEBUG: */ $this->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).')');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).')');
// Is it null?
if ((is_null($fieldValue)) && (!is_null($this->extraInstance))) {
* @see FileOutputStreamer
* @todo This method needs heavy rewrite
*/
- public final function saveFile ($fileName, $dataArray) {
+ public final function saveFile ($fileName, array $dataArray) {
// Try it five times
$dirName = ''; $fileInstance = NULL;
for ($idx = 0; $idx < 5; $idx++) {
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
public function readDirectoryExcept (array $except = array('.', '..')) {
if (count($except) == 0) {
// No exception given, so read all data
- $this->debugOutput('DIRECTORY: No exceptions given, please use readRawDirectory() instead!');
+ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: No exceptions given, please use readRawDirectory() instead!');
return $this->readRawDirectory();
} // END - if
// Shall we exclude directories?
if ((!is_null($rawLine)) && ($rawLine !== false) && (!in_array($rawLine, $except))) {
// Return read data
- //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
return $rawLine;
} elseif ((!is_null($rawLine)) && ($rawLine !== false)) {
// Exclude this part
- //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!');
return $this->readDirectoryExcept($except);
}
// End pointer reached
- //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: Returning NULL!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: Returning NULL!');
return NULL;
}
}
// Try to open a handler
- $filePointer = @fopen($fileName, 'rb');
+ $filePointer = fopen($fileName, 'rb');
if ((is_null($filePointer)) || ($filePointer === false)) {
// Something bad happend
throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
return fread($this->getPointer(), 1024);
}
- /**
- * Read lines from a file pointer
- *
- * @return mixed The result of fread()
- * @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
- * @throws InvalidResourceException If there is being set
- * an invalid file resource
- */
- public function readLinesFromFile () {
- if (is_null($this->getPointer())) {
- // Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_resource($this->getPointer())) {
- // Pointer is not a valid resource!
- throw new InvalidResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER);
- }
-
- // Read data from the file pointer and return it
- return fgets($this->getPointer(), 1024);
- }
-
/**
* Close a file source and set it's instance to null and the file name
* to empty
// Convert all to UTF8
if (empty($content)) {
// No empty content!
- $this->debugOutput('Empty content! Backtrace: <pre>');
+ self::createDebugInstance(__CLASS__)->debugOutput('Empty content! Backtrace: <pre>');
debug_print_backtrace();
- $this->debugOutput('</pre>');
+ self::createDebugInstance(__CLASS__)->debugOutput('</pre>');
die();
} elseif (function_exists('recode')) {
// Recode found, so use it
// "Walk" over all entries
foreach ($this->getEntries('object-name') as $key => $value) {
// Debug message
- //* DEBUG: */ $this->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
// If $value matches the $lookFor, we need to look for more entries for this!
if ($lookFor == $value) {
// Look for more entries
foreach ($this->getEntries() as $key2 => $value2) {
// Debug message
- //* DEBUG: */ $this->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2=' . print_r($value2, true) . ',lookFor=' . $lookFor);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2=' . print_r($value2, true) . ',lookFor=' . $lookFor);
// Both keys must match!
if (($key == $key2) || (isset($value2[$key]))) {
// Debug message
- //* DEBUG: */ $this->debugOutput('REGISTRY: Adding ' . $value2[$key] . ' ...');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY: Adding ' . $value2[$key] . ' ...');
// Then add it
$entry[$key2] = $value2[$key];
$this->setClassName($this->getClassPrefix() . 'DefaultNewsController');
// Generate the class name
- //* DEBUG: */ $this->debugOutput('BEFORE: controller=' . $controllerName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BEFORE: controller=' . $controllerName);
if ($controllerName != $defaultController) {
// Create controller class name
$className = $this->getClassPrefix() . $this->convertToClassName($controllerName) . 'Controller';
// No news at main command or non-news command
$this->setClassName($this->getClassPrefix() . 'DefaultNewsController');
}
- //* DEBUG: */ $this->debugOutput('AFTER: controller=' . $this->getClassName());
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('AFTER: controller=' . $this->getClassName());
// Is this class loaded?
if (!class_exists($this->getClassName())) {
// Send all headers
foreach ($this->responseHeaders as $name => $value) {
header($name . ': ' . $value);
- //* DEBUG: */ $this->debugOutput('name=' . $name . ',value=' . $value);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('name=' . $name . ',value=' . $value);
} // END - foreach
// Send cookies out?
* @throws UnsupportedOperationException If this method is called (which is a mistake)
*/
public function streamData ($data) {
- $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
* @throws UnsupportedOperationException If this method is called (which is a mistake)
*/
public function streamData ($data) {
- $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// If the stack is null, use the current group
if (is_null($stack)) {
// Use current group
- //* DEBUG: */ $this->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
$stack = $this->currGroup;
} // END - if
if ($this->isVarStackSet($stack)) {
// Now search for it
foreach ($this->getVarStack($stack) as $index => $currEntry) {
- //* DEBUG: */ $this->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName);
// Is the entry found?
if ($currEntry['name'] == $variableName) {
// Found!
- //* DEBUG: */ $this->debugOutput(__METHOD__.':FOUND!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':FOUND!');
$found = $index;
break;
} // END - if
// If the stack is null, use the current group
if (is_null($stack)) {
// Use current group
- //* DEBUG: */ $this->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
$stack = $this->currGroup;
} // END - if
} // END - if
// Return the current position
- //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $stack . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $stack . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content);
return $content;
}
*/
public function setVariableGroup ($groupName, $add = true) {
// Set group name
- //* DEBIG: */ $this->debugOutput(__METHOD__.': currGroup=' . $groupName);
+ //* DEBIG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': currGroup=' . $groupName);
$this->currGroup = $groupName;
// Skip group 'general'
$variableName = trim($this->convertDashesToUnderscores($variableName));
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value);
// Get current variables in group
$currVars = $this->readCurrentGroup();
// Was it found?
if ($index === false) {
// Add it to the stack
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
$this->addVariable($variableName, $value);
} elseif (!empty($value)) {
// Modify the stack entry
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
$this->modifyVariable($variableName, $value);
}
}
*/
protected final function setRawTemplateData ($rawTemplateData) {
// And store it in this class
- //* DEBUG: */ $this->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.');
- //* DEBUG: */ $this->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack));
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack));
$this->rawTemplateData = (string) $rawTemplateData;
}
* @return $rawTemplateData The raw data from the template
*/
public final function getRawTemplateData () {
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': ' . strlen($this->rawTemplateData) . ' Bytes read.');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': ' . strlen($this->rawTemplateData) . ' Bytes read.');
return $this->rawTemplateData;
}
*/
private final function setCompiledData ($compiledData) {
// And store it in this class
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': ' . strlen($compiledData) . ' Bytes set.');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': ' . strlen($compiledData) . ' Bytes set.');
$this->compiledData = (string) $compiledData;
}
* @return $compiledData Compiled template data
*/
public final function getCompiledData () {
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': ' . strlen($this->compiledData) . ' Bytes read.');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': ' . strlen($this->compiledData) . ' Bytes read.');
return $this->compiledData;
}
$ioInstance = $this->getFileIoInstance();
// Some debug code to look on the file which is being loaded
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': FQFN=' . $fqfn);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': FQFN=' . $fqfn);
// Load the raw template
$rawTemplateData = $ioInstance->loadFileContents($fqfn);
$variableName = trim($this->convertDashesToUnderscores($variableName));
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': varName=' . $varName . ',variableName=' . $variableName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': varName=' . $varName . ',variableName=' . $variableName);
// Is it not a config variable?
if ($varName != 'config') {
preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, true));
// Did we find some variables?
if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
// RECURSIVE PROTECTION! BE CAREFUL HERE!
if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':template=' . $template);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':template=' . $template);
// Template not found, but maybe variable assigned?
if ($this->getVariableIndex($template, 'config') !== false) {
*/
private function assignAllVariables (array $varMatches) {
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':varMatches()=' . count($varMatches));
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':varMatches()=' . count($varMatches));
// Search for all variables
foreach ($varMatches[1] as $key => $var) {
$var = trim($this->convertDashesToUnderscores($var));
// Debug message
- $this->debugOutput(__METHOD__ . ':key=' . $key . ',var=' . $var);
+ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':key=' . $key . ',var=' . $var);
// Detect leading equals
if (substr($varMatches[2][$key], 0, 1) == '=') {
*/
private function compileRawTemplateData (array $templateMatches) {
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':loadedRawData()= ' .count($this->loadedRawData));
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':loadedRawData()= ' .count($this->loadedRawData));
// Are some code-templates found which we need to compile?
if (count($this->loadedRawData) > 0) {
// Then compile all!
foreach ($this->loadedRawData as $template => $code) {
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':template=' . $template . ',code(' . strlen($code) . ')=' . $code);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':template=' . $template . ',code(' . strlen($code) . ')=' . $code);
// Is this template already compiled?
if (in_array($template, $this->compiledTemplates)) {
// Then skip it
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': Template ' . $template . ' already compiled. SKIPPED!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Template ' . $template . ' already compiled. SKIPPED!');
continue;
} // END - if
if (($foundIndex !== false) && (isset($templateMatches[3][$foundIndex]))) {
// Split it up with another reg. exp. into variable=value pairs
preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches);
- //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':varMatches=' . print_r($varMatches, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':varMatches=' . print_r($varMatches, true));
// Assign all variables
$this->assignAllVariables($varMatches);
private function finalizeVariableCompilation () {
// Get the content
$content = $this->getRawTemplateData();
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': content before=' . strlen($content) . ' (' . md5($content) . ')');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': content before=' . strlen($content) . ' (' . md5($content) . ')');
// Do we have the stack?
if (!$this->isVarStackSet('general')) {
// Walk through all variables
foreach ($this->getVarStack('general') as $currEntry) {
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': name=' . $currEntry['name'] . ', value=<pre>' . htmlentities($currEntry['value']) . '</pre>');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': name=' . $currEntry['name'] . ', value=<pre>' . htmlentities($currEntry['value']) . '</pre>');
// Replace all [$var] or {?$var?} with the content
// @TODO Old behaviour, will become obsolete!
$content = str_replace('$content[' . $currEntry['name'] . ']', $currEntry['value'], $content);
$content = str_replace('{?' . $currEntry['name'] . '?}', $currEntry['value'], $content);
} // END - for
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': content after=' . strlen($content) . ' (' . md5($content) . ')');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': content after=' . strlen($content) . ' (' . md5($content) . ')');
// Set the content back
$this->setRawTemplateData($content);
$variableName = trim($this->convertDashesToUnderscores($variableName));
// Sweet and simple...
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName));
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName));
$this->setVariable('config', $variableName, $this->getConfigInstance()->getConfigEntry($variableName));
}
// Do we have the stack?
if (!$this->isVarStackSet('general')) {
// Abort here silently
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': Aborted, variable stack general not found!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Aborted, variable stack general not found!');
return;
} // END - if
$value = $this->compileRawCode($this->readVariable($currVariable['name']), true);
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': name=' . $currVariable['name'] . ',value=' . $value);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': name=' . $currVariable['name'] . ',value=' . $value);
// Remove it from stack
$this->removeVariable($currVariable['name'], 'general');
// Re-assign the variable
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index);
$this->assignConfigVariable($value);
} // END - foreach
}
// Iterate through all general variables
foreach ($this->getVarStack('general') as $currVariable) {
// Transfer it's name/value combination to the $content array
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':' . $currVariable['name'] . '=<pre>' . htmlentities($currVariable['value']).'</pre>');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':' . $currVariable['name'] . '=<pre>' . htmlentities($currVariable['value']).'</pre>');
$dummy[$currVariable['name']] = $currVariable['value'];
}// END - if
// Goes something wrong?
if ((!isset($result)) || (empty($result))) {
// Output eval command
- $this->debugOutput(sprintf("Failed eval() code: <pre>%s</pre>", $this->markupCode($eval, true)), true);
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf("Failed eval() code: <pre>%s</pre>", $this->markupCode($eval, true)), true);
// Output backtrace here
$this->debugBackTrace();
preg_match_all($this->regExpCodeTags, $rawData, $templateMatches);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':templateMatches=' . print_r($templateMatches , true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':templateMatches=' . print_r($templateMatches , true));
// Analyze the matches array
if ((is_array($templateMatches)) && (count($templateMatches) == 4) && (count($templateMatches[0]) > 0)) {
*/
public function compileRawCode ($rawCode, $setMatchAsCode=false) {
// Find the variables
- //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':rawCode=<pre>' . htmlentities($rawCode) . '</pre>');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':rawCode=<pre>' . htmlentities($rawCode) . '</pre>');
preg_match_all($this->regExpVarValue, $rawCode, $varMatches);
// Compile all variables
- //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':<pre>' . print_r($varMatches, true) . '</pre>');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':<pre>' . print_r($varMatches, true) . '</pre>');
foreach ($varMatches[0] as $match) {
// Add variable tags around it
$varCode = '{?' . $match . '?}';
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':varCode=' . $varCode);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':varCode=' . $varCode);
// Is the variable found in code? (safes some calls)
if (strpos($rawCode, $varCode) !== false) {
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': match=' . $match . ',rawCode[' . gettype($rawCode) . ']=' . $rawCode);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': match=' . $match . ',rawCode[' . gettype($rawCode) . ']=' . $rawCode);
// Use $match as new value or $value from read variable?
if ($setMatchAsCode === true) {
} // END - foreach
// Return the compiled data
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':rawCode=<pre>' . htmlentities($rawCode) . '</pre>');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':rawCode=<pre>' . htmlentities($rawCode) . '</pre>');
return $rawCode;
}
* @return void
*/
public function renameVariable ($oldName, $newName) {
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': oldName=' . $oldName . ', newName=' . $newName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': oldName=' . $oldName . ', newName=' . $newName);
// Get raw template code
$rawData = $this->getRawTemplateData();
// Get instance
$databaseInstance = new DatabaseConnection();
- // Set debug output handler
- $databaseInstance->setDebugInstance($debugInstance);
-
// Set database layer
$databaseInstance->setDatabaseLayer($dbLayer);
/**
* Saves a file with data by using the current output stream
*
- * @param $fileName Name of the file
- * @param $dataArray Array with file contents
+ * @param $fileName Name of the file
+ * @param $dataStream File data stream
* @return void
* @see FileOutputStreamer
*/
- public function saveFile ($fileName, $dataArray) {
+ public function saveFile ($fileName, $dataStream) {
// Get output stream
$outInstance = $this->getOutputStream();
+ // Prepare output array
+ $dataArray = array(
+ // @TODO What is this for?
+ 0 => $this->__toString(),
+ 1 => $dataStream
+ );
+
// Send the fileName and dataArray to the output handler
$outInstance->saveFile($fileName, $dataArray);
}