Exemplo n.º 1
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::toHtml5($this->text);
     }
     $this->Template->text = \String::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
     $classes = deserialize($this->mooClasses);
     $this->Template->toggler = $classes[0] ?: 'toggler';
     $this->Template->accordion = $classes[1] ?: 'accordion';
     $this->Template->headlineStyle = $this->mooStyle;
     $this->Template->headline = $this->mooHeadline;
 }
Exemplo n.º 2
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::toHtml5($this->text);
     }
     // Add the static files URL to images
     if (TL_FILES_URL != '') {
         $path = $GLOBALS['TL_CONFIG']['uploadPath'] . '/';
         $this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
     }
     $this->Template->text = \String::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         if (!is_numeric($this->singleSRC)) {
             $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } else {
             $objModel = \FilesModel::findByPk($this->singleSRC);
             if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                 $this->singleSRC = $objModel->path;
                 $this->addImageToTemplate($this->Template, $this->arrData);
             }
         }
     }
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     if (TL_MODE == 'FE' && BE_USER_LOGGED_IN) {
         $objNewsletter = \NewsletterModel::findByIdOrAlias(\Input::get('items'));
     } else {
         $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     }
     if ($objNewsletter === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objNewsletter->subject != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
     }
     // Add enclosure
     if ($objNewsletter->addFile) {
         $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
     }
     if (!$objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = '';
         $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
         if ($objContentElements !== null) {
             if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
                 define('NEWSLETTER_CONTENT_PREVIEW', true);
             }
             foreach ($objContentElements as $objContentElement) {
                 $strContent .= $this->getContentElement($objContentElement->id);
             }
         }
         // Parse simple tokens and insert tags
         $strContent = $this->replaceInsertTags($strContent);
         $strContent = \String::parseSimpleTokens($strContent, array());
         // Encode e-mail addresses
         $strContent = \String::encodeEmail($strContent);
         $this->Template->content = $strContent;
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Convert relative URLs
     $strContent = $this->convertRelativeUrls($strContent);
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
 }
Exemplo n.º 4
0
 /**
  * Set Link href.
  *
  * @param Attributes $attributes Link attributes.
  *
  * @return void
  */
 protected function setHref(Attributes $attributes)
 {
     if (substr($this->url, 0, 7) == 'mailto:') {
         $attributes->setAttribute('href', \String::encodeEmail($this->url));
     } else {
         $attributes->setAttribute('href', ampersand($this->url));
     }
 }
Exemplo n.º 5
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
     if ($objFaq === null) {
         $this->Template->faq = array();
         return;
     }
     global $objPage;
     $arrFaq = array_fill_keys($this->faq_categories, array());
     // Add FAQs
     while ($objFaq->next()) {
         $objTemp = (object) $objFaq->row();
         // Clean RTE output
         if ($objPage->outputFormat == 'xhtml') {
             $objFaq->answer = \String::toXhtml($objFaq->answer);
         } else {
             $objFaq->answer = \String::toHtml5($objFaq->answer);
         }
         $objTemp->answer = \String::encodeEmail($objFaq->answer);
         $objTemp->addImage = false;
         // Add an image
         if ($objFaq->addImage && $objFaq->singleSRC != '') {
             if (!is_numeric($objFaq->singleSRC)) {
                 $objTemp->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             } else {
                 $objModel = \FilesModel::findByPk($objFaq->singleSRC);
                 if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                     $objFaq->singleSRC = $objModel->path;
                     $this->addImageToTemplate($objTemp, $objFaq->row());
                 }
             }
         }
         $objTemp->enclosure = array();
         // Add enclosure
         if ($objFaq->addEnclosure) {
             $this->addEnclosuresToTemplate($objTemp, $objFaq->row());
         }
         $objTemp->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name);
         // Order by PID
         $arrFaq[$objFaq->pid]['items'][] = $objTemp;
         $arrFaq[$objFaq->pid]['headline'] = $objFaq->category;
     }
     $arrFaq = array_values(array_filter($arrFaq));
     $limit_i = count($arrFaq) - 1;
     // Add classes first, last, even and odd
     for ($i = 0; $i <= $limit_i; $i++) {
         $class = ($i == 0 ? 'first ' : '') . ($i == $limit_i ? 'last ' : '') . ($i % 2 == 0 ? 'even' : 'odd');
         $arrFaq[$i]['class'] = trim($class);
         $limit_j = count($arrFaq[$i]['items']) - 1;
         for ($j = 0; $j <= $limit_j; $j++) {
             $class = ($j == 0 ? 'first ' : '') . ($j == $limit_j ? 'last ' : '') . ($j % 2 == 0 ? 'even' : 'odd');
             $arrFaq[$i]['items'][$j]->class = trim($class);
         }
     }
     $this->Template->faq = $arrFaq;
     $this->Template->request = $this->getIndexFreeRequest(true);
     $this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop'];
 }
Exemplo n.º 6
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     if (substr($this->url, 0, 7) == 'mailto:') {
         $this->url = \String::encodeEmail($this->url);
     } else {
         $this->url = ampersand($this->url);
     }
     $embed = explode('%s', $this->embed);
     if ($this->linkTitle == '') {
         $this->linkTitle = $this->url;
     }
     // Use an image instead of the title
     if ($this->useImage && $this->singleSRC != '' && is_numeric($this->singleSRC)) {
         $objModel = \FilesModel::findByPk($this->singleSRC);
         if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->Template = new \FrontendTemplate('ce_hyperlink_image');
             $this->Template->setData($this->arrData);
             $objFile = new \File($objModel->path);
             if ($objFile->isGdImage) {
                 $size = deserialize($this->size);
                 $intMaxWidth = TL_MODE == 'BE' ? 320 : $GLOBALS['TL_CONFIG']['maxImageWidth'];
                 // Adjust the image size
                 if ($intMaxWidth > 0 && ($size[0] > $intMaxWidth || !$size[0] && $objFile->width > $intMaxWidth)) {
                     $size[0] = $intMaxWidth;
                     $size[1] = floor($intMaxWidth * $objFile->height / $objFile->width);
                 }
                 $src = \Image::get($objModel->path, $size[0], $size[1], $size[2]);
                 if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) {
                     $this->Template->arrSize = $imgSize;
                     $this->Template->imgSize = ' ' . $imgSize[3];
                 }
                 $this->Template->src = TL_FILES_URL . $src;
                 $this->Template->alt = specialchars($this->alt);
                 $this->Template->linkTitle = specialchars($this->linkTitle);
                 $this->Template->caption = $this->caption;
             }
         }
     }
     if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
         $this->Template->attribute = ' rel="' . $this->rel . '"';
     } else {
         $this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
     }
     $this->Template->rel = $this->rel;
     // Backwards compatibility
     $this->Template->href = $this->url;
     $this->Template->embed_pre = $embed[0];
     $this->Template->embed_post = $embed[1];
     $this->Template->link = $this->linkTitle;
     $this->Template->linkTitle = specialchars($this->linkTitle);
     $this->Template->target = '';
     // Override the link target
     if ($this->target) {
         $this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
 }
Exemplo n.º 7
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     if (substr($this->url, 0, 7) == 'mailto:') {
         $this->url = \String::encodeEmail($this->url);
     } else {
         $this->url = ampersand($this->url);
     }
     $embed = explode('%s', $this->embed);
     if ($this->linkTitle == '') {
         $this->linkTitle = $this->url;
     }
     // Use an image instead of the title
     if ($this->useImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             /** @var \FrontendTemplate|object $objTemplate */
             $objTemplate = new \FrontendTemplate('ce_hyperlink_image');
             $this->Template = $objTemplate;
             $this->Template->setData($this->arrData);
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
             $this->Template->linkTitle = specialchars($this->linkTitle);
         }
     }
     if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
         $this->Template->attribute = ' rel="' . $this->rel . '"';
     } else {
         $this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
     }
     $this->Template->rel = $this->rel;
     // Backwards compatibility
     $this->Template->href = $this->url;
     $this->Template->embed_pre = $embed[0];
     $this->Template->embed_post = $embed[1];
     $this->Template->link = $this->linkTitle;
     $this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
     $this->Template->target = '';
     // Override the link target
     if ($this->target) {
         $this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
     // Unset the title attributes in the back end (see #6258)
     if (TL_MODE == 'BE') {
         $this->Template->title = '';
         $this->Template->linkTitle = '';
     }
 }
Exemplo n.º 8
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     // Accordion start
     if ($this->mooType == 'mooStart') {
         if (TL_MODE == 'FE') {
             $this->strTemplate = 'ce_accordion_start';
             $this->Template = new \FrontendTemplate($this->strTemplate);
             $this->Template->setData($this->arrData);
         } else {
             $this->strTemplate = 'be_wildcard';
             $this->Template = new \BackendTemplate($this->strTemplate);
             $this->Template->title = $this->mooHeadline;
         }
     } elseif ($this->mooType == 'mooStop') {
         if (TL_MODE == 'FE') {
             $this->strTemplate = 'ce_accordion_stop';
             $this->Template = new \FrontendTemplate($this->strTemplate);
             $this->Template->setData($this->arrData);
         } else {
             $this->strTemplate = 'be_wildcard';
             $this->Template = new \BackendTemplate($this->strTemplate);
         }
     } else {
         global $objPage;
         // Clean RTE output
         if ($objPage->outputFormat == 'xhtml') {
             $this->text = \String::toXhtml($this->text);
         } else {
             $this->text = \String::toHtml5($this->text);
         }
         $this->Template->text = \String::encodeEmail($this->text);
         $this->Template->addImage = false;
         // Add an image
         if ($this->addImage && $this->singleSRC != '') {
             if (!is_numeric($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             } else {
                 $objModel = \FilesModel::findByPk($this->singleSRC);
                 if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                     $this->singleSRC = $objModel->path;
                     $this->addImageToTemplate($this->Template, $this->arrData);
                 }
             }
         }
     }
     $classes = deserialize($this->mooClasses);
     $this->Template->toggler = $classes[0] ?: 'toggler';
     $this->Template->accordion = $classes[1] ?: 'accordion';
     $this->Template->headlineStyle = $this->mooStyle;
     $this->Template->headline = $this->mooHeadline;
 }
Exemplo n.º 9
0
 /**
  * Generate module
  */
 protected function compile()
 {
     $GLOBALS['TL_JAVASCRIPT']['googleapis-maps'] = 'https://maps.googleapis.com/maps/api/js?sensor=false&amp;language=' . $GLOBALS['TL_LANGUAGE'];
     $GLOBALS['TL_JAVASCRIPT']['markerclusterer'] = 'system/modules/anyStores/assets/js/markerclusterer.js';
     // get published stores from categories
     $objStores = AnyStoresModel::findPublishedByCategory(deserialize($this->anystores_categories));
     // return if no stores found
     if (!$objStores) {
         return;
     }
     // generate entries
     while ($objStores->next()) {
         // generate jump to
         //@todo copy do AnyStoresModule and extends from it
         if ($this->jumpTo) {
             if (($objLocation = \PageModel::findByPk($this->jumpTo)) !== null) {
                 //@todo language parameter
                 $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
                 $strStoreValue = $objStores->alias;
                 $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
             }
         }
         // unset logo because json_encode drops error:
         // Malformed UTF-8 characters, possibly incorrectly encoded
         //@todo maybe ->loadDetails() fix it
         $objStores->logo = null;
         // encode email
         $objStores->email = \String::encodeEmail($objStores->email);
     }
     // get all stores
     $arrStores = $objStores->fetchAll();
     $this->Template->entries = $arrStores;
     if (!($strJson = json_encode($arrStores))) {
         $this->log(json_last_error_msg(), __METHOD__, TL_ERROR);
         //@todo stop display the broken module
         return;
     }
     // Temporär
     $this->Template->json = $strJson;
     //@todo cleanup
     $path = 'system/modules/anyStores/html/' . $this->id . '-locations.json';
     $this->Template->path = $path;
     //JSON schreiben
     //@todo: Muss noch in tl_storelocator_map zum save_callback verschoben werden!!!
     #$file   =   new \File($path);
     #$file->write($strJson);
     //@todo language
     #$this->log('Neue JSON-Datei erstellt', __METHOD__, TL_FILES);
 }
Exemplo n.º 10
0
 /**
  * Generate the widget and return it as string
  *
  * @return string The widget markup
  */
 public function generate()
 {
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \String::toXhtml($this->text);
     } else {
         $this->text = \String::toHtml5($this->text);
     }
     // Add the static files URL to images
     if (TL_FILES_URL != '') {
         $path = \Config::get('uploadPath') . '/';
         $this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
     }
     return \String::encodeEmail($this->text);
 }
Exemplo n.º 11
0
 /**
  * compile button element, inspired by ContentHyperlink
  */
 protected function compile()
 {
     if ($this->linkTitle == '') {
         $this->linkTitle = $this->url;
     }
     $attributes = new Attributes();
     $attributes->addClass('btn');
     // @See: #6258
     if (TL_MODE != 'BE') {
         $attributes->setAttribute('title', $this->titleText ?: $this->linkTitle);
     }
     if (substr($this->url, 0, 7) == 'mailto:') {
         $attributes->setAttribute('href', \String::encodeEmail($this->url));
     } else {
         $attributes->setAttribute('href', ampersand($this->url));
     }
     if (strncmp($this->rel, 'lightbox', 8) !== 0) {
         $attributes->setAttribute('rel', $this->rel);
     } else {
         $attributes->setAttribute('data-lightbox', substr($this->rel, 9, -1));
     }
     // Override the link target
     if ($this->target) {
         $attributes->setAttribute('target', '_blank');
     }
     if ($this->cssID[1] == '') {
         $attributes->addClass('btn-default');
     } else {
         $attributes->addClass($this->cssID[1]);
     }
     if ($this->icon) {
         $this->Template->icon = Bootstrap::generateIcon($this->bootstrap_icon);
     }
     // add data attributes
     $this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true);
     if (!empty($this->bootstrap_dataAttributes)) {
         foreach ($this->bootstrap_dataAttributes as $attribute) {
             if (trim($attribute['value']) != '' && $attribute['name'] != '') {
                 $attributes->setAttribute('data-' . $attribute['name'], $attribute['value']);
             }
         }
     }
     $this->Template->attributes = $attributes;
     $this->Template->link = $this->linkTitle;
 }
Exemplo n.º 12
0
 /**
  * compile button element, inspired by ContentHyperlink
  */
 protected function compile()
 {
     if (substr($this->url, 0, 7) == 'mailto:') {
         $this->url = \String::encodeEmail($this->url);
     } else {
         $this->url = ampersand($this->url);
     }
     if ($this->linkTitle == '') {
         $this->linkTitle = $this->url;
     }
     if (strncmp($this->rel, 'lightbox', 8) !== 0) {
         $this->Template->attribute = ' rel="' . $this->rel . '"';
     } else {
         $this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
     }
     // Override the link target
     if ($this->target) {
         $this->Template->target = ' target="_blank"';
     }
     if ($this->cssID[1] == '') {
         $cssID = $this->cssID;
         $cssID[1] = 'btn-default';
         $this->cssID = $cssID;
     }
     if ($this->icon) {
         $this->Template->icon = Icons::generateIcon($this->icon);
     }
     // add data attributes
     $this->dataAttributes = deserialize($this->dataAttributes, true);
     if (!empty($this->dataAttributes)) {
         $attributes = array();
         foreach ($this->dataAttributes as $attribute) {
             if (trim($attribute['value']) != '' && $attribute['name'] != '') {
                 $attributes[] = 'data-' . $attribute['name'] . '=' . $attribute['value'];
             }
         }
         $this->Template->attribute = trim($this->attribute . ' ' . implode(' ', $attributes));
     }
     $this->Template->rel = $this->rel;
     // Backwards compatibility
     $this->Template->href = $this->url;
     $this->Template->link = $this->linkTitle;
     $this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
 }
Exemplo n.º 13
0
 /**
  * Replace bbcode and return the HTML string
  *
  * Supports the following tags:
  * - [b][/b] bold
  * - [i][/i] italic
  * - [u][/u] underline
  * - [img][/img]
  * - [code][/code]
  * - [color=#ff0000][/color]
  * - [quote][/quote]
  * - [quote=tim][/quote]
  * - [url][/url]
  * - [url=http://][/url]
  * - [email][/email]
  * - [email=name@example.com][/email]
  * @param string
  * @return string
  */
 public function parseBbCode($strComment)
 {
     $arrSearch = array('@\\[b\\](.*)\\[/b\\]@Uis', '@\\[i\\](.*)\\[/i\\]@Uis', '@\\[u\\](.*)\\[/u\\]@Uis', '@\\s*\\[code\\](.*)\\[/code\\]\\s*@Uis', '@\\[color=([^\\]" ]+)\\](.*)\\[/color\\]@Uis', '@\\s*\\[quote\\](.*)\\[/quote\\]\\s*@Uis', '@\\s*\\[quote=([^\\]]+)\\](.*)\\[/quote\\]\\s*@Uis', '@\\[img\\]\\s*([^\\[" ]+\\.(jpe?g|png|gif|bmp|tiff?|ico))\\s*\\[/img\\]@i', '@\\[url\\]\\s*([^\\[" ]+)\\s*\\[/url\\]@i', '@\\[url=([^\\]" ]+)\\](.*)\\[/url\\]@Uis', '@\\[email\\]\\s*([^\\[" ]+)\\s*\\[/email\\]@i', '@\\[email=([^\\]" ]+)\\](.*)\\[/email\\]@Uis', '@href="(([a-z0-9]+\\.)*[a-z0-9]+\\.([a-z]{2}|asia|biz|com|info|name|net|org|tel)(/|"))@i');
     $arrReplace = array('<strong>$1</strong>', '<em>$1</em>', '<span style="text-decoration:underline">$1</span>', "\n\n" . '<div class="code"><p>' . $GLOBALS['TL_LANG']['MSC']['com_code'] . '</p><pre>$1</pre></div>' . "\n\n", '<span style="color:$1">$2</span>', "\n\n" . '<div class="quote">$1</div>' . "\n\n", "\n\n" . '<div class="quote"><p>' . sprintf($GLOBALS['TL_LANG']['MSC']['com_quote'], '$1') . '</p>$2</div>' . "\n\n", '<img src="$1" alt="" />', '<a href="$1">$1</a>', '<a href="$1">$2</a>', '<a href="mailto:$1">$1</a>', '<a href="mailto:$1">$2</a>', 'href="http://$1');
     $strComment = preg_replace($arrSearch, $arrReplace, $strComment);
     // Encode e-mail addresses
     if (strpos($strComment, 'mailto:') !== false) {
         $strComment = \String::encodeEmail($strComment);
     }
     return $strComment;
 }
Exemplo n.º 14
0
     header('Content-Type: application/json');
     echo json_encode(array('status' => 'NO_STORES'));
     exit;
 }
 while ($objStores->next()) {
     // generate jump to
     if ($objModule->jumpTo) {
         if (($objLocation = \PageModel::findByPk($objModule->jumpTo)) !== null) {
             //@todo language parameter
             $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
             $strStoreValue = $objStores->alias;
             $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
         }
     }
     // Encode email
     $objStores->email = \String::encodeEmail($objStores->email);
     // Encode opening times
     $objStores->opening_times = deserialize($objStores->opening_times);
     // decode logo
     if (\Validator::isBinaryUuid($objStores->logo)) {
         if (($objFile = \FilesModel::findByPk($objStores->logo)) !== null) {
             $objStores->logo = $objFile->path;
         }
     }
     // decode marker
     if (\Validator::isBinaryUuid($objStores->marker)) {
         if (($objFile = \FilesModel::findByPk($objStores->marker)) !== null) {
             $objStores->marker = $objFile->path;
         }
     }
     // add category marker
Exemplo n.º 15
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $this->Template->referer = 'javascript:history.go(-1)';
     $objFaq = \FaqModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->faq_categories);
     if ($objFaq === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->error = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     // Overwrite the page title and description
     if ($objFaq->question != '') {
         $objPage->pageTitle = strip_insert_tags($objFaq->question);
         $objPage->description = $this->prepareMetaDescription($objFaq->question);
     }
     $this->Template->question = $objFaq->question;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $objFaq->answer = \String::toXhtml($objFaq->answer);
     } else {
         $objFaq->answer = \String::toHtml5($objFaq->answer);
     }
     $this->Template->answer = \String::encodeEmail($objFaq->answer);
     $this->Template->addImage = false;
     // Add image
     if ($objFaq->addImage && $objFaq->singleSRC != '') {
         if (!is_numeric($objFaq->singleSRC)) {
             $this->Template->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } else {
             $objModel = \FilesModel::findByPk($objFaq->singleSRC);
             if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                 $objFaq->singleSRC = $objModel->path;
                 $this->addImageToTemplate($this->Template, $objFaq->row());
             }
         }
     }
     $this->Template->enclosure = array();
     // Add enclosure
     if ($objFaq->addEnclosure) {
         $this->addEnclosuresToTemplate($this->Template, $objFaq->row());
     }
     $this->Template->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name);
     // HOOK: comments extension required
     if ($objFaq->noComments || !in_array('comments', $this->Config->getActiveModules())) {
         $this->Template->allowComments = false;
         return;
     }
     $objCategory = $objFaq->getRelated('pid');
     // Check whether comments are allowed
     if (!$objCategory->allowComments) {
         $this->Template->allowComments = false;
         return;
     }
     $this->Template->allowComments = true;
     // Adjust the comments headline level
     $intHl = min(intval(str_replace('h', '', $this->hl)), 5);
     $this->Template->hlc = 'h' . ($intHl + 1);
     $this->import('Comments');
     $arrNotifies = array();
     // Notify the system administrator
     if ($objCategory->notify != 'notify_author') {
         $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL'];
     }
     // Notify the author
     if ($objCategory->notify != 'notify_admin') {
         if (($objAuthor = $objFaq->getRelated('author')) !== null && $objAuthor->email != '') {
             $arrNotifies[] = $objAuthor->email;
         }
     }
     $objConfig = new \stdClass();
     $objConfig->perPage = $objCategory->perPage;
     $objConfig->order = $objCategory->sortOrder;
     $objConfig->template = $this->com_template;
     $objConfig->requireLogin = $objCategory->requireLogin;
     $objConfig->disableCaptcha = $objCategory->disableCaptcha;
     $objConfig->bbcode = $objCategory->bbcode;
     $objConfig->moderate = $objCategory->moderate;
     $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_faq', $objFaq->id, $arrNotifies);
 }
Exemplo n.º 16
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     if ($objNewsletter === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     $arrEnclosures = array();
     // Add enclosure
     if ($objNewsletter->addFile) {
         $arrEnclosure = deserialize($objNewsletter->files, true);
         $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
         if (is_array($arrEnclosure)) {
             // Send file to the browser
             if (\Input::get('file', true) != '' && in_array(\Input::get('file', true), $arrEnclosure)) {
                 $this->sendFileToBrowser(\Input::get('file', true));
             }
             // Add download links
             for ($i = 0; $i < count($arrEnclosure); $i++) {
                 if (is_file(TL_ROOT . '/' . $arrEnclosure[$i])) {
                     $objFile = new \File($arrEnclosure[$i]);
                     if (in_array($objFile->extension, $allowedDownload)) {
                         $src = 'system/themes/' . $this->getTheme() . '/images/' . $objFile->icon;
                         if (($imgSize = @getimagesize(TL_ROOT . '/' . $src)) !== false) {
                             $arrEnclosures[$i]['size'] = ' ' . $imgSize[3];
                         }
                         $arrEnclosures[$i]['icon'] = TL_FILES_URL . $src;
                         $arrEnclosures[$i]['link'] = basename($arrEnclosure[$i]);
                         $arrEnclosures[$i]['filesize'] = $this->getReadableSize($objFile->filesize);
                         $arrEnclosures[$i]['title'] = ucfirst(str_replace('_', ' ', $objFile->filename));
                         $arrEnclosures[$i]['href'] = \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&amp;' : '?') . 'file=' . $this->urlEncode($arrEnclosure[$i]);
                         $arrEnclosures[$i]['enclosure'] = $arrEnclosure[$i];
                     }
                 }
             }
         }
     }
     // Support plain text newsletters (thanks to Hagen Klemp)
     if ($objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = $nl2br($objNewsletter->text);
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
     $this->Template->enclosure = $arrEnclosures;
 }
 /**
  * Generate a URL and return it as string
  * @param object
  * @param boolean
  * @return string
  */
 protected function generateNewsUrl($objItem, $blnAddArchive = false)
 {
     $strCacheKey = 'id_' . $objItem->id;
     // Load the URL from cache
     if (isset(self::$arrUrlCache[$strCacheKey])) {
         return self::$arrUrlCache[$strCacheKey];
     }
     // Initialize the cache
     self::$arrUrlCache[$strCacheKey] = null;
     switch ($objItem->source) {
         // Link to an external page
         case 'external':
             if (substr($objItem->url, 0, 7) == 'mailto:') {
                 self::$arrUrlCache[$strCacheKey] = \String::encodeEmail($objItem->url);
             } else {
                 self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url);
             }
             break;
             // Link to an internal page
         // Link to an internal page
         case 'internal':
             if (($objTarget = $objItem->getRelated('jumpTo')) !== null) {
                 self::$arrUrlCache[$strCacheKey] = ampersand($this->generateFrontendUrl($objTarget->row()));
             }
             break;
             // Link to an article
         // Link to an article
         case 'article':
             if (($objArticle = \ArticleModel::findByPk($objItem->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
                 self::$arrUrlCache[$strCacheKey] = ampersand($this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)));
             }
             break;
     }
     // Link to the default page
     if (self::$arrUrlCache[$strCacheKey] === null) {
         if (!$GLOBALS['NEWS_LIST_EXCLUDE_RELATED']) {
             $objPage = \PageModel::findByPk($objItem->getRelated('pid')->jumpTo);
         }
         if ($objPage === null) {
             self::$arrUrlCache[$strCacheKey] = ampersand(\Environment::get('request'), true);
         } else {
             self::$arrUrlCache[$strCacheKey] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objItem->alias != '' ? $objItem->alias : $objItem->id)));
         }
         // Add the current archive parameter (news archive)
         if ($blnAddArchive && \Input::get('month') != '') {
             self::$arrUrlCache[$strCacheKey] .= (\Config::get('disableAlias') ? '&amp;' : '?') . 'month=' . \Input::get('month');
         }
     }
     return self::$arrUrlCache[$strCacheKey];
 }
Exemplo n.º 18
0
 /**
  * Recursively compile the navigation menu and return it as HTML string
  * @param integer
  * @param integer
  * @param string
  * @param string
  * @return string
  */
 protected function renderNavigation($pid, $level = 1, $host = null, $language = null)
 {
     // Get all active subpages
     $objSubpages = \PageModel::findPublishedSubpagesWithoutGuestsByPid($pid, $this->showHidden, $this instanceof \ModuleSitemap);
     if ($objSubpages === null) {
         return '';
     }
     $items = array();
     $groups = array();
     // Get all groups of the current front end user
     if (FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         $groups = $this->User->groups;
     }
     // Layout template fallback
     if ($this->navigationTpl == '') {
         $this->navigationTpl = 'nav_default';
     }
     $objTemplate = new \FrontendTemplate($this->navigationTpl);
     $objTemplate->type = get_class($this);
     $objTemplate->cssID = $this->cssID;
     // see #4897
     $objTemplate->level = 'level_' . $level++;
     // Get page object
     global $objPage;
     // Browse subpages
     while ($objSubpages->next()) {
         // Skip hidden sitemap pages
         if ($this instanceof \ModuleSitemap && $objSubpages->sitemap == 'map_never') {
             continue;
         }
         $subitems = '';
         $_groups = deserialize($objSubpages->groups);
         // Override the domain (see #3765)
         if ($host !== null) {
             $objSubpages->domain = $host;
         }
         // Do not show protected pages unless a back end or front end user is logged in
         if (!$objSubpages->protected || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected || $this instanceof \ModuleSitemap && $objSubpages->sitemap == 'map_always') {
             // Check whether there will be subpages
             if ($objSubpages->subpages > 0 && (!$this->showLevel || $this->showLevel >= $level || !$this->hardLimit && ($objPage->id == $objSubpages->id || in_array($objPage->id, $this->Database->getChildRecords($objSubpages->id, 'tl_page'))))) {
                 $subitems = $this->renderNavigation($objSubpages->id, $level, $host, $language);
             }
             // Get href
             switch ($objSubpages->type) {
                 case 'redirect':
                     $href = $objSubpages->url;
                     if (strncasecmp($href, 'mailto:', 7) === 0) {
                         $href = \String::encodeEmail($href);
                     }
                     break;
                 case 'forward':
                     if ($objSubpages->jumpTo) {
                         $objNext = $objSubpages->getRelated('jumpTo');
                     } else {
                         $objNext = \PageModel::findFirstPublishedRegularByPid($objSubpages->id);
                     }
                     if ($objNext !== null) {
                         // Hide the link if the target page is invisible
                         if (!$objNext->published || $objNext->start != '' && $objNext->start > time() || $objNext->stop != '' && $objNext->stop < time()) {
                             continue 2;
                         }
                         $strForceLang = null;
                         $objNext->loadDetails();
                         // Check the target page language (see #4706)
                         if (\Config::get('addLanguageToUrl')) {
                             $strForceLang = $objNext->language;
                         }
                         $href = $this->generateFrontendUrl($objNext->row(), null, $strForceLang, true);
                         break;
                     }
                     // DO NOT ADD A break; STATEMENT
                 // DO NOT ADD A break; STATEMENT
                 default:
                     $href = $this->generateFrontendUrl($objSubpages->row(), null, $language, true);
                     break;
             }
             $row = $objSubpages->row();
             // Active page
             if (($objPage->id == $objSubpages->id || $objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo) && !$this instanceof \ModuleSitemap && !\Input::get('articles')) {
                 // Mark active forward pages (see #4822)
                 $strClass = ($objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo ? 'forward' . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : '') : 'active') . ($subitems != '' ? ' submenu' : '') . ($objSubpages->protected ? ' protected' : '') . ($objSubpages->cssClass != '' ? ' ' . $objSubpages->cssClass : '');
                 $row['isActive'] = true;
             } else {
                 $strClass = ($subitems != '' ? 'submenu' : '') . ($objSubpages->protected ? ' protected' : '') . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : '') . ($objSubpages->cssClass != '' ? ' ' . $objSubpages->cssClass : '');
                 // Mark pages on the same level (see #2419)
                 if ($objSubpages->pid == $objPage->pid) {
                     $strClass .= ' sibling';
                 }
                 $row['isActive'] = false;
             }
             $row['subitems'] = $subitems;
             $row['class'] = trim($strClass);
             $row['title'] = specialchars($objSubpages->title, true);
             $row['pageTitle'] = specialchars($objSubpages->pageTitle, true);
             $row['link'] = $objSubpages->title;
             $row['href'] = $href;
             $row['nofollow'] = strncmp($objSubpages->robots, 'noindex', 7) === 0;
             $row['target'] = '';
             $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objSubpages->description);
             // Override the link target
             if ($objSubpages->type == 'redirect' && $objSubpages->target) {
                 $row['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
             }
             $items[] = $row;
         }
     }
     // Add classes first and last
     if (!empty($items)) {
         $last = count($items) - 1;
         $items[0]['class'] = trim($items[0]['class'] . ' first');
         $items[$last]['class'] = trim($items[$last]['class'] . ' last');
     }
     $objTemplate->items = $items;
     return !empty($items) ? $objTemplate->parse() : '';
 }
Exemplo n.º 19
0
 protected function generateParentList($objPage)
 {
     $type = null;
     $pageId = $objPage->id;
     $pages = array($objPage->row());
     $items = array();
     // Get all pages up to the root page
     $objPages = \PageModel::findParentsById($objPage->pid);
     if ($objPages !== null) {
         while ($pageId > 0 && $type != 'root' && $objPages->next()) {
             $type = $objPages->type;
             $pageId = $objPages->pid;
             $pages[] = $objPages->row();
         }
     }
     // Get the first active regular page and display it instead of the root page
     if ($type == 'root') {
         $objFirstPage = \PageModel::findFirstPublishedByPid($objPages->id);
         $items[] = array('isRoot' => true, 'isActive' => false, 'href' => $objFirstPage !== null ? \Controller::generateFrontendUrl($objFirstPage->row()) : \Environment::get('base'), 'title' => specialchars($objPages->pageTitle ?: $objPages->title, true), 'link' => $objPages->title, 'data' => $objFirstPage->row(), 'class' => '');
         array_pop($pages);
     }
     // Build the breadcrumb menu
     for ($i = count($pages) - 1; $i > 0; $i--) {
         if ($pages[$i]['hide'] && !$this->showHidden || !$pages[$i]['published'] && !BE_USER_LOGGED_IN) {
             continue;
         }
         // Get href
         switch ($pages[$i]['type']) {
             case 'redirect':
                 $href = $pages[$i]['url'];
                 if (strncasecmp($href, 'mailto:', 7) === 0) {
                     $href = \String::encodeEmail($href);
                 }
                 break;
             case 'forward':
                 $objNext = \PageModel::findPublishedById($pages[$i]['jumpTo']);
                 if ($objNext !== null) {
                     $href = \Controller::generateFrontendUrl($objNext->row());
                     break;
                 }
                 // DO NOT ADD A break; STATEMENT
             // DO NOT ADD A break; STATEMENT
             default:
                 $href = \Controller::generateFrontendUrl($pages[$i]);
                 break;
         }
         $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $href, 'title' => specialchars($pages[$i]['pageTitle'] ?: $pages[$i]['title'], true), 'link' => $pages[$i]['title'], 'data' => $pages[$i], 'class' => '');
     }
     // Active page
     $items[] = array('isRoot' => false, 'isActive' => true, 'href' => \Controller::generateFrontendUrl($pages[0]), 'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title']), 'link' => $pages[0]['title'], 'data' => $pages[0], 'class' => 'last');
     $items[0]['class'] = 'first';
     return $items;
 }
Exemplo n.º 20
0
 /**
  * Encode button value.
  *
  * @param array $button Button definition.
  *
  * @return button
  */
 protected static function encodeValue($button)
 {
     if (isset($button['button']) && $button['button'] == 'link') {
         if (substr($button['value'], 0, 7) == 'mailto:') {
             $button['value'] = \String::encodeEmail($button['value']);
         } else {
             $button['value'] = ampersand($button['value']);
         }
     }
     return $button;
 }
Exemplo n.º 21
0
 /**
  * load buttons defined in a field set definition, created by the MultiColumnWizard
  * @param $definition
  */
 public function loadFromFieldset($definition)
 {
     if (!is_array($definition)) {
         $definition = deserialize($definition, true);
     }
     $buttons = array();
     $group = false;
     $dropdown = false;
     foreach ($definition as $button) {
         if ($button['label'] == '' && $button['type'] != 'group') {
             continue;
         }
         // encode value
         if (isset($button['button']) && $button['button'] == 'link') {
             if (substr($button['value'], 0, 7) == 'mailto:') {
                 $button['value'] = \String::encodeEmail($button['value']);
             } else {
                 $button['value'] = ampersand($button['value']);
             }
         }
         if ($dropdown !== false && ($button['type'] != 'child' && $button['type'] != 'header')) {
             if ($group !== false) {
                 $this->addItemToTarget($group['items'], $dropdown);
             } else {
                 $this->addItem($dropdown);
             }
             $dropdown = false;
         }
         // create new group
         if ($button['type'] == 'group') {
             $this->toolbar = true;
             if ($dropdown !== false) {
                 if ($group) {
                     $this->addItemToTarget($group['items'], $dropdown);
                 } else {
                     $this->addItem($dropdown);
                 }
                 $dropdown = false;
             }
             if ($group !== false) {
                 $this->addItem($group);
             }
             $group = $button;
             $group['items'] = array();
         } elseif ($button['type'] == 'dropdown') {
             $dropdown = $button;
             $dropdown['items'] = array();
         } elseif ($button['type'] == 'child' || $button['type'] == 'header') {
             $dropdown['items'][] = $button;
         } elseif ($group !== false) {
             $this->addItemToTarget($group['items'], $button);
         } else {
             $this->addItem($button);
         }
     }
     if ($group !== false) {
         if ($dropdown !== false) {
             $this->addItemToTarget($group['items'], $dropdown);
         }
         $this->addItem($group);
     } elseif ($dropdown !== false) {
         $this->addItem($dropdown);
     }
 }
Exemplo n.º 22
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     if (null === $objNewsletter) {
         /** @var \PageError404 $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objNewsletter->subject != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
     }
     // Add enclosure
     if ($objNewsletter->addFile) {
         $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
     }
     // Support plain text newsletters (thanks to Hagen Klemp)
     if ($objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = $nl2br($objNewsletter->text);
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
 }
 /**
  * Generate a URL and return it as string
  * @param object
  * @param boolean
  * @return string
  */
 protected function generateMemberUrl($objItem)
 {
     $strCacheKey = 'id_' . $objItem->id;
     // Load the URL from cache
     if (isset(self::$arrUrlCache[$strCacheKey])) {
         return self::$arrUrlCache[$strCacheKey];
     }
     // Initialize the cache
     self::$arrUrlCache[$strCacheKey] = null;
     switch ($this->mlSource) {
         // Link to an external page
         case 'external':
             if (substr($objItem->url, 0, 7) == 'mailto:') {
                 self::$arrUrlCache[$strCacheKey] = \String::encodeEmail($objItem->mlUrl);
             } else {
                 self::$arrUrlCache[$strCacheKey] = ampersand($objItem->mlUrl);
             }
             break;
             // Link to an internal page
         // Link to an internal page
         case 'internal':
             if (($objTarget = \PageModel::findByPk($this->mlJumpTo)) !== null) {
                 self::$arrUrlCache[$strCacheKey] = ampersand($this->generateFrontendUrl($objTarget->row()));
             }
             break;
             // Link to an article with the Reader Module
         // Link to an article with the Reader Module
         case 'article_reader':
             if (($objArticle = \ArticleModel::findByPk($this->mlArticleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
                 //					$GLOBALS['TL_AUTO_ITEM'][] = ((\Config::get('disableAlias') && $objArticle->alias == '') ? : $objArticle->alias);
                 self::$arrUrlCache[$strCacheKey] = ampersand($this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)) . (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objItem->alias != '' ? $objItem->alias : $objItem->id));
             }
             break;
             // Link to an article
         // Link to an article
         case 'article':
             if (($objArticle = \ArticleModel::findByPk($this->mlArticleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
                 self::$arrUrlCache[$strCacheKey] = ampersand($this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)));
             }
             break;
     }
     return self::$arrUrlCache[$strCacheKey];
 }
Exemplo n.º 24
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->event = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     // Get the current event
     $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar);
     if ($objEvent === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>';
         return;
     }
     // Overwrite the page title
     if ($objEvent->title != '') {
         $objPage->pageTitle = strip_insert_tags($objEvent->title);
     }
     // Overwrite the page description
     if ($objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($objEvent->teaser);
     }
     $span = \Calendar::calculateSpan($objEvent->startTime, $objEvent->endTime);
     if ($objPage->outputFormat == 'xhtml') {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
     } else {
         $strTimeStart = '<time datetime="' . date('Y-m-d\\TH:i:sP', $objEvent->startTime) . '">';
         $strTimeEnd = '<time datetime="' . date('Y-m-d\\TH:i:sP', $objEvent->endTime) . '">';
         $strTimeClose = '</time>';
     }
     // Get date
     if ($span > 0) {
         $date = $strTimeStart . $this->parseDate($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $objEvent->startTime) . $strTimeClose . ' - ' . $strTimeEnd . $this->parseDate($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $objEvent->endTime) . $strTimeClose;
     } elseif ($objEvent->startTime == $objEvent->endTime) {
         $date = $strTimeStart . $this->parseDate($objPage->dateFormat, $objEvent->startTime) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $objEvent->startTime) . ')' : '') . $strTimeClose;
     } else {
         $date = $strTimeStart . $this->parseDate($objPage->dateFormat, $objEvent->startTime) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $objEvent->startTime) . $strTimeClose . ' - ' . $strTimeEnd . $this->parseDate($objPage->timeFormat, $objEvent->endTime) . ')' : '') . $strTimeClose;
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         $strKey = 'cal_' . $arrRange['unit'];
         $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
         if ($objEvent->recurrences > 0) {
             $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], $this->parseDate($objPage->dateFormat, $objEvent->repeatEnd));
         }
     }
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0) {
             $objEvent->size = $this->imgSize;
         }
     }
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData($objEvent->row());
     $objTemplate->date = $date;
     $objTemplate->start = $objEvent->startTime;
     $objTemplate->end = $objEvent->endTime;
     $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
     $objTemplate->recurring = $recurring;
     $objTemplate->until = $until;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $objEvent->details = \String::toXhtml($objEvent->details);
     } else {
         $objEvent->details = \String::toHtml5($objEvent->details);
     }
     $objTemplate->details = \String::encodeEmail($objEvent->details);
     $objTemplate->addImage = false;
     // Add an image
     if ($objEvent->addImage && $objEvent->singleSRC != '') {
         if (!is_numeric($objEvent->singleSRC)) {
             $objTemplate->details = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } else {
             $objModel = \FilesModel::findByPk($objEvent->singleSRC);
             if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                 $objEvent->singleSRC = $objModel->path;
                 $this->addImageToTemplate($objTemplate, $objEvent->row());
             }
         }
     }
     $objTemplate->enclosure = array();
     // Add enclosures
     if ($objEvent->addEnclosure) {
         $this->addEnclosuresToTemplate($objTemplate, $objEvent->row());
     }
     $this->Template->event = $objTemplate->parse();
     // HOOK: comments extension required
     if ($objEvent->noComments || !in_array('comments', $this->Config->getActiveModules())) {
         $this->Template->allowComments = false;
         return;
     }
     $objCalendar = $objEvent->getRelated('pid');
     $this->Template->allowComments = $objCalendar->allowComments;
     // Adjust the comments headline level
     $intHl = min(intval(str_replace('h', '', $this->hl)), 5);
     $this->Template->hlc = 'h' . ($intHl + 1);
     $this->import('Comments');
     $arrNotifies = array();
     // Notify the system administrator
     if ($objCalendar->notify != 'notify_author') {
         $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL'];
     }
     // Notify the author
     if ($objCalendar->notify != 'notify_admin') {
         if (($objAuthor = $objEvent->getRelated('author')) !== null && $objAuthor->email != '') {
             $arrNotifies[] = $objAuthor->email;
         }
     }
     $objConfig = new \stdClass();
     $objConfig->perPage = $objCalendar->perPage;
     $objConfig->order = $objCalendar->sortOrder;
     $objConfig->template = $this->com_template;
     $objConfig->requireLogin = $objCalendar->requireLogin;
     $objConfig->disableCaptcha = $objCalendar->disableCaptcha;
     $objConfig->bbcode = $objCalendar->bbcode;
     $objConfig->moderate = $objCalendar->moderate;
     $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_calendar_events', $objEvent->id, $arrNotifies);
 }
Exemplo n.º 25
0
 /**
  * Replace insert tags with their values
  * 
  * @param string  $strBuffer The text with the tags to be replaced
  * @param boolean $blnCache  If true, some tags will be preserved
  * 
  * @return string The text with the replaced tags
  */
 protected function replaceInsertTags($strBuffer, $blnCache = false)
 {
     global $objPage;
     // Preserve insert tags
     if ($GLOBALS['TL_CONFIG']['disableInsertTags']) {
         return $this->restoreBasicEntities($strBuffer);
     }
     $tags = preg_split('/\\{\\{([^\\}]+)\\}\\}/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE);
     $strBuffer = '';
     $arrCache = array();
     for ($_rit = 0; $_rit < count($tags); $_rit = $_rit + 2) {
         $strBuffer .= $tags[$_rit];
         $strTag = $tags[$_rit + 1];
         // Skip empty tags
         if ($strTag == '') {
             continue;
         }
         // Load value from cache array
         if (isset($arrCache[$strTag])) {
             $strBuffer .= $arrCache[$strTag];
             continue;
         }
         $elements = explode('::', $strTag);
         // Skip certain elements if the output will be cached
         if ($blnCache) {
             if ($elements[0] == 'date' || $elements[0] == 'ua' || $elements[0] == 'file' || $elements[1] == 'back' || $elements[1] == 'referer' || $elements[0] == 'request_token' || strncmp($elements[0], 'cache_', 6) === 0) {
                 $strBuffer .= '{{' . $strTag . '}}';
                 continue;
             }
         }
         $arrCache[$strTag] = '';
         // Replace the tag
         switch (strtolower($elements[0])) {
             // Date
             case 'date':
                 $arrCache[$strTag] = $this->parseDate($elements[1] ?: $GLOBALS['TL_CONFIG']['dateFormat']);
                 break;
                 // Accessibility tags
             // Accessibility tags
             case 'lang':
                 if ($elements[1] == '') {
                     $arrCache[$strTag] = '</span>';
                 } elseif ($objPage->outputFormat == 'xhtml') {
                     $arrCache[$strTag] = '<span lang="' . $elements[1] . '" xml:lang="' . $elements[1] . '">';
                 } else {
                     $arrCache[$strTag] = $arrCache[$strTag] = '<span lang="' . $elements[1] . '">';
                 }
                 break;
                 // E-mail addresses
             // E-mail addresses
             case 'email':
             case 'email_open':
             case 'email_url':
                 if ($elements[1] == '') {
                     $arrCache[$strTag] = '';
                     break;
                 }
                 $strEmail = \String::encodeEmail($elements[1]);
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'email':
                         $arrCache[$strTag] = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $strEmail . '" class="email">' . preg_replace('/\\?.*$/', '', $strEmail) . '</a>';
                         break;
                     case 'email_open':
                         $arrCache[$strTag] = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $strEmail . '" class="email">';
                         break;
                     case 'email_url':
                         $arrCache[$strTag] = $strEmail;
                         break;
                 }
                 break;
                 // Label tags
             // Label tags
             case 'label':
                 $keys = explode(':', $elements[1]);
                 if (count($keys) < 2) {
                     $arrCache[$strTag] = '';
                     break;
                 }
                 $this->loadLanguageFile($keys[0]);
                 if (count($keys) == 2) {
                     $arrCache[$strTag] = $GLOBALS['TL_LANG'][$keys[0]][$keys[1]];
                 } else {
                     $arrCache[$strTag] = $GLOBALS['TL_LANG'][$keys[0]][$keys[1]][$keys[2]];
                 }
                 break;
                 // Front end user
             // Front end user
             case 'user':
                 if (FE_USER_LOGGED_IN) {
                     $this->import('FrontendUser', 'User');
                     $value = $this->User->{$elements}[1];
                     if ($value == '') {
                         $arrCache[$strTag] = $value;
                         break;
                     }
                     $this->loadDataContainer('tl_member');
                     if ($GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['inputType'] == 'password') {
                         $arrCache[$strTag] = '';
                         break;
                     }
                     $value = deserialize($value);
                     $rgxp = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['eval']['rgxp'];
                     $opts = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['options'];
                     $rfrc = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['reference'];
                     if ($rgxp == 'date') {
                         $arrCache[$strTag] = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $value);
                     } elseif ($rgxp == 'time') {
                         $arrCache[$strTag] = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $value);
                     } elseif ($rgxp == 'datim') {
                         $arrCache[$strTag] = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $value);
                     } elseif (is_array($value)) {
                         $arrCache[$strTag] = implode(', ', $value);
                     } elseif (is_array($opts) && array_is_assoc($opts)) {
                         $arrCache[$strTag] = isset($opts[$value]) ? $opts[$value] : $value;
                     } elseif (is_array($rfrc)) {
                         $arrCache[$strTag] = isset($rfrc[$value]) ? is_array($rfrc[$value]) ? $rfrc[$value][0] : $rfrc[$value] : $value;
                     } else {
                         $arrCache[$strTag] = $value;
                     }
                     // Convert special characters (see #1890)
                     $arrCache[$strTag] = specialchars($arrCache[$strTag]);
                 }
                 break;
                 // Link
             // Link
             case 'link':
             case 'link_open':
             case 'link_url':
             case 'link_title':
                 // Back link
                 if ($elements[1] == 'back') {
                     $strUrl = 'javascript:history.go(-1)';
                     $strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
                     // No language files if the page is cached
                     if (!strlen($strTitle)) {
                         $strTitle = 'Go back';
                     }
                     $strName = $strTitle;
                 } elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
                     $strUrl = $elements[1];
                     $strTitle = $elements[1];
                     $strName = str_replace(array('http://', 'https://'), '', $elements[1]);
                 } else {
                     // User login page
                     if ($elements[1] == 'login') {
                         if (!FE_USER_LOGGED_IN) {
                             break;
                         }
                         $this->import('FrontendUser', 'User');
                         $elements[1] = $this->User->loginPage;
                     }
                     $objNextPage = \PageModel::findByIdOrAlias($elements[1]);
                     if ($objNextPage === null) {
                         break;
                     }
                     // Page type specific settings (thanks to Andreas Schempp)
                     switch ($objNextPage->type) {
                         case 'redirect':
                             $strUrl = $objNextPage->url;
                             if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
                                 $strUrl = \String::encodeEmail($strUrl);
                             }
                             break;
                         case 'forward':
                             if (($objTarget = $objNextPage->getRelated('jumpTo')) !== null) {
                                 $strUrl = $this->generateFrontendUrl($objTarget->row());
                                 break;
                             } elseif (($objTarget = \PageModel::findFirstPublishedRegularByPid($objNextPage->id)) !== null) {
                                 if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
                                     $objTarget = $this->getPageDetails($objTarget);
                                     // see #3983
                                     $strUrl = $this->generateFrontendUrl($objTarget->row(), null, $objTarget->language);
                                 } else {
                                     $strUrl = $this->generateFrontendUrl($objTarget->row());
                                 }
                                 break;
                             }
                             // DO NOT ADD A break; STATEMENT
                         // DO NOT ADD A break; STATEMENT
                         default:
                             if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
                                 $objNextPage = $this->getPageDetails($objNextPage);
                                 // see #3983
                                 $strUrl = $this->generateFrontendUrl($objNextPage->row(), null, $objNextPage->language);
                             } else {
                                 $strUrl = $this->generateFrontendUrl($objNextPage->row());
                             }
                             break;
                     }
                     $strName = $objNextPage->title;
                     $strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : '';
                     $strTitle = $objNextPage->pageTitle ?: $objNextPage->title;
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'link':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName));
                         break;
                     case 'link_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>', $strUrl, specialchars($strTitle), $strTarget);
                         break;
                     case 'link_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'link_title':
                         $arrCache[$strTag] = specialchars($strTitle);
                         break;
                     case 'link_target':
                         $arrCache[$strTag] = $strTarget;
                         break;
                 }
                 break;
                 // Closing link tag
             // Closing link tag
             case 'link_close':
                 $arrCache[$strTag] = '</a>';
                 break;
                 // Insert article
             // Insert article
             case 'insert_article':
                 if (($strOutput = $this->getArticle($elements[1], false, true)) !== false) {
                     $arrCache[$strTag] = $this->replaceInsertTags(ltrim($strOutput));
                 } else {
                     $arrCache[$strTag] = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $elements[1]) . '</p>';
                 }
                 break;
                 // Insert content element
             // Insert content element
             case 'insert_content':
                 $arrCache[$strTag] = $this->replaceInsertTags($this->getContentElement($elements[1]));
                 break;
                 // Insert module
             // Insert module
             case 'insert_module':
                 $arrCache[$strTag] = $this->replaceInsertTags($this->getFrontendModule($elements[1]));
                 break;
                 // Insert form
             // Insert form
             case 'insert_form':
                 $arrCache[$strTag] = $this->replaceInsertTags($this->getForm($elements[1]));
                 break;
                 // Article
             // Article
             case 'article':
             case 'article_open':
             case 'article_url':
             case 'article_title':
                 $objArticle = \ArticleModel::findByIdOrAlias($elements[1]);
                 if ($objArticle === null) {
                     break;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objArticle->row(), '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && strlen($objArticle->alias) ? $objArticle->alias : $objArticle->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'article':
                         $strLink = specialchars($objArticle->title);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'article_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objArticle->title));
                         break;
                     case 'article_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'article_title':
                         $arrCache[$strTag] = specialchars($objArticle->title);
                         break;
                 }
                 break;
                 // FAQ
             // FAQ
             case 'faq':
             case 'faq_open':
             case 'faq_url':
             case 'faq_title':
                 $objFaq = \FaqModel::findByIdOrAlias($elements[1]);
                 if ($objFaq === null) {
                     break;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objFaq->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objFaq->alias != '' ? $objFaq->alias : $objFaq->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'faq':
                         $strLink = specialchars($objFaq->question);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'faq_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objFaq->question));
                         break;
                     case 'faq_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'faq_title':
                         $arrCache[$strTag] = specialchars($objFaq->question);
                         break;
                 }
                 break;
                 // News
             // News
             case 'news':
             case 'news_open':
             case 'news_url':
             case 'news_title':
                 $objNews = \NewsModel::findByIdOrAlias($elements[1]);
                 if ($objNews === null) {
                     break;
                 } elseif ($objNews->source == 'internal') {
                     $strUrl = $this->generateFrontendUrl($objNews->getRelated('jumpTo')->row());
                 } elseif ($objNews->source == 'article') {
                     $objArticle = \ArticleModel::findByPk($objNews->articleId, array('eager' => true));
                     $strUrl = $this->generateFrontendUrl($objArticle->pid, '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
                 } elseif ($objNews->source == 'external') {
                     $strUrl = $objNews->url;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objNews->pid, ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objNews->alias != '' ? $objNews->alias : $objNews->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'news':
                         $strLink = specialchars($objNews->headline);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'news_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objNews->headline));
                         break;
                     case 'news_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'news_title':
                         $arrCache[$strTag] = specialchars($objNews->headline);
                         break;
                 }
                 break;
                 // Events
             // Events
             case 'event':
             case 'event_open':
             case 'event_url':
             case 'event_title':
                 $objEvent = \CalendarEventsModel::findByIdOrAlias($elements[1]);
                 if ($objEvent === null) {
                     break;
                 } elseif ($objEvent->source == 'internal') {
                     $strUrl = $this->generateFrontendUrl($objEvent->getRelated('jumpTo')->row());
                 } elseif ($objEvent->source == 'article') {
                     $objArticle = \ArticleModel::findByPk($objEvent->articleId, array('eager' => true));
                     $strUrl = $this->generateFrontendUrl($objArticle->pid, '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
                 } elseif ($objEvent->source == 'external') {
                     $strUrl = $objEvent->url;
                 } else {
                     $strUrl = $this->generateFrontendUrl($objEvent->pid, ($GLOBALS['TL_CONFIG']['useAutoItem'] ? '/' : '/events/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objEvent->alias != '' ? $objEvent->alias : $objEvent->id));
                 }
                 // Replace the tag
                 switch (strtolower($elements[0])) {
                     case 'event':
                         $strLink = specialchars($objEvent->title);
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink);
                         break;
                     case 'event_open':
                         $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objEvent->title));
                         break;
                     case 'event_url':
                         $arrCache[$strTag] = $strUrl;
                         break;
                     case 'event_title':
                         $arrCache[$strTag] = specialchars($objEvent->title);
                         break;
                 }
                 break;
                 // Article teaser
             // Article teaser
             case 'article_teaser':
                 $objTeaser = \ArticleModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser));
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser));
                     }
                 }
                 break;
                 // News teaser
             // News teaser
             case 'news_teaser':
                 $objTeaser = \NewsModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($objTeaser->teaser);
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($objTeaser->teaser);
                     }
                 }
                 break;
                 // Event teaser
             // Event teaser
             case 'event_teaser':
                 $objTeaser = \CalendarEventsModel::findByIdOrAlias($elements[1]);
                 if ($objTeaser !== null) {
                     if ($objPage->outputFormat == 'xhtml') {
                         $arrCache[$strTag] = \String::toXhtml($objTeaser->teaser);
                     } else {
                         $arrCache[$strTag] = \String::toHtml5($objTeaser->teaser);
                     }
                 }
                 break;
                 // News feed URL
             // News feed URL
             case 'news_feed':
                 // FIXME: feeds are now in tl_calendar_feed
                 $objFeed = \NewsArchiveModel::findByPk($elements[1]);
                 if ($objFeed !== null) {
                     $arrCache[$strTag] = $objFeed->feedBase . $objFeed->alias . '.xml';
                 }
                 break;
                 // Calendar feed URL
             // Calendar feed URL
             case 'calendar_feed':
                 // FIXME: feeds are now in tl_calendar_feed
                 $objFeed = \CalendarModel::findByPk($elements[1]);
                 if ($objFeed !== null) {
                     $arrCache[$strTag] = $objFeed->feedBase . $objFeed->alias . '.xml';
                 }
                 break;
                 // Last update
             // Last update
             case 'last_update':
                 $objUpdate = \Database::getInstance()->execute("SELECT MAX(tstamp) AS tc, (SELECT MAX(tstamp) FROM tl_news) AS tn, (SELECT MAX(tstamp) FROM tl_calendar_events) AS te FROM tl_content");
                 if ($objUpdate->numRows) {
                     $arrCache[$strTag] = $this->parseDate($elements[1] ?: $GLOBALS['TL_CONFIG']['datimFormat'], max($objUpdate->tc, $objUpdate->tn, $objUpdate->te));
                 }
                 break;
                 // Version
             // Version
             case 'version':
                 $arrCache[$strTag] = VERSION . '.' . BUILD;
                 break;
                 // Request token
             // Request token
             case 'request_token':
                 $arrCache[$strTag] = REQUEST_TOKEN;
                 break;
                 // Conditional tags
             // Conditional tags
             case 'iflng':
                 if ($elements[1] != '' && $elements[1] != $objPage->language) {
                     for ($_rit; $_rit < count($tags); $_rit += 2) {
                         if ($tags[$_rit + 1] == 'iflng') {
                             break;
                         }
                     }
                 }
                 unset($arrCache[$strTag]);
                 break;
             case 'ifnlng':
                 if ($elements[1] != '') {
                     $langs = trimsplit(',', $elements[1]);
                     if (in_array($objPage->language, $langs)) {
                         for ($_rit; $_rit < count($tags); $_rit += 2) {
                             if ($tags[$_rit + 1] == 'ifnlng') {
                                 break;
                             }
                         }
                     }
                 }
                 unset($arrCache[$strTag]);
                 break;
                 // Environment
             // Environment
             case 'env':
                 switch ($elements[1]) {
                     case 'host':
                         $arrCache[$strTag] = \Environment::get('host');
                         break;
                     case 'http_host':
                         $arrCache[$strTag] = \Environment::get('httpHost');
                         break;
                     case 'url':
                         $arrCache[$strTag] = \Environment::get('url');
                         break;
                     case 'path':
                         $arrCache[$strTag] = \Environment::get('base');
                         break;
                     case 'request':
                         $arrCache[$strTag] = $this->getIndexFreeRequest(true);
                         break;
                     case 'ip':
                         $arrCache[$strTag] = \Environment::get('ip');
                         break;
                     case 'referer':
                         $arrCache[$strTag] = $this->getReferer(true);
                         break;
                     case 'files_url':
                         $arrCache[$strTag] = TL_FILES_URL;
                         break;
                     case 'script_url':
                         $arrCache[$strTag] = TL_SCRIPT_URL;
                         break;
                     case 'plugins_url':
                         $arrCache[$strTag] = TL_PLUGINS_URL;
                         break;
                 }
                 break;
                 // Page
             // Page
             case 'page':
                 if ($elements[1] == 'pageTitle' && $objPage->pageTitle == '') {
                     $elements[1] = 'title';
                 } elseif ($elements[1] == 'parentPageTitle' && $objPage->parentPageTitle == '') {
                     $elements[1] = 'parentTitle';
                 } elseif ($elements[1] == 'mainPageTitle' && $objPage->mainPageTitle == '') {
                     $elements[1] = 'mainTitle';
                 }
                 $arrCache[$strTag] = specialchars($objPage->{$elements[1]});
                 break;
                 // User agent
             // User agent
             case 'ua':
                 $ua = \Environment::get('agent');
                 if ($elements[1] != '') {
                     $arrCache[$strTag] = $ua->{$elements[1]};
                 } else {
                     $arrCache[$strTag] = '';
                 }
                 break;
                 // Acronyms
             // Acronyms
             case 'acronym':
                 if ($objPage->outputFormat == 'xhtml') {
                     if ($elements[1] != '') {
                         $arrCache[$strTag] = '<acronym title="' . $elements[1] . '">';
                     } else {
                         $arrCache[$strTag] = '</acronym>';
                     }
                     break;
                 }
                 // NO break;
                 // Abbreviations
             // NO break;
             // Abbreviations
             case 'abbr':
                 if ($elements[1] != '') {
                     $arrCache[$strTag] = '<abbr title="' . $elements[1] . '">';
                 } else {
                     $arrCache[$strTag] = '</abbr>';
                 }
                 break;
                 // Images
             // Images
             case 'image':
                 $width = null;
                 $height = null;
                 $alt = '';
                 $class = '';
                 $rel = '';
                 $strFile = $elements[1];
                 $mode = '';
                 // Take arguments
                 if (strpos($elements[1], '?') !== false) {
                     $arrChunks = explode('?', urldecode($elements[1]), 2);
                     $strSource = \String::decodeEntities($arrChunks[1]);
                     $strSource = str_replace('[&]', '&', $strSource);
                     $arrParams = explode('&', $strSource);
                     foreach ($arrParams as $strParam) {
                         list($key, $value) = explode('=', $strParam);
                         switch ($key) {
                             case 'width':
                                 $width = $value;
                                 break;
                             case 'height':
                                 $height = $value;
                                 break;
                             case 'alt':
                                 $alt = specialchars($value);
                                 break;
                             case 'class':
                                 $class = $value;
                                 break;
                             case 'rel':
                                 $rel = $value;
                                 break;
                             case 'mode':
                                 $mode = $value;
                                 break;
                         }
                     }
                     $strFile = $arrChunks[0];
                 }
                 // Sanitize path
                 $strFile = str_replace('../', '', $strFile);
                 // Check maximum image width
                 if ($GLOBALS['TL_CONFIG']['maxImageWidth'] > 0 && $width > $GLOBALS['TL_CONFIG']['maxImageWidth']) {
                     $width = $GLOBALS['TL_CONFIG']['maxImageWidth'];
                     $height = null;
                 }
                 // Generate the thumbnail image
                 try {
                     $src = \Image::get($strFile, $width, $height, $mode);
                     $dimensions = '';
                     // Add the image dimensions
                     if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) {
                         $dimensions = $imgSize[3];
                     }
                     // Generate the HTML markup
                     if ($rel != '') {
                         if (strncmp($rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
                             $attribute = ' rel="' . $rel . '"';
                         } else {
                             $attribute = ' data-lightbox="' . substr($rel, 8) . '"';
                         }
                         $arrCache[$strTag] = '<a href="' . TL_FILES_URL . $strFile . '"' . ($alt != '' ? ' title="' . $alt . '"' : '') . $attribute . '><img src="' . TL_FILES_URL . $src . '" ' . $dimensions . ' alt="' . $alt . '"' . ($class != '' ? ' class="' . $class . '"' : '') . ($objPage->outputFormat == 'xhtml' ? ' />' : '>') . '</a>';
                     } else {
                         $arrCache[$strTag] = '<img src="' . TL_FILES_URL . $src . '" ' . $dimensions . ' alt="' . $alt . '"' . ($class != '' ? ' class="' . $class . '"' : '') . ($objPage->outputFormat == 'xhtml' ? ' />' : '>');
                     }
                 } catch (Exception $e) {
                     $arrCache[$strTag] = '';
                 }
                 break;
                 // Files from the templates directory
             // Files from the templates directory
             case 'file':
                 $arrGet = $_GET;
                 \Input::resetCache();
                 $strFile = $elements[1];
                 // Take arguments and add them to the $_GET array
                 if (strpos($elements[1], '?') !== false) {
                     $arrChunks = explode('?', urldecode($elements[1]));
                     $strSource = \String::decodeEntities($arrChunks[1]);
                     $strSource = str_replace('[&]', '&', $strSource);
                     $arrParams = explode('&', $strSource);
                     foreach ($arrParams as $strParam) {
                         $arrParam = explode('=', $strParam);
                         $_GET[$arrParam[0]] = $arrParam[1];
                     }
                     $strFile = $arrChunks[0];
                 }
                 // Sanitize path
                 $strFile = str_replace('../', '', $strFile);
                 // Include .php, .tpl, .xhtml and .html5 files
                 if (preg_match('/\\.(php|tpl|xhtml|html5)$/', $strFile) && file_exists(TL_ROOT . '/templates/' . $strFile)) {
                     ob_start();
                     include TL_ROOT . '/templates/' . $strFile;
                     $arrCache[$strTag] = ob_get_contents();
                     ob_end_clean();
                 }
                 $_GET = $arrGet;
                 \Input::resetCache();
                 break;
                 // HOOK: pass unknown tags to callback functions
             // HOOK: pass unknown tags to callback functions
             default:
                 if (isset($GLOBALS['TL_HOOKS']['replaceInsertTags']) && is_array($GLOBALS['TL_HOOKS']['replaceInsertTags'])) {
                     foreach ($GLOBALS['TL_HOOKS']['replaceInsertTags'] as $callback) {
                         $this->import($callback[0]);
                         $varValue = $this->{$callback}[0]->{$callback}[1]($strTag);
                         // Replace the tag and stop the loop
                         if ($varValue !== false) {
                             $arrCache[$strTag] = $varValue;
                             break;
                         }
                     }
                 }
                 break;
         }
         $strBuffer .= $arrCache[$strTag];
     }
     return $this->restoreBasicEntities($strBuffer);
 }
Exemplo n.º 26
0
 /**
  * Format a value
  *
  * @param string  $k
  * @param mixed   $value
  * @param boolean $blnListSingle
  *
  * @return mixed
  */
 protected function formatValue($k, $value, $blnListSingle = false)
 {
     $value = deserialize($value);
     // Return if empty
     if (empty($value)) {
         return '';
     }
     /** @var \PageModel $objPage */
     global $objPage;
     // Array
     if (is_array($value)) {
         $value = implode(', ', $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'date') {
         $value = \Date::parse($objPage->dateFormat, $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'time') {
         $value = \Date::parse($objPage->timeFormat, $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'datim') {
         $value = \Date::parse($objPage->datimFormat, $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'url' && preg_match('@^(https?://|ftp://)@i', $value)) {
         $value = \Idna::decode($value);
         // see #5946
         $value = '<a href="' . $value . '"' . ($objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"') . '>' . $value . '</a>';
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'email') {
         $value = \String::encodeEmail(\Idna::decode($value));
         // see #5946
         $value = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $value . '">' . $value . '</a>';
     } elseif (is_array($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'])) {
         $value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'][$value];
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'])) {
         if ($blnListSingle) {
             $value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value];
         } else {
             $value = '<span class="value">[' . $value . ']</span> ' . $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value];
         }
     }
     return $value;
 }
Exemplo n.º 27
0
 /**
  * FrontendAjax constructor.
  *
  * @param int $intModuleId
  */
 public static function run($intModuleId, $strToken)
 {
     if (!static::validateRequestToken($intModuleId, $strToken)) {
         static::respond(array('status' => 'error', 'message' => 'Invalid request token'));
     }
     $objModule = \ModuleModel::findByPk($intModuleId);
     if (!$objModule || $objModule->type !== 'anystores_map') {
         static::respond(array('status' => 'error', 'message' => 'Invalid module'));
     }
     // Hook to manipulate the module
     if (isset($GLOBALS['TL_HOOKS']['anystores_getAjaxModule']) && is_array($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'])) {
         foreach ($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'] as $callback) {
             \System::importStatic($callback[0])->{$callback[1]}($objModule);
         }
     }
     if (\Validator::isBinaryUuid($objModule->anystores_defaultMarker)) {
         $objFile = \FilesModel::findByPk($objModule->anystores_defaultMarker);
         $objModule->anystores_defaultMarker = $objFile ? $objFile->path : null;
     }
     // Find stores
     $objStores = AnyStoresModel::findPublishedByCategory(deserialize($objModule->anystores_categories));
     if (!$objStores) {
         static::respond(array('status' => 'error', 'message' => 'No stores found'));
     }
     while ($objStores->next()) {
         // generate jump to
         if ($objModule->jumpTo) {
             if (($objLocation = \PageModel::findByPk($objModule->jumpTo)) !== null) {
                 //@todo language parameter
                 $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
                 $strStoreValue = $objStores->alias;
                 $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
             }
         }
         // Encode email
         $objStores->email = \String::encodeEmail($objStores->email);
         // Encode opening times
         $objStores->opening_times = deserialize($objStores->opening_times);
         // decode logo
         if (\Validator::isBinaryUuid($objStores->logo)) {
             $objFile = \FilesModel::findByPk($objStores->logo);
             $objStores->logo = $objFile ? $objFile->path : null;
         }
         // decode marker
         if (\Validator::isBinaryUuid($objStores->marker)) {
             $objFile = \FilesModel::findByPk($objStores->marker);
             $objStores->marker = $objFile ? $objFile->path : null;
         }
         // add category marker
         $objStores->categoryMarker = null;
         if (($objCategory = AnyStoresCategoryModel::findByPk($objStores->pid)) !== null) {
             if (\Validator::isBinaryUuid($objCategory->defaultMarker)) {
                 $objFile = \FilesModel::findByPk($objCategory->defaultMarker);
                 if ($objFile) {
                     $objStores->categoryMarker = $objFile->path;
                 }
             }
         }
         // render html
         $strTemplate = $objModule->anystores_detailTpl ?: 'anystores_details';
         $objTemplate = new \FrontendTemplate($strTemplate);
         $objTemplate->setData($objStores->current()->row());
         $objStores->tiphtml = static::replaceInsertTags($objTemplate->parse());
     }
     $arrRespond = array('status' => 'success', 'count' => (int) $objStores->count(), 'module' => array('latitude' => (double) $objModule->anystores_latitude, 'longitude' => (double) $objModule->anystores_longitude, 'zoom' => (int) $objModule->anystores_zoom, 'streetview' => (bool) $objModule->anystores_streetview, 'maptype' => (string) $objModule->anystores_maptype, 'defaultMarker' => (string) $objModule->anystores_defaultMarker), 'stores' => $objStores->fetchAll());
     // decode global default marker
     $arrRespond['global']['defaultMarker'] = null;
     if (\Validator::isUuid(\Config::get('anystores_defaultMarker'))) {
         if (($objFile = \FilesModel::findByPk(\Config::get('anystores_defaultMarker'))) !== null) {
             $arrRespond['global']['defaultMarker'] = $objFile->path;
         }
     }
     static::respond($arrRespond);
 }
Exemplo n.º 28
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $type = null;
     $pageId = $objPage->id;
     $pages = array($objPage->row());
     $items = array();
     // Get all pages up to the root page
     $objPages = \PageModel::findParentsById($objPage->pid);
     if ($objPages !== null) {
         while ($objPages->next() && $pageId > 0 && $type != 'root') {
             $type = $objPages->type;
             $pageId = $objPages->pid;
             $pages[] = $objPages->row();
         }
     }
     // Get the first active regular page and display it instead of the root page
     if ($type == 'root') {
         $objFirstPage = \PageModel::findFirstPublishedByPid($objPages->id);
         $items[] = array('isRoot' => true, 'isActive' => false, 'href' => $objFirstPage !== null ? $this->generateFrontendUrl($objFirstPage->row()) : \Environment::get('base'), 'title' => specialchars($objPages->pageTitle ?: $objPages->title, true), 'link' => $objPages->title, 'data' => $objFirstPage->row(), 'class' => '');
         array_pop($pages);
     }
     // Build the breadcrumb menu
     for ($i = count($pages) - 1; $i > 0; $i--) {
         if ($pages[$i]['hide'] && !$this->showHidden || !$pages[$i]['published'] && !BE_USER_LOGGED_IN) {
             continue;
         }
         // Get href
         switch ($pages[$i]['type']) {
             case 'redirect':
                 $href = $pages[$i]['url'];
                 if (strncasecmp($href, 'mailto:', 7) === 0) {
                     $href = \String::encodeEmail($href);
                 }
                 break;
             case 'forward':
                 $objNext = \PageModel::findPublishedById($pages[$i]['jumpTo']);
                 if ($objNext !== null) {
                     $href = $this->generateFrontendUrl($objNext->row());
                     break;
                 }
                 // DO NOT ADD A break; STATEMENT
             // DO NOT ADD A break; STATEMENT
             default:
                 $href = $this->generateFrontendUrl($pages[$i]);
                 break;
         }
         $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $href, 'title' => specialchars($pages[$i]['pageTitle'] ?: $pages[$i]['title'], true), 'link' => $pages[$i]['title'], 'data' => $pages[$i], 'class' => '');
     }
     // Active article
     if (isset($_GET['articles'])) {
         $items[] = array('isRoot' => false, 'isActive' => false, 'href' => $this->generateFrontendUrl($pages[0]), 'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title'], true), 'link' => $pages[0]['title'], 'data' => $pages[0], 'class' => '');
         list($strSection, $strArticle) = explode(':', \Input::get('articles'));
         if ($strArticle === null) {
             $strArticle = $strSection;
         }
         // Get the article title
         $objArticle = \ArticleModel::findByIdOrAlias($strArticle);
         if ($objArticle !== null) {
             $items[] = array('isRoot' => false, 'isActive' => true, 'title' => specialchars($objArticle->title, true), 'link' => $objArticle->title, 'data' => $objArticle->row(), 'class' => '');
         }
     } else {
         $items[] = array('isRoot' => false, 'isActive' => true, 'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title']), 'link' => $pages[0]['title'], 'data' => $pages[0], 'class' => '');
     }
     // Mark the first element (see #4833)
     $items[0]['class'] = 'first';
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['generateBreadcrumb']) && is_array($GLOBALS['TL_HOOKS']['generateBreadcrumb'])) {
         foreach ($GLOBALS['TL_HOOKS']['generateBreadcrumb'] as $callback) {
             $this->import($callback[0]);
             $items = $this->{$callback}[0]->{$callback}[1]($items, $this);
         }
     }
     $this->Template->items = $items;
 }
 /**
  * Generate a URL and return it as string
  *
  * @param object
  * @param boolean
  *
  * @return string
  */
 protected function generateElementUrl($objItem)
 {
     $strCacheKey = 'id_' . $objItem->id;
     // Load the URL from cache
     if (isset(self::$arrUrlCache[$strCacheKey])) {
         return self::$arrUrlCache[$strCacheKey];
     }
     // Initialize the cache
     self::$arrUrlCache[$strCacheKey] = null;
     switch ($objItem->source) {
         // Link to an external page
         case 'external':
             if (substr($objItem->url, 0, 7) == 'mailto:') {
                 self::$arrUrlCache[$strCacheKey] = \String::encodeEmail($objItem->url);
             } else {
                 self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url);
             }
             break;
             // Link to an internal page
         // Link to an internal page
         case 'internal':
             if (($objTarget = $objItem->getRelated('jumpTo')) !== null) {
                 self::$arrUrlCache[$strCacheKey] = ampersand(\Controller::generateFrontendUrl($objTarget->row()));
             }
             break;
             // Link to an article
         // Link to an article
         case 'article':
             if (($objArticle = \ArticleModel::findByPk($objItem->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
                 self::$arrUrlCache[$strCacheKey] = ampersand(\Controller::generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)));
             }
             break;
     }
     return self::$arrUrlCache[$strCacheKey];
 }
 /**
  * Generate content element
  */
 protected function compile()
 {
     global $objPage;
     $this->import('String');
     $arrDownloadFiles = array();
     $time = time();
     foreach ($this->arrDownloadfiles as $k => $archive) {
         $objArchive = \FelixPfeiffer\Downloadarchive\DownloadarchiveModel::findByPk($k);
         $strLightboxId = 'lightbox[' . substr(md5($objArchive->title . '_' . $objArchive->id), 0, 6) . ']';
         foreach ($archive as $f => $arrFile) {
             #$objFile = \FilesModel::findByUuid($arrFile['singleSRC']);
             $objFile = new \File($f, true);
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $arrFile['description'] = \String::toXhtml($arrFile['description']);
             } else {
                 $arrFile['description'] = \String::toHtml5($arrFile['description']);
             }
             $arrFile['description'] = \String::encodeEmail($arrFile['description']);
             $arrFile['css'] = $objArchive->class != "" ? $objArchive->class . ' ' : '';
             $arrFile['ctime'] = $objFile->ctime;
             $arrFile['ctimeformated'] = date($GLOBALS['TL_CONFIG']['dateFormat'], $objFile->ctime);
             $arrFile['mtime'] = $objFile->mtime;
             $arrFile['mtimeformated'] = date($GLOBALS['TL_CONFIG']['dateFormat'], $objFile->mtime);
             $arrFile['atime'] = $objFile->mtime;
             $arrFile['atimeformated'] = date($GLOBALS['TL_CONFIG']['dateFormat'], $objFile->atime);
             // Add an image
             if ($arrFile['addImage'] && $arrFile['imgSRC'] != '') {
                 $objModel = \FilesModel::findByUuid($arrFile['imgSRC']);
                 if (is_file(TL_ROOT . '/' . $objModel->path)) {
                     $size = deserialize($arrFile['size']);
                     $arrFile['imgSRC'] = $arrFile['imgSrc'] = \Image::get($objModel->path, $size[0], $size[1], $size[2]);
                     // Image dimensions
                     if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($arrFile['imgSRC']))) !== false) {
                         $arrFile['arrSize'] = $imgSize;
                         $arrFile['imageSize'] = ' ' . $imgSize[3];
                     }
                     $arrFile['imgHref'] = $objModel->path;
                     $arrFile['alt'] = specialchars($arrFile['alt']);
                     $arrFile['imagemargin'] = $this->generateMargin(deserialize($arrFile['imagemargin']), 'padding');
                     $arrFile['floating'] = in_array($arrFile['floating'], array('left', 'right')) ? sprintf(' float:%s;', $arrFile['floating']) : '';
                     $arrFile['addImage'] = true;
                     $arrFile['lightbox'] = $objPage->outputFormat == 'xhtml' || VERSION < 2.11 ? ' rel="' . $strLightboxId . '"' : ' data-lightbox="' . substr($strLightboxId, 9, -1) . '"';
                 }
             }
             $arrFile['size'] = $this->getReadableSize($objFile->filesize);
             $src = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
             if (($imgSize = @getimagesize(TL_ROOT . '/' . $src)) !== false) {
                 $arrFile['iconSize'] = ' ' . $imgSize[3];
             }
             $arrFile['icon'] = $src;
             $arrFile['href'] = $this->Environment->request . (stristr($this->Environment->request, '?') ? '&' : '?') . 'file=' . $this->urlEncode($f);
             $arrFile['archive'] = $objArchive->title;
             $strSorting = str_replace(array(' ASC', ' DESC'), '', $this->downloadSorting);
             $arrDownloadFiles[$arrFile[$strSorting]][] = $arrFile;
         }
     }
     if (stristr($this->downloadSorting, 'DESC')) {
         krsort($arrDownloadFiles);
     } else {
         ksort($arrDownloadFiles);
     }
     $arrFiles = array();
     foreach ($arrDownloadFiles as $row) {
         foreach ($row as $file) {
             $arrFiles[] = $file;
         }
     }
     if ($this->downloadNumberOfItems > 0) {
         $arrFiles = array_slice($arrFiles, 0, $this->downloadNumberOfItems);
     }
     $i = 0;
     $length = count($arrFiles);
     if ($this->perPage > 0) {
         // Get the current page
         $page = $this->Input->get('page') ? $this->Input->get('page') : 1;
         if ($page > $length / $this->perPage) {
             $page = ceil($length / $this->perPage);
         }
         $offset = (($page > 1 ? $page : 1) - 1) * $this->perPage;
         $arrFiles = array_slice($arrFiles, $offset, $this->perPage);
         // Add pagination menu
         $objPagination = new Pagination($length, $this->perPage);
         $this->Template->pagination = $objPagination->generate("\n  ");
         $length = count($arrFiles);
     }
     foreach ($arrFiles as $file) {
         $class = "";
         if ($i++ == 0) {
             $class = "first ";
         }
         $class .= $i % 2 == 0 ? "even" : "odd";
         if ($i == $length) {
             $class .= " last";
         }
         $arrFiles[$i - 1]['css'] .= $class;
     }
     if (count($arrFiles) < 1) {
         $this->Template->arrFiles = $GLOBALS['TL_LANG']['MSC']['keinDownload'];
     } else {
         $this->Template->showMeta = $this->downloadShowMeta ? true : false;
         $this->Template->hideDate = $this->downloadHideDate ? true : false;
         $this->Template->arrFiles = $arrFiles;
     }
 }