Ejemplo n.º 1
0
 /**
  * Set the panel settings.
  */
 public function SetPanelSettings()
 {
     $cVendor = GetClass('ISC_VENDORS');
     $vendor = $cVendor->GetVendor();
     $GLOBALS['VendorId'] = $vendor['vendorid'];
     $GLOBALS['VendorName'] = $vendor['vendorname'];
     // Set the field we're sorting results by
     if (isset($_REQUEST['sort'])) {
         $sort = $_REQUEST['sort'];
     } else {
         $sort = '';
     }
     switch ($sort) {
         case 'newest':
             $sortField = 'p.productid DESC';
             $GLOBALS['SortNewestSelected'] = 'selected="selected"';
             break;
         case 'bestselling':
             $sortField = 'p.prodnumsold DESC';
             $GLOBALS['SortBestSellingSelected'] = 'selected="selected"';
             break;
         case 'alphaasc':
             $sortField = 'p.prodname ASC';
             $GLOBALS['SortAlphaAsc'] = 'selected="selected"';
             break;
         case 'alphadesc':
             $sortField = 'p.prodname DESC';
             $GLOBALS['SortAlphaDesc'] = 'selected="selected"';
             break;
         case 'avgcustomerreview':
             $sortField = 'prodavgrating DESC';
             $GLOBALS['SortAvgReview'] = 'selected="selected"';
             break;
         case 'priceasc':
             $sortField = 'p.prodcalculatedprice ASC';
             $GLOBALS['SortPriceAsc'] = 'selected="selected"';
             break;
         case 'pricedesc':
             $sortField = 'p.prodcalculatedprice DESC';
             $GLOBALS['SortPriceDesc'] = 'selected="selected"';
             break;
         default:
             $sortField = 'p.prodvendorfeatured DESC';
             $sort = 'featured';
             $GLOBALS['SortFeaturedSelected'] = 'selected="selected"';
             break;
     }
     // If we're viewing a certain page, fetch our starting position
     if (isset($_REQUEST['page']) && IsId($_REQUEST['page'])) {
         $page = (int) $_REQUEST['page'];
         $start = $page * GetConfig('CategoryProductsPerPage') - GetConfig('CategoryProductsPerPage');
     } else {
         $page = 1;
         $start = 0;
     }
     // Count the number of products that belong in this vendor
     $query = "\n\t\t\tSELECT COUNT(p.productid) AS numproducts\n\t\t\tFROM [|PREFIX|]products p\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tWHERE p.prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t";
     $numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
     $numPages = ceil($numProducts / GetConfig('CategoryProductsPerPage'));
     // Now load the actual products for this vendor
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND imageisthumb=1)\n\t\t\t\tWHERE prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t\t\tORDER BY " . $sortField . ", prodname ASC\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, GetConfig('CategoryProductsPerPage'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['SNIPPETS']['VendorProducts'] = '';
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     // Should we show the compare button?
     if (GetConfig('EnableProductComparisons') == 0 || $numProducts < 2) {
         $GLOBALS['HideCompareItems'] = "none";
     } else {
         $GLOBALS['CompareLink'] = CompareLink();
     }
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             $GLOBALS['ProductURL'] = CartLink($row['productid']);
             $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['HideProductVendorName'] = 'display: none';
         $GLOBALS['ProductVendor'] = '';
         if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['prodvendorid']])) {
                 $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                 $GLOBALS['HideProductVendorName'] = '';
             }
         }
         $GLOBALS['SNIPPETS']['VendorProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorProductsItem");
     }
     // Does paging need to be shown?
     if ($numProducts > GetConfig('CategoryProductsPerPage')) {
         $GLOBALS['SNIPPETS']['PagingData'] = "";
         $numEitherSide = 5;
         $start = max($page - $numEitherSide, 1);
         $end = min($page + $numEitherSide, $numPages);
         for ($i = $start; $i <= $end; $i++) {
             if ($i == $page) {
                 $snippet = "CategoryPagingItemCurrent";
             } else {
                 $snippet = "CategoryPagingItem";
             }
             $pageData = array('page' => $i, 'sort' => $sort);
             $GLOBALS['PageLink'] = VendorProductsLink($vendor, $pageData);
             $GLOBALS['PageNumber'] = $i;
             $GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
         }
         // Do we need to output a "Previous" link?
         if ($page > 1) {
             $pageData = array('page' => $page - 1, 'sort' => $sort);
             $GLOBALS['PrevLink'] = VendorProductsLink($vendor, $pageData);
             $GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
         }
         // Do we need to output a "Next" link?
         if ($page < $numPages) {
             $pageData = array('page' => $page + 1, 'sort' => $sort);
             $GLOBALS['NextLink'] = VendorProductsLink($vendor, $pageData);
             $GLOBALS['SNIPPETS']['CategoryPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
         }
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPaging");
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
         $GLOBALS['SNIPPETS']['ProductPaging'] = $output;
     }
     // Parse the sort select box snippet
     if ($numProducts > 1) {
         // Parse the sort select box snippet
         if ($GLOBALS['EnableSEOUrls'] == 1 && $vendor['vendorfriendlyname']) {
             $GLOBALS['URL'] = VendorProductsLink($vendor);
         } else {
             $GLOBALS['URL'] = $GLOBALS['ShopPath'] . "/vendors.php";
             $GLOBALS['HiddenSortField'] = "<input type=\"hidden\" name=\"vendorid\" value=\"" . (int) $vendor['vendorid'] . "\" />";
             $GLOBALS['HiddenSortField'] .= "<input type=\"hidden\" name=\"action\" value=\"products\" />";
         }
         $GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox");
     }
 }
Ejemplo n.º 2
0
		/**
		*	Show a list of items that the customer has recently viewed by browsing our site
		*/
		private function ShowRecentItems()
		{

			$viewed = "";

			if (isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) {
				$viewed = $_COOKIE['RECENTLY_VIEWED_PRODUCTS'];
			} else if (isset($_SESSION['RECENTLY_VIEWED_PRODUCTS'])) {
				$viewed = $_SESSION['RECENTLY_VIEWED_PRODUCTS'];
			}

			if ($viewed != "") {
				$GLOBALS['HideNoRecentItemsMessage'] = "none";
				$GLOBALS['SNIPPETS']['AccountRecentItems'] = "";

				$viewed_products = array();
				$viewed_products = explode(",", $viewed);
				foreach ($viewed_products as $k => $p) {
					$viewed_products[$k] = (int) $p;
				}

				// Reverse the array so recently viewed products appear up top
				$viewed_products = array_reverse($viewed_products);

				// Hide the compare button if there's less than 2 products
				if (GetConfig('EnableProductComparisons') == 0 || count($viewed_products) < 2) {
					$GLOBALS['HideCompareItems'] = "none";
				}

				if (!empty($viewed_products)) {
					if(!getProductReviewsEnabled()) {
						$GLOBALS['HideProductRating'] = "display: none";
					}
					$query = "
						SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL()."
						FROM [|PREFIX|]products p
						LEFT JOIN [|PREFIX|]product_images pi ON (productid=pi.imageprodid AND imageisthumb=1)
						WHERE prodvisible='1' AND productid in ('".implode("','", $viewed_products)."')
						".GetProdCustomerGroupPermissionsSQL()."
					";
					$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
					if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
						$GLOBALS['AlternateClass'] = '';
						while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
							if($GLOBALS['AlternateClass'] == 'Odd') {
								$GLOBALS['AlternateClass'] = 'Even';
							}
							else {
								$GLOBALS['AlternateClass'] = 'Odd';
							}

							$GLOBALS['ProductId'] = (int) $row['productid'];
							$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
							$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
							$GLOBALS['ProductRating'] = (int)$row['prodavgrating'];

							// Determine the price of this product
							$GLOBALS['ProductPrice'] = '';
							if (GetConfig('ShowProductPrice') && !$row['prodhideprice']) {
								$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
							}

							$GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname']));

							$GLOBALS['SNIPPETS']['AccountRecentItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountRecentlyViewedProducts");
						}
					}
				}
				else {
					$GLOBALS['HideRecentItemList'] = "none";
				}
			}
			else {
				$GLOBALS['HideRecentItemList'] = "none";
			}

			$GLOBALS['CompareLink'] = CompareLink();

			// Show the list of available shipping addresses
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName') . " - " . GetLang('RecentlyViewedItems'));
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("account_recentitems");
			$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
		}
Ejemplo n.º 3
0
	public function SetPanelSettings()
	{
		$viewed = "";

		if(isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) {
			$viewed = $_COOKIE['RECENTLY_VIEWED_PRODUCTS'];
		}
		else if(isset($_SESSION['RECENTLY_VIEWED_PRODUCTS'])) {
			$viewed = $_SESSION['RECENTLY_VIEWED_PRODUCTS'];
		}

		$GLOBALS['CompareLink'] = CompareLink();

		if(!$viewed) {
			$this->DontDisplay = true;
			return;
		}

		// Hide the top selling products panel from the cart page
		$GLOBALS['HideSideTopSellersPanel'] = "none";

		$output = "";
		$viewed_products = explode(",", $viewed);
		$viewed_products = array_map('intval', $viewed_products);

		// Reverse the array so recently viewed products appear up top
		$viewed_products = array_reverse($viewed_products);

		// Hide the compare button if there's less than 2 products
		if(GetConfig('EnableProductComparisons') == 0 || count($viewed_products) < 2) {
			$GLOBALS['HideSideProductRecentlyViewedCompare'] = "none";
		}

		if(!getProductReviewsEnabled()) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		$query = $this->getProductQuery('p.productid IN ('.implode(',', $viewed_products).')');
		$result = $GLOBALS['ISC_CLASS_DB']->query($query);
		$productData = array();
		while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$productData[$row['productid']] = $row;
		}

		if(empty($productData)) {
			$this->DontDisplay = true;
			return;
		}

		$GLOBALS['AlternateClass'] = '';
		foreach($viewed_products as $productId) {
			if(empty($productData[$productId])) {
				continue;
			}

			$this->setProductGlobals($productData[$productId]);
			$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideRecentlyViewedProducts");
		}

		$GLOBALS['SNIPPETS']['SideProductRecentlyViewed'] = $output;
	}
Ejemplo n.º 4
0
 public function ShowCategory()
 {
     $GLOBALS['CatId'] = (int) $this->GetId();
     $GLOBALS['CatName'] = isc_html_escape($this->GetName());
     $GLOBALS['CatDesc'] = $this->GetDesc();
     $GLOBALS['CompareLink'] = CompareLink();
     // Do we need to add RSS feeds in for this category?
     if (!isset($GLOBALS['HeadRSSLinks'])) {
         $GLOBALS['HeadRSSLinks'] = '';
     }
     if (GetConfig('RSSCategories') != 0) {
         if (GetConfig('RSSNewProducts') != 0) {
             $GLOBALS['HeadRSSLinks'] .= GenerateRSSHeaderLink($GLOBALS['ShopPath'] . "/rss.php?categoryid=" . $GLOBALS['CatId'], sprintf(GetLang('HeadRSSNewProductsCategory'), $GLOBALS['CatName']));
         }
         if (GetConfig('RSSPopularProducts') != 0) {
             $GLOBALS['HeadRSSLinks'] .= GenerateRSSHeaderLink($GLOBALS['ShopPath'] . "/rss.php?action=popularproducts&categoryid=" . $GLOBALS['CatId'], sprintf(GetLang('HeadRSSPopularProductsCategory'), $GLOBALS['CatName']));
         }
     }
     if ($this->_catmetakeywords != "") {
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($this->_catmetakeywords);
     }
     if ($this->_catmetadesc != "") {
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($this->_catmetadesc);
     }
     if (!$this->GetNumProducts()) {
         $GLOBALS['HideRightColumn'] = 'none';
         $GLOBALS['ExtraCategoryClass'] = 'Wide';
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->BuildTitle());
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate($this->GetLayoutFile());
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Ejemplo n.º 5
0
		public function ShowBrand()
		{
			$GLOBALS['BrandId'] = $this->GetId();
			$GLOBALS['BrandName'] = $this->GetBrand();
			if($this->GetPage() > 1) {
				$this->_brandcanonicallink = BrandLink($this->GetBrandName(), array('page' => $this->GetPage()));
			} else {
				$this->_brandcanonicallink = BrandLink($this->GetBrandName());
			}

			$GLOBALS['CompareLink'] = CompareLink();

			if ($this->GetBrand() == "") {
				$GLOBALS['TrailBrandName'] = GetLang('AllBrands');
				$this->_allbrands = true;
			} else {
				$GLOBALS['TrailBrandName'] = isc_html_escape($this->GetBrand());
			}

			if ($this->_brandmetakeywords != "") {
				$GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($this->_brandmetakeywords);
			}

			if ($this->_brandmetadesc != "") {
				$GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($this->_brandmetadesc);
			}

			if ($this->_brandcanonicallink != "") {
				$GLOBALS['ISC_CLASS_TEMPLATE']->SetCanonicalLink($this->_brandcanonicallink);
			}

			$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->BuildTitle());
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("brands");
			$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
		}
Ejemplo n.º 6
0
 /**
  *	Show the search page. If there are results, show them too. If we're in advanced mode then
  *	show the advanced search options as well.
  */
 function ShowSearchPage()
 {
     if (isset($_GET['category'])) {
         $selected_cats = $_GET['category'];
     } else {
         $selected_cats = 0;
     }
     if (isset($_GET['mode']) && $_GET['mode'] == "advanced") {
         $GLOBALS['HideAdvancedLink'] = "none";
     }
     include_once dirname(__FILE__) . "/class.brands.php";
     $GLOBALS['CompareLink'] = CompareLink();
     $GLOBALS['ISC_CLASS_BRANDS'] = GetClass('ISC_BRANDS');
     $GLOBALS['BrandNameOptions'] = $GLOBALS['ISC_CLASS_BRANDS']->GetBrandsAsOptions(@$this->_searchterms['brand']);
     $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
     $GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions($selected_cats, "<option %s value='%d'>%s</option>", 'selected="selected"', "", false, 1);
     if (isset($_GET['searchsubs']) && $_GET['searchsubs'] == "ON" || @$this->_searchterms['search_query'] == "") {
         $GLOBALS['IsSearchSubs'] = 'checked="checked"';
     }
     if (isset($this->_searchterms['price_from']) && is_numeric($this->_searchterms['price_from'])) {
         $GLOBALS['PriceFrom'] = $this->_searchterms['price_from'];
     }
     if (isset($this->_searchterms['price_to']) && is_numeric($this->_searchterms['price_to'])) {
         $GLOBALS['PriceTo'] = $this->_searchterms['price_to'];
     }
     if (isset($this->_searchterms['featured'])) {
         $GLOBALS["Featured" . $this->_searchterms['featured']] = 'selected="selected"';
     }
     if (isset($this->_searchterms['shipping'])) {
         $GLOBALS["Shipping" . $this->_searchterms['shipping']] = 'selected="selected"';
     }
     if (@$this->_searchterms['search_query'] != "") {
         $GLOBALS['SNIPPETS']['RelatedSearches'] = "";
         $has_suggestion = false;
         $changed_words = array();
         $query = $this->Suggest($this->_searchterms['search_query'], $has_suggestion, $changed_words);
         // Are we on a particular page?
         if (isset($_REQUEST['page'])) {
             $page = (int) $_REQUEST['page'];
             $this->_currentpage = $page;
             if ($page == 1) {
                 $start = 0;
             } else {
                 $start = ($page - 1) * GetConfig('CategoryProductsPerPage');
             }
         } else {
             $start = 0;
         }
         // Did pSpell make a suggestion?
         if ($query != $this->_searchterms['search_query']) {
             // pSpell made a suggestion
             $words = explode(" ", $this->_searchterms['search_query']);
             /* ---- the below below lines are commented for not showing as alternate names are shown instead - start ---- */
             /*foreach ($words as $k=>$word) {
             						foreach ($changed_words as $changed_word) {
             							if ($word == $changed_word[0]) {
             								$words[$k] = "<strong>" . $changed_word[1] . "</strong>";
             							}
             						}
             					}
             
             					$GLOBALS['SuggestQuery'] = implode(" ", $words);
             					$GLOBALS['SuggestQueryEscaped'] = urlencode($query);*/
             /* ------------ ends ---------- */
             /* --- this below patch is for getting alternate keywords as per client request ---- starts ---*/
             $GLOBALS['NewSuggestQuery'] = "";
             foreach ($changed_words as $key => $value) {
                 $words = explode(",", $value);
                 for ($i = 0; $i < count($words); $i++) {
                     $words[$i] = trim($words[$i]);
                     $GLOBALS['NewSuggestQuery'][] = "<a href='" . $GLOBALS['ShopPathNormal'] . "/search.php?search_query=" . urlencode($words[$i]) . "&search_key=1'>" . $words[$i] . "</a>";
                 }
             }
             if (!empty($GLOBALS['NewSuggestQuery'])) {
                 $GLOBALS['NewSuggestQuery'] = implode(" , ", $GLOBALS['NewSuggestQuery']);
             }
             /* ------ ends ----- */
             $GLOBALS['ShowSearchSuggestion'] = "";
         } else {
             // No search suggestion
             $GLOBALS['ShowSearchSuggestion'] = "none";
         }
         // Load up a list of results which the panel will take care of displaying
         $this->DoSearch($start, $GLOBALS['SearchResults'], $this->_numresults);
         //NI CLOUD
         //filter for single cat or brand
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) == 1) {
             $sresult = $GLOBALS['ISC_CLASS_DB']->Query($GLOBALS['DoSearchQuery']);
             $row = $GLOBALS['ISC_CLASS_DB']->Fetch($sresult);
             if (!isset($row["prodcode"])) {
                 if (isset($row["parentcatname"])) {
                     $query = "SELECT b.* FROM [|PREFIX|]brands b, [|PREFIX|]brand_series bs  WHERE b.brandid = bs.brandid and bs.seriesid = " . $row["brandseriesid"];
                     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                     if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
                         $crow = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                         if ($crow["displayproducts"] == '1') {
                             header("Location:" . $GLOBALS["ShopPath"] . $_SERVER["REQUEST_URI"] . "/series/" . MakeURLSafe($row["seriesname"]));
                         }
                     }
                 } else {
                     $query = "SELECT * FROM [|PREFIX|]categories c WHERE c.categoryid = (SELECT catparentid FROM [|PREFIX|]categories where categoryid = " . $row["categoryid"] . ")";
                     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                     if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
                         $crow = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                         if (strtolower($crow["displayproducts"]) == 'on') {
                             header("Location:" . $GLOBALS["ShopPath"] . $_SERVER["REQUEST_URI"] . "/subcategory/" . MakeURLSafe($row["catname"]));
                         }
                     } else {
                         $query = "(SELECT * FROM [|PREFIX|]categories where categoryid = " . $row["categoryid"] . ")";
                         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                         $crow = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                         if (strtolower($crow["displayproducts"]) == 'on') {
                             header("Location:" . $GLOBALS["ShopPath"] . $_SERVER["REQUEST_URI"] . "/subcategory/" . MakeURLSafe($row["catname"]));
                         }
                     }
                 }
             }
         }
         // Log the search result
         if ($start == 0) {
             //wirror_20100913: filter the request from yahoo,google,msn & baidu
             if (isset($_SERVER['HTTP_USER_AGENT'])) {
                 $userAgent = $_SERVER['HTTP_USER_AGENT'];
                 $webSpiders = array('Yahoo! Slurp', 'Baiduspider', 'Googlebot', 'msnbot');
                 $noSpider = true;
                 foreach ($webSpiders as $spider) {
                     if (strpos($userAgent, $spider) !== false) {
                         $noSpider = false;
                         break;
                     }
                 }
             }
             // lguan_20100520: Only do the log if smart search flag is on, means we only log the search terms user input in smart search box
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $url_array = split('/', strtolower($_SERVER['REQUEST_URI']));
                 $is_smart_search = $url_array[array_search('is_smart_search', $url_array, true) + 1];
                 if (isset($is_smart_search) && $is_smart_search == 1 && isset($this->_searchterms['search_query']) && strlen($this->_searchterms['search_query']) > 0 && $noSpider) {
                     $GLOBALS['SearchId'] = $this->LogSearch($this->_searchterms['search_query'], $this->_numresults);
                 }
             } else {
                 if (isset($_GET['is_smart_search']) && $_GET['is_smart_search'] == 1 && isset($this->_searchterms['search_query']) && strlen($this->_searchterms['search_query']) > 0 && $noSpider) {
                     $GLOBALS['SearchId'] = $this->LogSearch($this->_searchterms['search_query'], $this->_numresults);
                 }
             }
         }
         // Load up a list of related searches
         $related_searches = $this->GetRelatedSearchTerms($this->_searchterms['search_query']);
         if (!empty($related_searches)) {
             foreach ($related_searches as $related_search) {
                 $GLOBALS['RelatedSearchQuery'] = urlencode($related_search);
                 $GLOBALS['RelatedSearchText'] = isc_html_escape($related_search);
                 $GLOBALS['SNIPPETS']['RelatedSearches'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("RelatedSearchItem");
             }
             $GLOBALS['SNIPPETS']['RelatedSearches'] = trim($GLOBALS['SNIPPETS']['RelatedSearches'], ", ");
         } else {
             $GLOBALS['HideRelatedSearches'] = "none";
         }
         /* this below patch has been added to hide the below 3 sections as per client requirements */
         if ($this->_numresults == 0) {
             $GLOBALS['HideRelatedSearches'] = "none";
             if (!empty($GLOBALS['NewSuggestQuery'])) {
                 $GLOBALS['ShowSearchSuggestion'] = "";
             } else {
                 $GLOBALS['ShowSearchSuggestion'] = "none";
             }
             $GLOBALS['SearchTitle'] = "";
         } else {
             $GLOBALS['ShowSearchSuggestion'] = "none";
         }
         // How many pages of results are there?
         $this->_numpages = ceil($this->_numresults / GetConfig('CategoryProductsPerPage'));
     } else {
         // Show the advanced mode box instead and hide everything else if there's no search term
         if (@$this->_searchterms['search_query'] == "") {
             $GLOBALS['HideRelatedSearches'] = "none";
             $GLOBALS['ShowSearchSuggestion'] = "none";
             $GLOBALS['HideSearchResults'] = "none";
             $GLOBALS['HideNoResults'] = "none";
         }
     }
     /* Re-writing the search keywords as per the selection in the search field */
     $originalsearchquery = isset($GLOBALS['OriginalSearchQuery']) ? $GLOBALS['OriginalSearchQuery'] : '';
     $GLOBALS['OriginalSearchQuery'] = "";
     $searchquerystring = array();
     $ymmTitle = array();
     // This variable is used to get YMM and add it to title tag.
     if (isset($GLOBALS['ISC_SRCH_BRAND_NAME'])) {
         $searchquerystring[] = $GLOBALS['ISC_SRCH_BRAND_NAME'];
     }
     if (isset($this->_searchterms['partnumber'])) {
         $searchquerystring[] = $this->_searchterms['partnumber'];
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $searchquerystring[] = $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($this->_searchterms['year'])) {
         $searchquerystring[] = $this->_searchterms['year'];
         $ymmTitle[] = $this->_searchterms['year'];
     }
     if (isset($this->_searchterms['make'])) {
         $searchquerystring[] = strtoupper($this->_searchterms['make']);
         $ymmTitle[] = ucwords(strtolower($this->_searchterms['make']));
     }
     if (isset($_REQUEST['model']) && !empty($_REQUEST['model'])) {
         $searchquerystring[] = $_REQUEST['model'];
         $ymmTitle[] = ucwords(strtolower($_REQUEST['model']));
     }
     if (isset($this->_searchterms['submodel'])) {
         $searchquerystring[] = ucwords(strtolower($this->_searchterms['submodel']));
     }
     if (!empty($this->_searchterms['dynfilters'])) {
         $searchquerystring[] = implode(" ", $this->_searchterms['dynfilters']);
     }
     if (empty($searchquerystring) && $originalsearchquery != 'categories' && $originalsearchquery != 'brands' && !isset($_REQUEST['change'])) {
         // when none of the above selection is made, need to show the search keyword entered
         $searchquerystring[] = $originalsearchquery;
     }
     $GLOBALS['OriginalSearchQuery'] = implode(" ", $searchquerystring);
     $GLOBALS['FormattedSearchQuery'] = $GLOBALS['OriginalSearchQuery'];
     /* ----------------------------------------------------------------------- */
     /*---- The below two variables are added to set the search title and page title again after resetting ----*/
     //$GLOBALS['SearchTitle'] = $this->_numresults." ".sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']);
     //if( isset($this->_searchterms['partnumber']) || (isset($this->_searchterms['flag_srch_category']) && $this->_searchterms['flag_srch_category'] == 1 ) || ( isset($this->_searchterms['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1 ))
     if ($GLOBALS['results_page_flag'] == 2) {
         $GLOBALS['SearchTitle'] = $this->GetSearchResultMessage();
         //$GLOBALS['SearchTitle'] = $this->_numresults." ".sprintf(GetLang('SpecificResultsFor'), "Parts",  $GLOBALS['OriginalSearchQuery']);
     } else {
         if ($GLOBALS['results_page_flag'] == 1) {
             $GLOBALS['SearchTitle'] = $this->_numresults . " " . sprintf(GetLang('SpecificResultsFor'), "Series", $GLOBALS['OriginalSearchQuery']);
         } else {
             $GLOBALS['SearchTitle'] = $this->GetSearchResultMessage();
         }
     }
     /*
     			else {
         if(isset($this->_searchterms['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))  
         {
     					$GLOBALS['SearchTitle'] = $this->GetSearchResultMessage();
             //$GLOBALS['SearchTitle'] = $this->_numresults." ".sprintf(GetLang('SpecificResultsFor'), "Subcategories",  $GLOBALS['OriginalSearchQuery']);  
         }
         else
         {
             $GLOBALS['SearchTitle'] = $this->_numresults." ".sprintf(GetLang('SpecificResultsFor'), "Series", $GLOBALS['OriginalSearchQuery']);            
         }
     }
     */
     if ($this->_numresults == 0) {
         $GLOBALS['RedefinedSearchQuery'] = $GLOBALS['OriginalSearchQuery'];
         if ($GLOBALS['OriginalSearchQuery'] == '') {
             $GLOBALS['SearchTitle'] = '';
         } else {
             $GLOBALS['SearchTitle'] = $this->_numresults . " " . sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']);
         }
     }
     if (trim($this->_pagetitle) == "") {
         $this->_pagetitle = sprintf(GetLang('SearchSimpleTitle'), GetConfig('StoreName'), strip_tags($GLOBALS['SearchTitle']));
     }
     /*-- Prefixing YMM to actual title tag --*/
     if (!empty($ymmTitle)) {
         $ymmTitle[] = $this->_pagetitle;
         $this->_pagetitle = implode($ymmTitle, " ");
     }
     if ($this->_numresults == 0 && isset($this->_searchterms['searchtext'])) {
         $GLOBALS['RedefinedSearchQuery'] = $GLOBALS['OriginalSearchQuery'];
     }
     $GLOBALS['OriginalSearchQuery'] = '';
     if (isset($this->_searchterms['searchtext'])) {
         //$searchquerystring = array();
         $GLOBALS['OriginalSearchQuery'] = $this->_searchterms['searchtext'];
     }
     if (isset($this->_searchterms['search'])) {
         //$searchquerystring = array();
         $GLOBALS['OriginalSearchQuery'] = $this->_searchterms['search'];
         $GLOBALS['RedefinedSearchQuery'] = $GLOBALS['OriginalSearchQuery'];
     }
     // Hide the search form if we have just performed a search
     if (!empty($this->_searchterms)) {
         $GLOBALS['AutoHideSearchForm'] = "true";
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->_pagetitle);
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("search");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Ejemplo n.º 7
0
 public function ShowPrice()
 {
     $GLOBALS['CompareLink'] = CompareLink();
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->BuildTitle());
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("price");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Ejemplo n.º 8
0
 public function ShowPage()
 {
     if ($this->_prodid > 0) {
         $GLOBALS['ProductIds'] = $this->_prodid;
         // Check that the customer has permisison to view this product
         $canView = false;
         $path = GetConfig('ShopPath');
         $productCategories = explode(',', $this->_product['prodcatids']);
         foreach ($productCategories as $categoryId) {
             // Do we have permission to access this category?
             if (CustomerGroupHasAccessToCategory($categoryId)) {
                 $canView = true;
             }
         }
         if ($canView == false) {
             $noPermissionsPage = GetClass('ISC_403');
             $noPermissionsPage->HandlePage();
             exit;
         }
         if ($this->_prodmetakeywords != "") {
             $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords(isc_html_escape($this->_prodmetakeywords));
         }
         if ($this->_prodmetadesc != "") {
             $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription(isc_html_escape($this->_prodmetadesc));
         }
         $GLOBALS['CompareLink'] = CompareLink();
         // If we're showing images as a lightbox, we need to load up the URLs for the other images for this product
         if (GetConfig('ProductImageMode') == 'lightbox') {
             $GLOBALS['AdditionalStylesheets'][] = GetConfig('ShopPath') . '/javascript/jquery/plugins/lightbox/lightbox.css';
         }
         $url_string = $_SERVER['REQUEST_URI'];
         if (isset($_SERVER['QUERY_STRING'])) {
             $url_string .= $_SERVER['QUERY_STRING'];
         }
         if (eregi('refer=true', $url_string) && isset($_SESSION['back2url'])) {
             $GLOBALS['B2Search'] = "&nbsp;< <a href='{$path}/" . $_SESSION['back2url'] . "'>Back to search results</a>";
         } else {
             $_SESSION['v_cols'] = array();
             $_SESSION['p_cols'] = array();
         }
         //zcs=>only login customer can access "Product Reviews"
         $GLOBALS['StyleProductReviews'] = CustomerIsSignedIn() ? 'style="text-decoration:none;"' : 'style="display:none;"';
         //<=zcs
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate($this->_prodlayoutfile);
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     } else {
         ShowInvalidError('product');
         die;
     }
 }
Ejemplo n.º 9
0
		public function ShowPage()
		{
			if ($this->_prodid > 0) {
				// Check that the customer has permission to view this product
				$canView = false;
				$productCategories = explode(',', $this->_product['prodcatids']);
				foreach($productCategories as $categoryId) {
					// Do we have permission to access this category?
					if(CustomerGroupHasAccessToCategory($categoryId)) {
						$canView = true;
					}
				}
				if($canView == false) {
					$noPermissionsPage = GetClass('ISC_403');
					$noPermissionsPage->HandlePage();
					exit;
				}

				if ($this->_prodmetakeywords != "") {
					$GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords(isc_html_escape($this->_prodmetakeywords));
				}

				if ($this->_prodmetadesc != "") {
					$GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription(isc_html_escape($this->_prodmetadesc));
				}

				$GLOBALS['ISC_CLASS_TEMPLATE']->SetCanonicalLink(ProdLink($this->_prodname));
				$GLOBALS['CompareLink'] = CompareLink();

				// If we're showing images as a lightbox, we need to load up the URLs for the other images for this product
				if(GetConfig('ProductImageMode') == 'lightbox') {
					$GLOBALS['AdditionalStylesheets'][]  = 	GetConfig('ShopPath').'/javascript/jquery/plugins/lightbox/lightbox.css';
				}

				$GLOBALS['AdditionalMetaTags'] = ISC_OPENGRAPH::getMetaTags($this->_opengraph_type, $this->_opengraph_title, $this->_opengraph_description, $this->_opengraph_image, ProdLink($this->_prodname));

				ISC_PRODUCT_VIEWS::logView($this->_prodid);

				$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->BuildTitle());
				$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate($this->getLayoutFile());
				$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
			}
			// Visiting an invalid product, show a lovely error message
			else {
				$GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404');
				$GLOBALS['ISC_CLASS_404']->HandlePage();
				exit;
			}
		}
Ejemplo n.º 10
0
 public function SetPanelSettings()
 {
     $tagId = $GLOBALS['ISC_CLASS_TAGS']->GetTagId();
     $tagFriendlyName = $GLOBALS['ISC_CLASS_TAGS']->GetTagFriendlyName();
     $GLOBALS['TaggedProducts'] = sprintf(GetLang('ProductsTaggedWith'), $GLOBALS['ISC_CLASS_TAGS']->GetTagName());
     // Does paging need to be shown?
     if ($GLOBALS['ISC_CLASS_TAGS']->GetNumProducts() > GetConfig('CategoryProductsPerPage')) {
         $GLOBALS['SNIPPETS']['PagingData'] = "";
         $numEitherSide = 5;
         $start = max($GLOBALS['ISC_CLASS_TAGS']->GetPage() - $numEitherSide, 1);
         $end = min($GLOBALS['ISC_CLASS_TAGS']->GetPage() + $numEitherSide, $GLOBALS['ISC_CLASS_TAGS']->GetNumPages());
         for ($page = $start; $page <= $end; $page++) {
             if ($page == $GLOBALS['ISC_CLASS_TAGS']->GetPage()) {
                 $snippet = "CategoryPagingItemCurrent";
             } else {
                 $snippet = "CategoryPagingItem";
             }
             $pageData = array('page' => $page, 'sort' => $GLOBALS['ISC_CLASS_TAGS']->GetSort());
             $GLOBALS['PageLink'] = TagLink($tagFriendlyName, $tagId, $pageData);
             $GLOBALS['PageNumber'] = $page;
             $GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
         }
         // Do we need to output a "Previous" link?
         if ($GLOBALS['ISC_CLASS_TAGS']->GetPage() > 1) {
             $pageData = array('page' => $GLOBALS['ISC_CLASS_TAGS']->GetPage() - 1, 'sort' => $GLOBALS['ISC_CLASS_TAGS']->GetSort());
             $GLOBALS['PrevLink'] = TagLink($tagFriendlyName, $tagId, $pageData);
             $GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
         }
         // Do we need to output a "Next" link?
         if ($GLOBALS['ISC_CLASS_TAGS']->GetPage() < $GLOBALS['ISC_CLASS_TAGS']->GetNumPages()) {
             $pageData = array('page' => $GLOBALS['ISC_CLASS_TAGS']->GetPage() + 1, 'sort' => $GLOBALS['ISC_CLASS_TAGS']->GetSort());
             $GLOBALS['NextLink'] = TagLink($tagFriendlyName, $tagId, $pageData);
             $GLOBALS['SNIPPETS']['CategoryPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
         }
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPaging");
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
         $GLOBALS['SNIPPETS']['TagPaging'] = $output;
     }
     // Should we show the compare button?
     if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_TAGS']->GetNumProducts() < 2) {
         $GLOBALS['HideCompareItems'] = "display: none";
     } else {
         $GLOBALS['CompareLink'] = CompareLink();
     }
     // Parse the sort select box snippet
     if ($GLOBALS['ISC_CLASS_TAGS']->GetNumProducts() > 1) {
         // Parse the sort select box snippet
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $GLOBALS['URL'] = TagLink($tagFriendlyName, $tagId);
         } else {
             $GLOBALS['URL'] = $GLOBALS['ShopPath'] . "/tags.php";
             $GLOBALS['HiddenSortField'] = "<input type=\"hidden\" name=\"tagid\" value=\"" . (int) $tagId . "\" />";
         }
         $GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox");
     }
     // Actually load the products
     $products = $GLOBALS['ISC_CLASS_TAGS']->GetProducts();
     $GLOBALS['TagProductListing'] = '';
     // Show products for a specific tag
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $GLOBALS['AlternateClass'] = '';
     foreach ($products as $row) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             $GLOBALS['ProductURL'] = CartLink($row['productid']);
             $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['HideProductVendorName'] = 'display: none';
         $GLOBALS['ProductVendor'] = '';
         if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['prodvendorid']])) {
                 $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                 $GLOBALS['HideProductVendorName'] = '';
             }
         }
         $GLOBALS['TagProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("TagProductsItem");
     }
 }
 public function SetPanelSettings()
 {
     $viewed = "";
     if (isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) {
         $viewed = $_COOKIE['RECENTLY_VIEWED_PRODUCTS'];
     } else {
         if (isset($_SESSION['RECENTLY_VIEWED_PRODUCTS'])) {
             $viewed = $_SESSION['RECENTLY_VIEWED_PRODUCTS'];
         }
     }
     $GLOBALS['CompareLink'] = CompareLink();
     if ($viewed != "") {
         // Hide the top selling products panel from the cart page
         $GLOBALS['HideSideTopSellersPanel'] = "none";
         $output = "";
         $viewed_products = array();
         $viewed_products = explode(",", $viewed);
         foreach ($viewed_products as $k => $p) {
             $viewed_products[$k] = (int) $p;
         }
         // Reverse the array so recently viewed products appear up top
         $viewed_products = array_reverse($viewed_products);
         // Hide the compare button if there's less than 2 products
         if (GetConfig('EnableProductComparisons') == 0 || count($viewed_products) < 2) {
             $GLOBALS['HideSideProductRecentlyViewedCompare'] = "none";
         }
         if (!empty($viewed_products)) {
             if (GetConfig('EnableProductReviews') == 0) {
                 $GLOBALS['HideProductRating'] = "display: none";
             }
             $query = "\n\t\t\t\t\t\tSELECT p.*, prodratingtotal/prodnumratings AS prodavgrating, i.imagefile, i.imageisthumb, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid AND i.imageisthumb=1)\n\t\t\t\t\t\tWHERE prodvisible='1' AND productid IN ('" . implode("','", $viewed_products) . "')\n\t\t\t\t\t";
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     $recently_viewed_products[] = $row;
                 }
                 $GLOBALS['AlternateClass'] = '';
                 foreach ($viewed_products as $product_id) {
                     foreach ($recently_viewed_products as $row) {
                         if ($product_id == $row['productid']) {
                             if ($GLOBALS['AlternateClass'] == 'Odd') {
                                 $GLOBALS['AlternateClass'] = 'Even';
                             } else {
                                 $GLOBALS['AlternateClass'] = 'Odd';
                             }
                             $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                             $GLOBALS['ProductCartQuantity'] = '';
                             if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                                 $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                             }
                             $GLOBALS['ProductId'] = (int) $row['productid'];
                             //temp script to shortern the product name
                             if ($row['prodbrandid'] == 37) {
                                 $query = "SELECT c.catname, c.catcombine FROM [|PREFIX|]categories \tc left join [|PREFIX|]categoryassociations ca on c.categoryid = ca.categoryid  left join [|PREFIX|]products p on ca.productid = p.productid where p.productid =  '" . $row['productid'] . "' ";
                                 $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                                 $cat = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                                 if ($cat['catcombine'] != "") {
                                     $GLOBALS['ProductName'] = $cat['catcombine'] . " Part Number " . isc_html_escape($row['prodcode']);
                                 } else {
                                     $GLOBALS['ProductName'] = $cat['catname'] . " Part Number " . isc_html_escape($row['prodcode']);
                                 }
                             } else {
                                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                             }
                             //temp script to shortern the product name
                             //$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                             $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                             // Determine the price of this product
                             $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                             if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                                 $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
                                 $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                             } else {
                                 //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                                 $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
                                 //blessen
                                 if (intval($row['prodretailprice']) <= 0) {
                                     $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                                 } else {
                                     $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1');
                                 }
                                 //blessen
                                 //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                             }
                             if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                                 $GLOBALS['HideActionAdd'] = '';
                             } else {
                                 $GLOBALS['HideActionAdd'] = 'none';
                             }
                             $GLOBALS['HideProductVendorName'] = 'display: none';
                             $GLOBALS['ProductVendor'] = '';
                             if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                                 $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                                 if (isset($vendorCache[$row['prodvendorid']])) {
                                     $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                                     $GLOBALS['HideProductVendorName'] = '';
                                 }
                             }
                             $GLOBALS['ProductRating'] = $this->getRoundValue((double) $row['prodavgrating']);
                             $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideRecentlyViewedProducts");
                         }
                     }
                 }
             } else {
                 $GLOBALS['HideRecentlyViewedProductsPanel'] = "none";
                 $this->DontDisplay = true;
             }
         } else {
             $GLOBALS['HideRecentlyViewedProductsPanel'] = "none";
             $this->DontDisplay = true;
         }
         $GLOBALS['SNIPPETS']['SideProductRecentlyViewed'] = $output;
     } else {
         // Cookies aren't working, hide the panel
         $GLOBALS['HideRecentlyViewedProductsPanel'] = "none";
         $this->DontDisplay = true;
     }
 }
Ejemplo n.º 12
0
 public function LoadProductsToCompare()
 {
     $count = 0;
     $output = "";
     $tOutput = "";
     $products = array();
     // First row - the "Remove" link
     $GLOBALS['SNIPPETS']['TD1'] = "";
     $GLOBALS['SNIPPETS']['TD2'] = "";
     $GLOBALS['SNIPPETS']['TD3'] = "";
     $GLOBALS['SNIPPETS']['TD4'] = "";
     $GLOBALS['SNIPPETS']['TD5'] = "";
     $GLOBALS['SNIPPETS']['TD6'] = "";
     $GLOBALS['SNIPPETS']['TD7'] = "";
     $GLOBALS['SNIPPETS']['TD8'] = "";
     $GLOBALS['SNIPPETS']['TD9'] = "";
     $GLOBALS['SNIPPETS']['TD10'] = "";
     $GLOBALS['SNIPPETS']['TD11'] = "";
     // Do we need to sort?
     if ($this->_comparesort != "") {
         $sort = sprintf("order by %s", $this->_comparesort);
     } else {
         $sort = "";
     }
     $product_ids = $this->GetProductIds();
     if (empty($product_ids)) {
         return;
     }
     $productids_array = explode('/', $this->GetIds());
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $GLOBALS['BaseCompareLink'] = CompareLink($productids_array) . '?';
     } else {
         $GLOBALS['BaseCompareLink'] = CompareLink($productids_array) . '&amp;';
     }
     $compareWidth = 100 - 20;
     $compareWidth = floor($compareWidth / count($this->_compareproducts));
     $GLOBALS['CompareWidth'] = $compareWidth . "%";
     $GLOBALS['CompareHeadWidth'] = 100 - $compareWidth * count($this->_compareproducts) . "%";
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . ",\n\t\t\t\t(SELECT brandname FROM [|PREFIX|]brands WHERE brandid=prodbrandid) AS brand,\n\t\t\t\t(select count(fieldid) from [|PREFIX|]product_customfields where fieldprodid=p.productid) as numcustomfields,\n\t\t\t\t(select count(reviewid) from [|PREFIX|]reviews where revproductid=p.productid and revstatus='1') AS numreviews\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE p.prodvisible='1' AND p.productid IN (" . $product_ids . ") AND (pi.imageisthumb=1 OR ISNULL(pi.imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t" . $sort;
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['ProductNumber'] = $count++;
         if ($row['brand'] != "") {
             $GLOBALS['ProductBrand'] = sprintf("<a href='%s'>%s</a>", BrandLink($row['brand']), isc_html_escape($row['brand']));
         } else {
             $GLOBALS['ProductBrand'] = GetLang('NA');
         }
         // Build the page title
         $this->_comparetitle .= sprintf("%s %s ", isc_html_escape($row['prodname']), GetLang('VS'));
         $GLOBALS['ProductId'] = $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['NumReviews'] = $row['numreviews'];
         if ($row['numreviews'] == 0) {
             $GLOBALS['HideComparisonReviewLink'] = "none";
         } else {
             $GLOBALS['HideComparisonReviewLink'] = "";
         }
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
         if ($row['prodavailability'] != "") {
             $GLOBALS['ProductAvailability'] = isc_html_escape($row['prodavailability']);
         } else {
             $GLOBALS['ProductAvailability'] = GetLang('NA');
         }
         $compare_ids = array_diff($this->_compareproducts, array($row['productid']));
         if (count($compare_ids) == 1) {
             $GLOBALS['RemoveCompareLink'] = "javascript:alert('%%LNG_CompareTwoProducts%%');";
         } else {
             $GLOBALS['RemoveCompareLink'] = CompareLink($compare_ids);
             if (!empty($this->_comparesort)) {
                 $GLOBALS['RemoveCompareLink'] .= '?sort=' . $_GET['sort'];
             }
         }
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         if ($row['proddesc'] != "") {
             // Strip out HTML from the description first
             $row['proddesc'] = strip_tags($row['proddesc']);
             if (isc_strlen($row['proddesc']) > 200) {
                 $GLOBALS['ProductSummary'] = isc_substr($row['proddesc'], 0, 200) . "...";
             } else {
                 $GLOBALS['ProductSummary'] = $row['proddesc'];
             }
         } else {
             $GLOBALS['ProductSummary'] = GetLang('NA');
         }
         // Are there any custom fields?
         if ($row['numcustomfields'] > 0) {
             $GLOBALS['CustomFields'] = "";
             // Get the custom fields for this product
             $query = sprintf("select * from [|PREFIX|]product_customfields where fieldprodid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($row['productid']));
             $cResult = $GLOBALS['ISC_CLASS_DB']->Query($query);
             while ($cRow = $GLOBALS['ISC_CLASS_DB']->Fetch($cResult)) {
                 $GLOBALS['CustomFieldName'] = isc_html_escape($cRow['fieldname']);
                 $GLOBALS['CustomFieldValue'] = $cRow['fieldvalue'];
                 $GLOBALS['CustomFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductCustomField");
             }
         } else {
             $GLOBALS['CustomFields'] = GetLang('NA');
         }
         $GLOBALS['SNIPPETS']['TD1'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD1");
         $GLOBALS['SNIPPETS']['TD2'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD2");
         $GLOBALS['SNIPPETS']['TD3'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD3");
         $GLOBALS['SNIPPETS']['TD4'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD4");
         $GLOBALS['SNIPPETS']['TD5'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD5");
         $GLOBALS['SNIPPETS']['TD6'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD6");
         $GLOBALS['SNIPPETS']['TD7'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD7");
         $GLOBALS['SNIPPETS']['TD8'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD8");
         $GLOBALS['SNIPPETS']['TD9'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTD9");
     }
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none;";
     }
     $output1 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR1");
     $output2 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR2");
     $output3 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR3");
     $output4 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR4");
     $output5 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR5");
     $output6 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR6");
     $output7 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR7");
     $output8 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR8");
     $output9 = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareProductTR9");
     $output = $output1 . $output2 . $output3 . $output4 . $output9 . $output5 . $output6 . $output7 . $output8;
     $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
     $GLOBALS['SNIPPETS']['ComparisonList'] = $output;
 }
Ejemplo n.º 13
0
	public function SetPanelSettings()
	{
		$tagId = $GLOBALS['ISC_CLASS_TAGS']->GetTagId();
		$tagFriendlyName = $GLOBALS['ISC_CLASS_TAGS']->GetTagFriendlyName();
		$GLOBALS['TaggedProducts'] = sprintf(GetLang('ProductsTaggedWith'), $GLOBALS['ISC_CLASS_TAGS']->GetTagName());

		// Does paging need to be shown?
		if($GLOBALS['ISC_CLASS_TAGS']->GetNumProducts() > GetConfig('CategoryProductsPerPage')) {
			$GLOBALS['SNIPPETS']['PagingData'] = "";

			$numEitherSide = 5;
			if($GLOBALS['ISC_CLASS_TEMPLATE']->getIsMobileDevice()) {
				$numEitherSide = 3;
			}

			$start = max($GLOBALS['ISC_CLASS_TAGS']->GetPage()-$numEitherSide,1);
			$end = min($GLOBALS['ISC_CLASS_TAGS']->GetPage()+$numEitherSide, $GLOBALS['ISC_CLASS_TAGS']->GetNumPages());

			for($page = $start; $page <= $end; $page++) {
				if ($page == $GLOBALS['ISC_CLASS_TAGS']->GetPage()) {
					$snippet = "CategoryPagingItemCurrent";
				}
				else {
					$snippet = "CategoryPagingItem";
				}

				$pageData = array(
					'page' => $page,
					'sort' => $GLOBALS['ISC_CLASS_TAGS']->GetSort()
				);
				$GLOBALS['PageLink'] = TagLink($tagFriendlyName, $tagId, $pageData);
				$GLOBALS['PageNumber'] = $page;
				$GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
			}

			// Do we need to output a "Previous" link?
			if($GLOBALS['ISC_CLASS_TAGS']->GetPage() > 1) {
				$pageData = array(
					'page' => $GLOBALS['ISC_CLASS_TAGS']->GetPage()-1,
					'sort' => $GLOBALS['ISC_CLASS_TAGS']->GetSort()
				);
				$GLOBALS['PrevLink'] = TagLink($tagFriendlyName, $tagId, $pageData);
				$GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
			}

			// Do we need to output a "Next" link?
			if($GLOBALS['ISC_CLASS_TAGS']->GetPage() < $GLOBALS['ISC_CLASS_TAGS']->GetNumPages()) {
				$pageData = array(
					'page' => $GLOBALS['ISC_CLASS_TAGS']->GetPage()+1,
					'sort' => $GLOBALS['ISC_CLASS_TAGS']->GetSort()
				);
				$GLOBALS['NextLink'] = TagLink($tagFriendlyName, $tagId, $pageData);
				$GLOBALS['SNIPPETS']['CategoryPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
			}

			$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPaging");
			$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
			$GLOBALS['SNIPPETS']['TagPaging'] = $output;
		}

		// Should we show the compare button?
		if(GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_TAGS']->GetNumProducts() < 2) {
			$GLOBALS['HideCompareItems'] = "display: none";
		}
		else {
			$GLOBALS['CompareLink'] = CompareLink();
		}

		// Parse the sort select box snippet
		if($GLOBALS['ISC_CLASS_TAGS']->GetNumProducts() > 1) {

			// Parse the sort select box snippet
			if($GLOBALS['EnableSEOUrls'] == 1) {
				$GLOBALS['URL'] = TagLink($tagFriendlyName, $tagId);
			}
			else {
				$GLOBALS['URL'] = $GLOBALS['ShopPath']."/tags.php";
				$GLOBALS['HiddenSortField'] = "<input type=\"hidden\" name=\"tagid\" value=\"".(int)$tagId."\" />";
			}

			$GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox");
		}

		// Actually load the products
		$products = $GLOBALS['ISC_CLASS_TAGS']->GetProducts();

		$GLOBALS['TagProductListing'] = '';

		// Show products for a specific tag
		if(!getProductReviewsEnabled()) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		$GLOBALS['AlternateClass'] = '';
		foreach($products as $row) {
			$this->setProductGlobals($row);
			$GLOBALS['TagProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("TagProductsItem");
		}
	}
Ejemplo n.º 14
0
	/**
	 * Set the panel settings.
	 */
	public function SetPanelSettings()
	{
		$cVendor = GetClass('ISC_VENDORS');
		$vendor = $cVendor->GetVendor();

		$GLOBALS['VendorId'] = $vendor['vendorid'];
		$GLOBALS['VendorName'] = $vendor['vendorname'];

		// Set the field we're sorting results by
		if(isset($_REQUEST['sort'])) {
			$sort = $_REQUEST['sort'];
		}
		else {
			$sort = '';
		}

		switch($sort) {
			case 'newest':
				$sortField = 'p.productid DESC';
				$GLOBALS['SortNewestSelected'] = 'selected="selected"';
				break;
			case 'bestselling':
				$sortField = 'p.prodnumsold DESC';
				$GLOBALS['SortBestSellingSelected'] = 'selected="selected"';
				break;
			case 'alphaasc':
				$sortField = 'p.prodname ASC';
				$GLOBALS['SortAlphaAsc'] = 'selected="selected"';
				break;
			case 'alphadesc':
				$sortField = 'p.prodname DESC';
				$GLOBALS['SortAlphaDesc'] = 'selected="selected"';
				break;
			case 'avgcustomerreview':
				$sortField = 'prodavgrating DESC';
				$GLOBALS['SortAvgReview'] = 'selected="selected"';
				break;
			case 'priceasc':
				$sortField = 'p.calculated_price ASC';
				$GLOBALS['SortPriceAsc'] = 'selected="selected"';
				break;
			case 'pricedesc';
				$sortField = 'p.calculated_price DESC';
				$GLOBALS['SortPriceDesc'] = 'selected="selected"';
				break;
			default:
				$sortField = 'p.prodvendorfeatured DESC';
				$sort = 'featured';
				$GLOBALS['SortFeaturedSelected'] = 'selected="selected"';
				break;
		}

		// If we're viewing a certain page, fetch our starting position
		if(isset($_REQUEST['page']) && IsId($_REQUEST['page'])) {
			$page = (int)$_REQUEST['page'];
			$start = ($page * GetConfig('CategoryProductsPerPage')) - GetConfig('CategoryProductsPerPage');
		}
		else {
			$page = 1;
			$start = 0;
		}

		// Count the number of products that belong in this vendor
		$query = "
			SELECT COUNT(p.productid) AS numproducts
			FROM [|PREFIX|]products p
			".GetProdCustomerGroupPermissionsSQL()."
			WHERE p.prodvisible='1' AND p.prodvendorid='".(int)$vendor['vendorid']."'
		";
		$numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
		$numPages = ceil($numProducts / GetConfig('CategoryProductsPerPage'));

		// Now load the actual products for this vendor
		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'],
			$sortField.', prodname ASC',
			getConfig('CategoryProductsPerPage'),
			$start
		);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		$GLOBALS['SNIPPETS']['VendorProducts'] = '';

		if(!GetConfig('ShowProductRating')) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		// Should we show the compare button?
		if(GetConfig('EnableProductComparisons') == 0 || $numProducts < 2) {
			$GLOBALS['HideCompareItems'] = "none";
		}
		else {
			$GLOBALS['CompareLink'] = CompareLink();
		}

		$GLOBALS['AlternateClass'] = '';
		while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$this->setProductGlobals($row);
			$GLOBALS['SNIPPETS']['VendorProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorProductsItem");
		}

		// Does paging need to be shown?
		if($numProducts > GetConfig('CategoryProductsPerPage')) {
			$GLOBALS['SNIPPETS']['PagingData'] = "";

			$numEitherSide = 5;
			$start = max($page-$numEitherSide,1);
			$end = min($page+$numEitherSide, $numPages);

			for($i = $start; $i <= $end; $i++) {
				if ($i == $page) {
					$snippet = "CategoryPagingItemCurrent";
				}
				else {
					$snippet = "CategoryPagingItem";
				}

				$pageData = array(
					'page' => $i,
					'sort' => $sort
				);
				$GLOBALS['PageLink'] = VendorProductsLink($vendor, $pageData);
				$GLOBALS['PageNumber'] = $i;
				$GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
			}

			// Do we need to output a "Previous" link?
			if($page > 1) {
				$pageData = array(
					'page' => $page-1,
					'sort' => $sort
				);
				$GLOBALS['PrevLink'] = VendorProductsLink($vendor, $pageData);
				$GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
			}

			// Do we need to output a "Next" link?
			if($page < $numPages) {
				$pageData = array(
					'page' => $page+1,
					'sort' => $sort
				);
				$GLOBALS['NextLink'] = VendorProductsLink($vendor, $pageData);
				$GLOBALS['SNIPPETS']['CategoryPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
			}

			$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPaging");
			$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
			$GLOBALS['SNIPPETS']['ProductPaging'] = $output;
		}

		// Parse the sort select box snippet
		if($numProducts > 1) {

			// Parse the sort select box snippet
			if($GLOBALS['EnableSEOUrls'] == 1 && $vendor['vendorfriendlyname']) {
				$GLOBALS['URL'] = VendorProductsLink($vendor);
			}
			else {
				$GLOBALS['URL'] = $GLOBALS['ShopPath']."/vendors.php";
				$GLOBALS['HiddenSortField'] = "<input type=\"hidden\" name=\"vendorid\" value=\"".(int)$vendor['vendorid']."\" />";
				$GLOBALS['HiddenSortField'] .= "<input type=\"hidden\" name=\"action\" value=\"products\" />";
			}

			$GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox");
		}
	}
Ejemplo n.º 15
0
		/**
		*	Show the search page. If there are results, show them too. If we're in advanced mode then
		*	show the advanced search options as well.
		*/
		public function ShowSearchPage()
		{
			if (isset($_GET['ajax'])) {
				return $this->ShowAjaxSearchPage();
			}

			if (isset($_GET['category'])) {
				$selected_cats = $_GET['category'];
			} else {
				$selected_cats = 0;
			}

			if (isset($_GET['mode']) && $_GET['mode'] == "advanced") {
				$GLOBALS['HideAdvancedLink'] = "none";
			}

			$GLOBALS['CompareLink'] = CompareLink();

			$GLOBALS['ISC_CLASS_ADMIN_BRANDS'] = GetClass('ISC_ADMIN_BRANDS');
			$GLOBALS['BrandNameOptions'] = $GLOBALS['ISC_CLASS_ADMIN_BRANDS']->GetBrandsAsOptions(@$this->_searchterms['brand']);
			$GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
			$GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions($selected_cats, "<option %s value='%d'>%s</option>", 'selected="selected"', "", false, 1);

			if ((isset($_GET['searchsubs']) && $_GET['searchsubs'] == "ON") || @$this->_searchterms['search_query'] == "") {
				$GLOBALS['IsSearchSubs'] = 'checked="checked"';
			}

			if (isset($this->_searchterms['price_from']) && is_numeric($this->_searchterms['price_from'])) {
				$GLOBALS['PriceFrom'] = $this->_searchterms['price_from'];
			}

			if (isset($this->_searchterms['price_to']) && is_numeric($this->_searchterms['price_to'])) {
				$GLOBALS['PriceTo'] = $this->_searchterms['price_to'];
			}

			if (isset($this->_searchterms['featured'])) {
				$GLOBALS["Featured" . $this->_searchterms['featured']] = 'selected="selected"';
			}

			if (isset($this->_searchterms['shipping'])) {
				$GLOBALS["Shipping" . $this->_searchterms['shipping']] = 'selected="selected"';
			}

			if (@$this->_searchterms['search_query'] != "") {

				$GLOBALS['SNIPPETS']['RelatedSearches'] = "";
				$has_suggestion = false;
				$changed_words = array();
				$query = $this->Suggest($this->_searchterms['search_query'], $has_suggestion, $changed_words);

				// Did pSpell make a suggestion?
				if ($query != $this->_searchterms['search_query']) {
					// pSpell made a suggestion
					$words = explode(" ", isc_html_escape($this->_searchterms['search_query']));

					foreach ($words as $k => $word) {
						foreach ($changed_words as $changed_word) {
							if ($word == $changed_word[0]) {
								$words[$k] = "<strong>" . $changed_word[1] . "</strong>";
							}
						}
					}

					$GLOBALS['SuggestQuery'] = implode(" ", $words);
					$GLOBALS['SuggestQueryEscaped'] = urlencode($query);
					$GLOBALS['ShowSearchSuggestion'] = "";
				}
				else {
					// No search suggestion
					$GLOBALS['ShowSearchSuggestion'] = "none";
				}

				$page = (int)@$_GET['page'];
				if ($page < 1) {
					$page = 1;
				}

				$limit = (int)GetConfig("SearchResultsPerPage");

				$start = ($page - 1) * $limit;

				// Load up our search results
				$this->DoSearch($start, $limit, array("product", "content"));
				$this->DoSearch(0, -1, array("category", "brand"));

				// Commit the search terms to the session array
				$this->commitSearchSession();

				// Log the search result
				$GLOBALS['SearchId'] = $this->LogSearch($this->_searchterms['search_query'], $this->GetNumResults());

				// Load up a list of related searches
				$related_searches = $this->GetRelatedSearchTerms($this->_searchterms['search_query']);

				if (!empty($related_searches)) {
					foreach ($related_searches as $related_search) {
						$GLOBALS['RelatedSearchQuery'] = urlencode($related_search);
						$GLOBALS['RelatedSearchText'] = isc_html_escape($related_search);
						$GLOBALS['SNIPPETS']['RelatedSearches'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("RelatedSearchItem");
					}

					$GLOBALS['SNIPPETS']['RelatedSearches'] = trim($GLOBALS['SNIPPETS']['RelatedSearches'], ", ");
				}
				else {
					$GLOBALS['HideRelatedSearches'] = "none";
				}
			}
			else {
				// Show the advanced mode box instead and hide everything else if there's no search term
				if (@$this->_searchterms['search_query'] == "") {
					$GLOBALS['HideRelatedSearches'] = "none";
					$GLOBALS['ShowSearchSuggestion'] = "none";
					$GLOBALS['HideSearchResults'] = "none";
					$GLOBALS['HideNoResults'] = "none";
				}
			}

			// Hide the search form if we have just performed a search
			if (!empty($this->_searchterms)) {
				$GLOBALS['AutoHideSearchForm'] = "true";
			}

			$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->_pagetitle);
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("search");
			$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
		}