Ejemplo n.º 1
0
 /**
  * Add product items 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->Database->getChildRecords($intRoot, 'tl_page');
     }
     $time = time();
     $arrProcessed = array();
     // Get all catalog categories
     $objCategory = \CarpetCategoryModel::findByProtected('');
     // Walk through each archive
     if ($objCategory !== null) {
         while ($objCategory->next()) {
             // Skip catalog categories without target page
             if (!$objCategory->jumpTo) {
                 continue;
             }
             // Skip catalog categories outside the root nodes
             if (!empty($arrRoot) && !in_array($objCategory->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objCategory->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objCategory->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) {
                     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[$objCategory->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objCategory->jumpTo];
             // Get the items
             $objCarpet = \CarpetModel::findPublishedByPid($objCategory->id);
             if ($objCarpet !== null) {
                 while ($objCarpet->next()) {
                     $arrPages[] = $this->getLink($objCarpet, $strUrl);
                 }
             }
         }
     }
     return $arrPages;
 }
Ejemplo n.º 2
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->carpets = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objCarpet = \CarpetModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->carpet_categories);
     // Overwrite the page title
     if ($objCarpet->title != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objCarpet->title));
     }
     // Overwrite the page description
     if ($objCarpet->description != '') {
         $objPage->description = $this->prepareMetaDescription($objCarpet->description);
     }
     $arrCarpet = $this->parseCarpet($objCarpet);
     $this->Template->carpets = $arrCarpet;
 }
Ejemplo n.º 3
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $offset = intval($this->skipFirst);
     $limit = null;
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     $this->Template->carpets = array();
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyCategory'];
     $intTotal = \CarpetModel::countPublishedByPids($this->carpet_categories, $this->carpet_status);
     if ($intTotal < 1) {
         return;
     }
     $total = $intTotal - $offset;
     // Split the results
     if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) {
         // Adjust the overall limit
         if (isset($limit)) {
             $total = min($limit, $total);
         }
         // Get the current page
         $id = 'page_n' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             return;
         }
         // Set limit and offset
         $limit = $this->perPage;
         $offset += (max($page, 1) - 1) * $this->perPage;
         $skip = intval($this->skipFirst);
         // Overall limit
         if ($offset + $limit > $total + $skip) {
             $limit = $total + $skip - $offset;
         }
         // Add the pagination menu
         $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $arrOptions = array();
     if ($this->carpet_sortBy) {
         switch ($this->carpet_sortBy) {
             case 'title_asc':
                 $arrOptions['order'] = "title ASC";
                 break;
             case 'title_desc':
                 $arrOptions['order'] = "title DESC";
                 break;
             case 'alias_asc':
                 $arrOptions['order'] = "alias ASC";
                 break;
             case 'alias_desc':
                 $arrOptions['order'] = "alias DESC";
                 break;
             case 'date_asc':
                 $arrOptions['order'] = "date ASC";
                 break;
             case 'date_desc':
                 $arrOptions['order'] = "date DESC";
                 break;
             case 'custom':
                 $arrOptions['order'] = "sorting ASC";
                 break;
         }
     }
     // Get the items
     if (isset($limit)) {
         $objCarpets = \CarpetModel::findPublishedByPids($this->carpet_categories, $limit, $offset, $this->carpet_status, $arrOptions);
     } else {
         $objCarpets = \CarpetModel::findPublishedByPids($this->carpet_categories, 0, $offset, $this->carpet_status, $arrOptions);
     }
     // Add the Carpets
     if ($objCarpets !== null) {
         $this->Template->carpets = $this->parseCarpets($objCarpets);
     }
     $this->Template->gategories = $this->carpet_categories;
 }