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
foreach ($dbgInfo['args'] as $debug) {
// Add only non-array elements
if (!is_array($debug)) {
- $info .= $debug.", ";
+ $info .= $debug . ', ';
} // END - if
} // END - foreach
} // END - if
// The message
- $dbgMsg .= "\t at <em id=\"debug_id_".$dbgIndex."\">".$dbgIndex."</em> <em id=\"debug_file_".$dbgIndex."\">".$file."</em> (<em id=\"debug_line_".$dbgIndex."\">".$line."</em>) -> ".$dbgInfo['function']."(".$info.")<br />\n";
+ $dbgMsg .= "\t at <em id=\"debug_id_".$dbgIndex."\">".$dbgIndex."</em> <em id=\"debug_file_".$dbgIndex."\">".$file."</em> (<em id=\"debug_line_".$dbgIndex."\">".$line."</em>) -> ".$dbgInfo['function'].'('.$info.")<br />\n";
} // END - if
// Add end-message
);
// Set extra data
- $this->setExtraData($resolverInstance->getClassName().":".$this->getLine());
+ $this->setExtraData($resolverInstance->getClassName().':'.$this->getLine());
// Call parent contructor with message
parent::__construct($message, $code);
);
// 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);
);
// Set extra data
- $this->setExtraData($filterInstance->__toString().":".$length);
+ $this->setExtraData($filterInstance->__toString().':'.$length);
// Call parent exception constructor
parent::__construct($message, $code);
);
// Set extra data
- $this->setExtraData($classArray[1].":".$this->getLine());
+ $this->setExtraData($classArray[1].':'.$this->getLine());
// Call parent constructor
parent::__construct($message, $code);
);
// Set extra data
- $this->setExtraData($msgArray[0]->getClassName().":".$this->getLine());
+ $this->setExtraData($msgArray[0]->getClassName().':'.$this->getLine());
// Call parent constructor
parent::__construct($message, $code);
+++ /dev/null
-<?php
-/**
- * An exception thrown when a given view helper was not found
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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 <span class=\"exception_reason\">%s</span> ist ungültig.",
- $msgArray[0]->__toString(),
- $msgArray[1]
- );
-
- // Call parent constructor
- parent::__construct($message, $code);
- }
-}
-
-// [EOF]
-?>
*/
public function __construct (array $classArray, $code) {
// Extract attributes
- $attributes = "<em>None</em>";
+ $attributes = '<em>None</em>';
if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) {
- $attributes = implode(", ", $classArray[2]);
+ $attributes = implode(', ', $classArray[2]);
} // END - if
// Construct our message
* 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
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
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
/**
* 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);
*
* @return void
*/
- function output ($outStream=false);
+ function output ($outStream = false);
}
//
} elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
// Already destructed object
$this->debugOutput(sprintf("[%s:] The object <span class=\"object_name\">%s</span> is already destroyed.",
- __CLASS__, $this->__toString()
+ __CLASS__,
+ $this->__toString()
));
}
}
$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
* 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
$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;
*/
public final function addMissingTrailingSlash ($str) {
// Is there a trailing slash?
- if (substr($str, -1, 1) != "/") $str .= "/";
+ if (substr($str, -1, 1) != '/') $str .= '/';
return $str;
}
$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
$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
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
*
*/
public function doFilterFormatTimestamp ($timestamp) {
// Default value to return
- $readable = "???";
+ $readable = '???';
// Is the timestamp null?
if (is_null($timestamp)) {
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'),
$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');
// 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
/**
* 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';
}
}
*/
private $salt = '';
+ /**
+ * Seperator on many places
+ */
+ private $seperator '|';
+
/**
* Protected constructor
*
$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());
// 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;
}
$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());
$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);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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"
*/
/**
* The file's extension
*/
- private $fileExtension = "serialized";
+ private $fileExtension = 'serialized';
/**
* The last read file's name
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();
* 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
// 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()
);
$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!
$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!
*
* @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);
/**
* 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
/**
* 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) {
/**
* 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) {
*
* @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);
/**
* 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
/**
* Outputs the given data directly
*
- * @param $output The HTML output
+ * @param $output The HTML output
* @return void
*/
public final function outputStream ($output) {
/**
* 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) {
*
* @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);
} // 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);
$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');
* @return void
*/
protected final function addContent ($newContent) {
- $this->content .= (string) trim($newContent)."\n";
+ $this->content .= (string) trim($newContent) . "\n";
}
/**
// Add the group to the stack
$this->groups[$this->totalCounter] = $groupId;
$this->groups[$groupId]['opened'] = true;
- $this->groups[$groupId]['content'] = sprintf("<!-- group %s opened (length: %s, tag: %s) //-->%s\n", $groupId, strlen($content), $tag, $content);
+ $this->groups[$groupId]['content'] = sprintf(
+ "<!-- group %s opened (length: %s, tag: %s) //-->%s\n",
+ $groupId,
+ strlen($content),
+ $tag,
+ $content
+ );
$this->groups[$groupId]['tag'] = $tag;
// Mark this group as previously opened
// Is the content empty?
if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) {
// Get it from opener
- $content = sprintf("<!-- group %s auto-closed //--></%s>", $groupId, $this->groups[$groupId]['tag']);
+ $content = sprintf(
+ "<!-- group %s auto-closed //--></%s>",
+ $groupId,
+ $this->groups[$groupId]['tag']
+ );
} // END - if
// Add content to it and mark it as closed
- $this->groups[$groupId]['content'] .= sprintf("<!-- group %s closed (length: %s, tag: %s) //-->%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content);
+ $this->groups[$groupId]['content'] .= sprintf(
+ "<!-- group %s closed (length: %s, tag: %s) //-->%s\n",
+ $groupId,
+ strlen($content),
+ $this->groups[$groupId]['tag'],
+ $content
+ );
$this->groups[$groupId]['opened'] = false;
// Mark previous group as closed
// 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
// 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
* @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;
}
* @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;
}
* @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;
}
* @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;
}
* @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;
}
* @return $isUnique
*/
public function ifEmailMustBeUnique () {
- $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') === "Y");
+ $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') == 'Y');
return $isUnique;
}
* @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;
}
* @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;
}
* @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;
}
* @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;
}
* @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;
}
* @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;
}
}
*
* @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
*/
// 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);
* 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) {
} // END - if
// Close the form is default
- $formContent = "</form>";
+ $formContent = '</form>';
// Check wether we shall open or close the form
if (($this->formOpened === false) && ($this->formEnabled === true)) {
);
// Add close bracket
- $formContent .= ">";
+ $formContent .= '>';
// Open the form and remeber the form name
$this->formOpened = true;
$fieldValue
);
- // And add it maybe with a "li" tag
+ // And add it maybe with a 'li' tag
$this->addContentToPreviousGroup($inputContent);
}
public function addInputTextFieldWithDefault ($fieldName) {
// Get the value from instance
$fieldValue = $this->getValueField($fieldName);
- //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
// Add the text field
$this->addInputTextField($fieldName, $fieldValue);
public function addInputHiddenFieldWithDefault ($fieldName) {
// Get the value from instance
$fieldValue = $this->getValueField($fieldName);
- //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
// Add the text field
$this->addInputHiddenField($fieldName, $fieldValue);
public function addInputHiddenConfiguredField ($fieldName, $prefix) {
// Get the value from instance
$fieldValue = $this->getConfigInstance()->readConfig("{$prefix}_{$fieldName}");
- //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
// Add the text field
$this->addInputHiddenField($fieldName, $fieldValue);
// Set wether the check box is checked...
$checked = " checked=\"checked\"";
- if ($fieldChecked === false) $checked = " ";
+ if ($fieldChecked === false) $checked = ' ';
// Generate the content
$inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox %s_field\" value=\"1\"%s/>",
// All call it again if group name is not empty
if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
- //* DEBUG: */ echo $groupId."/".$prevGroupId."<br />\n";
+ //* DEBUG: */ echo $groupId.'/'.$prevGroupId."<br />\n";
$this->addFormGroup($groupId, $groupText);
} // END - if
}
* @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;
}
* @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;
}
* @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;
}
*/
private $linkBase = '';
+ /**
+ * First parameter seperator
+ */
+ private $firstParameter = '?';
+
+ /**
+ * Seperator for more paraemters
+ */
+ private $parameterSeperator = '&';
+
/**
* Protected constructor
*
// 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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
*/
}
/**
- * 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
$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])
));
$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();
$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) {
$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";
}
}
/**
* 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
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;
* @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) {
$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;
*
* @return void
*/
- public final function output ($outStream=false) {
+ public final function output ($outStream = false) {
print(stripslashes($outStream));
}
}
*/
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
$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])) {
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())) {
$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));
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())) {
// 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())) {
// 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())) {
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) {
//* 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()."<br />\n";
} // 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;
//* 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');
$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;
// 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
* @todo this will send only one cookie out, the first one.
*/
public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) {
- //* DEBUG: */ echo $cookieName."=".$cookieValue."<br />\n";
+ //* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
// Are headers already sent?
if (headers_sent()) {
// Throw an exception here
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;
// 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('');
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;
// 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('');
}
/**
- * 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));
}
/**
$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
// 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');
/**
* 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
*/
private $varGroups = array();
+ /**
+ * Code begin
+ */
+ private $codeBegin = '<?php';
+
+ /**
+ * Code end
+ */
+ private $codeEnd = '?>';
+
// Exception codes for the template engine
const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110;
const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
}
/**
- * 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
*/
protected final function setRawTemplateData ($rawTemplateData) {
// And store it in this class
- //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($rawTemplateData)." Bytes set.<br />\n";
- //* DEBUG: */ echo $this->currGroup." variables: ".count($this->varStack[$this->currGroup]).", groups=".count($this->varStack)."<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($rawTemplateData).' Bytes set.<br />\n';
+ //* DEBUG: */ echo $this->currGroup.' variables: '.count($this->varStack[$this->currGroup]).', groups='.count($this->varStack).'<br />\n';
$this->rawTemplateData = (string) $rawTemplateData;
}
* @return $rawTemplateData The raw data from the template
*/
public final function getRawTemplateData () {
- //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->rawTemplateData)." Bytes read.<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($this->rawTemplateData).' Bytes read.<br />\n';
return $this->rawTemplateData;
}
*/
private final function setCompiledData ($compiledData) {
// And store it in this class
- //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($compiledData)." Bytes set.<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($compiledData).' Bytes set.<br />\n';
$this->compiledData = (string) $compiledData;
}
* @return $compiledData Compiled template data
*/
public final function getCompiledData () {
- //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->compiledData)." Bytes read.<br />\n";
+ //* DEBUG: */ echo __METHOD__.':'.$this->getUniqueId().': '.strlen($this->compiledData).' Bytes read.<br />\n';
return $this->compiledData;
}
* 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
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 ...
/**
* 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) {
private function finalizeVariableCompilation () {
// Get the content
$content = $this->getRawTemplateData();
- //* DEBUG: */ echo __METHOD__.": content before=".strlen($content)." (".md5($content).")<br />\n";
+ //* DEBUG: */ echo __METHOD__.': content before='.strlen($content).' ('.md5($content).')<br />\n';
// Walk through all variables
foreach ($this->varStack['general'] as $currEntry) {
- //* DEBUG: */ echo __METHOD__.": name=".$currEntry['name'].", value=<pre>".htmlentities($currEntry['value'])."</pre>\n";
+ //* DEBUG: */ echo __METHOD__.': name='.$currEntry['name'].', value=<pre>'.htmlentities($currEntry['value']).'</pre>\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).")<br />\n";
+ //* DEBUG: */ echo __METHOD__.': content after='.strlen($content).' ('.md5($content).')<br />\n';
// Set the content back
$this->setRawTemplateData($content);
* 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) {
*/
public function assignConfigVariable ($var) {
// Sweet and simple...
- //* DEBUG: */ echo __METHOD__.":var={$var}<br />\n";
+ //* DEBUG: */ echo __METHOD__.':var={$var}<br />\n';
$this->varStack['config'][$var] = $this->getConfigInstance()->readConfig($var);
}
* 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) {
* 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) {
// 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']."=<pre>".htmlentities($currVariable['value'])."</pre>\n";
+ //* DEBUG: */ echo $currVariable['name'].'=<pre>'.htmlentities($currVariable['value']).'</pre>\n';
$dummy[$currVariable['name']] = $currVariable['value'];
}// END - if
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
);
// This loop does remove the backslashes (\) in PHP parameters
- while (strpos($eval, "<?php") !== false) {
+ while (strpos($eval, $this->codeBegin) !== false) {
// Get left part before "<?"
- $evalLeft = substr($eval, 0, strpos($eval, "<?php"));
+ $evalLeft = substr($eval, 0, strpos($eval, $this->codeBegin));
// Get all from right of "<?"
- $evalRight = substr($eval, (strpos($eval, "<?php") + 5));
+ $evalRight = substr($eval, (strpos($eval, $this->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);
$eval = str_replace(
"<%php", "\";",
str_replace(
- "%>", "\n\$result .= \"", $eval
+ "%>",
+ "\n\$result .= \"",
+ $eval
)
);
$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);
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 <span class=\"data\">%s</span> 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 <span class=\"data\">%s</span> detected.",
+ $this->__toString(),
+ __FUNCTION__,
+ $this->getTemplateType()
+ );
+
+ // Write the problem to the world...
+ $this->debugOutput($msg);
+ break;
+ } // END - switch
}
/**
*
* @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
// 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
//* DEBUG: */ echo "<pre>".print_r($varMatches, true)."</pre>";
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) {
// Now parse the XML tree
if (!xml_parse($xmlParser, $content)) {
// Error found in XML!
- //die("<pre>".htmlentities($content)."</pre>");
+ //die('<pre>'.htmlentities($content).'</pre>');
throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR);
} // END - if
/**
* 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
*/
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;
/**
* 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
// 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
*
* 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"),
* ")
*
* @copyright (c) 2007 by Primusportal.de
* @copyright (c) 2008 by Roland Haeder
*/
-class PrimeraApi {
+class PrimeraApi extends BaseFrameworkSystem {
/**
* Fehler - Interfacebenutzer
*/
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();
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
- $return = "";
+ $return = '';
while (!feof($fp)) {
$return.=fgets($fp,128);
}
$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];
}
* @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;
* - 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;
$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;
/**
* Static base API URL
*/
- private static $apiUrl = "http://www.wds66.com/api/";
+ private static $apiUrl = 'http://www.wds66.com/api/';
/**
* API Wernis amount
/**
* 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
*/
private $statusArray = array();
+ /**
+ * Status for 'okay'
+ */
+ private $statusOkay = 'OK';
+
/**
* Protected constructor
*
// 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",
$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();
} else {
// All fine here
$return = array(
- 'status' => "OK",
+ 'status' => $this->statusOkay,
'response' => $response
);
}
// 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'],
// 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 {
// 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'],
// 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 {
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
// Was the request successfull?
if ((!ereg("200 OK", $response[0])) && (empty($response[0]))) {
// Not found / access forbidden
- $response = array("", "", "");
+ $response = array('', '', '');
}
// Return response
$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
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.<br />\n";
- } // END - if
-
// Return the requested value
return $this->config[$cfgEntry];
}
*/
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;
*/
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'])) {
// 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// 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))) {
}
// 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]
?>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// 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: <span class=\"exception_reason\">%s</span>",
- $e->getMessage()
- ));
-} catch (SavePathNotFoundException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
- $e->getMessage()
- ));
-} catch (SavePathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
- $e->getMessage()
- ));
-} catch (SavePathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
- $e->getMessage()
- ));
-} catch (SavePathWriteProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
- $e->getMessage()
- ));
-}
+// For testing purposes we use a local file database
+$databaseInstance = LocalFileDatabase::createLocalFileDatabase(
+ FrameworkConfiguration::getInstance()->readConfig('local_db_path'),
+ FileIoHandler::getInstance()
+);
// [EOF]
?>
// Try to instance the language system
$lang = LanguageSystem::createLanguageSystem(
- $cfg->readConfig('base_path').
+ FrameworkConfiguration::getInstance()->readConfig('base_path').
FrameworkConfiguration::getInstance()->readConfig('lang_base_path')
);
// 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;
$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);
}
// 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))) {
}
}
+// Remove variables from namespace, which we don't need
+unset($cfg, $inc, $configAppIncludes, $fqfn);
+
// [EOF]
?>