/** * 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(); }
/** * 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); }
/** * Instantiate the Isotope object * @return object */ public static function getInstance() { if (!is_object(self::$objInstance)) { self::$objInstance = new Isotope(); // Make sure field data is available self::$objInstance->loadDataContainer('tl_iso_products'); self::$objInstance->loadLanguageFile('tl_iso_products'); if (strlen($_SESSION['ISOTOPE']['config_id'])) { self::$objInstance->overrideConfig($_SESSION['ISOTOPE']['config_id']); } else { self::$objInstance->resetConfig(); } if (TL_MODE == 'FE' && strpos(self::$objInstance->Environment->script, 'postsale.php') === false && strpos(self::$objInstance->Environment->script, 'cron.php') === false) { self::$objInstance->Cart = new IsotopeCart(); self::$objInstance->Cart->initializeCart((int) self::$objInstance->Config->id, (int) self::$objInstance->Config->store_id); // Initialize request cache for product list filters if (self::$objInstance->Input->get('isorc') != '') { $objRequestCache = self::$objInstance->Database->prepare("SELECT * FROM tl_iso_requestcache WHERE id=? AND store_id=?")->execute(self::$objInstance->Input->get('isorc'), self::$objInstance->Config->store_id); if ($objRequestCache->numRows) { $GLOBALS['ISO_FILTERS'] = deserialize($objRequestCache->filters); $GLOBALS['ISO_SORTING'] = deserialize($objRequestCache->sorting); $GLOBALS['ISO_LIMIT'] = deserialize($objRequestCache->limits); } } } } return self::$objInstance; }
/** * Format surcharge prices * @param array * @return array */ public static function formatSurcharges($arrSurcharges) { $Isotope = Isotope::getInstance(); foreach ($arrSurcharges as $k => $arrSurcharge) { $arrSurcharges[$k]['price'] = $Isotope->formatPriceWithCurrency($arrSurcharge['price']); $arrSurcharges[$k]['total_price'] = $Isotope->formatPriceWithCurrency($arrSurcharge['total_price']); $arrSurcharges[$k]['rowClass'] = trim('foot_' . ($k + 1) . ' ' . $arrSurcharge[$k]['rowClass']); } return $arrSurcharges; }
/** * Add a request string to the given URI string or page ID * @param string * @param mixed * @return string */ public static function addQueryStringToUrl($strRequest, $varUrl = null) { if ($varUrl === null) { $varUrl = Environment::getInstance()->request; } elseif (is_numeric($varUrl)) { $objJump = Database::getInstance()->prepare("SELECT * FROM tl_page WHERE id=?")->execute($varUrl); $varUrl = Isotope::getInstance()->generateFrontendUrl($objJump->row()); } list($strScript, $strQueryString) = explode('?', $varUrl, 2); $strRequest = preg_replace('/^&(amp;)?/i', '', $strRequest); $queries = preg_split('/&(amp;)?/i', $strQueryString); // Overwrite existing parameters and ignore "language", see #64 foreach ($queries as $k => $v) { $explode = explode('=', $v); if ($k === 'language' || preg_match('/(^|&(amp;)?)' . preg_quote($explode[0], '/') . '=/i', $strRequest)) { unset($queries[$k]); } } $href = '?'; if (!empty($queries)) { $href .= implode('&', $queries) . '&'; } return $strScript . $href . str_replace(' ', '%20', $strRequest); }