From efba981c9bf18c733dfde945b09111ff4b6007ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 29 Jun 2008 23:38:35 +0000 Subject: [PATCH] Debug mailer finished and debug messages removed: - The class DebugMailer is now 99% ready. It outputs the sent mail but has not been tested with multiple mails - Confirmation mail is now basicly done - A lot debug messages removed/rewritten - Two generic methods added to interface FrameworkInterface - XML headers added to XML templates --- .gitattributes | 3 + application/ship-simu/config.php | 9 + .../ship-simu/main/class_BaseSimulator.php | 8 +- application/ship-simu/main/class_Merchant.php | 4 +- .../ship-simu/main/class_WorksContract.php | 16 +- .../main/companies/class_ShippingCompany.php | 32 +- .../constructions/harbors/class_Harbor.php | 6 - .../constructions/yards/class_Shipyard.php | 10 +- .../main/drives/motor/class_Motor.php | 7 - .../parts/maschineroom/class_MaschineRoom.php | 6 - .../personell/class_SimulatorPersonell.php | 8 +- .../company/class_CompanyEmployee.php | 2 +- .../ship-simu/main/ships/class_BaseShip.php | 14 +- .../ships/passenger/class_PassengerShip.php | 8 +- .../cabines/ship/class_EconomyCabin.php | 6 - .../extended/cabines/ship/class_LowCabin.php | 6 - .../cabines/ship/class_LuxuryCabin.php | 6 - .../cabines/ship/class_PremierCabin.php | 3 - .../extended/class_BaseCabinStructure.php | 6 +- .../extended/class_BaseDeckStructure.php | 4 +- .../extended/decks/cargo/class_CarDeck.php | 6 - .../extended/decks/cargo/class_TrainDeck.php | 6 - .../extended/decks/cargo/class_TruckDeck.php | 6 - .../extended/upper/class_Bridge.php | 6 - .../templates/de/code/mail_debug.ctp | 25 ++ .../templates/de/emails/text_resend_link.tpl | 20 +- .../templates/images/de/image/base_code.itp | 1 + .../xml/class_XmlNodeMismatchException.php | 4 +- .../interfaces/class_FrameworkInterface.php | 18 + .../mailer/class_DeliverableMail.php | 12 +- .../main/class_BaseFrameworkSystem.php | 31 +- .../web/class_WebResendLinkCommand.php | 44 ++- .../main/console/class_ConsoleTools.php | 4 +- .../wrapper/class_UserDatabaseWrapper.php | 5 +- .../captcha/images/class_ImageHelper.php | 4 +- inc/classes/main/mailer/class_BaseMailer.php | 72 +++- .../main/mailer/debug/class_DebugMailer.php | 107 +++++- .../main/response/class_ImageResponse.php | 2 +- .../template/class_BaseTemplateEngine.php | 61 ++- .../image/class_ImageTemplateEngine.php | 41 +- inc/classes/main/template/mail/.htaccess | 1 + .../mail/class_MailTemplateEngine.php | 362 ++++++++++++++++++ inc/classes/main/user/user/class_User.php | 2 +- inc/config/class_FrameworkConfiguration.php | 23 +- templates/images/de/image/base_image.itp | 1 + 45 files changed, 792 insertions(+), 236 deletions(-) create mode 100644 application/ship-simu/templates/de/code/mail_debug.ctp create mode 100644 inc/classes/main/template/mail/.htaccess create mode 100644 inc/classes/main/template/mail/class_MailTemplateEngine.php diff --git a/.gitattributes b/.gitattributes index e3d7b8c..b34935c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -154,6 +154,7 @@ application/ship-simu/templates/de/code/login_failed.ctp -text application/ship-simu/templates/de/code/login_form.ctp -text application/ship-simu/templates/de/code/login_main.ctp -text application/ship-simu/templates/de/code/logout_done.ctp -text +application/ship-simu/templates/de/code/mail_debug.ctp -text application/ship-simu/templates/de/code/register_form.ctp -text application/ship-simu/templates/de/code/shipsimu_main.ctp -text application/ship-simu/templates/de/emails/.htaccess -text @@ -573,6 +574,8 @@ inc/classes/main/template/.htaccess -text inc/classes/main/template/class_BaseTemplateEngine.php -text inc/classes/main/template/image/.htaccess -text inc/classes/main/template/image/class_ImageTemplateEngine.php -text +inc/classes/main/template/mail/.htaccess -text +inc/classes/main/template/mail/class_MailTemplateEngine.php -text inc/classes/main/template/web/.htaccess -text inc/classes/main/template/web/class_WebTemplateEngine.php -text inc/classes/main/user/.htaccess -text diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index 5967ed3..fcaa33c 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -223,5 +223,14 @@ $cfg->setConfigEntry('company_db_wrapper_class', "CompanyDatabaseWrapper"); // CFG EMAIl-TPL-RESEND-LINK $cfg->setConfigEntry('email_tpl_resend_link', "text"); +// CFG: MAIL-TEMPLATE-ENGINE +$cfg->setConfigEntry('mail_template_class', "MailTemplateEngine"); + +// CFG: IMAGE-TEMPLATE-ENGINE +$cfg->setConfigEntry('image_template_class', "ImageTemplateEngine"); + +// CFG: ADMIN-EMAIL +$cfg->setConfigEntry('admin_email', "you@some-hoster.invalid"); + // [EOF] ?> diff --git a/application/ship-simu/main/class_BaseSimulator.php b/application/ship-simu/main/class_BaseSimulator.php index cb29c92..db7a1f2 100644 --- a/application/ship-simu/main/class_BaseSimulator.php +++ b/application/ship-simu/main/class_BaseSimulator.php @@ -117,7 +117,7 @@ class BaseSimulator extends BaseFrameworkSystem { $this->currShip = $shipInstance; $this->currPart = $partInstance; - if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Maschinenraum mit Motor %s wird fuer das Schiff %s konstruiert.", + if (defined('DEBUG_CORE')) $this->debugOutput(sprintf("[%s:] Maschinenraum mit Motor %s wird fuer das Schiff %s konstruiert.", $this->__toString(), $this->getCurrPart()->getObjectDescription(), $this->currShip->getShipName() @@ -126,7 +126,7 @@ class BaseSimulator extends BaseFrameworkSystem { // Passt ueberhaupt das Schiffsteil in's Schiff? if ($this->isShipPartSizeValid()) { // Berechnungen fuer umliegendes Objekt anpassen - if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Das Schiffsteil %s vom Typ %s passt in das Schiff %s hinein.", + if (defined('DEBUG_CORE')) $this->debugOutput(sprintf("[%s:] Das Schiffsteil %s vom Typ %s passt in das Schiff %s hinein.", $this->__toString(), $this->getCurrPart()->getObjectDescription(), $this->getCurrPart()->__toString(), @@ -143,7 +143,7 @@ class BaseSimulator extends BaseFrameworkSystem { // Passt dies nun immer noch? if ($this->isNewSizeValid()) { // Das passt auch, dann Werte setzen und Motor-Instanz merken - if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Das Schiffsteil %s passt in das Schiff %s hinein.", + if (defined('DEBUG_CORE')) $this->debugOutput(sprintf("[%s:] Das Schiffsteil %s passt in das Schiff %s hinein.", $this->__toString(), $this->getObjectDescription(), $this->currShip->getShipName() @@ -172,7 +172,7 @@ class BaseSimulator extends BaseFrameworkSystem { // Existiert ein Schiffsteil? if (!is_null($this->currPart)) { // Debug-Meldung ausgeben - if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Schiffsteil %s gefunden.", + if (defined('DEBUG_CORE')) $this->debugOutput(sprintf("[%s:] Schiffsteil %s gefunden.", $this->getCurrPart()->realClass, $this->getCurrPart()->getObjectDescription() )); diff --git a/application/ship-simu/main/class_Merchant.php b/application/ship-simu/main/class_Merchant.php index 8f23118..52f63c1 100644 --- a/application/ship-simu/main/class_Merchant.php +++ b/application/ship-simu/main/class_Merchant.php @@ -56,7 +56,7 @@ class Merchant extends BaseFrameworkSystem { // Debug message if ((defined('DEBUG_MERCHANT')) || (defined('DEBUG_ALL'))) { - $merchantInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Händler %s wird angelegt und soll sich am %s niederlassen.", + $merchantInstance->debugOutput(sprintf("[%s:%d] Ein Händler %s wird angelegt und soll sich am %s niederlassen.", __CLASS__, __LINE__, $merchantName, @@ -109,7 +109,7 @@ class Merchant extends BaseFrameworkSystem { $price = (float) $price; // Debug message - if ((defined('DEBUG_MERCHANT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Der Händler %s kann nun das Schiffsteil %s "%s" zu %s verkaufen.", + if ((defined('DEBUG_MERCHANT')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Der Händler %s kann nun das Schiffsteil %s "%s" zu %s verkaufen.", __CLASS__, __LINE__, $this->getMerchantName(), diff --git a/application/ship-simu/main/class_WorksContract.php b/application/ship-simu/main/class_WorksContract.php index 9527b23..4a60059 100644 --- a/application/ship-simu/main/class_WorksContract.php +++ b/application/ship-simu/main/class_WorksContract.php @@ -65,7 +65,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { $contractInstance = new WorksContract(); // Debug-Meldung ausgeben - if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $contractInstance->getDebugInstance()->output(sprintf("[%s:%d] Neuer Bauvertrag wird für das Schiff %s mit der %s %s erstellt.", + if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $contractInstance->debugOutput(sprintf("[%s:%d] Neuer Bauvertrag wird für das Schiff %s mit der %s %s erstellt.", __CLASS__, __LINE__, $shipName, @@ -123,7 +123,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { $parentPart = (string) $parentPart; // Debug message - if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiffsteil %s wird zusammen mit dem Konstruktionsteil %s in den Bauvertrag aufgenommen.", + if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiffsteil %s wird zusammen mit dem Konstruktionsteil %s in den Bauvertrag aufgenommen.", __CLASS__, __LINE__, $shipPart, @@ -137,13 +137,13 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { try { $partInstance = ObjectFactory::createObjectByName($shipPart, $dataArray); } catch (DimNotFoundInArrayException $e) { - $this->getDebugInstance()->output(sprintf("[main:] Die %s konnte nicht vervollständigt werden. Grund: %s
", + $this->debugOutput(sprintf("[main:] Die %s konnte nicht vervollständigt werden. Grund: %s
", $this->getShipInstance()->getShipName(), $e->getMessage() )); // Debug message - if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Versuche ein Schiffsteil in den Bauvertrag aufzunehmen.", + if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Versuche ein Schiffsteil in den Bauvertrag aufzunehmen.", __CLASS__, __LINE__ )); @@ -167,7 +167,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { $price = $this->getMerchantInstance()->getPriceFromList($partInstance); // Final debug message - if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] %s kostet %s.", + if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] %s kostet %s.", __CLASS__, __LINE__, $partInstance->getObjectDescription(), @@ -178,7 +178,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { $partInstance->setPrice($price); // Final debug message - if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] %s wurde in den Bauvertrag aufgenommen.", + if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] %s wurde in den Bauvertrag aufgenommen.", __CLASS__, __LINE__, $partInstance->getObjectDescription() @@ -239,7 +239,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { if ((defined('DEBUG_CONTRACT')) || (defined('DEBUG_ALL'))) { if ($partnerInstance->equals($partyInstance)) { // With itself - $this->getDebugInstance()->output(sprintf("[%s:%d] Die %s %s stimmt einem Bauvertrag über das %s %s zu.", + $this->debugOutput(sprintf("[%s:%d] Die %s %s stimmt einem Bauvertrag über das %s %s zu.", __CLASS__, __LINE__, $partnerInstance->getObjectDescription(), @@ -249,7 +249,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract { )); } else { // Other contract party - $this->getDebugInstance()->output(sprintf("[%s:%d] Die %s %s geht mit der %s %s einen Bauvertrag über das %s %s ein.", + $this->debugOutput(sprintf("[%s:%d] Die %s %s geht mit der %s %s einen Bauvertrag über das %s %s ein.", __CLASS__, __LINE__, $partnerInstance->getObjectDescription(), diff --git a/application/ship-simu/main/companies/class_ShippingCompany.php b/application/ship-simu/main/companies/class_ShippingCompany.php index 841be84..a7f12ef 100644 --- a/application/ship-simu/main/companies/class_ShippingCompany.php +++ b/application/ship-simu/main/companies/class_ShippingCompany.php @@ -251,7 +251,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Reedereien Werften bauen lassen public function createShipyardInHarbor($shipyardName, Harbor $harborInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s baut im %s eine Werft %s.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s baut im %s eine Werft %s.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -296,7 +296,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $amount = (int) $amount; // Debug-Meldung ausgeben - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s stellt per Zufall %d neue Mitarbeiter ein.", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s stellt per Zufall %d neue Mitarbeiter ein.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -350,7 +350,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $employee->increaseSalary((mt_rand(7, 14) * 100)); // Are 700 to 1400 EUR for the begin okay? // Debug message - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s stellt den/die Angestellte(n) %s %s ein.", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s stellt den/die Angestellte(n) %s %s ein.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -366,7 +366,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $personellInstance->resetCache(); // Debug-Meldung ausgeben - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat per Zufall %d neue Mitarbeiter eingestellt.", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat per Zufall %d neue Mitarbeiter eingestellt.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -376,7 +376,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Distribute all personells on all shipyards public function distributeAllPersonellOnShipyards () { - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s verteilt alle ihre %d Mitarbeiter auf alle %d Werft(en).", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s verteilt alle ihre %d Mitarbeiter auf alle %d Werft(en).", __CLASS__, __LINE__, $this->getCompanyName(), @@ -430,7 +430,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $total = $this->employeeList->count(); // Debug message - if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat %d Mitarbeiter.", + if ((defined('DEBUG_COMPANY_EMPLOYEE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat %d Mitarbeiter.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -443,7 +443,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Getter for total shipyards public final function getTotalShipyards () { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Für die Reederei %s werden die Anzahl der Werften in allen Häfen ermittelt.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Für die Reederei %s werden die Anzahl der Werften in allen Häfen ermittelt.", __CLASS__, __LINE__, $this->getCompanyName() @@ -459,7 +459,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $total = $this->shipyardList->count(); // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat %d Werft(en).", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat %d Werft(en).", __CLASS__, __LINE__, $this->getCompanyName(), @@ -488,7 +488,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner )); // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s baut in allen Werften bald Schiffe vom Typ %s.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s baut in allen Werften bald Schiffe vom Typ %s.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -519,7 +519,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Validate the requested ship type with the company if they can construct it public function validateWorksContractShipType (SignableContract $contractInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s prüft den Bauauftrag der %s.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s prüft den Bauauftrag der %s.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -542,7 +542,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $shipType = $shipInstance->__toString(); // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s prüft, ob die %s (Typ:%s) gebaut werden kann.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s prüft, ob die %s (Typ:%s) gebaut werden kann.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -560,7 +560,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $shipType = (string) $shipType; // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s fragt alle Werften ab, ob diese Schiffe vom Typ %s bauen können.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s fragt alle Werften ab, ob diese Schiffe vom Typ %s bauen können.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -595,7 +595,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner } // Debug message - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s hat die Suche nach einer Werft beendet, die Schiffe vom Typ %s bauen kann.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat die Suche nach einer Werft beendet, die Schiffe vom Typ %s bauen kann.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -608,7 +608,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // As a customer the shipping company can add new contracts public function addNewWorksContract (SignableContract $contractInstance) { - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erstellt einen Bauauftrag für ein %s mit dem Namen %s.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s erstellt einen Bauauftrag für ein %s mit dem Namen %s.", __CLASS__, __LINE__, $this->getCompanyName(), @@ -646,7 +646,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Determine if company "signs" own contract (must be done) or with an other party if ($this->equals($partnerInstance)) { // With itself - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s erteilt an sich selbst einen Bauauftrag für das %s "%s".", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s erteilt an sich selbst einen Bauauftrag für das %s "%s".", __CLASS__, __LINE__, $this->getCompanyName(), @@ -655,7 +655,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner )); } else { // Other external company - if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Reederei %s unterzeichnet einen Bauauftrag für das %s "%s" mit der %s.", + if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s unterzeichnet einen Bauauftrag für das %s "%s" mit der %s.", __CLASS__, __LINE__, $this->getCompanyName(), diff --git a/application/ship-simu/main/constructions/harbors/class_Harbor.php b/application/ship-simu/main/constructions/harbors/class_Harbor.php index e168cc4..9cae1be 100644 --- a/application/ship-simu/main/constructions/harbors/class_Harbor.php +++ b/application/ship-simu/main/constructions/harbors/class_Harbor.php @@ -55,18 +55,12 @@ class Harbor extends BaseConstruction { // Hafen-Instanz holen $harborInstance = new Harbor(); - // Debug message - if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $harborInstance->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen %s wird konstruiert.", $harborName)); - // Hafenname setzen $harborInstance->setHarborName($harborName); // Werftliste initialisieren $harborInstance->createshipyardList(); - // Debug-Meldung ausgeben - if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $harborInstance->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen %s ist jetzt fertig gebaut.", $harborName)); - // Instanz zurueckliefern return $harborInstance; } diff --git a/application/ship-simu/main/constructions/yards/class_Shipyard.php b/application/ship-simu/main/constructions/yards/class_Shipyard.php index f003694..474821a 100644 --- a/application/ship-simu/main/constructions/yards/class_Shipyard.php +++ b/application/ship-simu/main/constructions/yards/class_Shipyard.php @@ -81,7 +81,7 @@ class Shipyard extends BaseConstruction { $shipyardInstance = new Shipyard(); // Debug message - if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->getDebugInstance()->output(sprintf("[%s:%d] Eine Werft mit dem Namen %s wird im Hafen %s konstruiert.", + if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->debugOutput(sprintf("[%s:%d] Eine Werft mit dem Namen %s wird im Hafen %s konstruiert.", __CLASS__, __LINE__, $shipyardName, @@ -104,7 +104,7 @@ class Shipyard extends BaseConstruction { $shipyardInstance->removeSystemArray(); // Debug-Meldung - if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->getDebugInstance()->output(sprintf("[%s:%d] Die Werft %s wurde gebaut.", + if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->debugOutput(sprintf("[%s:%d] Die Werft %s wurde gebaut.", __CLASS__, __LINE__, $shipyardName @@ -166,7 +166,7 @@ class Shipyard extends BaseConstruction { $shipType = (string) $shipType; // Debug message - if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft %s kann bald Schiffe vom Typ %s bauen.", + if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft %s kann bald Schiffe vom Typ %s bauen.", __CLASS__, __LINE__, $this->getShipyardName(), @@ -186,7 +186,7 @@ class Shipyard extends BaseConstruction { $shipType = (string) $shipType; // Debug message - if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft %s prüft, ob Schiffe vom Typ %s baubar sind.", + if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft %s prüft, ob Schiffe vom Typ %s baubar sind.", __CLASS__, __LINE__, $this->getShipyardName(), @@ -206,7 +206,7 @@ class Shipyard extends BaseConstruction { } // Debug message - if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft %s hat die Suche nach dem Schiffstyp %s abgeschlossen.", + if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft %s hat die Suche nach dem Schiffstyp %s abgeschlossen.", __CLASS__, __LINE__, $this->getShipyardName(), diff --git a/application/ship-simu/main/drives/motor/class_Motor.php b/application/ship-simu/main/drives/motor/class_Motor.php index e347c06..8f8b61f 100644 --- a/application/ship-simu/main/drives/motor/class_Motor.php +++ b/application/ship-simu/main/drives/motor/class_Motor.php @@ -42,13 +42,6 @@ class Motor extends BaseDrive implements TradeableItem, ConstructableShipPart { // Get new instance $motorInstance = new Motor(); - // Debug message - if ((defined('DEBUG_DRIVE')) || (defined('DEBUG_ALL'))) $motorInstance->getDebugInstance()->output(sprintf("[%s:%d] Motor %s wird gebaut...", - __CLASS__, - __LINE__, - $descr - )); - // Beschreibung und Abmasse setzen $motorInstance->setObjectDescription($descr); $motorInstance->setWidth($w); diff --git a/application/ship-simu/main/parts/maschineroom/class_MaschineRoom.php b/application/ship-simu/main/parts/maschineroom/class_MaschineRoom.php index f1fc00b..d332c5f 100644 --- a/application/ship-simu/main/parts/maschineroom/class_MaschineRoom.php +++ b/application/ship-simu/main/parts/maschineroom/class_MaschineRoom.php @@ -42,12 +42,6 @@ class MaschineRoom extends BaseShipPart { // Get new instance $roomInstance = new MaschineRoom(); - // Debug message - if ((defined('DEBUG_MODE')) || (defined('DEBUG_ALL'))) $roomInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Maschinenraum wird konstruiert.", - __CLASS__, - __LINE__ - )); - // Umrechnungsfaktoren setzen $roomInstance->setResizeFactorElement('width' , 1.3); $roomInstance->setResizeFactorElement('height', 1.8); diff --git a/application/ship-simu/main/personell/class_SimulatorPersonell.php b/application/ship-simu/main/personell/class_SimulatorPersonell.php index 86b1ba0..1021c56 100644 --- a/application/ship-simu/main/personell/class_SimulatorPersonell.php +++ b/application/ship-simu/main/personell/class_SimulatorPersonell.php @@ -82,7 +82,7 @@ class SimulatorPersonell extends BasePersonell { $personellInstance = new SimulatorPersonell(); // Debug message - if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] Es werden %d Personal bereitgestellt.", + if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->debugOutput(sprintf("[%s:%d] Es werden %d Personal bereitgestellt.", __CLASS__, __LINE__, $amountPersonell @@ -97,7 +97,7 @@ class SimulatorPersonell extends BasePersonell { } // Debug message - if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] %d Personal bereitgestellt.", + if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->debugOutput(sprintf("[%s:%d] %d Personal bereitgestellt.", __CLASS__, __LINE__, $amountPersonell @@ -226,7 +226,7 @@ class SimulatorPersonell extends BasePersonell { // The same (last) conditions? if (($serialized == $this->cacheCond) && (!is_null($this->cacheCond))) { - if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Gecachte Liste wird verwendet.", + if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Gecachte Liste wird verwendet.", __CLASS__, __LINE__ )); @@ -236,7 +236,7 @@ class SimulatorPersonell extends BasePersonell { } // Output debug message - if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Personalliste wird nach Kriterien durchsucht...", + if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Personalliste wird nach Kriterien durchsucht...", __CLASS__, __LINE__ )); diff --git a/application/ship-simu/main/personell/company/class_CompanyEmployee.php b/application/ship-simu/main/personell/company/class_CompanyEmployee.php index 2fc0961..32d2abe 100644 --- a/application/ship-simu/main/personell/company/class_CompanyEmployee.php +++ b/application/ship-simu/main/personell/company/class_CompanyEmployee.php @@ -47,7 +47,7 @@ class CompanyEmployee extends SimulatorPersonell { // Debug message if (((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) { - $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] Der/Die Angestellte %s %s wird angelegt.", + $personellInstance->debugOutput(sprintf("[%s:%d] Der/Die Angestellte %s %s wird angelegt.", __CLASS__, __LINE__, $surname, diff --git a/application/ship-simu/main/ships/class_BaseShip.php b/application/ship-simu/main/ships/class_BaseShip.php index 36863fe..51f1559 100644 --- a/application/ship-simu/main/ships/class_BaseShip.php +++ b/application/ship-simu/main/ships/class_BaseShip.php @@ -62,7 +62,7 @@ class BaseShip extends BaseSimulator { // buildInstance = Das was in das Schiffsteil evtl. eingebaut werden soll (null = kein besonderes Teil einbauen!) // partClass = Das zu konstruierende Schiffsteil public function createShipPart (ConstructableShipPart $buildInstance, $partClass) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s erhält ein neues Schiffsteil (%s).", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s erhält ein neues Schiffsteil (%s).", __CLASS__, __LINE__, $this->getShipName(), @@ -82,7 +82,7 @@ class BaseShip extends BaseSimulator { try { $partInstance->addShipPartToShip($this, $buildInstance); } catch (MotorShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keinen Motor erhalten! Grund: %s", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keinen Motor erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -90,7 +90,7 @@ class BaseShip extends BaseSimulator { )); return false; } catch (RoomShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keinen Maschinenraum erhalten! Grund: %s", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keinen Maschinenraum erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -99,7 +99,7 @@ class BaseShip extends BaseSimulator { return false; } catch (StructureShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keine Aufbauten erhalten! Grund: %s", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keine Aufbauten erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -107,7 +107,7 @@ class BaseShip extends BaseSimulator { )); return false; } catch (CabinShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat keine Kabine erhalten! Grund: %s", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat keine Kabine erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -115,7 +115,7 @@ class BaseShip extends BaseSimulator { )); return false; } catch (DeckShipMismatchException $e) { - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat kein Deck erhalten! Grund: %s", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat kein Deck erhalten! Grund: %s", __CLASS__, __LINE__, $this->getShipName(), @@ -128,7 +128,7 @@ class BaseShip extends BaseSimulator { $this->structures->append($partInstance); // Debug-Meldung ausgeben - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Schiff %s hat das Schiffsteil %s eingebaut bekommen.", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff %s hat das Schiffsteil %s eingebaut bekommen.", __CLASS__, __LINE__, $this->getShipName(), diff --git a/application/ship-simu/main/ships/passenger/class_PassengerShip.php b/application/ship-simu/main/ships/passenger/class_PassengerShip.php index af742b3..4e8b130 100644 --- a/application/ship-simu/main/ships/passenger/class_PassengerShip.php +++ b/application/ship-simu/main/ships/passenger/class_PassengerShip.php @@ -45,7 +45,7 @@ class PassengerShip extends BaseShip implements ConstructableShip { // Debug message if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) { - $passInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.", + $passInstance->debugOutput(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.", __CLASS__, __LINE__ )); @@ -93,7 +93,7 @@ class PassengerShip extends BaseShip implements ConstructableShip { } // Debug-Meldung ausgeben - $this->getDebugInstance()->output(sprintf("[%s:%d] Es stehen %d Betten vom Kabinen-Typ %s bereit.", + $this->debugOutput(sprintf("[%s:%d] Es stehen %d Betten vom Kabinen-Typ %s bereit.", __CLASS__, __LINE__, $total, @@ -102,7 +102,7 @@ class PassengerShip extends BaseShip implements ConstructableShip { } } else { // Keine Kabine! - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] %s ist keine Kabine.", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] %s ist keine Kabine.", __CLASS__, __LINE__, $el->getObjectDescription() @@ -110,7 +110,7 @@ class PassengerShip extends BaseShip implements ConstructableShip { } } // END - for - if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das %s mit dem Namen %s hat %d Betten.", + if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das %s mit dem Namen %s hat %d Betten.", __CLASS__, __LINE__, $this->getObjectDescription(), diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php index ea295b7..0951622 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php @@ -42,12 +42,6 @@ class EconomyCabin extends BaseCabin implements TradeableItem, ConstructableShip // Get new instance $ecoInstance = new EconomyCabin(); - // Debug message - if ((defined('DEBUG_CABIN')) || (defined('DEBUG_ALL'))) $ecoInstance->getDebugInstance()->output(sprintf("[%s:%d] Eine Economy-Class-Kabine wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse extrahieren $ecoInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php index eb15261..3678828 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php @@ -42,12 +42,6 @@ class LowCabin extends BaseCabin implements TradeableItem, ConstructableShipPart // Get new instance $lowInstance = new LowCabin(); - // Debug message - if ((defined('DEBUG_CABIN')) || (defined('DEBUG_ALL'))) $lowInstance->getDebugInstance()->output(sprintf("[%s:%d] Eine 2-Sterne-Kabine wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse extrahieren $lowInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php index 32dde8e..3f181d8 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php @@ -42,12 +42,6 @@ class LuxuryCabin extends BaseCabin implements TradeableItem, ConstructableShipP // Get new instance $luxuryInstance = new LuxuryCabin(); - // Debug message - if ((defined('DEBUG_CABIN')) || (defined('DEBUG_ALL'))) $luxuryInstance->getDebugInstance()->output(sprintf("[%s:%d] Eine Luxuskabine wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse extrahieren $luxuryInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php index df8e09d..5a06df0 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php @@ -42,9 +42,6 @@ class PremierCabin extends BaseCabin implements TradeableItem, ConstructableShip // Get new instance $premierInstance = new PremierCabin(); - // Debug message - if ((defined('DEBUG_CABIN')) || (defined('DEBUG_ALL'))) $premierInstance->getDebugInstance()->output("[PremierCabin:] Eine Premier-Kabine wird konstruiert..."); - // Abmasse extrahieren $premierInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php b/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php index a184352..d0c0aaa 100644 --- a/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php +++ b/application/ship-simu/main/structures/extended/class_BaseCabinStructure.php @@ -43,7 +43,7 @@ class BaseCabinStructure extends BaseStructure { // Kabine hinzufuegen public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $cabinInstance) { - if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Kabine %s wird für das Schiff %s konstruiert.", + if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Kabine %s wird für das Schiff %s konstruiert.", __CLASS__, __LINE__, $cabinInstance->getObjectDescription(), @@ -67,7 +67,7 @@ class BaseCabinStructure extends BaseStructure { $this->setDeckInstance($cabinInstance); // Einbaut-Meldung ausgeben - if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Kabine %s wurde in das Schiff eingebaut.", + if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Kabine %s wurde in das Schiff eingebaut.", __CLASS__, __LINE__, $cabinInstance->getObjectDescription(), @@ -136,7 +136,7 @@ class BaseCabinStructure extends BaseStructure { } // Debug-Meldung ausgeben - $this->getDebugInstance()->output(sprintf("[%s:%d] Es exisitieren %d Kabinen vom Typ %s zu je %d Betten. Das sind %d Betten.", + $this->debugOutput(sprintf("[%s:%d] Es exisitieren %d Kabinen vom Typ %s zu je %d Betten. Das sind %d Betten.", __CLASS__, __LINE__, $num, diff --git a/application/ship-simu/main/structures/extended/class_BaseDeckStructure.php b/application/ship-simu/main/structures/extended/class_BaseDeckStructure.php index ce8abb4..371a004 100644 --- a/application/ship-simu/main/structures/extended/class_BaseDeckStructure.php +++ b/application/ship-simu/main/structures/extended/class_BaseDeckStructure.php @@ -36,7 +36,7 @@ class BaseDeckStructure extends BaseStructure { // Deckstruktur dem Schiff hinzufuegen public function addShipPartToShip (ConstructableShip $shipInstance, ConstructableShipPart $deckInstance) { - if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Deck %s wird für das Schiff %s konstruiert.", + if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Deck %s wird für das Schiff %s konstruiert.", __CLASS__, __LINE__, $deckInstance->getObjectDescription(), @@ -50,7 +50,7 @@ class BaseDeckStructure extends BaseStructure { $this->setNumDecks($deckInstance->getNumDecks()); $deckInstance->removeNumDecks(); - if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Das Deck %s wurde in das Schiff %s eingebaut.", + if ((defined('DEBUG_STRUCTURE')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Deck %s wurde in das Schiff %s eingebaut.", __CLASS__, __LINE__, $deckInstance->getObjectDescription(), diff --git a/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php b/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php index f2966f9..4f7163d 100644 --- a/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php +++ b/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php @@ -42,12 +42,6 @@ class CarDeck extends BaseDeck implements TradeableItem, ConstructableShipPart { // Get new instance $carInstance = new CarDeck(); - // Debug message - if ((defined('DEBUG_DECK')) || (defined('DEBUG_ALL'))) $carInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein Autodeck wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse extrahieren $carInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php b/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php index d5d6eaa..5fb92eb 100644 --- a/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php +++ b/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php @@ -42,12 +42,6 @@ class TrainDeck extends BaseDeck implements TradeableItem, ConstructableShipPart // Get new instance $trainInstance = new TrainDeck(); - // Debug message - if ((defined('DEBUG_DECK')) || (defined('DEBUG_ALL'))) $trainInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein LKW-Deck wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse extrahieren $trainInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php b/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php index acace1e..75e342e 100644 --- a/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php +++ b/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php @@ -43,12 +43,6 @@ class TruckDeck extends BaseDeck implements TradeableItem, ConstructableShipPart // Get new instance $truckInstance = new TruckDeck(); - // Debug message - if ((defined('DEBUG_DECK')) || (defined('DEBUG_ALL'))) $truckInstance->getDebugInstance()->output(sprintf("[%s:%d] Ein LKW-Deck wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse extrahieren $truckInstance->extractDimensions($dim); diff --git a/application/ship-simu/main/structures/extended/upper/class_Bridge.php b/application/ship-simu/main/structures/extended/upper/class_Bridge.php index 7516c66..ae3ca7d 100644 --- a/application/ship-simu/main/structures/extended/upper/class_Bridge.php +++ b/application/ship-simu/main/structures/extended/upper/class_Bridge.php @@ -43,12 +43,6 @@ class Bridge extends BaseUpperStructure implements TradeableItem, ConstructableS // Get new instance $bridgeInstance = new Bridge(); - // Debug message - if ((defined('DEBUG_MODE')) || (defined('DEBUG_ALL'))) $bridgeInstance->getDebugInstance()->output(sprintf("[%s:%d] Eine Brücke wird konstruiert...", - __CLASS__, - __LINE__ - )); - // Abmasse setzen $bridgeInstance->setWidth($width); $bridgeInstance->setHeight($height); diff --git a/application/ship-simu/templates/de/code/mail_debug.ctp b/application/ship-simu/templates/de/code/mail_debug.ctp new file mode 100644 index 0000000..e62dd07 --- /dev/null +++ b/application/ship-simu/templates/de/code/mail_debug.ctp @@ -0,0 +1,25 @@ +
+ Mail-Debug-Ausgabe: +
+ +
+
+ Von: {?sender?} +
+
+ An: {?recipient?} +
+
+ Betreff: {?subject?} +
+
+ +
+
+ Nachricht: +
+ +
+ {?message?} +
+
diff --git a/application/ship-simu/templates/de/emails/text_resend_link.tpl b/application/ship-simu/templates/de/emails/text_resend_link.tpl index aae1ddc..4451ec1 100644 --- a/application/ship-simu/templates/de/emails/text_resend_link.tpl +++ b/application/ship-simu/templates/de/emails/text_resend_link.tpl @@ -1,6 +1,10 @@ - - - + + + + + + + - - - html_entity_decode - - + + + diff --git a/application/ship-simu/templates/images/de/image/base_code.itp b/application/ship-simu/templates/images/de/image/base_code.itp index ecba6c9..6501b56 100644 --- a/application/ship-simu/templates/images/de/image/base_code.itp +++ b/application/ship-simu/templates/images/de/image/base_code.itp @@ -1,3 +1,4 @@ + diff --git a/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php b/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php index 0733edf..848d542 100644 --- a/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php +++ b/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php @@ -34,8 +34,8 @@ class XmlNodeMismatchException extends FrameworkException { $message = sprintf("[%s:%d] XML nodes mismatch. Given: %s, Expected: %s", $classArray[0]->__toString(), $this->getLine(), - $lassArray[1], - $lassArray[2] + $classArray[1], + $classArray[2] ); // Call parent exception constructor diff --git a/inc/classes/interfaces/class_FrameworkInterface.php b/inc/classes/interfaces/class_FrameworkInterface.php index 2b7246d..8d808b4 100644 --- a/inc/classes/interfaces/class_FrameworkInterface.php +++ b/inc/classes/interfaces/class_FrameworkInterface.php @@ -23,6 +23,24 @@ * along with this program. If not, see . */ interface FrameworkInterface { + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + * @throws NullPointerException If the result instance is null + */ + function getField ($fieldName); + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @throws DatabaseUpdateSupportException If this class does not support database updates + */ + function updateDatabaseField ($fieldName, $fieldValue); } // diff --git a/inc/classes/interfaces/mailer/class_DeliverableMail.php b/inc/classes/interfaces/mailer/class_DeliverableMail.php index 34a5508..675254d 100644 --- a/inc/classes/interfaces/mailer/class_DeliverableMail.php +++ b/inc/classes/interfaces/mailer/class_DeliverableMail.php @@ -22,14 +22,6 @@ * along with this program. If not, see . */ interface DeliverableMail extends FrameworkInterface { - /** - * Loads a text or HTML template depending on configuration into the template engine - * - * @param $templateName Name of the template we shall load - * @return void - */ - function loadTemplate ($templateName); - /** * Adds a user class to the recipient list for current template * @@ -50,14 +42,14 @@ interface DeliverableMail extends FrameworkInterface { * * @return void */ - function deliverEmail(); + function deliverEmail (); /** * Send notification to the admin * * @return void */ - function sendAdminNotification(); + function sendAdminNotification (); } // diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index ad7bfaf..4a6eb89 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -218,7 +218,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->resetUniqueID(); } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { // Already destructed object - $this->getDebugInstance()->output(sprintf("[%s:] The object %s is already destroyed.", + $this->debugOutput(sprintf("[%s:] The object %s is already destroyed.", __CLASS__, $this->__toString() )); } @@ -285,7 +285,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // Output stub message - $this->getDebugInstance()->output(sprintf("[%s->%s] Stub! Args: %s", + $this->debugOutput(sprintf("[%s->%s] Stub! Args: %s", $this->__toString(), $methodName, $argsString @@ -956,8 +956,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (is_null($appInstance)) { // Thrown an exception throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } - } + } // END - if + } // END - if // Generate FQFN for all application templates $fqfn = sprintf("%s%s/%s/%s", @@ -989,13 +989,20 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public final function debugInstance () { + // Restore the error handler to avoid trouble with missing array elements or undeclared variables + restore_error_handler(); + // Generate the output $content = sprintf("
%s
", - trim(print_r($this, true)) + trim( + htmlentities( + print_r($this, true) + ) + ) ); // Output it - ApplicationEntryPoint::app_die(sprintf("%s debug output:
%s
Loaded includes:
%s
", + ApplicationEntryPoint::app_die(sprintf("%s debug output:
%s
\nLoaded includes:
%s
", $this->__toString(), $content, ClassLoader::getInstance()->getPrintableIncludeList() @@ -1016,7 +1023,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $methodName = "UnknownClass->unknownMethod"; if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { $methodName = $backtrace[1]['class']."->".$backtrace[1]['function']; - } + } // END - if // Construct the full message $stubMessage = sprintf("[%s:] Partial stub!", @@ -1027,12 +1034,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!empty($message)) { // Then add it as well $stubMessage .= sprintf(" Message: %s", $message); - } + } // END - if // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - $this->getDebugInstance()->output($stubMessage); + $this->debugOutput($stubMessage); } else { // Trigger an error trigger_error($stubMessage."
\n"); @@ -1056,10 +1063,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * Outputs a debug message wether to debug instance (should be set!) or dies with or pints the message * * @param $message Message we shall send out... - * @param $doPrint Wether we shall print or die here which last is the default + * @param $doPrint Wether we shall print or die here which first is the default * @return void */ - public function debugOutput ($message, $doPrint = false) { + public function debugOutput ($message, $doPrint = true) { // Get debug instance $debugInstance = $this->getDebugInstance(); @@ -1070,10 +1077,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$doPrint) die(); // Die here if not printed } else { // Put directly out - // DO NOT REWRITE THIS TO app_die() !!! if ($doPrint) { print($message); } else { + // DO NOT REWRITE THIS TO app_die() !!! die($message); } } diff --git a/inc/classes/main/commands/web/class_WebResendLinkCommand.php b/inc/classes/main/commands/web/class_WebResendLinkCommand.php index 9ff8050..fda4669 100644 --- a/inc/classes/main/commands/web/class_WebResendLinkCommand.php +++ b/inc/classes/main/commands/web/class_WebResendLinkCommand.php @@ -76,18 +76,9 @@ class WebResendLinkCommand extends BaseCommand implements Commandable { throw new InvalidInterfaceException(array($userInstance, 'ManageableUser'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING); } // END - if - // Get template instance - $templateInstance = $responseInstance->getTemplateInstance(); - // Get an application instance $appInstance = $this->getResolverInstance()->getApplicationInstance(); - // Assign the application data with the template engine - $templateInstance->assignApplicationData($appInstance); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - // Get a RNG instance (Random Number Generator) $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); @@ -101,19 +92,34 @@ class WebResendLinkCommand extends BaseCommand implements Commandable { $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString)); // Update the user class - $userInstance->updateDatabaseField('confirm_hash', $hashedString); + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString); + + // Re-set config entry to mailer engine + $this->getConfigInstance()->setConfigEntry('template_class', $this->getConfigInstance()->readConfig('mail_template_class')); - // Assign the hash with a template variable - $templateInstance->assignVariable('confirm_hash', $hashedString); + // Prepare the template engine + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign the application data with the template engine + $templateInstance->assignApplicationData($appInstance); // Get a mailer class - $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance)); + $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $appInstance, 'resend_link')); - // Load the mail template - $mailerInstance->loadTemplate('resend_link'); + // Set this mailer in our template engine + $templateInstance->setMailerInstance($mailerInstance); - // Get a user instance from registry - $userInstance = Registry::getRegistry()->getInstance('user'); + // Add template variables we shall get + $mailerInstance->addConfigTemplateVariable('base_url'); + $mailerInstance->addConfigTemplateVariable('admin_email'); + $mailerInstance->addValueTemplateVariable('confirm_hash'); + $mailerInstance->addValueTemplateVariable('username'); + $mailerInstance->addValueTemplateVariable('email'); + + // Add the value instance for the confirmation hash + $mailerInstance->addValueInstance('confirm_hash', $userInstance); + $mailerInstance->addValueInstance('username', $userInstance); + $mailerInstance->addValueInstance('email', $userInstance); // Add the recipient $mailerInstance->addRecipientByUserInstance($userInstance); @@ -122,10 +128,10 @@ class WebResendLinkCommand extends BaseCommand implements Commandable { $mailerInstance->useSubjectFromTemplate(); // Send the email out - $mailerInstance->deliverEmail(); + $mailerInstance->deliverEmail($responseInstance); // Send out notification to admin (depends on settings) - $mailerInstance->sendAdminNotification(); + $mailerInstance->sendAdminNotification($responseInstance); } /** diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php index 26c956b..80433e3 100644 --- a/inc/classes/main/console/class_ConsoleTools.php +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -56,7 +56,7 @@ class ConsoleTools extends BaseFrameworkSystem { // Read the file $hostname = trim($io->readFromFile()); - $helper->getDebugInstance()->output(sprintf("[%s:] Our host name is: %s", + $helper->debugOutput(sprintf("[%s:] Our host name is: %s", $helper->__toString(), $hostname )); @@ -71,7 +71,7 @@ class ConsoleTools extends BaseFrameworkSystem { $ip = $ipResolved; // Debug message - $helper->getDebugInstance()->output(sprintf("[%s:] Resolved IP address is: %s\n", + $helper->debugOutput(sprintf("[%s:] Resolved IP address is: %s\n", $helper->__toString(), $ip )); diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index 9b480db..62c7d88 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -26,8 +26,9 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; // Constants for database columns - const DB_COLUMN_USERNAME = "username"; - const DB_COLUMN_EMAIL = "email"; + const DB_COLUMN_USERNAME = "username"; + const DB_COLUMN_EMAIL = "email"; + const DB_COLUMN_CONFIRM_HASH = "confirm_hash"; // Constants for database table names const DB_TABLE_USER = "user"; diff --git a/inc/classes/main/helper/captcha/images/class_ImageHelper.php b/inc/classes/main/helper/captcha/images/class_ImageHelper.php index 0f5af54..a29f5a1 100644 --- a/inc/classes/main/helper/captcha/images/class_ImageHelper.php +++ b/inc/classes/main/helper/captcha/images/class_ImageHelper.php @@ -368,7 +368,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { $templateInstance->assignVariable('image_fg_blue' , $this->foregroundColor['blue']); // Add all strings - foreach ($this->imageStrings as $id=>$imageString) { + foreach ($this->imageStrings as $id => $imageString) { // Set current string id to keep this helper in sync with template engine $this->currString = $id; @@ -386,7 +386,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { $imageContent = $templateInstance->getRawTemplateData(); // Transfer all to the template engine - $templateInstance->renderImageContent($imageContent); + $templateInstance->renderXmlContent($imageContent); } } diff --git a/inc/classes/main/mailer/class_BaseMailer.php b/inc/classes/main/mailer/class_BaseMailer.php index 3685bf7..2dcbd93 100644 --- a/inc/classes/main/mailer/class_BaseMailer.php +++ b/inc/classes/main/mailer/class_BaseMailer.php @@ -53,7 +53,7 @@ class BaseMailer extends BaseFrameworkSystem { * @param $templateName Name of the template we shall load * @return void */ - public function loadTemplate ($templateName) { + protected final function loadTemplate ($templateName) { // Set template name $this->setTemplateName($templateName); @@ -77,11 +77,66 @@ class BaseMailer extends BaseFrameworkSystem { // Is the list initialized? if (!isset($this->recipientList[$templateName]['recipients'])) { // Then initialize it here - $this->recipientList[$templateName]['recipients'] = new FrameworkArrayObject("FakedRecipientList"); + $this->recipientList[$templateName]['recipients'] = array(); } // END - if // Add it as a recipient - $this->recipientList[$templateName]['recipients']->append($userInstance); + $this->recipientList[$templateName]['recipients'][] = $userInstance; + } + + /** + * Adds a template variable (just the name) to the recipient list in given section of current template + * + * @param $section Section can be "config" or "value" currently + * @param $variableName Template variable name to add + * @return void + */ + private final function addTemplateVariable ($section, $variableName) { + // Get template name + $templateName = $this->getTemplateName(); + + // Generate full section name + $sectionName = $section . '_vars'; + + // Is the list initialized? + if (!isset($this->recipientList[$templateName][$sectionName])) { + // Then initialize it here + $this->recipientList[$templateName][$sectionName] = array(); + } // END - if + + // Add the variable to the list + $this->recipientList[$templateName][$sectionName][$variableName] = 'OK'; + } + + /** + * Adds a config template variable to the recipient list of current template + * + * @param $variableName Template variable name to add + * @return void + */ + public final function addConfigTemplateVariable ($variableName) { + $this->addTemplateVariable("config", $variableName); + } + + /** + * Adds a "value" template variable to the recipient list of current template + * + * @param $variableName Template variable name to add + * @return void + */ + public final function addValueTemplateVariable ($variableName) { + $this->addTemplateVariable("value", $variableName); + } + + /** + * Adds a value instance for a given variable name. It should be set! + * + * @param $variableName Template variable we want to assign a value instance + * @param $valueInstance An object instance which can provide "field values" + * @return void + */ + public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) { + $this->recipientList[$this->getTemplateName()]['values'][$variableName] = $valueInstance; } /** @@ -90,7 +145,7 @@ class BaseMailer extends BaseFrameworkSystem { * @param $templateName Name of email template * @return void */ - protected final function setTemplateName ($templateName) { + public final function setTemplateName ($templateName) { $this->templateName = (string) $templateName; } @@ -144,6 +199,15 @@ class BaseMailer extends BaseFrameworkSystem { // Set the subject line $this->setSubjectLine("{?subject?}"); } + + /** + * Getter for recipient list array + * + * @return $recipientList Array with reciepients + */ + public final function getRecipientList () { + return $this->recipientList; + } } // [EOF] diff --git a/inc/classes/main/mailer/debug/class_DebugMailer.php b/inc/classes/main/mailer/debug/class_DebugMailer.php index ee6f3ee..6a93267 100644 --- a/inc/classes/main/mailer/debug/class_DebugMailer.php +++ b/inc/classes/main/mailer/debug/class_DebugMailer.php @@ -43,15 +43,23 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * Creates an instance of this mailer class * * @param $templateInstance A template instance + * @param $appInstance An application helper class + * @param $templateName Name of email template to set * @return $mailerInstance An instance of this mailer class */ - public final static function createDebugMailer (CompileableTemplate $templateInstance) { + public final static function createDebugMailer (CompileableTemplate $templateInstance, ManageableApplication $appInstance, $templateName) { // Get a new instance $mailerInstance = new DebugMailer(); // Set template instance $mailerInstance->setTemplateInstance($templateInstance); + // Set application instance + $mailerInstance->setApplicationInstance($appInstance); + + // Set template name + $mailerInstance->setTemplateName('resend_link'); + // Return the instance return $mailerInstance; } @@ -62,16 +70,109 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * @return void */ public function deliverEmail () { - $this->partialStub(); + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // "Deliver" all emails + foreach ($this->getRecipientList() as $templateName => $recipientList) { + // Walk through all recipients and "sent", or better print, it out + foreach ($recipientList['recipients'] as $recipientInstance) { + // The recipient should be a user instance, right? + if ($recipientInstance instanceof ManageableUser) { + // User class found, so entry is valid, first load the template + $this->loadTemplate($templateName); + + // Set subject line + $templateInstance->assignVariable('subject', $this->getSubjectLine()); + + // Walk through all variables, first config to assign them + foreach ($recipientList['config_vars'] as $variable=>$dummy) { + // Load the config value and set it + $templateInstance->assignConfigVariable($variable); + } // END - if + + // Now do the same with the values but ask the "value instance" instead! + foreach ($recipientList['value_vars'] as $variable=>$dummy) { + // Is the value instance there? + if (!isset($recipientList['values'][$variable])) { + // Throw exception + throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the field from the value instance + $fieldValue = $recipientList['values'][$variable]->getField($variable); + + // Set it in the template engine + $templateInstance->assignVariable($variable, $fieldValue); + } + + // Render the content + $templateInstance->renderXmlContent(); + + // Get responce instance + $responseInstance = $this->getApplicationInstance()->getResponseInstance(); + + // Transfer the data to the response + $this->getTemplateInstance()->transferToResponse($responseInstance); + } else { + // Invalid entry found! + $this->partialStub("Handling of invalid recipient entries not yet finished."); + } + } // END - foreach + } // END - foreach } /** * Send notification to the admin * * @return void + * @todo 0% done */ public function sendAdminNotification () { - $this->partialStub(); + // Unfinished work + } + + /** + * Invokes the mail delivery process which will prepare the output of the message in a code template + * + * @return void + */ + public function invokeMailDelivery () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the compiled message and set it as new template variable + $message = $templateInstance->getCompiledData(); + $templateInstance->assignVariable('message', $message); + + // Load the code template + $templateInstance->loadCodeTemplate('mail_debug'); + + // Compile the template + $templateInstance->compileTemplate(); + + // Assign this template with variable + $templateInstance->assignTemplateWithVariable('mail_debug', 'content'); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the master template + $templateInstance->loadCodeTemplate($this->getApplicationInstance()->getMasterTemplate()); + + // Then compile it again + $templateInstance->compileVariables(); } } diff --git a/inc/classes/main/response/class_ImageResponse.php b/inc/classes/main/response/class_ImageResponse.php index abf3491..7112907 100644 --- a/inc/classes/main/response/class_ImageResponse.php +++ b/inc/classes/main/response/class_ImageResponse.php @@ -216,7 +216,7 @@ class ImageResponse extends BaseFrameworkSystem implements Responseable { $cfg = $this->getConfigInstance(); // Set new template engine - $cfg->setConfigEntry('template_class' , "ImageTemplateEngine"); + $cfg->setConfigEntry('template_class' , $cfg->readConfig('image_template_class')); $cfg->setConfigEntry('raw_template_extension' , ".img"); $cfg->setConfigEntry('code_template_extension', ".itp"); $cfg->setConfigEntry('tpl_base_path' , "templates/images/"); diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 7db635e..4db73b6 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -174,7 +174,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @param $var The variable we are looking for * @return $content Content of the variable or null if not found */ - private function readVariable ($var) { + protected function readVariable ($var) { // First everything is not found $content = null; @@ -232,7 +232,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * * @param $groupName Name of variable group * @param $add Wether add this group - * @return void + * @retur4n void */ public function setVariableGroup ($groupName, $add = true) { // Set group name @@ -461,7 +461,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @param $rawTemplateData The raw data from the template * @return void */ - private final function setRawTemplateData ($rawTemplateData) { + protected final function setRawTemplateData ($rawTemplateData) { // And store it in this class //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($rawTemplateData)." Bytes set.
\n"; //* DEBUG: */ echo $this->currGroup." variables: ".count($this->varStack[$this->currGroup]).", groups=".count($this->varStack)."
\n"; @@ -491,6 +491,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { /** * Getter for compiled templates + * + * @return $compiledData Compiled template data */ public final function getCompiledData () { //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->compiledData)." Bytes read.
\n"; @@ -967,18 +969,12 @@ class BaseTemplateEngine extends BaseFrameworkSystem { ); // This loop does remove the backslashes (\) in PHP parameters - while (strpos($eval, ""))); @@ -1246,6 +1242,47 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Set the code back $this->setRawTemplateData($rawData); } + + /** + * Renders the given XML content + * + * @param $content Valid XML content or if not set the current loaded raw content + * @return void + * @throws XmlParserException If an XML error was found + */ + public final function renderXmlContent ($content = null) { + // Is the content set? + if (is_null($content)) { + // Get current content + $content = $this->getRawTemplateData(); + } // END - if + + // Convert all to UTF8 + $content = recode("html..utf8", $content); + + // Get an XML parser + $xmlParser = xml_parser_create(); + + // Force case-folding to on + xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true); + + // Set object + xml_set_object($xmlParser, $this); + + // Set handler call-backs + xml_set_element_handler($xmlParser, 'startElement', 'endElement'); + xml_set_character_data_handler($xmlParser, 'characterHandler'); + + // Now parse the XML tree + if (!xml_parse($xmlParser, $content)) { + // Error found in XML! + //die("
".htmlentities($content)."
"); + throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR); + } // END - if + + // Free the parser + xml_parser_free($xmlParser); + } } // [EOF] diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php index b47c706..d60f102 100644 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -112,37 +112,6 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl return $tplInstance; } - /** - * Renders the given image content - * - * @param $imageContent A valid XML image content - * @return void - * @throws XmlParserException If an XML error was found - */ - public function renderImageContent ($imageContent) { - // Get an XML parser - $xmlParser = xml_parser_create(); - - // Force case-folding to on - xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true); - - // Set object - xml_set_object($xmlParser, $this); - - // Set handler call-backs - xml_set_element_handler($xmlParser, 'startElement', 'endElement'); - xml_set_character_data_handler($xmlParser, 'characterHandler'); - - // Now parse the XML tree - if (!xml_parse($xmlParser, $imageContent)) { - // Error found in XML! - throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR); - } // END - if - - // Free the parser - xml_parser_free($xmlParser); - } - /** * Handles the start element of an XML resource * @@ -185,16 +154,16 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @return void * @throws XmlNodeMismatchException If current main node mismatches the closing one */ - public function endElement ($resource, $nodeName) { + protected function endElement ($resource, $nodeName) { // Make all lower-case $nodeName = strtolower($nodeName); // Does this match with current main node? //* DEBUG: */ echo "END: >".$nodeName."<
\n"; - if (($nodeName != $this->currMainNode) && (in_array($nodeName, $this->mainNodes))) { + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { // Did not match! - throw new XmlNodeMismatchException (array($this, $nodeName, $this->currMainNode), BaseHelper::EXCEPTION_XML_NODE_MISMATCH); - } elseif (in_array($nodeName, $this->subNodes)) { + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH); + } elseif (in_array($nodeName, $this->getSubNodes())) { // Silently ignore sub nodes return; } @@ -214,7 +183,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @return void * @todo Find something usefull with this! */ - public function characterHandler ($resource, $characters) { + protected function characterHandler ($resource, $characters) { // Trim all spaces away $characters = trim($characters); diff --git a/inc/classes/main/template/mail/.htaccess b/inc/classes/main/template/mail/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/template/mail/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/mail/class_MailTemplateEngine.php b/inc/classes/main/template/mail/class_MailTemplateEngine.php new file mode 100644 index 0000000..84a24f4 --- /dev/null +++ b/inc/classes/main/template/mail/class_MailTemplateEngine.php @@ -0,0 +1,362 @@ + + * @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 . + */ +class MailTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree + */ + private $mainNodes = array("mail-data"); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array("subject-line", "sender-address", "recipient-address", "message"); + + /** + * Mailer instance + */ + private $mailerInstance = null; + + /** + * Current main node + */ + private $currMainNode = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("Mail template engine"); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $basePath The local base path for all templates + * @param $langInstance An instance of LanguageSystem (default) + * @param $ioInstance An instance of FileIoHandler (default, middleware!) + * @return $tplInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $basePath is empty + * @throws InvalidBasePathStringException If $basePath is no string + * @throws BasePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws BasePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createMailTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { + // Get a new instance + $tplInstance = new MailTemplateEngine(); + + // Is the base path valid? + if (empty($basePath)) { + // Base path is empty + throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Get configuration instance + $cfgInstance = FrameworkConfiguration::getInstance(); + + // Set the base path + $tplInstance->setBasePath($basePath); + + // Set the language and IO instances + $tplInstance->setLanguageInstance($langInstance); + $tplInstance->setFileIoInstance($ioInstance); + + // Set template extensions + $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); + $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); + + // Absolute output path for compiled templates + $tplInstance->setCompileOutputPath(PATH . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->currMainNode; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + protected function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'initEmail'; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
\n"; + if (in_array($element, $this->getMainNodes())) { + // Okay, main node found! + $methodName = 'setEmail' . $this->convertToClassName($element); + } elseif (in_array($element, $this->getSubNodes())) { + // Sub node found + $methodName = 'setEmailProperty' . $this->convertToClassName($element); + } elseif ($element != 'text-mail') { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
\n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + protected function endElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
\n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH); + } elseif (in_array($nodeName, $this->getSubNodes())) { + // Silently ignore sub nodes + return; + } + + // Construct method name + $methodName = 'finish' . $this->convertToClassName($nodeName); + + // Call the corresponding method + call_user_func_array(array($this, $methodName), array()); + } + + /** + * Adds the message text to the template engine + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + protected function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + // Add the message now + $this->assignVariable('message', $characters); + } + + /** + * Intializes the mail + * + * @return void + * @todo Add cache creation here + */ + private function initEmail () { + // Unfinished work! + } + + /** + * Setter for mail data node + * + * @return void + * @todo Should we call back the mailer class here? + */ + private function setEmailMailData () { + // Set current main node + $this->currMainNode = 'mail-data'; + } + + /** + * Setter for sender address property + * + * @param $senderAddress Sender address to set in email + * @return void + */ + private function setEmailPropertySenderAddress ($senderAddress) { + // Set the template variable + $this->assignVariable('sender', $senderAddress); + } + + /** + * Setter for recipient address property + * + * @param $recipientAddress Recipient address to set in email + * @return void + */ + private function setEmailPropertyRecipientAddress ($recipientAddress) { + // Set the template variable + $this->assignVariable('recipient', $recipientAddress); + } + + /** + * Setter for subject line property + * + * @param $subjectLine Subject line to set in email + * @return void + */ + private function setEmailPropertySubjectLine ($subjectLine) { + // Set the template variable + $this->assignVariable('subject', $subjectLine); + } + + /** + * Method stub to avoid output + * + * @return void + */ + private function setEmailPropertyMessage () { + // Empty for now + } + + /** + * Gets the template variable "message", stores it back as raw template data + * and compiles all variables so the mail message got prepared for output + * + * @return void + */ + private function finishMailData () { + // Get the message and set it as new raw template data back + $message = $this->readVariable('message'); + $this->setRawTemplateData($message); + + // Get some variables to compile + //$sender = $this->compileRawCode($this->readVariable('sender')); + //$this->assignVariable('sender', $sender); + + // Then compile all variables + $this->compileVariables(); + } + + /** + * Invokes the final mail process + * + * @return void + */ + private function finishTextMail () { + $this->getMailerInstance()->invokeMailDelivery(); + } + + /** + * Getter for image cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the image cache + */ + public function getMailCacheFqfn () { + // Unfinished work! + $fqfn = ""; + $this->debugBackTrace(); + + // Return it + return $fqfn; + } + + /** + * Setter for mailer instance + * + * @param $mailerInstance A mailer instance + * @return void + */ + public final function setMailerInstance (DeliverableMail $mailerInstance) { + $this->mailerInstance = $mailerInstance; + } + + /** + * Getter for mailer instance + * + * @return $mailerInstance A mailer instance + */ + protected final function getMailerInstance () { + return $this->mailerInstance; + } + + /** + * Outputs the mail to the world. This should only the mailer debug class do! + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + $responseInstance->writeToBody($this->getCompiledData()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/user/user/class_User.php b/inc/classes/main/user/user/class_User.php index 8380c85..6b0491d 100644 --- a/inc/classes/main/user/user/class_User.php +++ b/inc/classes/main/user/user/class_User.php @@ -22,7 +22,7 @@ * along with this program. If not, see . */ class User extends BaseUser implements ManageableUser, Registerable, Updateable { - // Exceptions + // Exception constances const EXCEPTION_USERNAME_NOT_FOUND = 0x150; const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151; const EXCEPTION_USER_PASS_MISMATCH = 0x152; diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 25125e5..74c9416 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -301,7 +301,28 @@ class FrameworkConfiguration implements Registerable { // Return it return $fullDomain; } -} // END - class + + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + */ + function getField ($fieldName) { + // Dummy method! + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Dummy method! + } +} // [EOF] ?> diff --git a/templates/images/de/image/base_image.itp b/templates/images/de/image/base_image.itp index ecba6c9..6501b56 100644 --- a/templates/images/de/image/base_image.itp +++ b/templates/images/de/image/base_image.itp @@ -1,3 +1,4 @@ + -- 2.30.2