From cb9f9b9c5859160ac8de5908f15f28a5957dcc9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 27 Aug 2008 18:51:59 +0000 Subject: [PATCH] Deprecated methods removed/purged --- application/ship-simu/main/class_Merchant.php | 36 +------- ...lass_MoneyRefillRequestValidatorFilter.php | 13 ++- .../personell/class_SimulatorPersonell.php | 52 +---------- .../class_FrameworkDatabaseInterface.php | 12 --- .../main/class_BaseFrameworkSystem.php | 19 ---- .../databases/class_LocalFileDatabase.php | 90 ------------------- .../action/class_BaseActionResolver.php | 3 - .../command/class_BaseCommandResolver.php | 3 - .../class_BaseControllerResolver.php | 3 - .../image/class_ImageControllerResolver.php | 3 - .../web/class_WebControllerResolver.php | 3 - .../database/class_DatabaseConnection.php | 19 ---- 12 files changed, 17 insertions(+), 239 deletions(-) diff --git a/application/ship-simu/main/class_Merchant.php b/application/ship-simu/main/class_Merchant.php index b0748e7..5298253 100644 --- a/application/ship-simu/main/class_Merchant.php +++ b/application/ship-simu/main/class_Merchant.php @@ -99,44 +99,12 @@ class Merchant extends BaseFrameworkSystem { // Add new item to merchant's price list public function addItemToPriceList (TradeableItem $itemInstance, $price) { - // Secure pricing - $price = (float) $price; - - // Construct pricing item and add it to the list - $this->priceList->append(array( - 'item' => $itemInstance, - 'price' => $price - )); - - // Remove price attribute - $itemInstance->removePrice(); + $this->makeDeprecated(); } // Get a price from the merchant's list public final function getPriceFromList (TradeableItem $itemInstance) { - $price = 0; - - // Iterate throw whole list - for ($iter = $this->priceList->getIterator(); $iter->valid(); $iter->next()) { - // Get current item - $item = $iter->current(); - - // Does this item match? The unique ID may not work... - if ($item['item']->itemMatches($itemInstance)) { - // Extract price and stop searching - $price = $item['price']; - break; - } - } - - // Was the item found? - if ($price === 0) { - // Throw exception - throw new ItemNotInPriceListException($itemInstance, self::EXCEPTION_ITEM_NOT_IN_PRICE_LIST); - } - - // Return price - return $price; + $this->makeDeprecated(); } } diff --git a/application/ship-simu/main/filter/validator/class_MoneyRefillRequestValidatorFilter.php b/application/ship-simu/main/filter/validator/class_MoneyRefillRequestValidatorFilter.php index 632df43..1bcd932 100644 --- a/application/ship-simu/main/filter/validator/class_MoneyRefillRequestValidatorFilter.php +++ b/application/ship-simu/main/filter/validator/class_MoneyRefillRequestValidatorFilter.php @@ -58,7 +58,18 @@ class MoneyRefillRequestValidatorFilter extends BaseFrameworkSystem implements F * @todo 0% done */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $requestInstance->debugInstance(); + // Are all required request fields set? + if ((!$requestInstance->isRequestElementSet('type')) || (!$requestInstance->isRequestElementSet('amount'))) { + // Something important is missing + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('refill_page_required_fields_missing'); + + // Abort here + return false; + } // END - if + die("OK!"); } } diff --git a/application/ship-simu/main/personell/class_SimulatorPersonell.php b/application/ship-simu/main/personell/class_SimulatorPersonell.php index 6c1e084..21fab3f 100644 --- a/application/ship-simu/main/personell/class_SimulatorPersonell.php +++ b/application/ship-simu/main/personell/class_SimulatorPersonell.php @@ -118,51 +118,12 @@ class SimulatorPersonell extends BasePersonell { * @throws InvalidIDFormatException If the given id number * $idNumber is invalid * @throws MissingSimulatorIdException If an ID number was not found + * @deprecated */ public final static function createSimulatorPersonellByID ($idNumber) { - // Use the direct ID number - $tempID = $idNumber; - - // Add the class name if it was not found - if (count(explode("@", $idNumber)) < 2) { - // Add class name in front of the incomplete ID number - $tempID = sprintf("%s@%s", __CLASS__, $idNumber); - } // END - if - - // Validate the ID number - if (!preg_match(sprintf("/%s\@([a-f0-9]){32}/i", __CLASS__), $tempID)) { - // Invalid format - throw new InvalidIDFormatException(new SimulatorPersonell(), self::EXCEPTION_ID_IS_INVALID_FORMAT); - } // END - if - // Get instance $personellInstance = new SimulatorPersonell(false); - - // Get database instance - $dbInstance = $personellInstance->getDatabaseInstance(); - - // Is the unique ID already used? Then it must be there! - if (!$dbInstance->isUniqueIdUsed($tempID)) { - // Entry not found! - throw new MissingSimulatorIdException(array($personellInstance, $idNumber), self::EXCEPTION_SIMULATOR_ID_INVALID); - } // END - if - - // Load the personell list and add it to this object - $personellInstance->loadPersonellList($tempID); - - // Clean-up a little - $personellInstance->removeGender(); - $personellInstance->removeNames(); - $personellInstance->removeBirthday(); - $personellInstance->removeSalary(); - $personellInstance->removeEmployed(); - $personellInstance->removeMarried(); - $personellInstance->removeNumberFormaters(); - //$personellInstance->removeCache(); - $personellInstance->removeSystemArray(); - - // Return instance - return $personellInstance; + $personellInstance->makeDeprecated(); } // Create personell list @@ -359,17 +320,10 @@ class SimulatorPersonell extends BasePersonell { * @param $idNumber The ID number we shall use for looking up * the right data. * @return void - * @throws ContainerItemIsNullException If a container item is null - * @throws ContainerItemIsNoArrayException If a container item is - * not an array - * @throws ContainerMaybeDamagedException If the container item - * is missing the indexes - * 'name' and/or 'value' * @deprecated */ public function loadPersonellList ($idNumber) { - // Cleared because old code - $this->partialStub("Cleared because old lost code was used."); + $this->makeDeprecated(); } } diff --git a/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php b/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php index 846f140..6e3f3d6 100644 --- a/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php +++ b/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php @@ -22,18 +22,6 @@ * along with this program. If not, see . */ interface FrameworkDatabaseInterface extends FrameworkInterface { - /** - * Analyses if a unique ID has already been used or not. This method does - * only pass the given ID through to the "real" database layer. - * - * @param $uniqueID A unique ID number which shall be checked - * before it will be used - * @param $inConstructor If called from a constructor or from - * somewhere else - * @return $isUnused true = The unique ID was not found in the database, - * false = It is already in use by an other object - */ - function isUniqueIdUsed ($uniqueID, $inConstructor = false); } // [EOF] diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 9dd62b4..5652f4f 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -557,25 +557,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->realClass = $realClass; } - /** - * Compare if both simulation part description and class name matches - * (shall be enough) - * - * @param $itemInstance An object instance to an other class - * @return boolean The result of comparing class name simulation part description - * @deprecated - */ - public function itemMatches ($itemInstance) { - $this->partialStub("Deprecated!"); - return ( - ( - $this->__toString() == $itemInstance->__toString() - ) && ( - $this->getObjectDescription() == $itemInstance->getObjectDescription() - ) - ); - } - /** * Compare class name of this and given class name * diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 69ce662..a8cda74 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -150,96 +150,6 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend return $this->lastException; } - /** - * Analyses if a unique ID has already been used or not by search in the - * local database folder. - * - * @param $uniqueID A unique ID number which shall be checked - * before it will be used - * @param $inConstructor If we got called in a de/con-structor or - * from somewhere else - * @return $isUnused true = The unique ID was not found in the database, - * false = It is already in use by an other object - * @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... ;-) - $isUsed = false; - - // Split the unique ID up in path and file name - $pathFile = explode("@", $uniqueID); - - // Are there two elements? Index 0 is the path, 1 the file name + global extension - if (!is_array($pathFile)) { - // No array found - if ($inConstructor) { - return false; - } else { - throw new NoArrayCreatedException(array($this, 'pathFile'), self::EXCEPTION_ARRAY_EXPECTED); - } - } elseif (count($pathFile) != 2) { - // Invalid ID returned! - if ($inConstructor) { - return false; - } else { - throw new InvalidArrayCountException(array($this, 'pathFile', count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } - } - - // Create full path name - $pathName = $this->getSavePath() . $pathFile[0]; - - // Check if the file is there with a file handler - if ($inConstructor) { - // No exceptions in constructors and destructors! - $dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName, true); - - // Has an object being created? - if (!is_object($dirInstance)) return false; - } else { - // Outside a constructor - try { - $dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName); - } catch (PathIsNoDirectoryException $e) { - // Okay, path not found - return false; - } - } - - // Initialize the search loop - $isValid = false; - while ($dataFile = $dirInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) { - // Generate FQFN for testing - $fqfn = sprintf("%s/%s", $pathName, $dataFile); - $this->setLastFile($fqfn); - - // Get instance for file handler - $inputHandler = $this->getFileIoInstance(); - - // Try to read from it. This makes it sure that the file is - // readable and a valid database file - $this->setLastFileContents($inputHandler->loadFileContents($fqfn)); - - // Extract filename (= unique ID) from it - $ID = substr(basename($fqfn), 0, -(strlen($this->getFileExtension()) + 1)); - - // Is this the required unique ID? - if ($ID == $pathFile[1]) { - // Okay, already in use! - $isUsed = true; - } - } - - // Close the directory handler - $dirInstance->closeDirectory(); - - // Now the same for the file... - return $isUsed; - } - /** * Setter for the last read file * diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php index 0f41a35..0c7f268 100644 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -101,9 +101,6 @@ class BaseActionResolver extends BaseResolver { $isValid = true; } // END - if - // Debug output - //* DEBUG: */ $this->debugBackTrace(); - // Set action name $this->setActionName($actionName); diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php index f26d351..d1fa003 100644 --- a/inc/classes/main/resolver/command/class_BaseCommandResolver.php +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -125,9 +125,6 @@ class BaseCommandResolver extends BaseResolver { $isValid = true; } // END - if - // Debug output - //* DEBUG: */ $this->debugBackTrace(); - // Set command name $this->setCommandName($commandName); diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index 2548b4f..ec61d4e 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -117,9 +117,6 @@ class BaseControllerResolver extends BaseResolver { } } // END - while - // Debug output - //* DEBUG: */ $this->debugBackTrace(); - // Return the result return $isValid; } diff --git a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php index 157a98c..b2f4fcd 100644 --- a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php +++ b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php @@ -120,9 +120,6 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll * controller class is missing (bad!) */ private function loadController ($controllerName) { - // Debug message - //* DEBUG: */ $this->debugBackTrace(); - // Cache default command $defaultController = $this->getConfigInstance()->readConfig('default_image_command'); diff --git a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php index 2446e6d..da09dca 100644 --- a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -120,9 +120,6 @@ class WebControllerResolver extends BaseControllerResolver implements Controller * controller class is missing (bad!) */ private function loadController ($controllerName) { - // Debug message - //* DEBUG: */ $this->debugBackTrace(); - // Cache default command $defaultController = $this->getConfigInstance()->readConfig('default_web_command'); diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php index 1d9fe9b..736ea4b 100644 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -98,25 +98,6 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re $this->dbLayer = $dbLayer; } - /** - * Analyses if a unique ID has already been used or not. This method does - * only pass the given ID through to the "real" database layer. - * - * @param $uniqueID A unique ID number which shall be checked - * before it will be used - * @param $inConstructor If called from a constructor or from - * somewhere else - * @return $isUnused true = The unique ID was not found in the database, - * false = It is already in use by an other object - */ - public function isUniqueIdUsed ($uniqueID, $inConstructor = false) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Pass the returning result through - return $this->dbLayer->isUniqueIdUsed($uniqueID, $inConstructor); - } - /** * Runs a "select" statement on the database layer with given table name * and criteria. If this doesn't fail the result will be returned -- 2.39.2