From: Roland Häder Date: Fri, 13 Mar 2009 22:38:55 +0000 (+0000) Subject: Rewritten a lot double-quotes to single-requotes, removed deprecated exception, some... X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=49f84a522f0ccac3b70728cd41011a0be0eed8cf Rewritten a lot double-quotes to single-requotes, removed deprecated exception, some code cosmetics --- diff --git a/.gitattributes b/.gitattributes index f7c63ef4..dc179059 100644 --- a/.gitattributes +++ b/.gitattributes @@ -108,7 +108,6 @@ inc/classes/exceptions/template/class_BasePathReadProtectedException.php -text inc/classes/exceptions/template/class_InvalidBasePathStringException.php -text inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php -text inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php -text -inc/classes/exceptions/template/class_ViewHelperNotFoundException.php -text inc/classes/exceptions/user/.htaccess -text inc/classes/exceptions/user/class_AccountPasswordMismatchException.php -text inc/classes/exceptions/user/class_UserEmailMissingException.php -text diff --git a/inc/classes/exceptions/class_FrameworkException.php b/inc/classes/exceptions/class_FrameworkException.php index f3a42895..ed71ebdd 100644 --- a/inc/classes/exceptions/class_FrameworkException.php +++ b/inc/classes/exceptions/class_FrameworkException.php @@ -122,7 +122,7 @@ abstract class FrameworkException extends ReflectionException { foreach ($dbgInfo['args'] as $debug) { // Add only non-array elements if (!is_array($debug)) { - $info .= $debug.", "; + $info .= $debug . ', '; } // END - if } // END - foreach @@ -146,7 +146,7 @@ abstract class FrameworkException extends ReflectionException { } // END - if // The message - $dbgMsg .= "\t at ".$dbgIndex." ".$file." (".$line.") -> ".$dbgInfo['function']."(".$info.")
\n"; + $dbgMsg .= "\t at ".$dbgIndex." ".$file." (".$line.") -> ".$dbgInfo['function'].'('.$info.")
\n"; } // END - if // Add end-message diff --git a/inc/classes/exceptions/controller/class_DefaultControllerException.php b/inc/classes/exceptions/controller/class_DefaultControllerException.php index c718c00b..f0065e5d 100644 --- a/inc/classes/exceptions/controller/class_DefaultControllerException.php +++ b/inc/classes/exceptions/controller/class_DefaultControllerException.php @@ -37,7 +37,7 @@ class DefaultControllerException extends FrameworkException { ); // Set extra data - $this->setExtraData($resolverInstance->getClassName().":".$this->getLine()); + $this->setExtraData($resolverInstance->getClassName().':'.$this->getLine()); // Call parent contructor with message parent::__construct($message, $code); diff --git a/inc/classes/exceptions/controller/class_InvalidControllerException.php b/inc/classes/exceptions/controller/class_InvalidControllerException.php index 5e25a52d..c8234e15 100644 --- a/inc/classes/exceptions/controller/class_InvalidControllerException.php +++ b/inc/classes/exceptions/controller/class_InvalidControllerException.php @@ -39,7 +39,7 @@ class InvalidControllerException extends FrameworkException { ); // Set extra data - $this->setExtraData($msgArray[0]->getClassName().":".$this->getLine()); + $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine()); // Call parent contructor with message parent::__construct($message, $code); diff --git a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php index 7fbe36c2..43d5a2ce 100644 --- a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php +++ b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php @@ -41,7 +41,7 @@ class EncryptInvalidLengthException extends FrameworkException { ); // Set extra data - $this->setExtraData($filterInstance->__toString().":".$length); + $this->setExtraData($filterInstance->__toString().':'.$length); // Call parent exception constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php index d0446134..ccffca89 100644 --- a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php +++ b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php @@ -40,7 +40,7 @@ class ConfigEntryNotFoundException extends FrameworkException { ); // Set extra data - $this->setExtraData($classArray[1].":".$this->getLine()); + $this->setExtraData($classArray[1].':'.$this->getLine()); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/main/class_InvalidCommandException.php b/inc/classes/exceptions/main/class_InvalidCommandException.php index 4076c7df..834b6c4b 100644 --- a/inc/classes/exceptions/main/class_InvalidCommandException.php +++ b/inc/classes/exceptions/main/class_InvalidCommandException.php @@ -39,7 +39,7 @@ class InvalidCommandException extends FrameworkException { ); // Set extra data - $this->setExtraData($msgArray[0]->getClassName().":".$this->getLine()); + $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine()); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php b/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php deleted file mode 100644 index e45325ae..00000000 --- a/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Rename this class to NoViewHelperException - * @deprecated - * - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ViewHelperNotFoundException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray An array holding our informations - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf("[%s:] View-Helper %s ist ungültig.", - $msgArray[0]->__toString(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php index 0e3f0cfa..e2c5781e 100644 --- a/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php +++ b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php @@ -31,9 +31,9 @@ class InvalidXmlNodeException extends FrameworkException { */ public function __construct (array $classArray, $code) { // Extract attributes - $attributes = "None"; + $attributes = 'None'; if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) { - $attributes = implode(", ", $classArray[2]); + $attributes = implode(', ', $classArray[2]); } // END - if // Construct our message diff --git a/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php b/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php index f5cd0d9d..726fc789 100644 --- a/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php +++ b/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php @@ -37,7 +37,7 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface { * Starts a SELECT query on the database by given return type, table name * and search criteria * - * @param $resultType Result type ("array", "object" and "indexed" are valid) + * @param $resultType Result type ('array', 'object' and 'indexed' are valid) * @param $tableName Name of the database table * @param $criteria Search criteria class * @return $resultData Result data of the query @@ -47,7 +47,7 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface { function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance); /** - * "Inserts" a data set instance into a local file database folder + * 'Inserts' a data set instance into a local file database folder * * @param $dataSetInstance A storeable data set * @return void @@ -56,7 +56,7 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface { function queryInsertDataSet (StoreableCriteria $dataSetInstance); /** - * "Updates" a data set instance with a database layer + * 'Updates' a data set instance with a database layer * * @param $dataSetInstance A storeable data set * @return void diff --git a/inc/classes/interfaces/io/output/class_OutputStreamer.php b/inc/classes/interfaces/io/output/class_OutputStreamer.php index 9c004771..76781217 100644 --- a/inc/classes/interfaces/io/output/class_OutputStreamer.php +++ b/inc/classes/interfaces/io/output/class_OutputStreamer.php @@ -25,8 +25,8 @@ interface OutputStreamer extends Streamable { /** * Assigns a variable for output * - * @param $var The variable we shall assign - * @param $value The value to store in the variable + * @param $var The variable we shall assign + * @param $value The value to store in the variable * @return void */ function assignVariable ($var, $value); @@ -36,7 +36,7 @@ interface OutputStreamer extends Streamable { * * @return void */ - function output ($outStream=false); + function output ($outStream = false); } // diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 06fddbc5..46280f89 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -208,7 +208,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { // Already destructed object $this->debugOutput(sprintf("[%s:] The object %s is already destroyed.", - __CLASS__, $this->__toString() + __CLASS__, + $this->__toString() )); } } @@ -223,27 +224,27 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $argsString = ''; if (empty($args)) { // No arguments - $argsString = "NULL"; + $argsString = 'NULL'; } elseif (is_array($args)) { // Some arguments are there foreach ($args as $arg) { // Add the type - $argsString .= $arg." (".gettype($arg); + $argsString .= $arg . ' (' . gettype($arg); // Add length if type is string - if (gettype($arg) == 'string') $argsString .= ", ".strlen($arg); + if (gettype($arg) == 'string') $argsString .= ', '.strlen($arg); // Closing bracket - $argsString .= "), "; + $argsString .= '), '; } // END - foreach // Remove last comma - if (substr($argsString, -2, 1) === ",") { + if (substr($argsString, -2, 1) == ',') { $argsString = substr($argsString, 0, -2); } // END - if } else { // Invalid arguments! - $argsString = sprintf("!INVALID:%s!", $args); + $argsString = '!INVALID:' . gettype($args) . '!'; } // Output stub message @@ -622,7 +623,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * thousands seperator * is missing */ - public function formatCurrency ($value, $currency = "€", $decNum = 2) { + public function formatCurrency ($value, $currency = '€', $decNum = 2) { // Are all required attriutes set? if ((!isset($this->decimals)) || (!isset($this->thousands))) { // Throw an exception @@ -633,10 +634,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $value = (float) $value; // Reformat the US number - $price = sprintf("%s %s", - number_format($value, $decNum, $this->decimals, $this->thousands), - $currency - ); + $price = number_format($value, $decNum, $this->decimals, $this->thousands) . $currency; // Return as string... return $price; @@ -690,7 +688,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public final function addMissingTrailingSlash ($str) { // Is there a trailing slash? - if (substr($str, -1, 1) != "/") $str .= "/"; + if (substr($str, -1, 1) != '/') $str .= '/'; return $str; } @@ -812,7 +810,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $backtrace = debug_backtrace(); // Generate the class::method string - $methodName = "UnknownClass->unknownMethod"; + $methodName = 'UnknownClass->unknownMethod'; if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { $methodName = $backtrace[1]['class']."->".$backtrace[1]['function']; } // END - if @@ -889,10 +887,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $className = ''; // Convert all dashes in underscores - $str = str_replace("-", "_", $str); + $str = $this->convertDashesToUnderscore($str); // Now use that underscores to get classname parts for hungarian style - foreach (explode("_", $str) as $strPart) { + foreach (explode('_', $str) as $strPart) { // Make the class name part lower case and first upper case $className .= ucfirst(strtolower($strPart)); } // END - foreach @@ -901,6 +899,20 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $className; } + /** + * Converts dashes to underscores, e.g. useable for configuration entries + * + * @param $str The string with maybe dashes inside + * @return $str The converted string with no dashed, but underscores + */ + public final function convertDashesToUnderscores ($str) { + // Convert them all + $str = str_replace('-', '_', $str); + + // Return converted string + return $str; + } + /** * Marks up the code by adding e.g. line numbers * @@ -948,7 +960,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public function doFilterFormatTimestamp ($timestamp) { // Default value to return - $readable = "???"; + $readable = '???'; // Is the timestamp null? if (is_null($timestamp)) { @@ -958,9 +970,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { switch ($this->getLanguageInstance()->getLanguageCode()) { case "de": // German format is a bit different to default // Split the GMT stamp up - $dateTime = explode(" ", $timestamp); - $dateArray = explode("-", $dateTime[0]); - $timeArray = explode(":", $dateTime[1]); + $dateTime = explode(' ', $timestamp ); + $dateArray = explode('-', $dateTime[0]); + $timeArray = explode(':', $dateTime[1]); // Construct the timestamp $readable = sprintf($this->getConfigInstance()->readConfig('german_date_time'), diff --git a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php index 7531fa1f..2cd3c9c1 100644 --- a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -159,10 +159,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { $appInstance = $registryInstance->getInstance('application'); // Default action is the one from configuration - $this->actionName = sprintf("%s_login_%s", - str_replace("-", "_", $appInstance->getAppShortName()), - $this->getConfigInstance()->readConfig('login_default_action') - ); + $this->actionName = $this->convertDashesToUnderscores($appInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->readConfig('login_default_action'); // Get "action" from request $actReq = $requestInstance->getRequestElement('action'); @@ -170,10 +167,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // Do we have a "action" parameter set? if ((is_string($actReq)) && (!empty($actReq))) { // Then use it with prefix - $this->actionName = sprintf("%s_login_%s", - str_replace("-", "_", $appInstance->getAppShortName()), - $actReq - ); + $this->actionName = $this->convertDashesToUnderscores($appInstance->getAppShortName()) . '_login_' . $actReq; } // END - if // Get application instance diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php index b4cc5208..8ba2d72e 100644 --- a/inc/classes/main/compressor/class_GzipCompressor.php +++ b/inc/classes/main/compressor/class_GzipCompressor.php @@ -88,10 +88,10 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { /** * Getter for the file extension of this compressor * - * @return $string Returns always "gz" + * @return $string Returns always 'gz' */ public final function getCompressorExtension () { - return "gz"; + return 'gz'; } } diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index bc1c191f..004ea24f 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -41,6 +41,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { */ private $salt = ''; + /** + * Seperator on many places + */ + private $seperator '|'; + /** * Protected constructor * @@ -166,7 +171,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); // Get key - if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') === "Y") { + if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') == 'Y') { $key = md5($this->rngInstance->getFixedSalt()); } else { $key = md5($this->rngInstance->getExtraSalt()); @@ -175,39 +180,39 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { // Add some "garbage" to the string switch ($this->rngInstance->randomNumber(0, 8)) { case 0: - $garbageString = crc32($this->rngInstance->randomString(10))."|".base64_encode($str)."|".crc32($this->rngInstance->randomString(20)); + $garbageString = crc32($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . crc32($this->rngInstance->randomString(20)); break; case 1: - $garbageString = crc32($this->rngInstance->randomString(10))."|".base64_encode($str)."|".md5($this->rngInstance->randomString(20)); + $garbageString = crc32($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . md5($this->rngInstance->randomString(20)); break; case 2: - $garbageString = crc32($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + $garbageString = crc32($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . sha1($this->rngInstance->randomString(20)); break; case 3: - $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".crc32($this->rngInstance->randomString(20)); + $garbageString = md5($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . crc32($this->rngInstance->randomString(20)); break; case 4: - $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".md5($this->rngInstance->randomString(20)); + $garbageString = md5($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . md5($this->rngInstance->randomString(20)); break; case 5: - $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + $garbageString = md5($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . sha1($this->rngInstance->randomString(20)); break; case 6: - $garbageString = sha1($this->rngInstance->randomString(10))."|".base64_encode($str)."|".crc32($this->rngInstance->randomString(20)); + $garbageString = sha1($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . crc32($this->rngInstance->randomString(20)); break; case 7: - $garbageString = sha1($this->rngInstance->randomString(10))."|".base64_encode($str)."|".md5($this->rngInstance->randomString(20)); + $garbageString = sha1($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . md5($this->rngInstance->randomString(20)); break; case 8: - $garbageString = sha1($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + $garbageString = sha1($this->rngInstance->randomString(10)) . $this->seperator . base64_encode($str) . $this->seperator . sha1($this->rngInstance->randomString(20)); break; } @@ -230,7 +235,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); // Get key - if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') === "Y") { + if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') == 'Y') { $key = md5($this->rngInstance->getFixedSalt()); } else { $key = md5($this->rngInstance->getExtraSalt()); @@ -240,7 +245,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { $garbageString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); // Get the real string out - $strArray = explode("|", $garbageString); + $strArray = explode($this->seperator, $garbageString); // Does the element count match? assert(count($strArray) == 3); diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 2e284430..d026afd4 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -24,12 +24,14 @@ * along with this program. If not, see . */ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface { - // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) const DB_CODE_TABLE_MISSING = 0x100; const DB_CODE_TABLE_UNWRITEABLE = 0x101; const DB_CODE_DATA_FILE_CORRUPT = 0x102; + // Status results + const RESULT_OKAY = 'ok'; + /** * Save path for "file database" */ @@ -38,7 +40,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend /** * The file's extension */ - private $fileExtension = "serialized"; + private $fileExtension = 'serialized'; /** * The last read file's name @@ -331,7 +333,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend if (!isset($this->tableInfo['primary'])) { // Then create the info file $this->createTableInfoFile($dataSetInstance); - } elseif (($this->getConfigInstance()->readConfig('db_update_primary_forced') === "Y") && ($dataSetInstance->getPrimaryKey() != $this->tableInfo['primary'])) { + } elseif (($this->getConfigInstance()->readConfig('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo['primary'])) { // Set the array element $this->tableInfo[$dataSetInstance->getTableName()]['primary'] = $dataSetInstance->getPrimaryKey(); @@ -353,12 +355,12 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend * Starts a SELECT query on the database by given return type, table name * and search criteria * - * @param $resultType Result type ("array", "object" and "indexed" are valid) + * @param $resultType Result type ('array', 'object' and 'indexed' are valid) * @param $tableName Name of the database table * @param $criteria Local search criteria class * @return $resultData Result data of the query * @throws UnsupportedCriteriaException If the criteria is unsupported - * @throws SqlException If an "SQL error" occurs + * @throws SqlException If an 'SQL error' occurs */ public function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance) { // The result is null by any errors @@ -367,15 +369,15 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend // Create full path name $pathName = $this->getSavePath() . $tableName . '/'; - // A "select" query is not that easy on local files, so first try to - // find the "table" which is in fact a directory on the server + // A 'select' query is not that easy on local files, so first try to + // find the 'table' which is in fact a directory on the server try { // Get a directory pointer instance $directoryInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName); // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read $resultData = array( - 'status' => "ok", + 'status' => LocalfileDatabase::RESULT_OKAY, 'rows' => array() ); @@ -385,7 +387,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend $idx = 1; // Read the directory with some exceptions - while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) { + while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) { // Does the extension match? if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { // Skip this file! @@ -521,7 +523,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend $searchInstance = $dataSetInstance->getSearchInstance(); // Read the directory with some exceptions - while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $searchInstance->getLimit())) { + while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', "info." . $this->getFileExtension()))) && ($limitFound < $searchInstance->getLimit())) { // Does the extension match? if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { // Skip this file! diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php index 2d76aa15..94edad9b 100644 --- a/inc/classes/main/debug/class_DebugConsoleOutput.php +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -72,7 +72,7 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output * * @return void */ - public final function output ($outStream=false) { + public final function output ($outStream = false) { // Empty output will be silently ignored if ($outStream !== false) { $this->outputStream($outStream); diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php index 59a3aabf..b873a91c 100644 --- a/inc/classes/main/debug/class_DebugErrorLogOutput.php +++ b/inc/classes/main/debug/class_DebugErrorLogOutput.php @@ -35,7 +35,7 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu /** * Creates an instance of this class * - * @return $debugInstance The prepared debug instance + * @return $debugInstance The prepared debug instance */ public final static function createDebugErrorLogOutput () { // Get a new instance @@ -48,7 +48,7 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu /** * Outputs the given data without HTML tags * - * @param $output The HTML'ed output + * @param $output The HTML'ed output * @return void */ public final function outputStream ($output) { @@ -67,8 +67,8 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu /** * Assigns a variable for output * - * @param $var The variable we shall assign - * @param $value The value to store in the variable + * @param $var The variable we shall assign + * @param $value The value to store in the variable * @return void */ public final function assignVariable ($var, $value) { @@ -81,7 +81,7 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu * * @return void */ - public final function output ($outStream=false) { + public final function output ($outStream = false) { // Empty output will be silently ignored if ($outStream !== false) { $this->outputStream($outStream); diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php index 7406574d..1464814e 100644 --- a/inc/classes/main/debug/class_DebugWebOutput.php +++ b/inc/classes/main/debug/class_DebugWebOutput.php @@ -35,7 +35,7 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre /** * Creates an instance of this class * - * @return $debugInstance The prepared debug instance + * @return $debugInstance The prepared debug instance */ public final static function createDebugWebOutput () { // Get a new instance @@ -48,7 +48,7 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre /** * Outputs the given data directly * - * @param $output The HTML output + * @param $output The HTML output * @return void */ public final function outputStream ($output) { @@ -60,8 +60,8 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre /** * Assigns a variable for output * - * @param $var The variable we shall assign - * @param $value The value to store in the variable + * @param $var The variable we shall assign + * @param $value The value to store in the variable * @return void */ public final function assignVariable ($var, $value) { @@ -74,7 +74,7 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre * * @return void */ - public final function output ($outStream=false) { + public final function output ($outStream = false) { // Empty output will be silently ignored if ($outStream !== false) { $this->outputStream($outStream); diff --git a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php index 8444ced8..ef8dbfc2 100644 --- a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php +++ b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php @@ -67,7 +67,7 @@ class CaptchaEncryptFilter extends BaseFilter implements Filterable { } // END - if // Decode it fully - $encryptDecoded = base64_decode(str_replace(" ", "+", urldecode($encryptRequest))); + $encryptDecoded = base64_decode(str_replace(' ', '+', urldecode($encryptRequest))); // Get a crypto helper and decrypt the string $decryptedString = ObjectFactory::createObjectByConfiguredName('crypto_class')->decryptString($encryptDecoded); diff --git a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php index 9dabfc39..bf01652b 100644 --- a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php @@ -61,7 +61,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { $email = $requestInstance->getRequestElement('email'); // Is the Email set? - if ((is_null($email)) || ($this->getConfigInstance()->readConfig('register_email_unique') === "Y")) { + if ((is_null($email)) || ($this->getConfigInstance()->readConfig('register_email_unique') == 'Y')) { // Try it again $email1 = $requestInstance->getRequestElement('email1'); $email2 = $requestInstance->getRequestElement('email2'); diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index c651872c..89a3babe 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -89,7 +89,7 @@ class BaseHelper extends BaseFrameworkSystem { * @return void */ protected final function addContent ($newContent) { - $this->content .= (string) trim($newContent)."\n"; + $this->content .= (string) trim($newContent) . "\n"; } /** @@ -244,7 +244,13 @@ class BaseHelper extends BaseFrameworkSystem { // Add the group to the stack $this->groups[$this->totalCounter] = $groupId; $this->groups[$groupId]['opened'] = true; - $this->groups[$groupId]['content'] = sprintf("%s\n", $groupId, strlen($content), $tag, $content); + $this->groups[$groupId]['content'] = sprintf( + "%s\n", + $groupId, + strlen($content), + $tag, + $content + ); $this->groups[$groupId]['tag'] = $tag; // Mark this group as previously opened @@ -278,11 +284,21 @@ class BaseHelper extends BaseFrameworkSystem { // Is the content empty? if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) { // Get it from opener - $content = sprintf("", $groupId, $this->groups[$groupId]['tag']); + $content = sprintf( + "", + $groupId, + $this->groups[$groupId]['tag'] + ); } // END - if // Add content to it and mark it as closed - $this->groups[$groupId]['content'] .= sprintf("%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content); + $this->groups[$groupId]['content'] .= sprintf( + "%s\n", + $groupId, + strlen($content), + $this->groups[$groupId]['tag'], + $content + ); $this->groups[$groupId]['opened'] = false; // Mark previous group as closed @@ -367,7 +383,7 @@ class BaseHelper extends BaseFrameworkSystem { // Is header content there? if (isset($this->groups['header'])) { // Then add it - $content .= $this->groups['header']['content']."\n"; + $content .= $this->groups['header']['content'] . "\n"; } // END - if // Initiate content @@ -395,7 +411,7 @@ class BaseHelper extends BaseFrameworkSystem { // Is footer content there? if (isset($this->groups['footer'])) { // Then add it - $content .= $this->groups['footer']['content']."\n"; + $content .= $this->groups['footer']['content'] . "\n"; } // END - if // Return it diff --git a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php index bcdeb5ff..5f17a563 100644 --- a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php +++ b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php @@ -83,7 +83,7 @@ class WebBlockHelper extends BaseWebHelper implements HelpableTemplate { * @return $withRegistration Wether with registration date */ public function ifIncludeRegistrationStamp () { - $withRegistration = ($this->getConfigInstance()->readConfig('block_shows_registration') === "Y"); + $withRegistration = ($this->getConfigInstance()->readConfig('block_shows_registration') == 'Y'); return $withRegistration; } diff --git a/inc/classes/main/helper/web/class_BaseWebHelper.php b/inc/classes/main/helper/web/class_BaseWebHelper.php index 5b56aaa3..6aad86ce 100644 --- a/inc/classes/main/helper/web/class_BaseWebHelper.php +++ b/inc/classes/main/helper/web/class_BaseWebHelper.php @@ -40,7 +40,7 @@ class BaseWebHelper extends BaseHelper { * @return $required Wether the email address is required */ public function ifRegisterRequiresEmailVerification () { - $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y"); + $required = ($this->getConfigInstance()->readConfig('register_requires_email') == 'Y'); return $required; } @@ -50,7 +50,7 @@ class BaseWebHelper extends BaseHelper { * @return $required Wether profile shall be asked */ public function ifRegisterIncludesProfile () { - $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y"); + $required = ($this->getConfigInstance()->readConfig('register_includes_profile') == 'Y'); return $required; } @@ -60,7 +60,7 @@ class BaseWebHelper extends BaseHelper { * @return $required Wether personal data shall be asked */ public function ifRegisterIncludesPersonaData () { - $required = ($this->getConfigInstance()->readConfig('register_personal_data') === "Y"); + $required = ($this->getConfigInstance()->readConfig('register_personal_data') == 'Y'); return $required; } @@ -70,7 +70,7 @@ class BaseWebHelper extends BaseHelper { * @return $required Wether birthday shall be asked */ public function ifProfileIncludesBirthDay () { - $required = ($this->getConfigInstance()->readConfig('profile_includes_birthday') === "Y"); + $required = ($this->getConfigInstance()->readConfig('profile_includes_birthday') == 'Y'); return $required; } @@ -80,7 +80,7 @@ class BaseWebHelper extends BaseHelper { * @return $isUnique */ public function ifEmailMustBeUnique () { - $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') === "Y"); + $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') == 'Y'); return $isUnique; } @@ -90,7 +90,7 @@ class BaseWebHelper extends BaseHelper { * @return $required Wether the specified chat protocol is enabled */ public function ifChatEnabled ($chatProtocol) { - $required = ($this->getConfigInstance()->readConfig(sprintf("chat_enabled_%s", $chatProtocol)) == "Y"); + $required = ($this->getConfigInstance()->readConfig('chat_enabled_' . $chatProtocol) == 'Y'); return $required; } @@ -100,7 +100,7 @@ class BaseWebHelper extends BaseHelper { * @return $isEnabled Wether the login is enabled or disabled */ public function ifLoginIsEnabled () { - $isEnabled = ($this->getConfigInstance()->readConfig('login_enabled') === "Y"); + $isEnabled = ($this->getConfigInstance()->readConfig('login_enabled') == 'Y'); return $isEnabled; } @@ -130,7 +130,7 @@ class BaseWebHelper extends BaseHelper { * @return $isAllowed Wether guest login is allowed */ public function ifGuestLoginAllowed () { - $isAllowed = ($this->getConfigInstance()->readConfig('guest_login_allowed') === "Y"); + $isAllowed = ($this->getConfigInstance()->readConfig('guest_login_allowed') == 'Y'); return $isAllowed; } @@ -140,7 +140,7 @@ class BaseWebHelper extends BaseHelper { * @return $requireConfirm Wether email change must be confirmed */ public function ifEmailChangeRequireConfirmation () { - $requireConfirm = ($this->getConfigInstance()->readConfig('email_change_confirmation') === "Y"); + $requireConfirm = ($this->getConfigInstance()->readConfig('email_change_confirmation') == 'Y'); return $requireConfirm; } @@ -160,7 +160,7 @@ class BaseWebHelper extends BaseHelper { * @return $emailChange Wether changing email address is allowed */ public function ifEmailChangeAllowed () { - $emailChange = ($this->getConfigInstance()->readConfig('email_change_allowed') === "Y"); + $emailChange = ($this->getConfigInstance()->readConfig('email_change_allowed') == 'Y'); return $emailChange; } @@ -201,7 +201,7 @@ class BaseWebHelper extends BaseHelper { * @return $refillActive Wether the refill page is active */ public function ifRefillPageActive () { - $refillActive = ($this->getConfigInstance()->readConfig('refill_page_active') === "Y"); + $refillActive = ($this->getConfigInstance()->readConfig('refill_page_active') == 'Y'); return $refillActive; } } diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php index e20545f0..9a35b9f3 100644 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -59,7 +59,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * * @param $templateInstance An instance of a valid template engine * @param $formName Name of the form - * @param $formId Value for "id" attribute (default: $formName) + * @param $formId Value for 'id' attribute (default: $formName) * @param $withForm Wether include the form tag * @return $helperInstance A preparedf instance of this helper */ @@ -79,7 +79,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { // Set form name $helperInstance->setFormName($formName); - // A form-less field may say "false" here... + // A form-less field may say 'false' here... if ($withForm === true) { // Create the form $helperInstance->addFormTag($formName, $formId); @@ -96,9 +96,9 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * Add the form tag or close it an already opened form tag * * @param $formName Name of the form (default: false) - * @param $formId Id of the form (attribute "id"; default: false) + * @param $formId Id of the form (attribute 'id'; default: false) * @return void - * @throws InvalidFormNameException If the form name is invalid (=false) + * @throws InvalidFormNameException If the form name is invalid ( = false) * @todo Add some unique PIN here to bypass problems with some browser and/or extensions */ public function addFormTag ($formName = false, $formId = false) { @@ -109,7 +109,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { } // END - if // Close the form is default - $formContent = ""; + $formContent = ''; // Check wether we shall open or close the form if (($this->formOpened === false) && ($this->formEnabled === true)) { @@ -128,7 +128,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // Add close bracket - $formContent .= ">"; + $formContent .= '>'; // Open the form and remeber the form name $this->formOpened = true; @@ -176,7 +176,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { $fieldValue ); - // And add it maybe with a "li" tag + // And add it maybe with a 'li' tag $this->addContentToPreviousGroup($inputContent); } @@ -189,7 +189,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { public function addInputTextFieldWithDefault ($fieldName) { // Get the value from instance $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."
\n"; + //* DEBUG: */ echo __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; // Add the text field $this->addInputTextField($fieldName, $fieldValue); @@ -257,7 +257,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { public function addInputHiddenFieldWithDefault ($fieldName) { // Get the value from instance $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."
\n"; + //* DEBUG: */ echo __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; // Add the text field $this->addInputHiddenField($fieldName, $fieldValue); @@ -273,7 +273,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { public function addInputHiddenConfiguredField ($fieldName, $prefix) { // Get the value from instance $fieldValue = $this->getConfigInstance()->readConfig("{$prefix}_{$fieldName}"); - //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."
\n"; + //* DEBUG: */ echo __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; // Add the text field $this->addInputHiddenField($fieldName, $fieldValue); @@ -297,7 +297,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { // Set wether the check box is checked... $checked = " checked=\"checked\""; - if ($fieldChecked === false) $checked = " "; + if ($fieldChecked === false) $checked = ' '; // Generate the content $inputContent = sprintf("", @@ -428,7 +428,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { // All call it again if group name is not empty if ((!empty($groupId)) && ($groupId != $prevGroupId)) { - //* DEBUG: */ echo $groupId."/".$prevGroupId."
\n"; + //* DEBUG: */ echo $groupId.'/'.$prevGroupId."
\n"; $this->addFormGroup($groupId, $groupText); } // END - if } @@ -723,7 +723,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * @return $required Wether the email address is required */ public function ifRegisterRequiresEmailVerification () { - $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y"); + $required = ($this->getConfigInstance()->readConfig('register_requires_email') == 'Y'); return $required; } @@ -733,7 +733,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * @return $required Wether profile data shall be asked */ public function ifRegisterIncludesProfile () { - $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y"); + $required = ($this->getConfigInstance()->readConfig('register_includes_profile') == 'Y'); return $required; } @@ -743,7 +743,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * @return $isSecured Wether this form is secured by a CAPTCHA */ public function ifFormSecuredWithCaptcha () { - $isSecured = ($this->getConfigInstance()->readConfig($this->getFormName().'_captcha_secured') === "Y"); + $isSecured = ($this->getConfigInstance()->readConfig($this->getFormName().'_captcha_secured') == 'Y'); return $isSecured; } diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index 83b806d8..5dd2ef7e 100644 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -32,6 +32,16 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { */ private $linkBase = ''; + /** + * First parameter seperator + */ + private $firstParameter = '?'; + + /** + * Seperator for more paraemters + */ + private $parameterSeperator = '&'; + /** * Protected constructor * @@ -226,17 +236,17 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { // Check if a previous group was opened if ($this->ifGroupOpenedPreviously() === false) { // No group was opened before! - throw new NoGroupOpenedException(array($this, $linkAction."(".$linkText.")"), self::EXCEPTION_GROUP_NOT_OPENED); + throw new NoGroupOpenedException(array($this, $linkAction . '(' . $linkText . ')'), self::EXCEPTION_GROUP_NOT_OPENED); } // END - if // Default parameter seperator is & - $seperator = "&"; + $seperator = $this->parameterSeperator; // Is there a question mark in? - $linkArray = explode("?", $this->getLinkBase()); + $linkArray = explode($this->firstParameter, $this->getLinkBase()); if (count($linkArray) == 0) { // No question mark - $seperator = "?"; + $seperator = $this->firstParameter; } // END - if // Prepare action diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php index b4a85480..b1e37446 100644 --- a/inc/classes/main/io/class_FileIoStream.php +++ b/inc/classes/main/io/class_FileIoStream.php @@ -22,6 +22,26 @@ * along with this program. If not, see . */ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer { + /** + * File header indicator + */ + private $fileHeader = '@head'; + + /** + * Data block indicator + */ + private $dataBlock = '@data'; + + /** + * Seperator #1 + */ + private $chunker = ':'; + + /** + * Seperator #2 + */ + private $seperator = '^'; + /** * Protected constructor */ @@ -49,12 +69,13 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil } /** - * Saves data to a given local file + * Saves data to a given local file and create missing directory structures * - * @param $fileName The file name for the to be saved file - * @param $dataArray The data we shall store to the file + * @param $fileName The file name for the to be saved file + * @param $dataArray The data we shall store to the file * @return void * @see FileOutputStreamer + * @todo This method needs heavy rewrite */ public final function saveFile ($fileName, $dataArray) { // Try it five times @@ -68,17 +89,23 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil $dirName = dirname($fileName); for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) { $dirName = dirname($dirName); - } + } // END - for + // Try to create it @mkdir($dirName); } - } + } // END - for // Write a header information for validation purposes - $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n", + $fileInstance->writeToFile(sprintf("%s%s%s%s%s%s%s%s%s\n", + $this->fileHeader, + $this->seperator, $dataArray[0], + $this->chunker, time(), + $this->chunker, strlen($dataArray[1]), + $this->chunker, md5($dataArray[1]) )); @@ -86,20 +113,23 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil $b64Stream = base64_encode($dataArray[1]); // write the data line by line - $line = str_repeat(" ", 50); $idx = 0; + $line = str_repeat(' ', 50); $idx = 0; while (strlen($line) == 50) { // Get 50 chars or less $line = substr($b64Stream, $idx, 50); // Save it to the stream - $fileInstance->writeToFile(sprintf("@data^%s:%s\n", + $fileInstance->writeToFile(sprintf("%s%s%s%s%s\n", + $this->dataBlock, + $this->seperator, $line, + $this->chunker, md5($line) )); // Advance to the next 50-chars block $idx += 50; - } + } // END - while // Close the file $fileInstance->closeFile(); @@ -147,26 +177,26 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil $rawLine = rtrim($rawLine); // Analyze this line - if (substr($rawLine, 0, 5) == "@head") { + if (substr($rawLine, 0, 5) == $this->fileHeader) { // Header found, so let's extract it - $header = explode("^", $rawLine); + $header = explode($this->seperator, $rawLine); $header = trim($header[1]); // Now we must convert it again into an array - $header = explode(":", $header); + $header = explode($this->chunker, $header); // Is the header (maybe) valid? if (count($header) != 4) { // Throw an exception throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); } - } elseif (substr($rawLine, 0, 5) == "@data") { + } elseif (substr($rawLine, 0, 5) == $this->dataBlock) { // Is a data line! - $data = explode("^", $rawLine); + $data = explode($this->seperator, $rawLine); $data = $data[1]; // First element is the data, second the MD5 checksum - $data = explode(":", $data); + $data = explode($this->chunker, $data); // Validate the read line if (count($data) == 2) { @@ -183,7 +213,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil $readData .= $data[0]; } else { // Other raw lines than header/data tagged lines and re-add the new-line char - $readData .= $rawLine."\n"; + $readData .= $rawLine . "\n"; } } diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php index c1d66e4f..fe66586a 100644 --- a/inc/classes/main/language/class_LanguageSystem.php +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -31,7 +31,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, /** * The 2-char language code */ - private $langCode = "xx"; // This will later be overwritten! + private $langCode = 'xx'; // This will later be overwritten! /** * The array-object for all language strings diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php index b0df4fef..f149914c 100644 --- a/inc/classes/main/output/class_ConsoleOutput.php +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -58,11 +58,12 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { self::$consoleInstance = new ConsoleOutput(); // Set the content type + // @TODO Need to rewrite this to $requestInstance->addHeader() if (!empty($contentType)) { @header(sprintf("Content-type: %s", $contentType )); - } + } // END - if // Return instance return self::$consoleInstance; @@ -87,7 +88,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { * @param $outStream Something we shall sent to the console * @return void */ - public final function output ($outStream=false) { + public final function output ($outStream = false) { if ($outStream === false) { // Output something here... foreach ($this->vars as $var => $value) { diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php index ad5bd90b..adbf50c5 100644 --- a/inc/classes/main/output/class_WebOutput.php +++ b/inc/classes/main/output/class_WebOutput.php @@ -52,15 +52,16 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registera $contentType = trim($contentType); // Set the content type + // @TODO Need to rewrite this to $requestInstance->addHeader() if (!empty($contentType)) { @header(sprintf("Content-type: %s", $contentType )); - } + } // END - if // Get a new instance and set it self::$webInstance = new WebOutput(); - } + } // END - if // Return instance return self::$webInstance; @@ -83,7 +84,7 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registera * * @return void */ - public final function output ($outStream=false) { + public final function output ($outStream = false) { print(stripslashes($outStream)); } } diff --git a/inc/classes/main/registry/class_Registry.php b/inc/classes/main/registry/class_Registry.php index d5ad6e6b..808a35a3 100644 --- a/inc/classes/main/registry/class_Registry.php +++ b/inc/classes/main/registry/class_Registry.php @@ -78,7 +78,7 @@ class Registry extends BaseFrameworkSystem implements Register { */ public final static function isInitialized ($initialized = null) { // If no parameter (null by default) is provided we want to get the - // parameter. If set to e.g. "OK" then the registry is set to + // parameter. If set to e.g. 'OK' then the registry is set to // "initialized". if (is_null($initialized)) { // Get status if initialized diff --git a/inc/classes/main/request/class_HttpRequest.php b/inc/classes/main/request/class_HttpRequest.php index 7f60316c..8409470a 100644 --- a/inc/classes/main/request/class_HttpRequest.php +++ b/inc/classes/main/request/class_HttpRequest.php @@ -144,7 +144,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { $headerValue = null; // Construct the name - $name = 'HTTP_' . strtolower(str_replace('-', '_', $headerName)); + $name = 'HTTP_' . strtolower($this->convertDashesToUnderscores($headerName)); // Does this header exist? if (isset($_SERVER[$name])) { diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php index 5d4738b9..b8b701ea 100644 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -89,11 +89,11 @@ class BaseActionResolver extends BaseResolver { throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } // END - if + // Create class name + $className = $this->actionPrefix . $this->convertToClassName($actionName) . 'Action'; + // Now, let us create the full name of the action class - $this->setClassName(sprintf("%s%sAction", - $this->actionPrefix, - $this->convertToClassName($actionName) - )); + $this->setClassName($className); // Is this class already loaded? if (class_exists($this->getClassName())) { @@ -118,9 +118,10 @@ class BaseActionResolver extends BaseResolver { $actionInstance = null; // Create action class name - $this->setClassName(sprintf("Web%sAction", - $this->convertToClassName($this->getActionName()) - )); + $className = $this->actionPrefix . $this->convertToClassName($this->getActionName()) . 'Action'; + + // ... and set it + $this->setClassName($className); // Initiate the action $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php index fc662c3a..ac9c0cab 100644 --- a/inc/classes/main/resolver/command/class_BaseCommandResolver.php +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -87,13 +87,13 @@ class BaseCommandResolver extends BaseResolver { if (empty($commandName)) { // Then thrown an exception here throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } + } // END - if + + // Create the full class name + $className = $this->commandPrefix . $this->convertToClassName($commandName) . 'Command'; // Now, let us create the full name of the command class - $this->setClassName(sprintf("%s%sCommand", - $this->commandPrefix, - $this->convertToClassName($commandName) - )); + $this->setClassName($className); // Is this class already loaded? if (class_exists($this->getClassName())) { diff --git a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php index d70e25c0..85be798b 100644 --- a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php +++ b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php @@ -155,10 +155,8 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve // Init command instance $commandInstance = null; - // Create command class name - $this->setClassName(sprintf("Image%sCommand", - $this->convertToClassName($commandName) - )); + // Create class name + $className = 'Image' . $this->convertToClassName($commandName) . 'Command'; // Is this class loaded? if (!class_exists($this->getClassName())) { diff --git a/inc/classes/main/resolver/command/web/class_WebCommandResolver.php b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php index f61f0cdd..56ad9e1c 100644 --- a/inc/classes/main/resolver/command/web/class_WebCommandResolver.php +++ b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php @@ -155,10 +155,11 @@ class WebCommandResolver extends BaseCommandResolver implements CommandResolver // Init command instance $commandInstance = null; + // Create class name + $className = 'Web' . $this->convertToClassName($commandName) . 'Command'; + // Create command class name - $this->setClassName(sprintf("Web%sCommand", - $this->convertToClassName($commandName) - )); + $this->setClassName($className); // Is this class loaded? if (!class_exists($this->getClassName())) { diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index 6295df90..2b80405f 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -90,11 +90,11 @@ class BaseControllerResolver extends BaseResolver { throw new EmptyVariableException(array($this, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } // END - if + // Create class name + $className = $this->controllerPrefix . $this->convertToClassName($controllerName) . 'Controller'; + // Now, let us create the full name of the controller class - $this->setClassName(sprintf("%s%sController", - $this->controllerPrefix, - $this->convertToClassName($controllerName) - )); + $this->setClassName($className); // Try it hard to get an controller while ($isValid === false) { diff --git a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php index dc664e87..191609f6 100644 --- a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php +++ b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php @@ -133,9 +133,10 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll //* DEBUG: */ echo __METHOD__.": Controller=".$controllerName; if ($controllerName != $defaultController) { // Create controller class name - $this->setClassName(sprintf("Image%sController", - $this->convertToClassName($controllerName) - )); + $className = 'Image' . $this->convertToClassName($controllerName) . 'Controller'; + + // ... and set it + $this->setClassName($className); } // END - if //* DEBUG: */ echo ", controller=".$this->getClassName()."
\n"; @@ -146,11 +147,17 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll } // END - if // Initiate the resolver and controller - $resolverInstance = ObjectFactory::createObjectByConfiguredName('image_cmd_resolver_class', array($controllerName, $this->getApplicationInstance())); - $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance)); - - // Remove resolver - unset($resolverInstance); + $resolverInstance = ObjectFactory::createObjectByConfiguredName( + 'image_cmd_resolver_class', + array( + $controllerName, + $this->getApplicationInstance() + ) + ); + $controllerInstance = ObjectFactory::createObjectByName( + $this->getClassName(), + array($resolverInstance) + ); // Return the result return $controllerInstance; diff --git a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php index 06ba1118..297a40c2 100644 --- a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -133,9 +133,10 @@ class WebControllerResolver extends BaseControllerResolver implements Controller //* DEBUG: */ echo __METHOD__.": Controller=".$controllerName; if ($controllerName != $defaultController) { // Create controller class name - $this->setClassName(sprintf("Web%sController", - $this->convertToClassName($controllerName) - )); + $className = 'Web' . $this->convertToClassName($controllerName) . 'Controller'; + + // ... and set it + $this->setClassName($className); } elseif ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) { // Yes, display news in home then set default controller with news $this->setClassName('WebDefaultNewsController'); @@ -163,15 +164,22 @@ class WebControllerResolver extends BaseControllerResolver implements Controller $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry); } catch (ConfigEntryNotFoundException $e) { // Use default resolver entry - $resolverConfigEntry = "web_cmd_resolver_class"; + // @TODO Maybe we need to log this? + $resolverConfigEntry = 'web_cmd_resolver_class'; } // Initiate the resolver and controller - $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance())); - $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance)); - - // Remove resolver (we don't need it anymore) - unset($resolverInstance); + $resolverInstance = ObjectFactory::createObjectByConfiguredName( + $resolverConfigEntry, + array( + $controllerName, + $this->getApplicationInstance() + ) + ); + $controllerInstance = ObjectFactory::createObjectByName( + $this->getClassName(), + array($resolverInstance) + ); // Return the result return $controllerInstance; diff --git a/inc/classes/main/response/class_BaseResponse.php b/inc/classes/main/response/class_BaseResponse.php index 7e40ce77..fbcd41b5 100644 --- a/inc/classes/main/response/class_BaseResponse.php +++ b/inc/classes/main/response/class_BaseResponse.php @@ -181,7 +181,7 @@ class BaseResponse extends BaseFrameworkSystem { // Send cookies out? if (count($this->cookies) > 0) { // Send all cookies - $cookieString = implode(" ", $this->cookies); + $cookieString = implode(' ', $this->cookies); header("Set-Cookie: {$cookieString}"); // Remove them all diff --git a/inc/classes/main/response/http/class_HttpResponse.php b/inc/classes/main/response/http/class_HttpResponse.php index 19a453bb..46f42d6f 100644 --- a/inc/classes/main/response/http/class_HttpResponse.php +++ b/inc/classes/main/response/http/class_HttpResponse.php @@ -80,7 +80,7 @@ class HttpResponse extends BaseResponse implements Responseable { * @todo this will send only one cookie out, the first one. */ public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) { - //* DEBUG: */ echo $cookieName."=".$cookieValue."
\n"; + //* DEBUG: */ echo $cookieName.'='.$cookieValue."
\n"; // Are headers already sent? if (headers_sent()) { // Throw an exception here @@ -108,7 +108,7 @@ class HttpResponse extends BaseResponse implements Responseable { return; // Now construct the full header - $cookieString = $cookieName . "=" . $cookieValue . "; "; + $cookieString = $cookieName . '=' . $cookieValue . '; '; $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; // $cookieString .= "; path=".$path."; domain=".$domain; @@ -140,20 +140,20 @@ class HttpResponse extends BaseResponse implements Responseable { // Compile the URL $url = $this->getTemplateInstance()->compileRawCode($url); - // Do we have a "http" in front of the URL? - if (substr(strtolower($url), 0, 4) != "http") { + // Do we have a 'http' in front of the URL? + if (substr(strtolower($url), 0, 4) != 'http') { // Is there a / in front of the relative URL? - if (substr($url, 0, 1) == "/") $url = substr($url, 1); + if (substr($url, 0, 1) == '/') $url = substr($url, 1); // No, then extend it with our base URL - $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url; + $url = $this->getConfigInstance()->readConfig('base_url') . '/' . $url; } // END - if // Add redirect header - $this->addHeader("Location", $url); + $this->addHeader('Location', $url); // Set correct response status - $this->setResponseStatus("301 Moved Permanently"); + $this->setResponseStatus('301 Moved Permanently'); // Clear the body $this->setResponseBody(''); diff --git a/inc/classes/main/response/image/class_ImageResponse.php b/inc/classes/main/response/image/class_ImageResponse.php index dc6e5ad0..21344c45 100644 --- a/inc/classes/main/response/image/class_ImageResponse.php +++ b/inc/classes/main/response/image/class_ImageResponse.php @@ -122,7 +122,7 @@ class ImageResponse extends BaseResponse implements Responseable { return; // Now construct the full header - $cookieString = $cookieName . "=" . $cookieValue . "; "; + $cookieString = $cookieName . '=' . $cookieValue . '; '; $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; // $cookieString .= "; path=".$path."; domain=".$domain; @@ -154,20 +154,20 @@ class ImageResponse extends BaseResponse implements Responseable { // Compile the URL $url = $this->getTemplateInstance()->compileRawCode($url); - // Do we have a "http" in front of the URL? - if (substr(strtolower($url), 0, 4) != "http") { + // Do we have a 'http' in front of the URL? + if (substr(strtolower($url), 0, 4) != 'http') { // Is there a / in front of the relative URL? - if (substr($url, 0, 1) == "/") $url = substr($url, 1); + if (substr($url, 0, 1) == '/') $url = substr($url, 1); // No, then extend it with our base URL - $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url; + $url = $this->getConfigInstance()->readConfig('base_url') . '/' . $url; } // END - if // Add redirect header - $this->addHeader("Location", $url); + $this->addHeader('Location', $url); // Set correct response status - $this->setResponseStatus("301 Moved Permanently"); + $this->setResponseStatus('301 Moved Permanently'); // Clear the body $this->setResponseBody(''); diff --git a/inc/classes/main/result/class_DatabaseResult.php b/inc/classes/main/result/class_DatabaseResult.php index e0d169a5..19f8b3e7 100644 --- a/inc/classes/main/result/class_DatabaseResult.php +++ b/inc/classes/main/result/class_DatabaseResult.php @@ -195,12 +195,12 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up } /** - * Determines wether the status of the query was fine ("ok") + * Determines wether the status of the query was fine (LocalfileDatabase::RESULT_OKAY) * * @return $ifStatusOkay Wether the status of the query was okay */ public function ifStatusIsOkay () { - return ((isset($this->resultArray['status'])) && ($this->resultArray['status'] === "ok")); + return ((isset($this->resultArray['status'])) && ($this->resultArray['status'] === LocalfileDatabase::RESULT_OKAY)); } /** diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php index 431b9d13..e52715b4 100644 --- a/inc/classes/main/rng/class_RandomNumberGenerator.php +++ b/inc/classes/main/rng/class_RandomNumberGenerator.php @@ -101,7 +101,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { $serverIp = "cluster"; // Do we have a single server? - if ($this->getConfigInstance()->readConfig('is_single_server') === "Y") { + if ($this->getConfigInstance()->readConfig('is_single_server') == 'Y') { // Then use that IP for extra security $serverIp = getenv('SERVER_ADDR'); } // END - if @@ -109,14 +109,14 @@ class RandomNumberGenerator extends BaseFrameworkSystem { // Yet-another fixed salt. This is not dependend on server software or date if ($extraInstance instanceof FrameworkInterface) { // With extra instance information - $this->fixedSalt = sha1($serverIp . ":" . $extraInstance->__toString() . ":" . serialize($this->getDatabaseInstance()->getConnectionData())); + $this->fixedSalt = sha1($serverIp . ':' . $extraInstance->__toString() . ':' . serialize($this->getDatabaseInstance()->getConnectionData())); } else { // Without extra information - $this->fixedSalt = sha1($serverIp . ":" . serialize($this->getDatabaseInstance()->getConnectionData())); + $this->fixedSalt = sha1($serverIp . ':' . serialize($this->getDatabaseInstance()->getConnectionData())); } // One-way data we need for "extra-salting" the random number - $this->extraSalt = sha1($this->fixedSalt . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . $this->getConfigInstance()->readConfig('base_url')); + $this->extraSalt = sha1($this->fixedSalt . ':' . getenv('SERVER_SOFTWARE') . ':' . $this->getConfigInstance()->readConfig('date_key') . $this->getConfigInstance()->readConfig('base_url')); // Get config entry for max salt length $this->rndStrLen = $this->getConfigInstance()->readConfig('rnd_str_length'); diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 7052d5f8..c40b183c 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -32,22 +32,22 @@ class BaseTemplateEngine extends BaseFrameworkSystem { /** * Template type */ - private $templateType = "html"; + private $templateType = 'html'; /** * The extension for web and email templates (not compiled templates) */ - private $templateExtension = ".tpl"; + private $templateExtension = '.tpl'; /** * The extension for code templates (not compiled templates) */ - private $codeExtension = ".ctp"; + private $codeExtension = '.ctp'; /** * Path relative to $basePath and language code for compiled code-templates */ - private $compileOutputPath = "templates/_compiled"; + private $compileOutputPath = 'templates/_compiled'; /** * The raw (maybe uncompiled) template @@ -116,6 +116,16 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ private $varGroups = array(); + /** + * Code begin + */ + private $codeBegin = ''; + // Exception codes for the template engine const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110; const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111; @@ -285,7 +295,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { } /** - * Setter for template type. Only "html", "emails" and "compiled" should + * Setter for template type. Only 'html', 'emails' and 'compiled' should * be sent here * * @param $templateType The current template's type @@ -460,8 +470,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ protected final function setRawTemplateData ($rawTemplateData) { // And store it in this class - //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($rawTemplateData)." Bytes set.
\n"; - //* DEBUG: */ echo $this->currGroup." variables: ".count($this->varStack[$this->currGroup]).", groups=".count($this->varStack)."
\n"; + //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($rawTemplateData).' Bytes set.
\n'; + //* DEBUG: */ echo $this->currGroup.' variables: '.count($this->varStack[$this->currGroup]).', groups='.count($this->varStack).'
\n'; $this->rawTemplateData = (string) $rawTemplateData; } @@ -471,7 +481,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return $rawTemplateData The raw data from the template */ public final function getRawTemplateData () { - //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->rawTemplateData)." Bytes read.
\n"; + //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($this->rawTemplateData).' Bytes read.
\n'; return $this->rawTemplateData; } @@ -482,7 +492,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ private final function setCompiledData ($compiledData) { // And store it in this class - //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($compiledData)." Bytes set.
\n"; + //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($compiledData).' Bytes set.
\n'; $this->compiledData = (string) $compiledData; } @@ -492,7 +502,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return $compiledData Compiled template data */ public final function getCompiledData () { - //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->compiledData)." Bytes read.
\n"; + //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($this->compiledData).' Bytes read.
\n'; return $this->compiledData; } @@ -606,9 +616,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * Structure of $templateMatches: *--------------------------------- * [0] => Array - An array with all full matches - * [1] => Array - An array with left part (before the ":") of a match - * [2] => Array - An array with right part of a match including ":" - * [3] => Array - An array with right part of a match excluding ":" + * [1] => Array - An array with left part (before the ':') of a match + * [2] => Array - An array with right part of a match including ':' + * [3] => Array - An array with right part of a match excluding ':' */ private function analyzeTemplate (array $templateMatches) { // Backup raw template data @@ -773,18 +783,18 @@ class BaseTemplateEngine extends BaseFrameworkSystem { foreach ($varMatches[1] as $key => $var) { // Detect leading equals - if (substr($varMatches[2][$key], 0, 1) == "=") { + if (substr($varMatches[2][$key], 0, 1) == '=') { // Remove and cast it $varMatches[2][$key] = (string) substr($varMatches[2][$key], 1); - } + } // END - if // Do we have some quotes left and right side? Then it is free text if ((substr($varMatches[2][$key], 0, 1) == "\"") && (substr($varMatches[2][$key], -1, 1) == "\"")) { // Free string detected! Which we can assign directly $this->assignVariable($var, $varMatches[3][$key]); } elseif (!empty($varMatches[2][$key])) { - // Non-string found so we need some deeper analysis... - die("Deeper analysis not yet implemented!"); + // @TODO Non-string found so we need some deeper analysis... + ApplicationEntryPoint::app_die('Deeper analysis not yet implemented!'); } } // for ($varMatches ... @@ -792,7 +802,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { /** * Compiles all loaded raw templates * - * @param $templateMatches See method analyzeTemplate() for details + * @param $templateMatches See method analyzeTemplate() for details * @return void */ private function compileRawTemplateData (array $templateMatches) { @@ -854,23 +864,23 @@ class BaseTemplateEngine extends BaseFrameworkSystem { private function finalizeVariableCompilation () { // Get the content $content = $this->getRawTemplateData(); - //* DEBUG: */ echo __METHOD__.": content before=".strlen($content)." (".md5($content).")
\n"; + //* DEBUG: */ echo __METHOD__.': content before='.strlen($content).' ('.md5($content).')
\n'; // Walk through all variables foreach ($this->varStack['general'] as $currEntry) { - //* DEBUG: */ echo __METHOD__.": name=".$currEntry['name'].", value=
".htmlentities($currEntry['value'])."
\n"; + //* DEBUG: */ echo __METHOD__.': name='.$currEntry['name'].', value=
'.htmlentities($currEntry['value']).'
\n'; // Replace all [$var] or {?$var?} with the content - // Old behaviour, will become obsolete! - $content = str_replace("\$content[".$currEntry['name']."]", $currEntry['value'], $content); + // @TODO Old behaviour, will become obsolete! + $content = str_replace("\$content[".$currEntry['name'].']', $currEntry['value'], $content); - // Yet another old way - $content = str_replace("[".$currEntry['name']."]", $currEntry['value'], $content); + // @TODO Yet another old way + $content = str_replace('['.$currEntry['name'].']', $currEntry['value'], $content); // The new behaviour - $content = str_replace("{?".$currEntry['name']."?}", $currEntry['value'], $content); + $content = str_replace('{?'.$currEntry['name'].'?}', $currEntry['value'], $content); } // END - for - //* DEBUG: */ echo __METHOD__.": content after=".strlen($content)." (".md5($content).")
\n"; + //* DEBUG: */ echo __METHOD__.': content after='.strlen($content).' ('.md5($content).')
\n'; // Set the content back $this->setRawTemplateData($content); @@ -880,7 +890,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * Load a specified web template into the engine * * @param $template The web template we shall load which is located in - * "html" by default + * 'html' by default * @return void */ public function loadWebTemplate ($template) { @@ -899,7 +909,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public function assignConfigVariable ($var) { // Sweet and simple... - //* DEBUG: */ echo __METHOD__.":var={$var}
\n"; + //* DEBUG: */ echo __METHOD__.':var={$var}
\n'; $this->varStack['config'][$var] = $this->getConfigInstance()->readConfig($var); } @@ -907,7 +917,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * Load a specified email template into the engine * * @param $template The email template we shall load which is located in - * "emails" by default + * 'emails' by default * @return void */ public function loadEmailTemplate ($template) { @@ -922,7 +932,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * Load a specified code template into the engine * * @param $template The code template we shall load which is - * located in "code" by default + * located in 'code' by default * @return void */ public function loadCodeTemplate ($template) { @@ -947,7 +957,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Iterate through all general variables foreach ($this->varStack['general'] as $currVariable) { // Transfer it's name/value combination to the $content array - //* DEBUG: */ echo $currVariable['name']."=
".htmlentities($currVariable['value'])."
\n"; + //* DEBUG: */ echo $currVariable['name'].'=
'.htmlentities($currVariable['value']).'
\n'; $dummy[$currVariable['name']] = $currVariable['value']; }// END - if @@ -964,7 +974,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { unset($idx); unset($currVariable); - // Run the compilation twice to get content from helper classes in + // Run the compilation three times to get content from helper classes in $cnt = 0; while ($cnt < 3) { // Finalize the compilation of template variables @@ -976,19 +986,19 @@ class BaseTemplateEngine extends BaseFrameworkSystem { ); // This loop does remove the backslashes (\) in PHP parameters - while (strpos($eval, "codeBegin) !== false) { // Get left part before "codeBegin)); // Get all from right of "codeBegin) + 5)); // Cut middle part out and remove escapes - $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, "?>"))); + $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, $this->codeEnd))); $evalMiddle = stripslashes($evalMiddle); // Remove the middle part from right one - $evalRight = substr($evalRight, (strpos($evalRight, "?>") + 2)); + $evalRight = substr($evalRight, (strpos($evalRight, $this->codeEnd) + 2)); // And put all together $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight); @@ -998,7 +1008,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $eval = str_replace( "<%php", "\";", str_replace( - "%>", "\n\$result .= \"", $eval + "%>", + "\n\$result .= \"", + $eval ) ); @@ -1046,7 +1058,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $rawData = $this->getRawTemplateData(); // Remove double spaces and trim leading/trailing spaces - $rawData = trim(str_replace(" ", " ", $rawData)); + $rawData = trim(str_replace(' ', ' ', $rawData)); // Search for raw variables $this->extractVariablesFromRawData($rawData); @@ -1091,23 +1103,23 @@ class BaseTemplateEngine extends BaseFrameworkSystem { public function output () { // Check which type of template we have switch ($this->getTemplateType()) { - case "html": // Raw HTML templates can be send to the output buffer - // Quick-N-Dirty: - $this->getWebOutputInstance()->output($this->getCompiledData()); - break; - - default: // Unknown type found - // Construct message - $msg = sprintf("[%s->%s] Unknown/unsupported template type %s detected.", - $this->__toString(), - __FUNCTION__, - $this->getTemplateType() - ); - - // Write the problem to the world... - $this->debugOutput($msg); - break; - } + case 'html': // Raw HTML templates can be send to the output buffer + // Quick-N-Dirty: + $this->getWebOutputInstance()->output($this->getCompiledData()); + break; + + default: // Unknown type found + // Construct message + $msg = sprintf("[%s->%s] Unknown/unsupported template type %s detected.", + $this->__toString(), + __FUNCTION__, + $this->getTemplateType() + ); + + // Write the problem to the world... + $this->debugOutput($msg); + break; + } // END - switch } /** @@ -1115,7 +1127,6 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * * @param $helperName The helper's name * @return void - * @throws ViewHelperNotFoundException If the given view helper was not found */ protected function loadViewHelper ($helperName) { // Make first character upper case, rest low @@ -1126,21 +1137,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Create a class name $className = "{$helperName}ViewHelper"; - // Does this class exists? - if (!class_exists($className)) { - // Abort here! - throw new ViewHelperNotFoundException(array($this, $helperName), self::EXCEPTION_INVALID_VIEW_HELPER); - } // END - if - // Generate new instance - $eval = sprintf("\$this->helpers[%s] = %s::create%s();", - $helperName, - $className, - $className - ); - - // Run the code - eval($eval); + $this->helpers[$helperName] = ObjectFactory::createObjectByName($className); } // END - if // Return the requested instance @@ -1211,7 +1209,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { //* DEBUG: */ echo "
".print_r($varMatches, true)."
"; foreach ($varMatches[0] as $match) { // Add variable tags around it - $varCode = "{?".$match."?}"; + $varCode = '{?' . $match . '?}'; // Is the variable found in code? (safes some calls) if (strpos($rawCode, $varCode) !== false) { @@ -1290,7 +1288,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Now parse the XML tree if (!xml_parse($xmlParser, $content)) { // Error found in XML! - //die("
".htmlentities($content)."
"); + //die('
'.htmlentities($content).'
'); throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR); } // END - if diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php index 309279a6..f20dc1b6 100644 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -25,12 +25,31 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl /** * Main nodes in the XML tree ('image' is ignored) */ - private $mainNodes = array("base", "type", "resolution", "background-color", "foreground-color", "image-string"); + private $mainNodes = array( + 'base', + 'type', + 'resolution', + 'background-color', + 'foreground-color', + 'image-string' + ); /** * Sub nodes in the XML tree */ - private $subNodes = array("name", "string-name", "x", "y", "font-size", "width", "height", "red", "green", "blue", "text"); + private $subNodes = array( + 'name', + 'string-name', + 'x', + 'y', + 'font-size', + 'width', + 'height', + 'red', + 'green', + 'blue', + 'text' + ); /** * Image instance @@ -450,7 +469,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl */ public function getImageCacheFqfn () { // Get the FQFN ready - $fqfn = $this->getBasePath().'_cache/' . md5($this->imageInstance->getImageName().":".$this->__toString().":".$this->imageInstance->__toString()) . "." . $this->imageInstance->getImageType(); + $fqfn = $this->getBasePath().'_cache/' . md5($this->imageInstance->getImageName().':'.$this->__toString().':'.$this->imageInstance->__toString()) . '.' . $this->imageInstance->getImageType(); // Return it return $fqfn; diff --git a/inc/classes/main/template/mail/class_MailTemplateEngine.php b/inc/classes/main/template/mail/class_MailTemplateEngine.php index 241e24fe..64811c5e 100644 --- a/inc/classes/main/template/mail/class_MailTemplateEngine.php +++ b/inc/classes/main/template/mail/class_MailTemplateEngine.php @@ -30,7 +30,12 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla /** * Sub nodes in the XML tree */ - private $subNodes = array("subject-line", "sender-address", "recipient-address", "message"); + private $subNodes = array( + 'subject-line', + 'sender-address', + 'recipient-address', + 'message' + ); /** * Mailer instance diff --git a/inc/classes/main/user/class_BaseUser.php b/inc/classes/main/user/class_BaseUser.php index f1a63026..d995e331 100644 --- a/inc/classes/main/user/class_BaseUser.php +++ b/inc/classes/main/user/class_BaseUser.php @@ -251,7 +251,7 @@ class BaseUser extends BaseFrameworkSystem { // Search for it if ($this->getResultInstance()->find('pass_hash')) { // So does the hashes match? - //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash']; + //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash').'/'.$entry['pass_hash']; $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue()); } // END - if diff --git a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php index fba74634..de237fd6 100644 --- a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php +++ b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php @@ -45,7 +45,7 @@ * * Die komplette Rückgabe des Interfaces wird als assoziatives Array in der Klassen- * variable __data gespeichert: - * __data => array("status" => Rückgabecode (PI_DONE, PI_SENDER_ERROR, ...), + * __data => array('status' => Rückgabecode (PI_DONE, PI_SENDER_ERROR, ...), * "statustext" => Status in Worten (z.B.: "Transaktion erfolgreich durchgeführt"), * ") * @@ -56,7 +56,7 @@ * @copyright (c) 2007 by Primusportal.de * @copyright (c) 2008 by Roland Haeder */ -class PrimeraApi { +class PrimeraApi extends BaseFrameworkSystem { /** * Fehler - Interfacebenutzer */ @@ -109,12 +109,12 @@ class PrimeraApi { private $path = "/transfer.interface.2.0.php"; private $errno = 0; - private $err = ""; + private $err = ''; - private $seperator = ":"; + private $seperator = ':'; - private $username = ""; - private $password = ""; + private $username = ''; + private $password = ''; private $data = array(); @@ -154,7 +154,7 @@ class PrimeraApi { fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); - $return = ""; + $return = ''; while (!feof($fp)) { $return.=fgets($fp,128); } @@ -170,7 +170,7 @@ class PrimeraApi { $x = explode("\n", $content); $return = array(); foreach($x as $currentLine) { - $line_exploded = explode(":", $currentLine,2); + $line_exploded = explode($this->seperator, $currentLine,2); if (count($line_exploded) > 1) { $return[$line_exploded[0]] = $line_exploded[1]; } @@ -183,17 +183,18 @@ class PrimeraApi { * @param int$Amount Betrag in ganzzahligen Primera * @param string $Description Beschreibung (Sichtbar in Einzelauflistung) */ - public function payPrimera ($Receiver, $Amount, $Description = "") { + public function payPrimera ($Receiver, $Amount, $Description = '') { $valid = false; - $PostData = array("PrimusInterface_Action" => "Pay", - "PrimusInterface_Receiver" => base64_encode($Receiver), - "PrimusInterface_Amount" => base64_encode($Amount), - "PrimusInterface_Description" => base64_encode($Description) ); + $PostData = array( + 'PrimusInterface_Action' => 'Pay', + 'PrimusInterface_Receiver' => base64_encode($Receiver), + 'PrimusInterface_Amount' => base64_encode($Amount), + 'PrimusInterface_Description' => base64_encode($Description) ); $PostReturn = $this->parseContent( $this->queryApi($PostData) ); $this->data = $PostReturn; - if ($PostReturn["status"] == "200") { + if ($PostReturn['status'] == '200') { $valid = true; } return $valid; @@ -205,16 +206,17 @@ class PrimeraApi { * - ist er aktiv * @param string/int $User Userid / Username */ - function CheckPrimusUser($User) { + function CheckPrimusUser ($User) { $valid = false; - $PostData = array("PrimusInterface_Action"=> "CheckPrimusUser", - "PrimusInterface_CheckPrimusUser" => $User); + $PostData = array( + 'PrimusInterface_Action' => 'CheckPrimusUser', + 'PrimusInterface_CheckPrimusUser' => $User); $PostReturn = $this->parseContent( $this->queryApi($PostData) ); $this->data = $PostReturn; - if ($PostReturn["status"] == self::PI_USER_CHECK_OK) { + if ($PostReturn['status'] == self::PI_USER_CHECK_OK) { $valid = true; } return $valid; @@ -229,7 +231,7 @@ class PrimeraApi { $PostReturn = $this->parseContent( $this->queryApi($PostData) ); $this->data = $PostReturn; - if ($PostReturn["status"] == self::PI_GET_PRIMERA_DONE) { + if ($PostReturn['status'] == self::PI_GET_PRIMERA_DONE) { $primera = $PostReturn["primera"]; } return $primera; diff --git a/inc/classes/third_party/api/wernisportal/class_WernisApi.php b/inc/classes/third_party/api/wernisportal/class_WernisApi.php index c333778b..42936f10 100644 --- a/inc/classes/third_party/api/wernisportal/class_WernisApi.php +++ b/inc/classes/third_party/api/wernisportal/class_WernisApi.php @@ -25,7 +25,7 @@ class WernisApi extends BaseFrameworkSystem { /** * Static base API URL */ - private static $apiUrl = "http://www.wds66.com/api/"; + private static $apiUrl = 'http://www.wds66.com/api/'; /** * API Wernis amount @@ -40,12 +40,12 @@ class WernisApi extends BaseFrameworkSystem { /** * API Wernis password (not account password!) */ - private $w_md5 = ""; + private $w_md5 = ''; /** * Nickname of the user */ - private $w_nick = ""; + private $w_nick = ''; /** * Wernis amount of the user @@ -57,6 +57,11 @@ class WernisApi extends BaseFrameworkSystem { */ private $statusArray = array(); + /** + * Status for 'okay' + */ + private $statusOkay = 'OK'; + /** * Protected constructor * @@ -201,14 +206,14 @@ class WernisApi extends BaseFrameworkSystem { // Construct the request string $requestString = $this->config['api_url'] . $scriptName."?api_id=".$this->config['wernis_api_id']."&api_key=".$this->config['wernis_api_key']; foreach ($requestData as $key => $value) { - $requestString .= "&".$key."=".$value; + $requestString .= '&' . $key . '=' . $value; } // Get the raw response from the lower function $response = $this->sendRawRequest($requestString); // Check the response header if all is fine - if (strpos($response[0], "200") === false) { + if (strpos($response[0], '200') === false) { // Something bad happend... :( return array( 'status' => "request_error", @@ -220,13 +225,13 @@ class WernisApi extends BaseFrameworkSystem { $response = $response[(count($response) - 1)]; // Prepare the returning result for higher functions - if (substr($response, 0, 1) == "&") { + if (substr($response, 0, 1) == '&') { // Remove the leading & (which can be used in Flash) $response = substr($response, 1); } // Bring back the response - $data = explode("=", $response); + $data = explode('=', $response); // Default return array (should not stay empty) $return = array(); @@ -283,7 +288,7 @@ class WernisApi extends BaseFrameworkSystem { } else { // All fine here $return = array( - 'status' => "OK", + 'status' => $this->statusOkay, 'response' => $response ); } @@ -302,7 +307,7 @@ class WernisApi extends BaseFrameworkSystem { // Prepare the request data $requestData = array( - 'sub_request' => "receive", + 'sub_request' => 'receive', 't_uid' => $this->w_id, 't_md5' => $this->w_md5, 'r_uid' => (int)$this->config['wernis_refid'], @@ -313,7 +318,7 @@ class WernisApi extends BaseFrameworkSystem { // Return the result from the lower functions $return = $this->sendRequest("book.php", $requestData); - if ($return['status'] == "OK") { + if ($return['status'] == $this->statusOkay) { // All fine! $result = true; } else { @@ -335,7 +340,7 @@ class WernisApi extends BaseFrameworkSystem { // Prepare the request data $requestData = array( - 'sub_request' => "send", + 'sub_request' => 'send', 't_uid' => $this->w_id, 't_md5' => $this->w_md5, 'r_uid' => (int)$this->config['wernis_refid'], @@ -346,7 +351,7 @@ class WernisApi extends BaseFrameworkSystem { // Return the result from the lower functions $return = $this->sendRequest("book.php", $requestData); - if ($return['status'] == "OK") { + if ($return['status'] == $this->statusOkay) { // All fine! $result = true; } else { @@ -362,24 +367,24 @@ class WernisApi extends BaseFrameworkSystem { private function sendRawRequest ($script) { // Use the hostname from script URL as new hostname $url = substr($script, 7); - $extract = explode("/", $url); + $extract = explode('/', $url); // Done extracting the URL :) $url = $extract[0]; // Extract host name - $host = str_replace("http://", "", $url); - if (ereg("/", $host)) $host = substr($host, 0, strpos($host, "/")); + $host = str_replace("http://", '', $url); + if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); // Generate relative URL $script = substr($script, (strlen($url) + 7)); - if (substr($script, 0, 1) == "/") $script = substr($script, 1); + if (substr($script, 0, 1) == '/') $script = substr($script, 1); // Open connection $fp = @fsockopen($host, 80, $errno, $errdesc, 30); if (!$fp) { // Failed! - return array("", "", ""); + return array('', '', ''); } // Generate request header @@ -404,7 +409,7 @@ class WernisApi extends BaseFrameworkSystem { // Was the request successfull? if ((!ereg("200 OK", $response[0])) && (empty($response[0]))) { // Not found / access forbidden - $response = array("", "", ""); + $response = array('', '', ''); } // Return response diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index aa00607c..5d47232c 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -109,9 +109,9 @@ class FrameworkConfiguration implements Registerable { $fqfn = $inc; // Base path added? (Uni* / Windows) - if ((substr($inc, 0, 1) != "/") && (substr($inc, 1, 1) != ":")) { + if ((substr($inc, 0, 1) != '/') && (substr($inc, 1, 1) != ':')) { // Generate FQFN - $fqfn = sprintf("%s/inc/extra/%s", $this->readConfig('base_path'), $inc); + $fqfn = $this->readConfig('base_path') . '/inc/extra/' . $inc; } // END - if } // END - if @@ -143,11 +143,6 @@ class FrameworkConfiguration implements Registerable { throw new ConfigEntryNotFoundException(array(__CLASS__, $cfgEntry), self::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); } - // Debug message - if ((defined('DEBUG_CONFIG')) || (defined('DEBUG_ALL'))) { - echo "[".__METHOD__."] Configuration entry ".$cfgEntry." requested.
\n"; - } // END - if - // Return the requested value return $this->config[$cfgEntry]; } @@ -194,16 +189,16 @@ class FrameworkConfiguration implements Registerable { */ public function detectBaseUrl() { // Initialize the URL - $baseUrl = "http"; + $baseUrl = 'http'; // Do we have HTTPS? if (isset($_SERVER['HTTPS'])) { // Add the >s< for HTTPS - $baseUrl .= "s"; + $baseUrl .= 's'; } // END - if - // Construct the full URL now and secure it against CSRF attacks - $baseUrl = $baseUrl . "://" . $this->detectDomain() . $this->detectScriptPath(); + // Construct the full URL and secure it against CSRF attacks + $baseUrl = $baseUrl . '://' . $this->detectDomain() . $this->detectScriptPath(); // Return the URL return $baseUrl; @@ -216,7 +211,7 @@ class FrameworkConfiguration implements Registerable { */ public function detectDomain () { // Full domain is localnet.invalid by default - $fullDomain = "localnet.invalid"; + $fullDomain = 'localnet.invalid'; // Is the server name there? if (isset($_SERVER['SERVER_NAME'])) { @@ -241,7 +236,7 @@ class FrameworkConfiguration implements Registerable { // Is the scriptname set? if (isset($_SERVER['SCRIPT_NAME'])) { // Get dirname from it and replace back-slashes with slashes for lame OSes... - $scriptPath = str_replace("\\", "/", dirname($_SERVER['SCRIPT_NAME'])); + $scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME'])); } // END - if // Return it diff --git a/inc/database.php b/inc/database.php index b9f40fa6..6a57e201 100644 --- a/inc/database.php +++ b/inc/database.php @@ -22,17 +22,14 @@ * along with this program. If not, see . */ -// Initialize layer -$layerInstance = null; +// Initialize database layer +$databaseInstance = null; // Get config instance $cfg = FrameworkConfiguration::getInstance(); // Generate FQFN for the database layer -$fqfn = sprintf("%sinc/database/lib-%s.php", - $cfg->readConfig('base_path'), - $cfg->readConfig('db_type') -); +$fqfn = $cfg->readConfig('base_path') . 'inc/database/lib-' . $cfg->readConfig('db_type') . '.php'; // Load the database layer include if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { @@ -46,14 +43,14 @@ if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { } // Clean it up -unset($fqfn); +unset($fqfn, $cfg); // Prepare database instance -$db = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $layerInstance); +$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $databaseInstance); // Is the app variable there and valid? // @TODO Rewrite this -if (is_object($app)) $app->setDatabaseInstance($db); +if (is_object($app)) $app->setDatabaseInstance($connectionInstance); // [EOF] ?> diff --git a/inc/database/lib-local.php b/inc/database/lib-local.php index 68ef141b..84fd7238 100644 --- a/inc/database/lib-local.php +++ b/inc/database/lib-local.php @@ -22,30 +22,11 @@ * along with this program. If not, see . */ -// Zum Testen speichern wir in lokale Dateien (LocalFileDatabase) -try { - $layerInstance = LocalFileDatabase::createLocalFileDatabase(FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance()); -} catch (SavePathIsEmptyException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", - $e->getMessage() - )); -} catch (SavePathNotFoundException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", - $e->getMessage() - )); -} catch (SavePathIsNoDirectoryException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", - $e->getMessage() - )); -} catch (SavePathReadProtectedException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", - $e->getMessage() - )); -} catch (SavePathWriteProtectedException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", - $e->getMessage() - )); -} +// For testing purposes we use a local file database +$databaseInstance = LocalFileDatabase::createLocalFileDatabase( + FrameworkConfiguration::getInstance()->readConfig('local_db_path'), + FileIoHandler::getInstance() +); // [EOF] ?> diff --git a/inc/language.php b/inc/language.php index 30a35751..b4735458 100644 --- a/inc/language.php +++ b/inc/language.php @@ -23,7 +23,7 @@ // Try to instance the language system $lang = LanguageSystem::createLanguageSystem( - $cfg->readConfig('base_path'). + FrameworkConfiguration::getInstance()->readConfig('base_path'). FrameworkConfiguration::getInstance()->readConfig('lang_base_path') ); diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index 7b551d87..df4e3631 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -261,10 +261,10 @@ class ClassLoader { // Directories which our class loader ignores by default while // deep-scanning the directory structure. - $ignoreList[] = "."; - $ignoreList[] = ".."; - $ignoreList[] = ".htaccess"; - $ignoreList[] = ".svn"; + $ignoreList[] = '.'; + $ignoreList[] = '..'; + $ignoreList[] = '.htaccess'; + $ignoreList[] = '.svn'; // Keep it in class for later usage $this->ignoreList = $ignoreList; @@ -312,10 +312,10 @@ class ClassLoader { $oldPrefix = $this->prefix; // Set new prefix (temporary!) - $this->prefix = "config-"; + $this->prefix = 'config-'; // Set base directory - $basePath = sprintf("%sinc/config/", $this->configInstance->readConfig('base_path')); + $basePath = $this->configInstance->readConfig('base_path') . 'inc/config/'; // Load all classes from the config directory $this->scanClassPath($basePath); diff --git a/inc/selector.php b/inc/selector.php index 33a4fa96..7e7dee50 100644 --- a/inc/selector.php +++ b/inc/selector.php @@ -46,11 +46,7 @@ foreach ($configAppIncludes as $inc) { } // Generate a FQFN for the helper class - $fqfn = sprintf("%s%s/%s.php", - $cfg->readConfig('application_path'), - $cfg->readConfig('app_name'), - $inc - ); + $fqfn = $cfg->readConfig('application_path') . $cfg->readConfig('app_name') . '/' . $inc . '.php'; // Does the include file exists? if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { @@ -64,5 +60,8 @@ foreach ($configAppIncludes as $inc) { } } +// Remove variables from namespace, which we don't need +unset($cfg, $inc, $configAppIncludes, $fqfn); + // [EOF] ?>