/**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->project = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     // Get the Project item
     $objProject = \PortfolioProjectModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->portfolio_project_categories);
     if ($objProject === 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->projects = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     $arrProject = $this->parseProject($objProject);
     $this->Template->project = $arrProject;
     // Get the Client items
     $objClient = \PortfolioClientModel::findPublishedByParentAndIdOrAlias($objProject->clientID, $this->portfolio_project_categories);
     $this->Template->client = '';
     if ($objClient !== null) {
         $this->Template->client = $this->parseClient($objClient);
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objProject->title != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objProject->title));
     }
 }
Esempio n. 2
0
 /**
  * Add portfolio 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 client categories
     $objClientCategory = \PortfolioClientCategoryModel::findAll();
     // Walk through each category
     if ($objClientCategory !== null) {
         while ($objClientCategory->next()) {
             // Skip FAQs without target page
             if (!$objClientCategory->jumpTo) {
                 continue;
             }
             // Skip FAQs outside the root nodes
             if (!empty($arrRoot) && !in_array($objClientCategory->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objClientCategory->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objClientCategory->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[$objClientCategory->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objClientCategory->jumpTo];
             // Get the items
             $objClient = \PortfolioClientModel::findPublishedByPid($objClientCategory->id);
             if ($objClient !== null) {
                 while ($objClient->next()) {
                     $arrPages[] = sprintf($strUrl, $objClient->alias != '' && !\Config::get('disableAlias') ? $objClient->alias : $objClient->id);
                 }
             }
         }
     }
     // Get all project categories
     $objProjectCategory = \PortfolioProjectCategoryModel::findAll();
     // Walk through each category
     if ($objProjectCategory !== null) {
         while ($objProjectCategory->next()) {
             // Skip FAQs without target page
             if (!$objProjectCategory->jumpTo) {
                 continue;
             }
             // Skip FAQs outside the root nodes
             if (!empty($arrRoot) && !in_array($objProjectCategory->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objProjectCategory->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objProjectCategory->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[$objProjectCategory->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objProjectCategory->jumpTo];
             // Get the items
             $objProject = \PortfolioProjectModel::findPublishedByPid($objProjectCategory->id);
             if ($objProject !== null) {
                 while ($objProject->next()) {
                     $arrPages[] = sprintf($strUrl, $objProject->alias != '' && !\Config::get('disableAlias') ? $objProject->alias : $objProject->id);
                 }
             }
         }
     }
     return $arrPages;
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     $offset = intval($this->skipFirst);
     $limit = null;
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     // Handle featured news
     if ($this->cleint_featured == 'featured') {
         $blnFeatured = true;
     } elseif ($this->client_featured == 'unfeatured') {
         $blnFeatured = false;
     } else {
         $blnFeatured = null;
     }
     $this->Template->projects = array();
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyClientList'];
     // Get the total number of items
     $intTotal = \PortfolioClientModel::countPublishedByPids($this->portfolio_client_categories, $blnFeatured);
     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, $GLOBALS['TL_CONFIG']['maxPaginationLinks'], $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     // Get the items
     if (isset($limit)) {
         $objClients = \PortfolioClientModel::findPublishedByPids($this->portfolio_client_categories, $blnFeatured, $limit, $offset);
     } else {
         $objClients = \PortfolioClientModel::findPublishedByPids($this->portfolio_client_categories, $blnFeatured, 0, $offset);
     }
     // No items found
     if ($objClients !== null) {
         $this->Template->clients = $this->parseClients($objClients);
     }
     $this->Template->portfolio_client_categories = $this->portfolio_client_categories;
 }