Example #1
0
		public function SetPanelSettings()
		{
			if (!$GLOBALS["ISC_CLASS_SEARCH"]->searchIsLoaded()) {
				return;
			}

			// Do we have any pages and news items?
			$GLOBALS["SearchResultsContent"] = "";
			$contentSearchResults = "";
			$searchResults = $GLOBALS["ISC_CLASS_SEARCH"]->GetResults("content");
			$contentSearchResults = "";

			if (!empty($searchResults["results"]) && is_array($searchResults["results"])) {
				foreach ($searchResults["results"] as $item) {
					if ($item["nodetype"] == "page") {
						$contentSearchResults .= ISC_PAGE::buildContentSearchResultHTML($item);
					} else {
						$contentSearchResults .= ISC_NEWS::buildContentSearchResultHTML($item);
					}
				}
			}

			if (trim($contentSearchResults) !== "") {
				$GLOBALS["SectionResults"] = $contentSearchResults;
				$GLOBALS["SectionType"] = "ContentList";
				$GLOBALS["SectionExtraClass"] = "";

				$totalPages = $GLOBALS['ISC_CLASS_SEARCH']->GetNumPages("content");
				$totalRecords = $GLOBALS['ISC_CLASS_SEARCH']->GetNumResults("content");

				$page = (int)@$_REQUEST['page'];
				if ($page < 1) {
					$page = 1;
				} else if ($page > $totalPages) {
					$page = $totalPages;
				}

				// generate url with all current GET params except page, ajax and section
				$url = array();
				foreach ($_GET as $key => $value) {
					if ($key == 'page' || $key == 'ajax' || $key == 'section') {
						continue;
					}
					if (is_array($value)) {
						foreach ($value as $subvalue) {
							$url[] = urlencode($key . '[]') . '=' . urlencode($subvalue);
						}
					} else {
						$url[] = urlencode($key) . '=' . urlencode($value);
					}
				}
				$url[] = "page={page}";
				$url[] = "section=content";
				$url = 'search.php?' . implode('&', $url) . '#results';

				$GLOBALS['SectionPaging'] = '';

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

				$start = max($page - $maxPagingLinks, 1);
				$end = min($page + $maxPagingLinks, $totalPages);

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

					$GLOBALS['PageLink'] = str_replace('{page}', $i, $url);
					$GLOBALS['PageNumber'] = $i;
					$GLOBALS['SectionPaging'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
				}

				// Parse the paging snippet
				if($page > 1) {
					$prevPage = $page - 1;
					$GLOBALS['PrevLink'] = str_replace('{page}', $prevPage, $url);
					$GLOBALS['SectionPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
				}

				if($page < $totalPages) {
					$prevPage = $page + 1;
					$GLOBALS['NextLink'] = str_replace('{page}', $prevPage, $url);
					$GLOBALS['SectionPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
				}

				if ($totalPages > 1) {
					$GLOBALS["HideSectionPaging"] = "";
				} else {
					$GLOBALS["HideSectionPaging"] = "none";
				}

				if ($GLOBALS["ISC_CLASS_SEARCH"]->GetNumResults("content") <= 1) {
					$GLOBALS["HideSectionSorting"] = "none";
				} else {
					$GLOBALS["HideSectionSorting"] = "";
				}

				$GLOBALS["SectionSortingOptions"] = getAdvanceSearchSortOptions("content");
				$GLOBALS["SectionSearchResults"] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultGrid");
				$GLOBALS["SearchResultsContent"] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultSectionContent");
			}

			// If no results then show the 'no results found' div
			if (trim($GLOBALS["SearchResultsContent"]) !== "") {
				$GLOBALS["HideSearchResultsContent"] = "";
				$GLOBALS["HideSearchResultsNoResult"] = "none";
			} else {
				$GLOBALS["HideSearchResultsContent"] = "none";
				$GLOBALS["HideSearchResultsNoResult"] = "";
			}
		}
Example #2
0
		/**
		* Shows a page of results when requested by an ajax query
		*
		*/
		public function ShowAjaxSearchPage()
		{
			$section = isc_strtolower(trim(@$_REQUEST["section"]));
			if (!$section) {
				exit;
			}

			$GLOBALS["ISC_CLASS_SEARCH"] = GetClass("ISC_SEARCH");

			$searchTerms = $GLOBALS["ISC_CLASS_SEARCH"]->readSearchSession();

			$sortBy = trim(@$_REQUEST["sortBy"]);

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

			// Do the search
			$limit = (int)GetConfig("SearchResultsPerPage");

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

			// We have all the details, now we need to load up the ISC_SEARCH class
			$GLOBALS["ISC_CLASS_SEARCH"]->_SetSearchData($searchTerms);
			$GLOBALS["ISC_CLASS_SEARCH"]->DoSearch($start, $limit, $section, $sortBy);

			$GLOBALS["SectionResults"] = "";

			if ($section == "content") {
				$searchResults = $GLOBALS["ISC_CLASS_SEARCH"]->GetResults("content");

				if (is_array($searchResults["results"]) && !empty($searchResults["results"])) {
					foreach ($searchResults["results"] as $item) {
						if ($item["nodetype"] == "page") {
							$GLOBALS["SectionResults"] .= ISC_PAGE::buildContentSearchResultHTML($item);
						} else {
							$GLOBALS["SectionResults"] .= ISC_NEWS::buildContentSearchResultHTML($item);
						}
					}
				}
			} else if ($section == "product") {
				$GLOBALS["SectionResults"] = ISC_PRODUCT::buildSearchResultsHTML();
			} else {
				exit;
			}

			$totalPages = $GLOBALS['ISC_CLASS_SEARCH']->GetNumPages($section);
			$totalRecords = $GLOBALS['ISC_CLASS_SEARCH']->GetNumResults($section);

			if (GetConfig("SearchProductDisplayMode") == "list") {
				$GLOBALS["SectionExtraClass"] = 'List';
			} else {
				$GLOBALS["SectionExtraClass"] = '';
			}

			$GLOBALS["SectionType"] = ucfirst($section) . 'List';

			$navTitle = GetLang("SearchResultsTab" . ucfirst($section));

			// generate url with all current GET params except page and ajax
			$url = array();
			foreach ($_GET as $key => $value) {
				if ($key == 'page' || $key == 'ajax') {
					continue;
				}
				if (is_array($value)) {
					foreach ($value as $subvalue) {
						$url[] = urlencode($key . '[]') . '=' . urlencode($subvalue);
					}
				} else {
					$url[] = urlencode($key) . '=' . urlencode($value);
				}
			}
			$url[] = "page={page}";
			$url = 'search.php?' . implode('&', $url) . '#results';

			$GLOBALS['SectionPaging'] = '';

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

			$start = max($page - $maxPagingLinks, 1);
			$end = min($page + $maxPagingLinks, $totalPages);

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

				$GLOBALS['PageLink'] = str_replace('{page}', $i, $url);
				$GLOBALS['PageNumber'] = $i;
				$GLOBALS['SectionPaging'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
			}

			// Parse the paging snippet
			if($page > 1) {
				$prevPage = $page - 1;
				$GLOBALS['PrevLink'] = str_replace('{page}', $prevPage, $url);
				$GLOBALS['SectionPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
			}

			if($page < $totalPages) {
				$prevPage = $page + 1;
				$GLOBALS['NextLink'] = str_replace('{page}', $prevPage, $url);
				$GLOBALS['SectionPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
			}

			if ($totalPages > 1) {
				$GLOBALS["HideSectionPaging"] = "";
			} else {
				$GLOBALS["HideSectionPaging"] = "none";
			}

			$GLOBALS["SectionSortingOptions"] = getAdvanceSearchSortOptions($section, $sortBy);
			print $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultGrid");
			exit;
		}