/**
  * Returns the message
  * @return string
  */
 public function getText()
 {
     $strText = $this->objLanguage->sms_text;
     $strText = StringUtil::recursiveReplaceTokensAndTags($strText, $this->arrTokens, StringUtil::NO_TAGS);
     return \Controller::convertRelativeUrls($strText, '', true);
 }
Example #2
0
 /**
  * Generate and return document template
  * @return  string
  */
 protected function generateTemplate(IsotopeProductCollection $objCollection, array $arrTokens)
 {
     $objTemplate = new \Isotope\Template($this->documentTpl);
     $objTemplate->setData($this->arrData);
     $objTemplate->title = \String::parseSimpleTokens($this->documentTitle, $arrTokens);
     $objTemplate->collection = $objCollection;
     // Render the collection
     $objCollectionTemplate = new \Isotope\Template($this->collectionTpl);
     $objCollection->addToTemplate($objCollectionTemplate, array('gallery' => $this->gallery, 'sorting' => $objCollection->getItemsSortingCallable($this->orderCollectionBy)));
     $objTemplate->products = $objCollectionTemplate->parse();
     // Generate template and fix PDF issues, see Contao's ModuleArticle
     $strBuffer = Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), false));
     $strBuffer = html_entity_decode($strBuffer, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']);
     $strBuffer = \Controller::convertRelativeUrls($strBuffer, '', true);
     // Remove form elements and JavaScript links
     $arrSearch = array('@<form.*</form>@Us', '@<a [^>]*href="[^"]*javascript:[^>]+>.*</a>@Us');
     $strBuffer = preg_replace($arrSearch, '', $strBuffer);
     // URL decode image paths (see contao/core#6411)
     // Make image paths absolute
     $strBuffer = preg_replace_callback('@(src=")([^"]+)(")@', function ($args) {
         if (preg_match('@^(http://|https://)@', $args[2])) {
             return $args[2];
         }
         return $args[1] . TL_ROOT . '/' . rawurldecode($args[2]) . $args[3];
     }, $strBuffer);
     // Handle line breaks in preformatted text
     $strBuffer = preg_replace_callback('@(<pre.*</pre>)@Us', 'nl2br_callback', $strBuffer);
     // Default PDF export using TCPDF
     $arrSearch = array('@<span style="text-decoration: ?underline;?">(.*)</span>@Us', '@(<img[^>]+>)@', '@(<div[^>]+block[^>]+>)@', '@[\\n\\r\\t]+@', '@<br( /)?><div class="mod_article@', '@href="([^"]+)(pdf=[0-9]*(&|&amp;)?)([^"]*)"@');
     $arrReplace = array('<u>$1</u>', '<br>$1', '<br>$1', ' ', '<div class="mod_article', 'href="$1$4"');
     $strBuffer = preg_replace($arrSearch, $arrReplace, $strBuffer);
     return $strBuffer;
 }
 /**
  * Returns the html body as a string
  * @return  string
  */
 public function getHtmlBody()
 {
     if ($this->objLanguage->email_mode == 'textAndHtml') {
         $objTemplate = new \FrontendTemplate($this->objMessage->email_template);
         $objTemplate->body = $this->objLanguage->email_html;
         $objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
         // Prevent parseSimpleTokens from stripping important HTML tags
         $GLOBALS['TL_CONFIG']['allowedTags'] .= '<doctype><html><head><meta><style><body>';
         $strHtml = str_replace('<!DOCTYPE', '<DOCTYPE', $objTemplate->parse());
         $strHtml = String::recursiveReplaceTokensAndTags($strHtml, $this->arrTokens);
         $strHtml = \Controller::convertRelativeUrls($strHtml, '', true);
         $strHtml = str_replace('<DOCTYPE', '<!DOCTYPE', $strHtml);
         return $strHtml;
     }
     return '';
 }
Example #4
0
 public function convertRelativeUrls($strContent, $strBase = '', $blnHrefOnly = false)
 {
     return parent::convertRelativeUrls($strContent, $strBase, $blnHrefOnly);
 }