예제 #1
0
 /**
  * Add newsletters to the indexer
  *
  * @param array   $arrPages
  * @param integer $intRoot
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     $time = \Date::floorToMinute();
     // Get all channels
     $objNewsletter = \NewsletterChannelModel::findAll();
     // Walk through each channel
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (!$objNewsletter->jumpTo) {
                 continue;
             }
             // Skip channels outside the root nodes
             if (!empty($arrRoot) && !in_array($objNewsletter->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objNewsletter->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objNewsletter->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop <= $time + 60) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 $arrProcessed[$objNewsletter->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objNewsletter->jumpTo];
             // Get the items
             $objItem = \NewsletterModel::findSentByPid($objNewsletter->id);
             if ($objItem !== null) {
                 while ($objItem->next()) {
                     $arrPages[] = sprintf($strUrl, $objItem->alias != '' && !\Config::get('disableAlias') ? $objItem->alias : $objItem->id);
                 }
             }
         }
     }
     return $arrPages;
 }
예제 #2
0
파일: Newsletter.php 프로젝트: rikaix/core
 /**
  * Add newsletters to the indexer
  * @param array
  * @param integer
  * @param boolean
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     // Get all channels
     $objNewsletter = \NewsletterChannelModel::findAll();
     // Walk through each channel
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             // Skip channels without target page
             if (!$objNewsletter->jumpTo) {
                 continue;
             }
             // Skip channels outside the root nodes
             if (!empty($arrRoot) && !in_array($objNewsletter->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objNewsletter->jumpTo])) {
                 $domain = \Environment::get('base');
                 $objParent = $this->getPageDetails($objNewsletter->jumpTo);
                 if ($objParent->domain != '') {
                     $domain = (\Environment::get('ssl') ? 'https://' : 'http://') . $objParent->domain . TL_PATH . '/';
                 }
                 $arrProcessed[$objNewsletter->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objNewsletter->jumpTo];
             // Get the items
             $objItem = \NewsletterModel::findSentByPid($objNewsletter->id);
             if ($objItem !== null) {
                 while ($objItem->next()) {
                     $arrPages[] = sprintf($strUrl, $objItem->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objItem->alias : $objItem->id);
                 }
             }
         }
     }
     return $arrPages;
 }