예제 #1
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     $link = '/articles/';
     $objArticle = $this->objArticle;
     if ($objArticle->inColumn != 'main') {
         $link .= $objArticle->inColumn . ':';
     }
     $link .= $objArticle->alias ?: $objArticle->id;
     $this->Template->href = $this->objParent->getFrontendUrl($link);
     // Clean the RTE output
     $this->Template->text = \StringUtil::toHtml5($objArticle->teaser);
     $this->Template->headline = $objArticle->title;
     $this->Template->readMore = \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title));
     $this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
 }
예제 #2
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $link = '/articles/';
     $objArticle = $this->objArticle;
     if ($objArticle->inColumn != 'main') {
         $link .= $objArticle->inColumn . ':';
     }
     $link .= $objArticle->alias != '' && !\Config::get('disableAlias') ? $objArticle->alias : $objArticle->id;
     $this->Template->href = $this->objParent->getFrontendUrl($link);
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->Template->text = \StringUtil::toXhtml($objArticle->teaser);
     } else {
         $this->Template->text = \StringUtil::toHtml5($objArticle->teaser);
     }
     $this->Template->headline = $objArticle->title;
     $this->Template->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title));
     $this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
 }
 /**
  * Get the category URL
  *
  * @param \PageModel $page
  *
  * @return string
  */
 public function getUrl(\PageModel $page)
 {
     $page->loadDetails();
     return $page->getFrontendUrl('/' . NewsCategories::getParameterName($page->rootId) . '/' . $this->alias);
 }
예제 #4
0
 /**
  * Get all searchable pages and return them as array
  *
  * @param integer $pid
  * @param string  $domain
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public static function findSearchablePages($pid = 0, $domain = '', $blnIsSitemap = false)
 {
     $time = \Date::floorToMinute();
     $objDatabase = \Database::getInstance();
     // Get published pages
     $objPages = $objDatabase->prepare("SELECT * FROM tl_page WHERE pid=? AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1' ORDER BY sorting")->execute($pid);
     if ($objPages->numRows < 1) {
         return array();
     }
     // Fallback domain
     if ($domain == '') {
         $domain = \Environment::get('base');
     }
     $arrPages = array();
     $objRegistry = \Model\Registry::getInstance();
     // Recursively walk through all subpages
     while ($objPages->next()) {
         $objPage = $objRegistry->fetch('tl_page', $objPages->id);
         if ($objPage === null) {
             $objPage = new \PageModel($objPages);
         }
         if ($objPage->type == 'regular') {
             // Searchable and not protected
             if ((!$objPage->noSearch || $blnIsSitemap) && (!$objPage->protected || \Config::get('indexProtected') && (!$blnIsSitemap || $objPage->sitemap == 'map_always')) && (!$blnIsSitemap || $objPage->sitemap != 'map_never')) {
                 // Published
                 if ($objPage->published && ($objPage->start == '' || $objPage->start <= $time) && ($objPage->stop == '' || $objPage->stop > $time + 60)) {
                     $feUrl = $objPage->getFrontendUrl();
                     if (strncmp($feUrl, 'http://', 7) !== 0 && strncmp($feUrl, 'https://', 8) !== 0) {
                         $feUrl = $domain . $feUrl;
                     }
                     $arrPages[] = $feUrl;
                     // Get articles with teaser
                     $objArticles = $objDatabase->prepare("SELECT * FROM tl_article WHERE pid=? AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1' AND showTeaser='1' ORDER BY sorting")->execute($objPages->id);
                     if ($objArticles->numRows) {
                         $feUrl = $objPage->getFrontendUrl('/articles/%s');
                         if (strncmp($feUrl, 'http://', 7) !== 0 && strncmp($feUrl, 'https://', 8) !== 0) {
                             $feUrl = $domain . $feUrl;
                         }
                         while ($objArticles->next()) {
                             $arrPages[] = sprintf($feUrl, $objArticles->alias != '' && !\Config::get('disableAlias') ? $objArticles->alias : $objArticles->id);
                         }
                     }
                 }
             }
         }
         // Get subpages
         if ((!$objPage->protected || \Config::get('indexProtected')) && ($arrSubpages = static::findSearchablePages($objPage->id, $domain, $blnIsSitemap)) != false) {
             $arrPages = array_merge($arrPages, $arrSubpages);
         }
     }
     return $arrPages;
 }