Exemplo n.º 1
0
 /** send()
  * Description:
  * • This method is called when NewsletterMailer is instanciated
  * • All newsletter, sender and recipient info are ready
  *
  * @return boolean has_invalid email addresses
  */
 public function send()
 {
     // Get newsletter email main template and template body and css by template name
     $oEmailTemplate = new Template('main', array(DIRNAME_TEMPLATES, 'newsletter'));
     $oEmailTemplate->replaceIdentifier('newsletter_template_css', new Template("{$this->oNewsletter->getTemplateName()}.css", array(DIRNAME_TEMPLATES, 'newsletter')));
     // Parse links differently in text
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
     $oEMailContent = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($this->oNewsletter->getNewsletterBody()));
     RichtextUtil::$USE_ABSOLUTE_LINKS = null;
     // Replace add surrounding (body.tmpl) before content if exists. Template needs to contain a newsletter_content identifier
     if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME, "{$this->oNewsletter->getTemplateName()}.body.tmpl")) !== null) {
         $oEmailTemplate->replaceIdentifier('newsletter_content', new Template("{$this->oNewsletter->getTemplateName()}.body", array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME)), null, Template::LEAVE_IDENTIFIERS);
     }
     $oEmailTemplate->replaceIdentifier('newsletter_content', $oEMailContent, null, Template::LEAVE_IDENTIFIERS);
     $oEmailTemplate->replaceIdentifier('subject', $this->oNewsletter->getSubject());
     $oEmailTemplate->replaceIdentifier('language', $this->oNewsletter->getLanguageId());
     $oEmailTemplate->replaceIdentifier('newsletter_link', LinkUtil::absoluteLink($this->oNewsletter->getDisplayLink()));
     $oEmailTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate(null, $this->oNewsletter->getLanguageId()));
     $oEmailTemplate->replaceIdentifier('newsletter_timestamp', time());
     // Process templates with each recipient, depending on whether recipient is object and object of Subscriber or string
     foreach ($this->aRecipients as $mRecipient) {
         $this->sendNewsletter($mRecipient, clone $oEmailTemplate);
     }
     return count($this->aInvalidEmails) === 0;
 }
Exemplo n.º 2
0
 public function __construct($aRequestPath, Page $oJournalPage = null, $aJournalIds = null)
 {
     if ($aRequestPath === false) {
         $this->oJournalPage = $oJournalPage;
         $this->aJournalIds = $aJournalIds;
     } else {
         parent::__construct($aRequestPath);
         Manager::usePath();
         //the “journal” bit
         $this->oJournalPage = PagePeer::getRootPage()->getPageOfType('journal');
         $sLanguageId = Manager::usePath();
         if (LanguagePeer::languageIsActive($sLanguageId)) {
             Session::getSession()->setLanguage($sLanguageId);
         }
     }
     header("Content-Type: application/rss+xml;charset=" . Settings::getSetting('encoding', 'db', 'utf-8'));
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
 }
 private function contentAction()
 {
     $sLanguageId = Manager::usePath();
     $sDocumentationKey = Manager::usePath();
     $sPartKey = Manager::usePath();
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
     if ($sPartKey) {
         $oPart = DocumentationPartQuery::create()->filterByLanguageId($sLanguageId)->filterByKeys($sDocumentationKey, $sPartKey)->findOne();
         if (!$oPart) {
             if ($sPartKey === self::TUTORIAL_KEY) {
                 return TranslationPeer::getString('wns.documentation.video_tutorial', $sLanguageId, "Tutorial");
             }
             return null;
         }
         return RichtextUtil::parseStorageForFrontendOutput($oPart->getBody())->render();
     } else {
         $oDocumentation = DocumentationQuery::create()->filterByLanguageId($sLanguageId)->filterByKey($sDocumentationKey)->findOne();
         if (!$oDocumentation) {
             return null;
         }
         $sHtmlOutput = RichtextUtil::parseStorageForFrontendOutput($oDocumentation->getDescription())->render();
         $aParts = $oDocumentation->getDocumentationPartsOrdered();
         if (count($aParts) > 0) {
             $sHtmlOutput .= '<ul class="documentation_parts">';
             foreach ($aParts as $i => $oPart) {
                 $sHtmlOutput .= TagWriter::quickTag('li', array(), self::addPartLink($oPart));
             }
             $sHtmlOutput .= '</ul>';
         }
         $bDisplayVideo = false;
         if ($bDisplayVideo && $oDocumentation->getYoutubeUrl()) {
             $sHtmlOutput .= $this->embedVideo($oDocumentation->getYoutubeUrl());
         }
         return $sHtmlOutput;
     }
 }