/** * Generate AJAX scripts * @return string */ public function generateAjax() { $objProduct = IsotopeFrontend::getProduct($this->Input->get('product'), IsotopeFrontend::getReaderPageId(), false); if ($objProduct) { return $objProduct->generateAjax($this); } return ''; }
/** * Generate a single product and return it's HTML string * @return string */ public function generateAjax() { $objProduct = IsotopeFrontend::getProduct($this->Input->get('product'), IsotopeFrontend::getReaderPageId(null, $this->iso_reader_jumpTo), false); if ($objProduct !== null) { return $objProduct->generateAjax($this); } return ''; }
/** * Generate products from database result or array of IDs * @param Database_Result|array * @param integer * @param boolean * @param array * @param array * @return array */ public static function getProducts($objProductData, $intReaderPage = 0, $blnCheckAvailability = true, array $arrFilters = array(), array $arrSorting = array()) { // $objProductData can also be an array of product ids if (is_array($objProductData) && count($objProductData)) { $time = time(); $Database = Database::getInstance(); $objProductData = $Database->execute(IsotopeProduct::getSelectStatement() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p1.language='' AND p1.id IN (" . implode(',', array_map('intval', $objProductData)) . ")" . (BE_USER_LOGGED_IN === true ? '' : " AND p1.published='1' AND (p1.start='' OR p1.start<{$time}) AND (p1.stop='' OR p1.stop>{$time})") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY p1.id=" . implode(' DESC, p1.id=', $objProductData) . " DESC"); } if (!$objProductData instanceof Database_Result || !$objProductData->numRows) { return array(); } $arrProducts = array(); while ($objProductData->next()) { $objProduct = IsotopeFrontend::getProduct($objProductData, $intReaderPage, $blnCheckAvailability); if ($objProduct !== null) { $arrProducts[$objProductData->id] = $objProduct; } } if (!empty($arrFilters)) { global $filterConfig; $filterConfig = $arrFilters; $arrProducts = array_filter($arrProducts, array(self, 'filterProducts')); } // $arrProducts can be empty if the filter removed all records if (!empty($arrSorting) && !empty($arrProducts)) { $arrParam = array(); $arrData = array(); foreach ($arrSorting as $strField => $arrConfig) { foreach ($arrProducts as $id => $objProduct) { // Both SORT_STRING and SORT_REGULAR are case sensitive, strings starting with a capital letter will come before strings starting with a lowercase letter. // To perform a case insensitive search, force the sorting order to be determined by a lowercase copy of the original value. $arrData[$strField][$id] = strtolower(str_replace('"', '', $objProduct->{$strField})); } $arrParam[] =& $arrData[$strField]; foreach ($arrConfig as $k => $v) { $arrParam[] = $v; } } $strEval = ''; foreach ($arrParam as $k => $v) { $strEval .= '$arrParam[' . $k . '], '; } // Add product array as the last item. This will sort the products array based on the sorting of the passed in arguments. eval('array_multisort(' . $strEval . '$arrProducts);'); } return $arrProducts; }
/** * Shortcut for a single product by ID or from database result * @deprecated * @see IsotopeFrontend::getProduct() */ protected function getProduct($objProductData, $blnCheckAvailability = true) { trigger_error('Using ModuleIsotope::getProduct() is deprecated. Please use IsotopeFrontend::getProduct()', E_USER_NOTICE); return IsotopeFrontend::getProduct($objProductData, IsotopeFrontend::getReaderPageId(null, $this->iso_reader_jumpTo), $blnCheckAvailability); }