Example #1
0
 /**
  * Fill the object's arrProducts array
  * @param   array|null
  * @return  array
  */
 protected function findProducts($arrCacheIds = null)
 {
     $t = Product::getTable();
     $arrColumns = array();
     $arrCategories = $this->findCategories();
     $arrProductIds = \Database::getInstance()->query("SELECT pid FROM " . ProductCategory::getTable() . " WHERE page_id IN (" . implode(',', $arrCategories) . ")")->fetchEach('pid');
     $arrTypes = \Database::getInstance()->query("SELECT id FROM " . ProductType::getTable() . " WHERE variants='1'")->fetchEach('id');
     if (empty($arrProductIds)) {
         return array();
     }
     list($arrFilters, $arrSorting, $strWhere, $arrValues) = $this->getFiltersAndSorting();
     if (!is_array($arrValues)) {
         $arrValues = array();
     }
     $arrColumns[] = "(\n            ({$t}.id IN (" . implode(',', $arrProductIds) . ") AND {$t}.type NOT IN (" . implode(',', $arrTypes) . "))\n            OR {$t}.pid IN (" . implode(',', $arrProductIds) . ")\n        )";
     if (!empty($arrCacheIds) && is_array($arrCacheIds)) {
         $arrColumns[] = Product::getTable() . ".id IN (" . implode(',', $arrCacheIds) . ")";
     }
     // Apply new/old product filter
     if ($this->iso_newFilter == 'show_new') {
         $arrColumns[] = Product::getTable() . ".dateAdded>=" . Isotope::getConfig()->getNewProductLimit();
     } elseif ($this->iso_newFilter == 'show_old') {
         $arrColumns[] = Product::getTable() . ".dateAdded<" . Isotope::getConfig()->getNewProductLimit();
     }
     if ($this->iso_list_where != '') {
         $arrColumns[] = Haste::getInstance()->call('replaceInsertTags', $this->iso_list_where);
     }
     if ($strWhere != '') {
         $arrColumns[] = $strWhere;
     }
     $objProducts = Product::findAvailableBy($arrColumns, $arrValues, array('order' => 'c.sorting', 'filters' => $arrFilters, 'sorting' => $arrSorting));
     return null === $objProducts ? array() : $objProducts->getModels();
 }
Example #2
0
 /**
  * Check the Isotope config directory for a particular template
  *
  * @param string $strTemplate
  * @param string $strFormat
  *
  * @return string
  */
 public static function getTemplate($strTemplate, $strFormat = 'html5')
 {
     $arrAllowed = trimsplit(',', $GLOBALS['TL_CONFIG']['templateFiles']);
     if (is_array($GLOBALS['TL_CONFIG']['templateFiles']) && !in_array($strFormat, $arrAllowed)) {
         throw new \InvalidArgumentException("Invalid output format {$strFormat}");
     }
     $strKey = $strTemplate . '.' . $strFormat;
     $strPath = TL_ROOT . '/templates';
     $strTemplate = basename($strTemplate);
     // Check the templates subfolder
     $strTemplateGroup = str_replace(array('../', 'templates/'), '', Isotope::getConfig()->templateGroup);
     if ($strTemplateGroup != '') {
         $strFile = $strPath . '/' . $strTemplateGroup . '/' . $strKey;
         if (file_exists($strFile)) {
             return $strFile;
         }
         if (file_exists($strFile)) {
             return $strFile;
         }
     }
     return parent::getTemplate($strTemplate, $strFormat);
 }