Пример #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;
 }
 private function renderRecentJournalEntryTeaser($mJournalId)
 {
     $oJournalEntry = FrontendJournalEntryQuery::create()->filterByJournalId($mJournalId)->mostRecentFirst()->findOne();
     if ($oJournalEntry === null) {
         return null;
     }
     $oTemplate = $this->constructTemplate('journal_entry_teaser');
     $sHref = LinkUtil::link($oJournalEntry->getLink($this->oJournalPage));
     $oTemplate->replaceIdentifier('title', TagWriter::quickTag('a', array('href' => $sHref), $oJournalEntry->getTitle()));
     $oTemplate->replaceIdentifier('link_to_detail', $sHref);
     $oTemplate->replaceIdentifier('publish_at', $oJournalEntry->getPublishAt('U'));
     $oTemplate->replaceIdentifier('user_name', $oJournalEntry->getUserRelatedByCreatedBy()->getFullName());
     $sTextShort = RichtextUtil::parseStorageForFrontendOutput($oJournalEntry->getTextShort());
     $oTemplate->replaceIdentifier('text_short', $sTextShort);
     $oTemplate->replaceIdentifier('text_short_truncated', StringUtil::truncate(strip_tags($sTextShort), 300));
     return $oTemplate;
 }
Пример #3
0
 public function getRssAttributes($oJournalPage = null, $bIsForRpc = false)
 {
     $aResult = array();
     $aResult['title'] = $this->getTitle();
     $aJournalPageLink = $this->getLink($oJournalPage);
     $aResult['link'] = LinkUtil::absoluteLink(LinkUtil::link($aJournalPageLink, 'FrontendManager'), null, LinkUtil::isSSL());
     if ($bIsForRpc) {
         $aResult['description'] = RichtextUtil::parseStorageForBackendOutput($this->getText())->render();
     } else {
         $aResult['description'] = RichtextUtil::parseStorageForFrontendOutput($this->getText())->render();
     }
     $aResult['author'] = $this->getUserRelatedByCreatedBy()->getEmail() . ' (' . $this->getUserRelatedByCreatedBy()->getFullName() . ')';
     $aTags = TagPeer::tagInstancesForObject($this);
     $aCategories = array();
     foreach ($aTags as $oTag) {
         $aCategories[] = $oTag->getTagName();
     }
     $aResult[$bIsForRpc ? 'categories' : 'category'] = $aCategories;
     if ($aJournalPageLink) {
         $aResult['guid'] = $aResult['link'];
     } else {
         $aResult['guid'] = array('isPermaLink' => 'false', '__content' => $this->getId() . "-" . $this->getJournal()->getId());
     }
     $aResult['pubDate'] = date(DATE_RSS, (int) $this->getCreatedAtTimestamp());
     if ($bIsForRpc) {
         $aResult['dateCreated'] = new xmlrpcval(iso8601_encode((int) $this->getCreatedAtTimestamp()), 'dateTime.iso8601');
         $aResult['date_created_gmt'] = new xmlrpcval(iso8601_encode((int) $this->getCreatedAtTimestamp(), 1), 'dateTime.iso8601');
         $aResult['postid'] = $this->getId();
     } else {
         $aEnclosures = array();
         foreach ($this->getImages() as $oImage) {
             $oDocument = $oImage->getDocument();
             $aEnclosures[] = array('length' => $oDocument->getDataSize(), 'type' => $oDocument->getMimetype(), 'url' => LinkUtil::absoluteLink($oDocument->getLink(), null, LinkUtil::isSSL()));
         }
         $aResult['enclosure'] = $aEnclosures;
     }
     return $aResult;
 }
 /**
  * renderFile()
  * @return string xhtml output
  */
 public function renderFile()
 {
     $oOutput = new XHTMLOutput(XHTMLOutput::SETTING_HTML_4_TRANSITIONAL, true, null, $this->oNewsletter->getLanguageId());
     $oOutput->render();
     $oNewsletterTemplate = new Template('main_display', array(DIRNAME_TEMPLATES, 'newsletter'), false, true);
     $oNewsletterTemplate->replaceIdentifier('newsletter_template_css', new Template("{$this->oNewsletter->getTemplateName()}.css", array(DIRNAME_TEMPLATES, 'newsletter')));
     $oNewsletterContent = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($this->oNewsletter->getNewsletterBody()));
     if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME, "{$this->oNewsletter->getTemplateName()}.body.tmpl")) !== null) {
         $oNewsletterTemplate->replaceIdentifier('newsletter_content', new Template("{$this->oNewsletter->getTemplateName()}.body", array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME)), null, Template::LEAVE_IDENTIFIERS);
     }
     $oNewsletterTemplate->replaceIdentifier('newsletter_content', $oNewsletterContent, null, Template::LEAVE_IDENTIFIERS);
     $oNewsletterTemplate->replaceIdentifier('language', $this->oNewsletter->getLanguageId());
     if ($this->oMailing !== null) {
         $oNewsletterTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate($this->oMailing->getDateSent(null)->getTimestamp(), $this->oNewsletter->getLanguageId()));
         $oNewsletterTemplate->replaceIdentifier('newsletter_timestamp', $this->oMailing->getDateSent(null)->getTimestamp());
     } else {
         $oNewsletterTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate($this->oNewsletter->getCreatedAt(null)->getTimestamp(), $this->oNewsletter->getLanguageId()));
         $oNewsletterTemplate->replaceIdentifier('newsletter_timestamp', $this->oNewsletter->getCreatedAt(null)->getTimestamp());
     }
     $oNewsletterTemplate->replaceIdentifier('recipient', TranslationPeer::getString('wns.newsletter.recipient', $this->oNewsletter->getLanguageId()));
     $oNewsletterTemplate->replaceIdentifier('subject', $this->oNewsletter->getSubject());
     $oNewsletterTemplate->render();
 }
 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;
     }
 }
 private function renderEntry(JournalEntry $oEntry, Template $oEntryTemplate, $bIsAjax = false)
 {
     $oCommentQuery = JournalCommentQuery::create()->excludeUnverified();
     $oEntryTemplate->replaceIdentifier('journal_title', $oEntry->getJournal()->getName());
     $oEntryTemplate->replaceIdentifier('slug', $oEntry->getSlug());
     $oEntryTemplate->replaceIdentifier('name', $oEntry->getSlug());
     $oEntryTemplate->replaceIdentifier('user_name', $oEntry->getUserRelatedByCreatedBy()->getFullName());
     $oEntryTemplate->replaceIdentifier('id', $oEntry->getId());
     $oEntryTemplate->replaceIdentifier('date', LocaleUtil::localizeDate($oEntry->getPublishAtTimestamp()));
     $oEntryTemplate->replaceIdentifier('title', $oEntry->getTitle());
     $oEntryTemplate->replaceIdentifier('comment_count', $oEntry->countJournalComments($oCommentQuery));
     // Manager in link has to be set manually for the case when it's called asynchroneously in preview
     $sDetailLink = LinkUtil::link($oEntry->getLink($this->oPage), $this->bIsPreview ? 'PreviewManager' : 'FrontendManager');
     $oEntryTemplate->replaceIdentifier('link', LinkUtil::absoluteLink($sDetailLink), null, LinkUtil::isSSL());
     $oEntryTemplate->replaceIdentifier('detail_link_title', TranslationPeer::getString('journal_entry.add_comment_title', null, null, array('title' => $oEntry->getTitle())));
     if ($oEntryTemplate->hasIdentifier('text')) {
         $oEntryTemplate->replaceIdentifier('text', RichtextUtil::parseStorageForFrontendOutput($oEntry->getText()));
     }
     if ($oEntryTemplate->hasIdentifier('text_short')) {
         $oEntryTemplate->replaceIdentifier('text_short', RichtextUtil::parseStorageForFrontendOutput($oEntry->getTextShort()));
     }
     if ($this->oEntry !== null && $this->oEntry == $oEntry) {
         $oEntryTemplate->replaceIdentifier('current_class', ' class="current"', null, Template::NO_HTML_ESCAPE);
     }
     if ($oEntryTemplate->hasIdentifier('tags')) {
         $aTagInstances = TagInstanceQuery::create()->filterByModelName('JournalEntry')->filterByTaggedItemId($oEntry->getId())->joinTag()->find();
         foreach ($aTagInstances as $i => $oTagInstance) {
             if ($i > 0) {
                 $oEntryTemplate->replaceIdentifierMultiple('tags', ', ', null, Template::NO_NEWLINE | Template::NO_NEW_CONTEXT);
             }
             $oEntryTemplate->replaceIdentifierMultiple('tags', $oTagInstance->getTag()->getReadableName(), null, Template::NO_NEW_CONTEXT | Template::NO_NEWLINE);
         }
     }
     if ($oEntryTemplate->hasIdentifier('journal_comments')) {
         $oEntryTemplate->replaceIdentifier('journal_comments', $this->renderComments($oEntry->getJournalComments($oCommentQuery), $oEntry, $oEntry === $this->oEntry));
     }
     if ($oEntryTemplate->hasIdentifier('journal_gallery') && $oEntry->countJournalEntryImages() > 0) {
         $oEntryTemplate->replaceIdentifier('journal_gallery', $this->renderGallery($oEntry));
     }
     if ($this->bIsPreview && !$bIsAjax) {
         $oEntryTemplate = TagWriter::quickTag('div', array('class' => 'journal_entry-container filled-container', 'data-entry-id' => $oEntry->getId(), 'data-is-not-shown' => $oEntry->isNotShown(), 'data-template' => $oEntryTemplate->getTemplateName()), $oEntryTemplate);
     }
     return $oEntryTemplate;
 }
 public function renderDetail(Documentation $oDocumentation = null)
 {
     if (self::$DOCUMENTATION_PARTS == null) {
         self::$DOCUMENTATION_PARTS = DocumentationPartQuery::create()->filterByDocumentationId($oDocumentation->getId())->filterByIsPublished(true)->orderBySort()->find();
     }
     if ($oDocumentation) {
         $sName = $oDocumentation->getName();
         $sEmbedUrl = $oDocumentation->getYoutubeUrl();
         $sDescription = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($oDocumentation->getDescription()));
     } else {
         $sName = TranslationPeer::getString('documentations.uncategorized');
         $sEmbedUrl = null;
         $sDescription = null;
     }
     $oTemplate = $this->constructTemplate('documentation');
     // render video if exists
     if ($sEmbedUrl != null) {
         $this->embedVideo($oTemplate, $sEmbedUrl);
     }
     $oTemplate->replaceIdentifier('documentation_name', $sName);
     $oTemplate->replaceIdentifier('description', $sDescription);
     // render parts
     $oPartTmpl = $this->constructTemplate('part');
     $sLinkToSelf = LinkUtil::linkToSelf();
     $bRequiresQuicklinks = count(self::$DOCUMENTATION_PARTS) > 1;
     $oPartLinkPrototype = $this->constructTemplate('part_link');
     foreach (self::$DOCUMENTATION_PARTS as $sKey => $mPart) {
         if ($mPart === true) {
             $mPart = DocumentationPartQuery::create()->filterByKey($sKey)->findOne();
         }
         $bIsOverview = false;
         if ($mPart instanceof DocumentationPart) {
             //Internal documentation
             $sBody = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($mPart->getBody()));
             $sLinkText = $mPart->getName();
             $sTitle = $mPart->getTitle();
             $sImageUrl = null;
             if ($mPart->getDocument()) {
                 $sImageUrl = $mPart->getDocument()->getDisplayUrl();
                 if (RichtextUtil::$USE_ABSOLUTE_LINKS) {
                     $sImageUrl = LinkUtil::absoluteLink($sImageUrl);
                 }
             }
             $sKey = $mPart->getKey();
             $bIsOverview = $mPart->getIsOverview();
             $sExternalLink = null;
         } else {
             //External documentation
             $aData = DocumentationProviderTypeModule::dataForPart($sKey, Session::language());
             $sBody = new Template($aData['content'], null, true);
             $sLinkText = $aData['title'];
             $sTitle = null;
             $sImageUrl = null;
             $sExternalLink = $aData['url'];
         }
         // Add quick links
         if ($bRequiresQuicklinks) {
             $oPartLink = clone $oPartLinkPrototype;
             $oPartLink->replaceIdentifier('href', $sLinkToSelf . '#' . $sKey);
             $oPartLink->replaceIdentifier('link_text', $sLinkText);
             if ($sTitle != null) {
                 $oPartLink->replaceIdentifier('title', $sTitle);
             }
             $oTemplate->replaceIdentifierMultiple('part_links', $oPartLink, null, Template::NO_NEW_CONTEXT);
         }
         // Add documentation part
         $oPartTemplate = clone $oPartTmpl;
         $oPartTemplate->replaceIdentifier('name', $sLinkText);
         $oPartTemplate->replaceIdentifier('anchor', $sKey);
         $oPartTemplate->replaceIdentifier('href_top', $sLinkToSelf . "#top_of_page");
         $oPartTemplate->replaceIdentifier('external_link', $sExternalLink);
         if ($sImageUrl) {
             $oPartTemplate->replaceIdentifier('image', TagWriter::quickTag('img', array('class' => !$bIsOverview ? 'image_float' : "image_fullwidth", 'src' => $sImageUrl, 'alt' => 'Bildschirmfoto von ' . $sLinkText)));
             $oPartTemplate->replaceIdentifier('margin_left_class', $bIsOverview ? '' : ' margin_left_class');
         }
         $oPartTemplate->replaceIdentifier('content', $sBody);
         $oTemplate->replaceIdentifierMultiple('part', $oPartTemplate);
     }
     return $oTemplate;
 }
Пример #8
0
 public static function getContentInfo($oLanguageObject)
 {
     $sText = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($oLanguageObject->getData()));
     return implode(" ", StringUtil::getWords($sText, true));
 }