application/ship-simu/exceptions/class_ItemNotTradeableException.php -text
application/ship-simu/exceptions/class_MissingSimulatorIdException.php -text
application/ship-simu/exceptions/class_MotorShipMismatchException.php -text
+application/ship-simu/exceptions/class_NoShippingCompanyOwnedException.php -text
application/ship-simu/exceptions/class_NoShipyardsConstructedException.php -text
application/ship-simu/exceptions/class_PersonellListAlreadyCreatedException.php -text
application/ship-simu/exceptions/class_RoomShipMismatchException.php -text
application/ship-simu/main/structures/extended/lower/.htaccess -text
application/ship-simu/main/structures/extended/upper/.htaccess -text
application/ship-simu/main/structures/extended/upper/class_Bridge.php -text
+application/ship-simu/main/wrapper/.htaccess -text
+application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php -text
application/ship-simu/starter.php -text
application/ship-simu/templates/.htaccess -text
application/ship-simu/templates/de/.htaccess -text
+application/ship-simu/templates/de/code/block_persona_data.ctp -text
application/ship-simu/templates/de/code/captch_graphic_code.ctp -text
application/ship-simu/templates/de/code/footer.ctp -text
application/ship-simu/templates/de/code/header.ctp -text
inc/classes/main/debug/class_DebugConsoleOutput.php -text
inc/classes/main/debug/class_DebugErrorLogOutput.php -text
inc/classes/main/debug/class_DebugWebOutput.php -text
-inc/classes/main/extended/.htaccess -text
-inc/classes/main/extended/class_ObjectLimits.php -text
-inc/classes/main/extended/class_SerializationContainer.php -text
inc/classes/main/factories/.htaccess -text
inc/classes/main/factories/cache/.htaccess -text
inc/classes/main/factories/cache/class_CacheFactory.php -text
inc/classes/main/helper/web/.htaccess -text
inc/classes/main/helper/web/blocks/.htaccess -text
inc/classes/main/helper/web/blocks/class_WebBlockHelper.php -text
+inc/classes/main/helper/web/class_ -text
inc/classes/main/helper/web/class_BaseWebHelper.php -text
inc/classes/main/helper/web/forms/.htaccess -text
inc/classes/main/helper/web/forms/class_WebFormHelper.php -text
+inc/classes/main/helper/web/links/.htaccess -text
+inc/classes/main/helper/web/links/class_WebLinkHelper.php -text
inc/classes/main/images/.htaccess -text
inc/classes/main/images/class_ -text
inc/classes/main/images/class_BaseImage.php -text
// CFG: BLOCK-SHOWS-REGISTRATION
$cfg->setConfigEntry('block_shows_registration', "Y");
+// CFG: COMPANY-CLASS
+$cfg->setConfigEntry('company_class', "ShippingCompany");
+
+// CFG: COMPANY-DB-WRAPPER-CLASS
+$cfg->setConfigEntry('company_db_wrapper_class', "CompanyDatabaseWrapper");
+
// [EOF]
?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when a user owns no shipping companies
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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 NoShippingCompanyOwnedException extends FrameworkException {
+ /**
+ * Constructor of this exception
+ *
+ * @param $msgArray Message array with exception data
+ * @param $code Exception code
+ * @return void
+ */
+ public function __construct (array $msgArray, $code) {
+ // Add a message around the missing class
+ $message = sprintf("[%s:%d] Current user (class <u>%s</u>) does not own any shipping companies.",
+ $msgArray[0]->__toString(),
+ $this->getLine(),
+ $msgArray[1]->__toString()
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class ToMuchEmployeesException extends FrameworkException {
- public function __construct ($amountArray, $code) {
- // Cast the array
- $amountArray = (array) $amountArray;
-
+ public function __construct (array $amountArray, $code) {
// Add a message around the missing class
$message = sprintf("<u>%d</u> Leute nicht einstellbar, da nur <u>%d</u> arbeitslos sind!",
$amountArray[0],
private $contractList = null;
/**
- * Main constructor
+ * Database result instance
+ */
+ private $resultInstance = null;
+
+ // Exception constants
+ const EXCEPTION_USER_OWNS_NO_COMPANY = 0x200;
+
+ /**
+ * Protected constructor
*
* @return void
*/
parent::__construct(__CLASS__);
// Set description
- $this->setObjectDescription("Reederei");
+ $this->setObjectDescription("A shipping company class");
// Generate unique ID number
$this->generateUniqueId();
$this->removeSystemArray();
}
- // Reederei gruenden (create wegen Namenskonvention)
- public final static function createShippingCompany ($companyName, Harbor $hqInstance) {
+ /**
+ * Creates an instance of this company class or throws an exception if the
+ * given user owns no company.
+ *
+ * @param $userInstance A user class
+ * @return $companyInstance Prepared company instance
+ * @throws NoShippingCompanyOwnedException If the user owns no shipping companies
+ */
+ public final static function createShippingCompany (BaseUser $userInstance) {
// Get new instance
$companyInstance = new ShippingCompany();
- if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $companyInstance->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> wird gegründet.",
- __CLASS__,
- __LINE__,
- $companyName
- ));
+ // Does the given user owns a company?
+ if (!$companyInstance->ifUserOwnsShippingCompany($userInstance)) {
+ // Throw an exception here
+ throw new NoShippingCompanyOwnedException(array($companyInstance, $userInstance), self::EXCEPTION_USER_OWNS_NO_COMPANY);
+ } // END - if
- // Firmennamen setzen
- $companyInstance->setCompanyName($companyName);
+ // Set the user instance. We don't care here if he is founder or employee.
+ $companyInstance->setUserInstance($userInstance);
- // Kuerzel setzen
- $companyInstance->createShortName();
+ // Init all lists
+ $companyInstance->initCompanyLists();
- // Sitz festlegen
- $companyInstance->setHQInstance($hqInstance);
+ // Return instance
+ return $companyInstance;
+ }
- // Werftenliste erstellen
- $companyInstance->createshipyardList();
+ /**
+ * Checks wether the given user owns a company or not
+ *
+ * @param $userInstance An instance of a user class
+ * @return $ownsCompany Wether the user owns at least one company
+ */
+ protected function ifUserOwnsShippingCompany (BaseUser $userInstance) {
+ // By default no user owns any company... ;)
+ $ownsCompany = false;
- // Angestellten-Liste erstellen
- $companyInstance->createEmployeeList();
+ // Get a company database wrapper class
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class');
- // Auftragsliste erstellen
- $companyInstance->createContractList();
+ // Get a search criteria class
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
- // Clean up a little
- $companyInstance->removeWidth();
- $companyInstance->removeHeight();
- $companyInstance->removeLength();
- $companyInstance->removeDraught();
- $companyInstance->removePartInstance();
+ // Add the user primary key as a search criteria
+ $criteriaInstance->addCriteria('company_owner', $userInstance->getPrimaryKey());
+ $criteriaInstance->setLimit(1);
- // Instanz zurueckgeben
- return $companyInstance;
+ // Get the result back
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance->debugInstance();
}
- // Angestellten-Liste erstellen
- private function createEmployeeList () {
- if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erhält eine Angestelltenliste.",
- __CLASS__,
- __LINE__,
- $this->getCompanyName()
- ));
+ /**
+ * Intialize all lists
+ *
+ * @return void
+ */
+ protected function initCompanyLists () {
+ // Employees
$this->employeeList = new FrameworkArrayObject("FakedEmployeeList");
- }
- // Werftenliste erstellen
- public function createShipyardList () {
- if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erhält eine Werftsliste.",
- __CLASS__,
- __LINE__,
- $this->getCompanyName()
- ));
+ // Ship yards
$this->shipyardList = new FrameworkArrayObject("FakedShipyardList");
- }
- // Auftragsliste erstellen
- public function createContractList () {
- if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei <strong>%s</strong> erhält eine Auftragsliste.",
- __CLASS__,
- __LINE__,
- $this->getCompanyName()
- ));
+ // Contracts
$this->contractList = new FrameworkArrayObject("FakedContractList");
}
+ //----------------------------------------------------------------------------
+ // From here is very old code which needs to be translated and changed heavily
+ //----------------------------------------------------------------------------
+
// Setter-Methode fuer Firmennamen
public final function setCompanyName ($companyName) {
$this->companyName = (string) $companyName;
}
// Kuerzel setzen
- private function createShortName () {
+ private function initShortName () {
// Mindestens eine Leerstelle?
$dummy = explode(" ", $this->getCompanyName());
foreach ($dummy as $part) {
$this->shortName .= substr($part, 0, 1);
- }
+ } // END - if
}
// Reedereien Werften bauen lassen
* @throws ContainerMaybeDamagedException If the container item
* is missing the indexes
* 'name' and/or 'value'
- * @see SerializationContainer A special container class which
- * helps storing only some attributes
- * of a class.
*/
public function loadPersonellList ($idNumber) {
// Cleared because old code
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A wrapper for database access to shipping company data
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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 CompanyDatabaseWrapper extends BaseDatabaseWrapper {
+ // Constants for database tables
+ const DB_TABLE_COMPANY = "company";
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A wrapper for database access to company data");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * Creates an instance of this wrapper class
+ *
+ * @return $wrapperInstance An instance of this wrapper class
+ */
+ public final static function createCompanyDatabaseWrapper () {
+ // Create a new instance
+ $wrapperInstance = new CompanyDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_COMPANY);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+// Get a helper instance for the profile link (and maybe later more!)
+$helperInstance = WebLinkHelper::createWebLinkHelper($this, 'profile_link');
+
+// Prefetch user instance
+$helperInstance->prefetchValueInstance('user');
+
+// Flush the content out
+$helperInstance->flushContent();
+
+// End of PHP commands
+?>
+<div class="gamer_name_div">
+ Spielername: <span class="gamer_name">{?block_username?}</span>
+</div>
+<div class="gamer_profile_div">
+ {?profile_link?}
+</div>
+<div class="gamer_registered_div">
+ Angemeldet seit: <span class="registered">{?block_registered?}</span>
+</div>
<?php
+///////////////////////////////
+// Assign personal user data //
+///////////////////////////////
+
// Get a new instance for personal data
$blockInstance = WebBlockHelper::createWebBlockHelper($this, 'persona_data');
// Flush the content out to a template variable
$blockInstance->flushContent();
+//////////////////////////////////////
+// Assign the shipping company data //
+//////////////////////////////////////
+
+// Get a new instance for personal data
+$blockInstance = WebBlockHelper::createWebBlockHelper($this, 'company_data');
+
+// Get the user instance
+$userInstance = Registry::getRegistry()->getInstance('user');
+
+// Get a shipping company instance ready
+$companyInstance = ObjectFactory::createObjectByConfiguredName('company_class', array($userInstance));
+
+// Flush the content out to a template variable
+//$blockInstance->flushContent();
+
// End of all PHP commands
?>
<div id="content_header">
// Return the code
return $markedCode;
}
+
+ /**
+ * Filter a given timestamp to make it look more beatifull for web-based
+ * front-ends. If null is given a message id null_timestamp will be
+ * resolved and returned.
+ *
+ * @param $timestamp Timestamp to prepare (filter) for display
+ * @return $readable A readable timestamp
+ */
+ public function doFilterFormatTimestamp ($timestamp) {
+ // Default value to return
+ $readable = "???";
+
+ // Is the timestamp null?
+ if (is_null($timestamp)) {
+ // Get a message string
+ $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
+ } else {
+ $this->partialStub("Do further analysis on timestamp {$timestamp}.");
+ }
+
+ // Return the stamp
+ return $readable;
+ }
}
// [EOF]
*/
private $uniqueKey = "";
+ /**
+ * Primary key
+ */
+ private $primaryKey = "";
+
/**
* Protected constructor
*
/**
* Creates an instance of this criteria
*
- * @return $criteriaInstance An instance of this criteria
+ * @param $tableName Name of the table
+ * @return $criteriaInstance An instance of this criteria
*/
- public final static function createDataSetCriteria () {
+ public final static function createDataSetCriteria ($tableName) {
// Get a new instance
$criteriaInstance = new DataSetCriteria();
+ // Set table name
+ $criteriaInstance->setTableName($tableName);
+
// Return the instance
return $criteriaInstance;
}
public final function getCriteriaArray () {
return $this->tableColumns;
}
+
+ /**
+ * Getter for primary key or unique key if not set
+ *
+ * @return $primaryKey Primary key or unique key if not set
+ */
+ public final function getPrimaryKey () {
+ // Get primary key by default
+ $primaryKey = $this->primaryKey;
+
+ if (empty($primaryKey)) {
+ // Get uniqueKey
+ $primaryKey = $this->getUniqueKey();
+ } // END - if
+
+ // Return it
+ return $primaryKey;
+ }
+
+ /**
+ * Setter for primary key
+ *
+ * @param $primaryKey Primary key to set
+ * @return void
+ */
+ public final function setPrimaryKey ($primaryKey) {
+ $this->primaryKey = (string) $primaryKey;
+ }
}
// [EOF]
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseDatabaseWrapper extends BaseFrameworkSystem {
+ /**
+ * Cache instance
+ */
+ private $cacheInstance = null;
+
+ /**
+ * Current table name to use
+ */
+ private $tableName = "unknown";
+
/**
* Protected constructor
*
// Call parent constructor
parent::__construct($class);
+ // Initialize the cache instance
+ $this->initCacheInstance();
+
// Clean up a little
$this->removeNumberFormaters();
$this->removeSystemArray();
}
+
+ /**
+ * Initializes the cache instance with a new object
+ *
+ * @return void
+ */
+ private final function initCacheInstance () {
+ // Set the new instance
+ $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+ }
+
+ /**
+ * Do a "select" query on the current table with the given search criteria and
+ * store it in cache for later usage
+ *
+ * @param $criteriaInstance An instance of a Criteria class
+ * @return $resultInstance An instance of a database result class
+ */
+ public function doSelectByCriteria (Criteria $criteriaInstance) {
+ // First get a key suitable for our cache and extend it with this class name
+ $cacheKey = sprintf("%s@%s",
+ $this->__toString(),
+ $criteriaInstance->getCacheKey()
+ );
+
+ // Does this key exists in cache?
+ if ($this->cacheInstance->offsetExists($cacheKey)) {
+ // Then use this result
+ $result = $cacheInstance->offsetGet($cacheKey);
+ } else {
+ // Now it's time to ask the database layer for this select statement
+ $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
+
+ // Cache the result if not null
+ if (!is_null($result)) {
+ // A valid result has returned from the database layer
+ $this->cacheInstance->offsetSet($cacheKey, $result);
+ } else {
+ // This invalid result must be wrapped
+ $result = array(
+ 'status' => "invalid",
+ 'exception' => $this->getDatabaseInstance()->getLastException()
+ );
+ }
+ }
+
+ // Create an instance of a DatabaseResult class with the given result
+ $resultInstance = DatabaseResult::createDatabaseResult($result);
+
+ // And return the instance
+ return $resultInstance;
+ }
+
+ /**
+ * Setter for table name
+ *
+ * @param $tableName Name of table name to set
+ * @return void
+ */
+ protected final function setTableName ($tableName) {
+ $this->tableName = (string) $tableName;
+ }
+
+ /**
+ * Getter for table name
+ *
+ * @return $tableName Name of table name to set
+ */
+ protected final function getTableName () {
+ return $this->tableName;
+ }
+
+ /**
+ * Getter for primary key used in wrapped table
+ *
+ * @return $primaryKey Primary key used in wrapped table
+ */
+ public final function getPrimaryKeyValue () {
+ // Get the table name and a database instance and ask for it
+ $primaryKey = $this->getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName());
+
+ // Return value
+ return $primaryKey;
+ }
}
// [EOF]
*/
private $lastException = null;
+ /**
+ * Table information array
+ */
+ private $tableInfo = array();
+
/**
* The protected constructor. Do never instance from outside! You need to
* set a local file path. The class will then validate it.
* @throws NoArrayCreatedException If explode() fails to create an array
* @throws InvalidArrayCountException If the array contains less or
* more than two elements
+ * @deprecated
*/
public function isUniqueIdUsed ($uniqueID, $inConstructor = false) {
// Currently not used... ;-)
// Initialize the search loop
$isValid = false;
- while ($dataFile = $dirInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn"))) {
+ while ($dataFile = $dirInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) {
// Generate FQFN for testing
$fqfn = sprintf("%s/%s", $pathName, $dataFile);
$this->setLastFile($fqfn);
$fileInstance->closeFile();
}
+ /**
+ * Getter for table information file contents or an empty if the info file was not created
+ *
+ * @param $dataSetInstance An instance of a database set class
+ * @return $infoArray An array with all table informations
+ */
+ private function getContentsFromTableInfoFile (StoreableCriteria $dataSetInstance) {
+ // Default content is no data
+ $infoArray = array();
+
+ // Create FQFN for getting the table information file
+ $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/info.' . $this->getFileExtension();
+
+ // Get the file contents
+ try {
+ $infoArray = $this->getDataArrayFromFile($fqfn);
+ } catch (FileNotFoundException $e) {
+ // Not found, so ignore it here
+ }
+
+ // ... and return it
+ return $infoArray;
+ }
+
+ /**
+ * Creates the table info file from given dataset instance
+ *
+ * @param $dataSetInstance An instance of a database set class
+ * @return void
+ */
+ private function createTableInfoFile (StoreableCriteria $dataSetInstance) {
+ // Create FQFN for creating the table information file
+ $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/info.' . $this->getFileExtension();
+
+ // Get the data out from dataset in a local array
+ $this->tableInfo[$dataSetInstance->getTableName()] = array(
+ 'primary' => $dataSetInstance->getPrimaryKey(),
+ 'created' => time(),
+ 'last_updated' => time()
+ );
+
+ // Write the data to the file
+ $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]);
+ }
+
+ /**
+ * Updates the primary key information or creates the table info file if not found
+ *
+ * @param $dataSetInstance An instance of a database set class
+ * @return void
+ */
+ private function updatePrimaryKey (StoreableCriteria $dataSetInstance) {
+ // Get the information array from lower method
+ $infoArray = $this->getContentsFromTableInfoFile($dataSetInstance);
+
+ // Is the primary key there?
+ 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'])) {
+ // Set the array element
+ $this->tableInfo[$dataSetInstance->getTableName()]['primary'] = $dataSetInstance->getPrimaryKey();
+
+ // Update the entry
+ $this->updateTableInfoFile($dataSetInstance);
+ }
+ }
+
/**
* Makes sure that the database connection is alive
*
);
// Initialize limit/skip
- $limitFound = 0; $skipFound = 0;
+ $limitFound = 0;
+ $skipFound = 0;
// Read the directory with some exceptions
- while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn"))) && ($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!
+ continue;
+ }
+
// Read the file
$dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
} // END - foreach
} else {
// Throw an exception here
- throw new SqlException(sprintf("File '%s' contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT);
+ throw new SqlException(array($this, sprintf("File '%s' contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY);
}
} // END - while
// Write the data away
$this->writeDataArrayToFqfn($fqfn, $dataSetInstance->getCriteriaArray());
+ // Update the primary key
+ $this->updatePrimaryKey($dataSetInstance);
+
// Reset last error message and exception
$this->resetLastError();
} catch (FrameworkException $e) {
$directoryInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName);
// Initialize limit/skip
- $limitFound = 0; $skipFound = 0;
+ $limitFound = 0;
+ $skipFound = 0;
// Get the criteria array from the dataset
$criteriaArray = $dataSetInstance->getCriteriaArray();
$searchInstance = $dataSetInstance->getSearchInstance();
// Read the directory with some exceptions
- while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn"))) && ($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!
+ continue;
+ }
+
// Open this file for reading
$dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
// Close the file pointer
$directoryInstance->closeDirectory();
+ // Update the primary key
+ $this->updatePrimaryKey($dataSetInstance);
+
// Reset last error message and exception
$this->resetLastError();
} catch (FrameworkException $e) {
$this->lastError = $e->getMessage();
// Throw an SQL exception
- throw new SqlException (array($this, sprintf("Cannot write data to table '%s'", $tableName), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
+ throw new SqlException (array($this, sprintf("Cannot write data to table '%s'", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
}
}
+
+ /**
+ * Getter for primary key of specified table or if not found null will be
+ * returned. This must be database-specific.
+ *
+ * @param $tableName Name of the table we need the primary key from
+ * @return $primaryKey Primary key column of the given table
+ */
+ public function getPrimaryKeyOfTable ($tableName) {
+ // Default key is null
+ $primaryKey = null;
+
+ // Does the table information exist?
+ if (isset($this->tableInfo[$tableName])) {
+ // Then return the primary key
+ $primaryKey = $this->tableInfo[$tableName]['primary'];
+ } // END - if
+
+ // Return the column
+ return $primaryKey;
+ }
}
// [EOF]
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class NewsDatabaseWrapper extends BaseDatabaseWrapper {
- /**
- * Cache instance
- */
- private $cacheInstance = null;
-
- // Constants for exceptions
- const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x160;
-
- // Constants for database columns
-
// Constants for database table names
const DB_TABLE_NEWS = "news";
// Get a new instance
$wrapperInstance = new NewsDatabaseWrapper();
- // Initialize the cache instance
- $wrapperInstance->initCacheInstance();
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_NEWS);
// Return the instance
return $wrapperInstance;
}
-
- /**
- * Initializes the cache instance with a new object
- *
- * @return void
- */
- protected function initCacheInstance () {
- // Set the new instance
- $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
- }
-
- /**
- * Do a "select" query on the user table with the given search criteria and
- * store it in cache for later usage
- *
- * @param $criteriaInstance An instance of a Criteria class
- * @return $resultInstance An instance of a database result class
- */
- public function doSelectByCriteria (Criteria $criteriaInstance) {
- // First get a key suitable for our cache and extend it with this class name
- $cacheKey = sprintf("%s@%s",
- $this->__toString(),
- $criteriaInstance->getCacheKey()
- );
-
- // Does this key exists in cache?
- if ($this->cacheInstance->offsetExists($cacheKey)) {
- // Then use this result
- $result = $cacheInstance->offsetGet($cacheKey);
- } else {
- // Now it's time to ask the database layer for this select statement
- $result = $this->getDatabaseInstance()->doSelectByTableCriteria(self::DB_TABLE_NEWS, $criteriaInstance);
-
- // Cache the result if not null
- if (!is_null($result)) {
- // A valid result has returned from the database layer
- $this->cacheInstance->offsetSet($cacheKey, $result);
- } else {
- // This invalid result must be wrapped
- $result = array(
- 'status' => "invalid",
- 'exception' => $this->getDatabaseInstance()->getLastException()
- );
- }
- }
-
- // Create an instance of a DatabaseResult class with the given result
- $resultInstance = DatabaseResult::createDatabaseResult($result);
-
- // And return the instance
- return $resultInstance;
- }
}
// [EOF]
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class UserDatabaseWrapper extends BaseDatabaseWrapper {
- /**
- * Cache instance
- */
- private $cacheInstance = null;
-
// Constants for exceptions
const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
// Get a new instance
$wrapperInstance = new UserDatabaseWrapper();
- // Initialize the cache instance
- $wrapperInstance->initCacheInstance();
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_USER);
// Return the instance
return $wrapperInstance;
}
- /**
- * Initializes the cache instance with a new object
- *
- * @return void
- */
- protected function initCacheInstance () {
- // Set the new instance
- $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
- }
-
- /**
- * Do a "select" query on the user table with the given search criteria and
- * store it in cache for later usage
- *
- * @param $criteriaInstance An instance of a Criteria class
- * @return $resultInstance An instance of a database result class
- */
- public function doSelectByCriteria (Criteria $criteriaInstance) {
- // First get a key suitable for our cache and extend it with this class name
- $cacheKey = sprintf("%s@%s",
- $this->__toString(),
- $criteriaInstance->getCacheKey()
- );
-
- // Does this key exists in cache?
- if ($this->cacheInstance->offsetExists($cacheKey)) {
- // Then use this result
- $result = $cacheInstance->offsetGet($cacheKey);
- } else {
- // Now it's time to ask the database layer for this select statement
- $result = $this->getDatabaseInstance()->doSelectByTableCriteria(self::DB_TABLE_USER, $criteriaInstance);
-
- // Cache the result if not null
- if (!is_null($result)) {
- // A valid result has returned from the database layer
- $this->cacheInstance->offsetSet($cacheKey, $result);
- } else {
- // This invalid result must be wrapped
- $result = array(
- 'status' => "invalid",
- 'exception' => $this->getDatabaseInstance()->getLastException()
- );
- }
- }
-
- // Create an instance of a DatabaseResult class with the given result
- $resultInstance = DatabaseResult::createDatabaseResult($result);
-
- // And return the instance
- return $resultInstance;
- }
-
/**
* Handles inserting the registration data from a registration instance into the database
*
*/
public function insertRegistrationObject (UserRegister $registrationInstance) {
// Generate a data set for the request
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class');
- $dataSetInstance->setTableName(self::DB_TABLE_USER);
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey('username');
// Add registration elements to the dataset
$registrationInstance->addElementsToDataSet($dataSetInstance);
*/
public function doUpdateByResult (UpdateableResult $resultInstance) {
// Generate a data set object
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class');
- $dataSetInstance->setTableName(self::DB_TABLE_USER);
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER));
// Add all update criteria to the database set
$resultInstance->addElementsToDataSet($dataSetInstance);
// Add seach criteria
$dataSetInstance->setSearchInstance($resultInstance->getSearchInstance());
- // Add the primary key
+ // Set the primary key
$dataSetInstance->setUniqueKey('username');
// "Update" this request with the database
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * This object limits other objects. This is mostly being used to prepare
- * objects to the datatabase connection or else a lot heap would be saved.
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- * @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 ObjectLimits extends BaseFrameworkSystem {
- /**
- * Limitation array for storing all attribute names we will use later
- * only.
- */
- private $limitArray = null;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set part description
- $this->setObjectDescription("Class for "limiting" other classes. See description for details.");
-
- // Create unique ID number
- $this->generateUniqueId();
-
- // Clean up a little
- $this->removeNumberFormaters();
- }
-
- /**
- * Create a new ObjectLimits object and (maybe prepare it a little)
- *
- * @param $limitationArray The limitation array we "walk" through
- * @return $limitInstance The instance to an ObjectLimits object
- */
- public final static function createObjectLimits (array $limitationArray) {
- // Is there a limitation array given?
- if (count($limitationArray) > 0) {
- // Get instance
- $limitInstance = new ObjectLimits();
-
- // Get all limitations and do them
- foreach ($limitationArray as $limit) {
- // What shall we limitate?
- if ($limit instanceof FrameworkInterface) {
- // Add an object
- $limitInstance->addObject($limit);
- } elseif (is_string($limit)) {
- // Add a string
- $limitInstance->addString($limit);
- } else {
- // Others are not supported (yet)
- throw new UnsupportedLimitationPartException($limit, self::EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED);
- }
- }
-
- // Return instance
- return $limitInstance;
- } else {
- // No limitation given so we send "null" back
- return null;
- }
- }
-
- /**
- * Add an object's name to the limitation list
- *
- * @param $object The object's name we shall add to the list
- * @return void
- */
- private final function addObject (FrameworkInterface $object) {
- // Auto-initialization
- if (is_null($this->limitArray)) {
- // Initialize this array
- $this->limitArray = new FrameworkArrayObject('FakedLimitArray');
- }
-
- // Add the object's name to it
- $this->limitArray->append($object->__toString());
- }
-
- /**
- * Add a string directly to the limitation list
- *
- * @param $str The string we want to add directly
- * @return void
- */
- private final function addString ($str) {
- // Auto-initialization
- if (is_null($this->limitArray)) {
- // Initialize this array
- $this->limitArray = new FrameworkArrayObject("FakedLimitArray");
- }
-
- // Add the direct string to ArrayObject
- $this->limitArray->append($str);
- }
-
- /**
- * Getter for limitArray
- *
- * @return $limitArray The object ArrayObject which holds limitations
- */
- public final function getLimitArray () {
- return $this->limitArray;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * This class contains object attributes which we can now send together to
- * other classes
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- * @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 SerializationContainer extends FrameworkArrayObject {
- /**
- * Protected constructor, must stay as public... *sigh*
- *
- * @return void
- */
- public function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Create a SerializationContainer object by applying the limitations
- * in $limitInstance on $object. The resulting data container will only
- * hold the attributed and their values which we have specified in
- * the limitation object.
- *
- * @param $limitInstance The instance to the object ObjectLimits
- * @param $object The origin object. We don't touch it here.
- * @return $containerInstance An instance of SerializationContainer
- * @throws GetterNotFoundException If a getter was not found
- */
- public final static function createSerializationContainer (ObjectLimits $limitInstance, FrameworkInterface $object) {
- // Get an instance
- $containerInstance = new SerializationContainer();
-
- // Iterate through the whole limitation array
- for ($idx = $limitInstance->getLimitArray()->getIterator(); $idx->valid(); $idx->next()) {
- // Get current item from list
- $curr = ucfirst($idx->current());
-
- // Is the required method available?
- if (method_exists($object, sprintf("get%s", $curr))) {
- // Generate call-back function
- $value = call_user_func_array(array($object, sprintf("get%s", $curr)));
-
- // Add this item to the container list
- $containerInstance->append(array(
- 'name' => $curr,
- 'value' => $value
- ));
- } else {
- // Throw an exception
- throw new GetterNotFoundException(array($object, $curr), self::EXCEPTION_GETTER_IS_MISSING);
- }
- } // END - for
-
- // Return container instance
- return $containerInstance;
- }
-}
-
-// [EOF]
-?>
*
* @param $templateInstance An instance of a template engine
* @param $imageType Type of the image
- * @return $helperInstance A preparedf instance of this class
+ * @return $helperInstance A preparedf instance of this helper
*/
public final static function createImageHelper (CompileableTemplate $templateInstance, $imageType) {
// Get new instance
/**
* Creates the helper class
*
- * @return $helperInstance A prepared instance of this class
+ * @return $helperInstance A prepared instance of this helper
*/
public final static function create???Helper () {
// Get new instance
// Get the value from value instance
$fieldValue = $this->getField($fieldName);
- // Add a group
- $this->getTemplateInstance()->setVariableGroup('values');
-
// Assign it with a template variable
- $this->getTemplateInstance()->addGroupVariable($fieldName, $fieldValue);
+ $this->getTemplateInstance()->assignVariable("block_" . $fieldName, $fieldValue);
}
/**
* @param $fieldName Name of the field to assign
* @param $filterMethod Method name to call of the value instance
* @return void
+ * @todo Rewrite this method using a helper class for filtering data
*/
public function assignFieldWithFilter ($fieldName, $filterMethod) {
// Get the value
$fieldValue = $this->getField($fieldName);
// Now filter it through the value through the filter method
- $filteredValue = call_user_func_array(array($this->valueInstance, "doFilter" . ucfirst($filterMethod)), array($fieldValue));
-
- // Add a group
- $this->getTemplateInstance()->setVariableGroup('values');
+ $filteredValue = call_user_func_array(array($this, "doFilter" . ucfirst($filterMethod)), array($fieldValue));
// Assign it with a template variable
- $this->getTemplateInstance()->addGroupVariable($fieldName, $fieldValue);
+ $this->getTemplateInstance()->assignVariable("block_" . $fieldName, $filteredValue);
}
/**
*
* @param $templateInstance An instance of a template engine
* @param $blockName Name of the block we shall generate
- * @return $helperInstance A prepared instance of this class
+ * @return $helperInstance A prepared instance of this helper
*/
public final static function createWebBlockHelper (CompileableTemplate $templateInstance, $blockName) {
// Get new instance
* @return void
*/
public function flushContent () {
- $this->partialStub();
+ // Get template instance
+ $templateInstance = $this->getTemplateInstance();
+
+ // Get the template named like this block
+ $templateInstance->loadCodeTemplate("block_" . $this->getBlockName());
+
+ // Transfer it to the template instance
+ $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData());
}
}
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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 Web???Helper extends BaseWebHelper implements HelpableTemplate {
+ /**
+ * Name of the ???
+ */
+ private $???Name = "";
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("");
+ }
+
+ /**
+ * Creates the helper class
+ *
+ * @param $templateInstance An instance of a template engine
+ * @param $???Name Name of the ??? we shall generate
+ * @return $helperInstance A prepared instance of this helper
+ */
+ public final static function createWeb???Helper (CompileableTemplate $templateInstance, $???Name) {
+ // Get new instance
+ $helperInstance = new Web???Helper();
+
+ // Set template instance
+ $helperInstance->setTemplateInstance($templateInstance);
+
+ // Set ??? name
+ $helperInstance->set???Name($???Name);
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+
+ /**
+ * Flush the content out,e g. to a template variable
+ *
+ * @return void
+ */
+ public function flushContent () {
+ $this->partialStub("Please implement this method.");
+ }
+}
+
+// [EOF]
+?>
* @param $formName Name of the form
* @param $formId Value for "id" attribute (default: $formName)
* @param $withForm Wether include the form tag
- * @return $helperInstance A preparedf instance of this class
+ * @return $helperInstance A preparedf instance of this helper
*/
public final static function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false, $withForm = true) {
// Get new instance
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A helper for web links
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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 WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
+ /**
+ * Name of the link
+ */
+ private $linkName = "";
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A helper for generating web links");
+ }
+
+ /**
+ * Creates the helper class
+ *
+ * @param $templateInstance An instance of a template engine
+ * @param $linkName Name of the link we shall generate
+ * @return $helperInstance A prepared instance of this helper
+ */
+ public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName) {
+ // Get new instance
+ $helperInstance = new WebLinkHelper();
+
+ // Set template instance
+ $helperInstance->setTemplateInstance($templateInstance);
+
+ // Set Link name
+ $helperInstance->setLinkName($linkName);
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+
+ /**
+ * Setter for link name
+ *
+ * @param $linkName Name of the link we shall generate
+ * @return void
+ */
+ protected final function setLinkName ($linkName) {
+ $this->linkName = (string) $linkName;
+ }
+
+ /**
+ * Getter for link name
+ *
+ * @return $linkName Name of the link we shall generate
+ */
+ public final function getLinkName () {
+ return $this->linkName;
+ }
+
+ /**
+ * Flush the content out,e g. to a template variable
+ *
+ * @return void
+ */
+ public function flushContent () {
+ $this->partialStub("Please implement this method.");
+ }
+}
+
+// [EOF]
+?>
*
* @return $passHash User's password hash from database result
*/
- public function getPasswordHash () {
+ public final function getPasswordHash () {
// Default is missing password hash
$passHash = null;
* @return $fieldValue Field value from the user
* @todo Do we need to secure this here against missing results?
*/
- public function getField ($fieldName) {
+ public final function getField ($fieldName) {
// Default field value
$fieldValue = null;
// Return it
return $fieldValue;
}
+
+ /**
+ * Getter for primary key value
+ *
+ * @return $primaryValue Value of the primary key based on database type
+ */
+ public final function getPrimaryKey () {
+ // Get a user database wrapper
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+ // Get the primary key back from the wrapper
+ $primaryKey = $wrapperInstance->getPrimaryKeyValue();
+
+ // Get that field
+ $primaryValue = $this->getField($primaryKey);
+
+ // Return the value
+ return $primaryValue;
+ }
}
// [EOF]
// Ask the database layer
$this->dbLayer->queryUpdateDataSet($dataSetInstance);
}
+
+ /**
+ * Getter for primary key column of specified table name
+ *
+ * @param $tableName Name of table we need the primary key column from
+ * @return $primaryKey Primary key column of requested table
+ */
+ public function getPrimaryKeyOfTable ($tableName) {
+ // Connect to the database
+ $this->dbLayer->connectToDatabase();
+
+ // Ask the database layer
+ $primaryKey = $this->dbLayer->getPrimaryKeyOfTable($tableName);
+
+ // Return the value
+ return $primaryKey;
+ }
}
// [EOF]
// CFG: CRYPT-FIXED-SALT
$cfg->setConfigEntry('crypt_fixed_salt', "N");
+// CFG: DB-UPDATE-PRIMARY-FORCED
+$cfg->setConfigEntry('db_update_primary_forced', "Y");
+
// [EOF]
?>
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/**
* The application's emergency exit
*
- * @param $message The optional message we shall output on exit
+ * @param $message The optional message we shall output on exit
+ * @param $code Error code from exception
+ * @param $extraData Extra information from exceptions
* @return void
*/
- public static function app_die ($message = "") {
+ public static function app_die ($message = "", $code = false, $extraData = "") {
// Is this method already called?
if (defined('EMERGENCY_EXIT_CALLED')) {
// Then output the text directly
die($message);
- }
+ } // END - if
// This method shall not be called twice
define('EMERGENCY_EXIT_CALLED', true);
$lang = LanguageSystem::getInstance();
$io = FileIoHandler::getInstance();
+ // Get response instance
+ $responseInstance = ApplicationHelper::getInstance()->getResponseInstance();
+
// Is the template engine loaded?
if ((class_exists($tpl)) && (is_object($lang)) && (is_object($io))) {
// Use the template engine for putting out (nicer look) the message
if (!isset($trace['line'])) $trace['line'] = 5;
if (!isset($trace['args'])) $trace['args'] = array();
$backtrace .= "<span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span><br />";
- }
+ } // END - foreach
// Assign variables
$tplEngine->assignVariable('message', $message);
+ $tplEngine->assignVariable('code', $code);
+ $tplEngine->assignVariable('extra', $extraData);
$tplEngine->assignVariable('backtrace', $backtrace);
$tplEngine->assignVariable('total_includes', ClassLoader::getInstance()->getTotal());
$tplEngine->assignVariable('total_objects', ObjectFactory::getTotal());
// Compile all variables
$tplEngine->compileVariables();
- // Output all
- $tplEngine->output();
+ // Transfer data to response
+ $tplEngine->transferToResponse($responseInstance);
+
+ // Flush the response
+ $responseInstance->flushBuffer();
// Good bye...
exit();