vendor/memo_development/contao-portfolio-bundle/src/Module/ModulePortfolioListing.php line 91

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * @package   Memo\MemoPortfolioBundle
  4.  * @author    Media Motion AG
  5.  * @license   LGPL-3.0+
  6.  * @copyright Media Motion AG
  7.  */
  8. namespace Memo\PortfolioBundle\Module;
  9. use Memo\FoundationBundle\Module\FoundationModule;
  10. use Memo\PortfolioBundle\Model\PortfolioModel;
  11. use Terminal42\ChangeLanguage\PageFinder;
  12. class ModulePortfolioListing extends FoundationModule
  13. {
  14.     /**
  15.     * Template
  16.     * @var string
  17.     */
  18.     protected $strTemplate 'mod_portfolio_listing';
  19.     protected function compile()
  20.     {
  21.         if (TL_MODE == 'FE')
  22.         {
  23.             // Get all selected Archives
  24.             $arrArchives unserialize$this->foundation_archives );
  25.             // Get override detail-page
  26.             if($this->jumpTo)
  27.             {
  28.                 // Get translated Detailpage if not in main-language
  29.                 $objPageFinder = new PageFinder();
  30.                 $objDetailPage $objPageFinder->findAssociatedForLanguage(\PageModel::findByPk($this->jumpTo), $GLOBALS['TL_LANGUAGE']);
  31.             }
  32.             else
  33.             {
  34.                 $objDetailPage null;
  35.             }
  36.             // Get category filters
  37.             $arrCategoryFilters = array();
  38.             if($this->categories_filter){
  39.                 $arrCategoryFilters unserialize$this->categories_filter );
  40.             }
  41.             // Get the category filter type
  42.             $strCategoryFilterTyp $this->categories_filter_type;
  43.             // Define default filters
  44.             $arrColumns = array();
  45.             $arrValues = array();
  46.             if(count($arrCategoryFilters) > ) {
  47.                 if($strCategoryFilterTyp == 'and'){
  48.                     foreach($arrCategoryFilters as $intCategoryFilter){
  49.                         $arrColumns[] = 'categories LIKE ?';
  50.                         $arrValues[] = '%"' $intCategoryFilter '"%';
  51.                     }
  52.                 } else {
  53.                     $strColumns '(';
  54.                     foreach($arrCategoryFilters as $intCategoryFilter){
  55.                         $strColumns .= 'categories LIKE ? OR ';
  56.                         $arrValues[] = '%"' $intCategoryFilter '"%';
  57.                     }
  58.                     $strColumns substr($strColumns,0,-3);
  59.                     $strColumns .= ')';
  60.                     $arrColumns[] = $strColumns;
  61.                 }
  62.             }
  63.             // Respect the sql_filter
  64.             if($this->sql_filter){
  65.                 $arrColumns[] = $this->sql_filter;
  66.             }
  67.             // Define the findByOptions
  68.             $strTable PortfolioModel::getTable();
  69.             $arrFindByOptions $this->getFindByOptions($strTable);
  70.             // Retrieve Portfolio-Items
  71.             $colItems PortfolioModel::findPublishedByPids($arrArchives$arrFindByOptions$arrColumns$arrValues);
  72.             if( is_object($colItems) )
  73.             {
  74.                 $arrCategories = (!is_null($this->categories)) ? unserialize($this->categories) : array();
  75.                 $arrItems $this->parseItems($colItems$objDetailPagetrue$arrCategories);
  76.                 $this->Template->items $arrItems;
  77.             }
  78.             // Get custom Template
  79.             if( $this->customTpl )
  80.             {
  81.                 $this->Template->strTemplate $this->customTpl;
  82.             }
  83.             if( gettype($this->Template->cssID) === 'array' ) {
  84.                 if(array_key_exists(0$this->Template->cssID)){
  85.                     $this->Template->cssID $this->Template->cssID[0];
  86.                 } else {
  87.                     $this->Template->cssID '';
  88.                 }
  89.             }
  90.             // Parse Template
  91.             $this->Template->parse();
  92.         }
  93.         else
  94.         {
  95.             // Parse BackendTemplate
  96.             $this->parseBackendTemplate();
  97.         }
  98.     }
  99. }