00001 <?php 00024 class BaseMailer extends BaseFrameworkSystem { 00028 private $recipientList = array(); 00029 00033 private $templateName = ""; 00034 00041 protected function __construct ($className) { 00042 // Call parent constructor 00043 parent::__construct($className); 00044 00045 // Clean up a little 00046 $this->removeNumberFormaters(); 00047 $this->removeSystemArray(); 00048 } 00049 00056 protected final function loadTemplate ($templateName) { 00057 // Set template name 00058 $this->setTemplateName($templateName); 00059 00060 // Get configuration entry 00061 $templatePrefix = $this->getConfigInstance()->readConfig('email_tpl_' . $templateName); 00062 00063 // Load this email template 00064 $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName); 00065 } 00066 00073 public function addRecipientByUserInstance (ManageableMember $userInstance) { 00074 // Get template name 00075 $templateName = $this->getTemplateName(); 00076 00077 // Is the list initialized? 00078 if (!isset($this->recipientList[$templateName]['recipients'])) { 00079 // Then initialize it here 00080 $this->recipientList[$templateName]['recipients'] = array(); 00081 } // END - if 00082 00083 // Add it as a recipient 00084 $this->recipientList[$templateName]['recipients'][] = $userInstance; 00085 } 00086 00094 private final function addTemplateVariable ($section, $variableName) { 00095 // Get template name 00096 $templateName = $this->getTemplateName(); 00097 00098 // Generate full section name 00099 $sectionName = $section . '_vars'; 00100 00101 // Is the list initialized? 00102 if (!isset($this->recipientList[$templateName][$sectionName])) { 00103 // Then initialize it here 00104 $this->recipientList[$templateName][$sectionName] = array(); 00105 } // END - if 00106 00107 // Add the variable to the list 00108 $this->recipientList[$templateName][$sectionName][$variableName] = 'OK'; 00109 } 00110 00117 public final function addConfigTemplateVariable ($variableName) { 00118 $this->addTemplateVariable("config", $variableName); 00119 } 00120 00127 public final function addValueTemplateVariable ($variableName) { 00128 $this->addTemplateVariable("value", $variableName); 00129 } 00130 00138 public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) { 00139 $this->recipientList[$this->getTemplateName()]['values'][$variableName] = $valueInstance; 00140 } 00141 00148 public final function setTemplateName ($templateName) { 00149 $this->templateName = (string) $templateName; 00150 } 00151 00157 protected final function getTemplateName () { 00158 return $this->templateName; 00159 } 00160 00167 public final function setSubjectLine ($subjectLine) { 00168 $this->recipientList[$this->getTemplateName()]['subject'] = (string) $subjectLine; 00169 } 00170 00176 public final function getSubjectLine () { 00177 // Default subject is null 00178 $subjectLine = null; 00179 00180 // Get template name 00181 $templateName = $this->getTemplateName(); 00182 00183 // Does the subject line exist? 00184 if ((!empty($templateName)) && (isset($this->recipientList[$templateName]['subject']))) { 00185 // Then use it 00186 $subjectLine = $this->recipientList[$templateName]['subject']; 00187 } // END - if 00188 00189 // Return it 00190 return $subjectLine; 00191 } 00192 00198 public function useSubjectFromTemplate () { 00199 // Set the subject line 00200 $this->setSubjectLine("{?subject?}"); 00201 } 00202 00208 public final function getRecipientList () { 00209 return $this->recipientList; 00210 } 00211 } 00212 00213 // [EOF] 00214 ?>
1.5.6