X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fmailer%2Fclass_BaseMailer.php;h=709945e4b44c3f586c35f67c5fd2fbc569d310bb;hp=4230fbc4892e979acd4e0c62608614afffe15325;hb=8f7c53d0f83ff9e3c43761c669b2799bbe20f9f3;hpb=c6d73b0e3246efc824cb98338d4be7ee5bc9f308 diff --git a/inc/classes/main/mailer/class_BaseMailer.php b/inc/classes/main/mailer/class_BaseMailer.php index 4230fbc4..709945e4 100644 --- a/inc/classes/main/mailer/class_BaseMailer.php +++ b/inc/classes/main/mailer/class_BaseMailer.php @@ -2,11 +2,11 @@ /** * A general mailer class for all other mailers * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.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 @@ -22,15 +22,10 @@ * along with this program. If not, see . */ class BaseMailer extends BaseFrameworkSystem { - /** - * Iterateable list of recipients - */ - private $recipientList = array(); - /** * Template name */ - private $templateName = ""; + private $templateName = ''; /** * Protected constructor @@ -41,10 +36,6 @@ class BaseMailer extends BaseFrameworkSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -58,10 +49,12 @@ class BaseMailer extends BaseFrameworkSystem { $this->setTemplateName($templateName); // Get configuration entry - $templatePrefix = $this->getConfigInstance()->readConfig('email_tpl_' . $templateName); + $templatePrefix = $this->getConfigInstance()->getConfigEntry('email_tpl_' . $templateName); // Load this email template - $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName); + // @TODO This needs testing/fixes because the deprecated method + // loadEmailTemplate() has been removed from interface CompileableTemplate. + $this->getTemplateInstance()->loadCodeTemplate($templatePrefix . '_' . $templateName); } /** @@ -75,19 +68,13 @@ class BaseMailer extends BaseFrameworkSystem { $templateName = $this->getTemplateName(); // Is the list initialized? - if (!isset($this->recipientList[$templateName]['recipients'])) { - // Then initialize it here - $this->recipientList[$templateName]['recipients'] = array(); - } // END - if - - // Add it as a recipient - $this->recipientList[$templateName]['recipients'][] = $userInstance; + $this->pushValueToGenericArrayKey('recipients', $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 $section Section can be 'config' or "value" currently * @param $variableName Template variable name to add * @return void */ @@ -99,13 +86,7 @@ class BaseMailer extends BaseFrameworkSystem { $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'; + $this->setGenericArrayElement('recipients', $templateName, $sectionName, $variableName, 'OK'); } /** @@ -115,17 +96,17 @@ class BaseMailer extends BaseFrameworkSystem { * @return void */ public final function addConfigTemplateVariable ($variableName) { - $this->addTemplateVariable("config", $variableName); + $this->addTemplateVariable('config', $variableName); } /** - * Adds a "value" template variable to the recipient list of current template + * 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); + $this->addTemplateVariable('value', $variableName); } /** @@ -136,7 +117,7 @@ class BaseMailer extends BaseFrameworkSystem { * @return void */ public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) { - $this->recipientList[$this->getTemplateName()]['values'][$variableName] = $valueInstance; + $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance); } /** @@ -165,7 +146,7 @@ class BaseMailer extends BaseFrameworkSystem { * @return void */ public final function setSubjectLine ($subjectLine) { - $this->recipientList[$this->getTemplateName()]['subject'] = (string) $subjectLine; + $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'generic', 'subject', $subjectLine); } /** @@ -175,15 +156,15 @@ class BaseMailer extends BaseFrameworkSystem { */ public final function getSubjectLine () { // Default subject is null - $subjectLine = null; + $subjectLine = NULL; // Get template name $templateName = $this->getTemplateName(); // Does the subject line exist? - if ((!empty($templateName)) && (isset($this->recipientList[$templateName]['subject']))) { + if ((!empty($templateName)) && ($this->isGenericArrayElementSet('recipients', $templateName, 'generic', 'subject'))) { // Then use it - $subjectLine = $this->recipientList[$templateName]['subject']; + $subjectLine = $this->getGenericArrayElement('recipients', $templateName, 'generic', 'subject'); } // END - if // Return it @@ -197,7 +178,7 @@ class BaseMailer extends BaseFrameworkSystem { */ public function useSubjectFromTemplate () { // Set the subject line - $this->setSubjectLine("{?subject?}"); + $this->setSubjectLine('{?subject?}'); } /** @@ -206,7 +187,7 @@ class BaseMailer extends BaseFrameworkSystem { * @return $recipientList Array with reciepients */ public final function getRecipientList () { - return $this->recipientList; + return $this->getGenericArray('recipients'); } }