Example #1
0
	/**
	 * Returns the URL for a category based on it's category id
	 *
	 * @param integer $categoryId The ID number of the category to generate the URL for
	 */
	public static function getCategoryUrl($categoryId, $returnTitle=false)
	{
		$categoryId = (int)$categoryId;
		if($categoryId < 1) {
			return false;
		}

		$categoryQuery = $GLOBALS['ISC_CLASS_DB']->Query('select * from `[|PREFIX|]categories` where categoryid=' . $categoryId);
		$categoryInfo = $GLOBALS['ISC_CLASS_DB']->Fetch($categoryQuery);

		if(empty($categoryInfo)) {
			return false;
		}

		$isParent = false;

		if($categoryInfo['catparentid'] == 0) {
			$isParent = true;
		}

		if($returnTitle) {
			return array('title'=>$categoryInfo['catname'], 'url'=> CatLink($categoryInfo['categoryid'], $categoryInfo['catname'], $isParent));
		}

		return CatLink($categoryInfo['categoryid'], $categoryInfo['catname'], $isParent);
	}
	/**
	* Generates a sitemap tree for the categories model based on the categories nested set
	*
	* @param int $limit
	* @param int $offset
	* @return ISC_SITEMAP_NODE
	*/
	public function getTree($limit = null, $offset = null)
	{
		$root = new ISC_SITEMAP_ROOT();

		$set = new ISC_NESTEDSET_CATEGORIES();

		$sql = $set->generateGetTreeSql(array('categoryid', 'catname'), ISC_NESTEDSET_START_ROOT, $this->getMaximumDepth(), $limit, $offset, true, $this->_getRestrictions());
		$result = $GLOBALS['ISC_CLASS_DB']->Query($sql);

		$previousDepth = -1;

		$node = $root;
		while ($category = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$depth = (int)$category['catdepth'];

			if ($depth > $previousDepth) {
				$parent = $node;
			} else if ($depth < $previousDepth) {
				for ($depthCounter = $previousDepth - $depth; $depthCounter > 0; $depthCounter--) {
					$parent = $parent->getParent();
				}
			}

			$label = $category['catname'];
			$url = CatLink($category['categoryid'], $label);

			$node = new ISC_SITEMAP_NODE($url, $label);
			$parent->appendChild($node);

			$previousDepth = $depth;
		}


		return $root;
	}
 public function SetPanelSettings()
 {
     // Do we need to show paging, etc?
     if ($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() > GetConfig('CategoryProductsPerPage')) {
         // Workout the paging data
         $GLOBALS['SNIPPETS']['PagingData'] = "";
         $num_pages_either_side_of_current = 5;
         $start = max($GLOBALS['ISC_CLASS_CATEGORY']->GetPage() - $num_pages_either_side_of_current, 1);
         $end = min($GLOBALS['ISC_CLASS_CATEGORY']->GetPage() + $num_pages_either_side_of_current, $GLOBALS['ISC_CLASS_CATEGORY']->GetNumPages());
         for ($page = $start; $page <= $end; $page++) {
             if ($page == $GLOBALS['ISC_CLASS_CATEGORY']->GetPage()) {
                 $snippet = "CategoryPagingItemCurrent";
             } else {
                 $snippet = "CategoryPagingItem";
             }
             $GLOBALS['PageLink'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false, array("page" => $page, "sort" => $GLOBALS['ISC_CLASS_CATEGORY']->GetSort()));
             $GLOBALS['PageNumber'] = $page;
             $GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
         }
         // Parse the paging snippet
         if ($GLOBALS['ISC_CLASS_CATEGORY']->GetPage() > 1) {
             // Do we need to output a "Previous" link?
             $GLOBALS['PrevLink'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false, array("page" => $GLOBALS['ISC_CLASS_CATEGORY']->GetPage() - 1, "sort" => $GLOBALS['ISC_CLASS_CATEGORY']->GetSort()));
             $GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
         }
         if ($GLOBALS['ISC_CLASS_CATEGORY']->GetPage() < $GLOBALS['ISC_CLASS_CATEGORY']->GetNumPages()) {
             // Do we need to output a "Next" link?
             $GLOBALS['NextLink'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false, array("page" => $GLOBALS['ISC_CLASS_CATEGORY']->GetPage() + 1, "sort" => $GLOBALS['ISC_CLASS_CATEGORY']->GetSort()));
             $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']['CategoryPaging'] = $output;
     }
 }
Example #4
0
	public function __construct()
	{
		// Setup the page title
		$this->pageTitle = GetConfig('StoreName') . " - " . GetLang('ShoppingCart');

		if($this->getQuote()->getNumitems() > 0) {
			$GLOBALS['KeepShoppingText'] = GetLang('ClickHereToKeepShopping');
			$GLOBALS['KeepShoppingLink'] = $GLOBALS['ShopPath'];
		} else {
			$GLOBALS['KeepShoppingText'] = '';
			$GLOBALS['KeepShoppingLink'] = '';
		}

		if (isset($_SESSION['JustAddedProduct']) && $_SESSION['JustAddedProduct'] != '') {
			// Get the category of the last product added to the store
			$query = sprintf("select c.categoryid, catname from [|PREFIX|]categoryassociations ca inner join [|PREFIX|]categories c on ca.categoryid=c.categoryid where ca.productid='%d' ", $GLOBALS['ISC_CLASS_DB']->Quote((int)$_SESSION['JustAddedProduct']));
			$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 1);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				if(CustomerGroupHasAccessToCategory($row['categoryid'])) {
					$GLOBALS['KeepShoppingLink'] = CatLink($row['categoryid'], $row['catname']);
					$GLOBALS['KeepShoppingText'] = sprintf(GetLang('ClickHereToKeepShoppingCat'), isc_html_escape($row['catname']));
					break;
				}
			}
		}
	}
Example #5
0
 private function GetCategories()
 {
     header('Content-type: text/xml');
     // Return a list of categories
     echo '<?xml version="1.0"?>';
     echo '<results>';
     $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
     $categories = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->getCats("");
     foreach ($categories as $catid => $catname) {
         $catpadding = substr_count($catname, '&nbsp') * 6;
         if ($catpadding > 0) {
             $catpadding = sprintf('padding="%d"', $catpadding);
         } else {
             $catpadding = '';
         }
         $catname = preg_replace('/^(&nbsp;)*/', '', $catname);
         $catname = preg_replace('/(&nbsp;)*$/', '', $catname);
         $catlink = CatLink($catid, $catname);
         echo sprintf('<result title="%s" icon="images/category.gif" catid="%s" %s>%s</result>', $catname, $catid, $catpadding, $catlink);
     }
     echo '</results>';
 }
Example #6
0
		/**
		 * Build the searched item results HTML
		 *
		 * Method will build the searched item results HMTL. Method will work with the ISC_SEARCH class to get the results
		 * so make sure that the object is initialised and the DoSearch executed.
		 *
		 * @access public
		 * @return string The search item result HTML on success, empty string on error
		 */
		static public function buildSearchResultsHTML()
		{
			if (!isset($GLOBALS["ISC_CLASS_SEARCH"]) || !is_object($GLOBALS["ISC_CLASS_SEARCH"])) {
				return "";
			}

			$totalRecords = $GLOBALS["ISC_CLASS_SEARCH"]->GetNumResults("category");

			if ($totalRecords == 0) {
				return "";
			}

			$results = $GLOBALS["ISC_CLASS_SEARCH"]->GetResults("category");
			$resultHTML = array();

			if (!array_key_exists("results", $results) || !is_array($results["results"])) {
				return "";
			}

			foreach ($results["results"] as $category) {
				if (!is_array($category) || !array_key_exists("categoryid", $category)) {
					continue;
				}

				// @TO-DO: Gywlim is doing a categories manager but until then just read from the database
				$catBreadCrumbs = array(array($category["categoryid"], $category["catname"]));
				$parentCategoryId = (int)$category["catparentid"];
				$query = "SELECT categoryid, catparentid, catname
							FROM [|PREFIX|]categories
							WHERE categoryid=%d";

				while ($parentCategoryId !== 0) {
					$result = $GLOBALS["ISC_CLASS_DB"]->Query(sprintf($query, $parentCategoryId));
					$row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result);

					if (!$row) {
						break;
					}

					$parentCategoryId = (int)$row["catparentid"];
					array_unshift($catBreadCrumbs, array($row["categoryid"], $row["catname"]));
				}

				$link = array();
				$isParent = true;

				foreach ($catBreadCrumbs as $part) {
					$link[] = "<a href=\"" . CatLink($part[0], $part[1], $isParent) . "\">" . isc_html_escape($part[1]) . "</a>";

					if ($isParent) {
						$isParent = false;
					}
				}

				if (empty($link)) {
					continue;
				}

				$resultHTML[] = implode(" &gt; ", $link);
			}

			$resultHTML = implode(", ", $resultHTML);
			$resultHTML = trim($resultHTML);

			return $resultHTML;
		}
 /**
  * get the html for sub category list
  *
  * @param array $categories the array of all categories in a tree structure
  * @param int $parentCatId the parent category ID of the sub category list
  *
  * return string the html of the sub category list
  */
 function GetSubCategory($categories, $parentCatId)
 {
     $output = '';
     //if there is sub category for this parent cat
     if (isset($categories[$parentCatId]) && !empty($categories[$parentCatId])) {
         $i = 1;
         foreach ($categories[$parentCatId] as $subCat) {
             // If we don't have permission to view this category then skip
             if (!CustomerGroupHasAccessToCategory($subCat['categoryid'])) {
                 continue;
             }
             $catLink = CatLink($subCat['categoryid'], $subCat['catname'], false);
             $catName = isc_html_escape($subCat['catname']);
             $GLOBALS['SubCategoryList'] = $this->GetSubCategory($categories, $subCat['categoryid']);
             //set the class for the last category of its parent category
             $GLOBALS['LastChildClass'] = '';
             if ($i == count($categories[$parentCatId])) {
                 $GLOBALS['LastChildClass'] = 'LastChild';
             }
             $i++;
             $GLOBALS['CategoryName'] = $catName;
             $GLOBALS['CategoryLink'] = $catLink;
             $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList");
         }
     }
     if ($output != '') {
         $output = '<ul>' . $output . '</ul>';
     }
     return $output;
 }
Example #8
0
		private function ManageBannersGrid(&$numBanners)
		{
			$GLOBALS['BannerGrid'] = '';
			$GLOBALS['Nav'] = '';
			$searchURL = '';

			if (isset($_GET['searchQuery'])) {
				$query = $_GET['searchQuery'];
				$GLOBALS['Query'] = isc_html_escape($query);
				$searchURL .= '&amp;searchQuery='.urlencode($query);
			} else {
				$query = "";
				$GLOBALS['Query'] = "";
			}

			if (isset($_GET['sortOrder']) && $_GET['sortOrder'] == 'desc') {
				$sortOrder = 'desc';
			} else {
				$sortOrder = "asc";
			}

			$sortLinks = array(
				"Name" => "name",
				"Location" => "page",
				"Date" => "datecreated",
				"Status" => "status"
			);

			if (isset($_GET['sortField']) && in_array($_GET['sortField'], $sortLinks)) {
				$sortField = $_GET['sortField'];
				SaveDefaultSortField("ManageBanners", $_REQUEST['sortField'], $sortOrder);
			}
			else {
				list($sortField, $sortOrder) = GetDefaultSortField("ManageBanners", "name", $sortOrder);
			}

			if (isset($_GET['page'])) {
				$page = (int)$_GET['page'];
			} else {
				$page = 1;
			}

			$sortURL = sprintf("&sortField=%s&sortOrder=%s", $sortField, $sortOrder);
			$GLOBALS['SortURL'] = $sortURL;

			// Get the results for the query
			$bannerResult = $this->_GetBannerList($query, $sortField, $sortOrder, $numBanners);

			if(!$numBanners) {
				return '';
			}

			$GLOBALS['SearchQuery'] = isc_html_escape($query);
			$GLOBALS['SortField'] = $sortField;
			$GLOBALS['SortOrder'] = $sortOrder;

			BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewBanners&amp;".$searchURL."&amp;page=".$page, $sortField, $sortOrder);


			$GLOBALS['NameSortUpLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&&sortField=name&sortOrder=asc", $query);
			$GLOBALS['NameSortDownLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&sortField=name&sortOrder=desc", $query);

			$GLOBALS['LocationSortUpLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&&sortField=page&sortOrder=asc", $query);
			$GLOBALS['LocationSortDownLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&sortField=page&sortOrder=desc", $query);

			$GLOBALS['DateSortUpLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&&sortField=datecreated&sortOrder=asc", $query);
			$GLOBALS['DateSortDownLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&sortField=datecreated&sortOrder=desc", $query);

			$GLOBALS['StatusSortUpLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&&sortField=status&sortOrder=asc", $query);
			$GLOBALS['StatusSortDownLink'] = sprintf("index.php?ToDo=viewBanners&searchQuery=%s&sortField=status&sortOrder=desc", $query);

			while ($banner = $GLOBALS["ISC_CLASS_DB"]->Fetch($bannerResult)) {
				$GLOBALS['BannerId'] = (int) $banner['bannerid'];
				$GLOBALS['Name'] = isc_html_escape($banner['name']);

				$GLOBALS['Location'] = "";

				switch ($banner['page']) {
					case "home_page": {
						$GLOBALS['Location'] = sprintf("<a target='_blank' href='../'>%s</a>", GetLang('BannerHomePage'));
						break;
					}
					case "category_page": {
						$GLOBALS['Location'] = sprintf("<a target='_blank' href='%s'>%s %s</a>", CatLink($banner['catorbrandid'], $banner["location_name"]), $banner['name'], GetLang('BannerCategory'));
						break;
					}
					case "brand_page": {
						$GLOBALS['Location'] = sprintf("<a target='_blank' href='%s'>%s %s</a>", BrandLink($banner['location_name']), $banner["location_name"], GetLang('ProductsPage'));
						break;
					}
					case "search_page": {
						$GLOBALS['Location'] = sprintf("<a target='_blank' href='../search.php?mode=advanced'>%s</a>", GetLang('SearchResultsPage'));
						break;
					}
				}

				if ($banner['location'] == "top") {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerTopOfPage'));
				}
				else {
					$GLOBALS['Location'] .= sprintf(" (%s)", GetLang('BannerBottomOfPage'));
				}

				$GLOBALS['Date'] = isc_date(GetConfig('ExportDateFormat'), $banner['datecreated']);

				if ($banner['status'] == 1) {
					$GLOBALS['Visible'] = sprintf("<a title='%s' href='index.php?ToDo=editBannerVisibility&amp;bannerId=%d&amp;visible=0'><img border='0' src='images/tick.gif'></a>", GetLang('ClickToHideBanner'), $banner['bannerid']);
				}
				else {
					$GLOBALS['Visible'] = sprintf("<a title='%s' href='index.php?ToDo=editBannerVisibility&amp;bannerId=%d&amp;visible=1'><img border='0' src='images/cross.gif'></a>", GetLang('ClickToShowBanner'), $banner['bannerid']);
				}

				$GLOBALS['BannerGrid'] .= $this->template->render('banner.manage.row.tpl');
			}
			return $this->template->render('banners.manage.grid.tpl');
		}
Example #9
0
		private function EditCategory()
		{
			$GLOBALS['Message'] = GetFlashMessageBoxes();

			if (isset($_GET['catId'])) {
				$catId = (int) $_GET['catId'];

				$this->categoryAPI->load($catId);

				$GLOBALS['CategoryName'] = isc_html_escape($this->categoryAPI->catname);
				$GLOBALS['CategoryOptions'] = $this->GetCategoryParentOptions($catId, array($this->categoryAPI->catparentid));
				$GLOBALS['CategorySort'] = isc_html_escape($this->categoryAPI->catsort);
				$GLOBALS['CategoryPageTitle'] = isc_html_escape($this->categoryAPI->catpagetitle);
				$GLOBALS['CategoryMetaKeywords'] = isc_html_escape($this->categoryAPI->catmetakeywords);
				$GLOBALS['CategoryMetaDesc'] = isc_html_escape($this->categoryAPI->catmetadesc);
				$GLOBALS['CategorySearchKeywords'] = isc_html_escape($this->categoryAPI->catsearchkeywords);

				$wysiwygOptions = array(
					'id'		=> 'wysiwyg',
					'width'		=> '656px',
					'height'	=> '250px',
					'value'		=> $this->categoryAPI->catdesc
				);
				$GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions);

				$GLOBALS['FormAction'] = "saveUpdatedCategory";
				$GLOBALS['CatTitle'] = GetLang('EditCatTitle');
				$GLOBALS['CatIntro'] = GetLang('EditCatIntro');
				$GLOBALS['CancelMessage'] = GetLang('CancelEditCategory');
				$GLOBALS['hiddenFields'] = sprintf("<input type='hidden' name='categoryId' value='%d'>", $catId);

				if ($this->categoryAPI->catparentid == '0') {
					$GLOBALS['DisableFileUpload'] = 'disabled="disabled"';
					$GLOBALS['ShowFileUploadMessage'] = '';
				} else {
					$GLOBALS['DisableFileUpload'] = '';
					$GLOBALS['ShowFileUploadMessage'] = 'none';
				}

				// Get a list of all layout files
				$layoutFile = 'category.html';
				if($this->categoryAPI->catlayoutfile != '') {
					$layoutFile = $this->categoryAPI->catlayoutfile;
				}
				$GLOBALS['LayoutFiles'] = GetCustomLayoutFilesAsOptions("category.html", $layoutFile);

				$GLOBALS["CatImageMessage"] = '';
				$this->template->assign('ShowYesUseImageRow', 'none');
				if ($this->categoryAPI->catimagefile !== '') {
					$image = '../' . GetConfig('ImageDirectory') . '/' . $this->categoryAPI->catimagefile;
					$GLOBALS["CatImageMessage"] = sprintf(GetLang('CatImageDesc'), $image, $this->categoryAPI->catimagefile);
					$this->template->assign('CatImageFile', basename($this->categoryAPI->catimagefile));
					$this->template->assign('ShowYesUseImageRow', 'block');
					$this->template->assign('CatImageLink', $image);
				}


				//Google website optimizer
				$GLOBALS['GoogleWebsiteOptimizerIntro'] = GetLang('CatGoogleWebsiteOptimizerIntro');
				$GLOBALS['HideOptimizerConfigForm'] = 'display:none;';
				$GLOBALS['CheckEnableOptimizer'] = '';
				$GLOBALS['SkipOptimizerConfirmMsg'] = 'true';

				$enabledOptimizers = GetConfig('OptimizerMethods');
				if(!empty($enabledOptimizers)) {
					foreach ($enabledOptimizers as $id => $date) {
						GetModuleById('optimizer', $optimizerModule, $id);
						if ($optimizerModule->_testPage == 'categories' || $optimizerModule->_testPage == 'all') {
							$GLOBALS['SkipOptimizerConfirmMsg'] = 'false';
							break;
						}
					}
				}
				if($this->categoryAPI->cat_enable_optimizer == '1') {
					$GLOBALS['HideOptimizerConfigForm'] = '';
					$GLOBALS['CheckEnableOptimizer'] = 'Checked';
				}

				$optimizer = getClass('ISC_ADMIN_OPTIMIZER');
				$GLOBALS['OptimizerConfigForm'] = $optimizer->showPerItemConfigForm('category', $catId, CatLink($catId, $this->categoryAPI->catname));

				if(isset($_REQUEST['currentTab'])) {
					$GLOBALS['CurrentTab'] = $_REQUEST['currentTab'];
				}
				else {
					$GLOBALS['CurrentTab'] = 'details';
				}

				// Get shopping comparison options
				$shoppingComparisonModules = Isc_ShoppingComparison::getModulesWithTaxonomies();
				$GLOBALS['AlternateCategoriesCache'] = (array)json_decode($this->categoryAPI->cataltcategoriescache);
				$GLOBALS['ShoppingComparisonModules'] = $shoppingComparisonModules;

				$GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndContinueEditing');

				$this->template->display('category.form.tpl');
			} else {
				if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Categories)) {
					$this->ManageCategories();
				} else {
					$GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
				}
			}
		}
Example #10
0
		/**
		 * This method creates and returns front-end output for original, non-flyout-enabled category menus
		 *
		 * @return string
		 */
		protected function _generateClassicOutput ()
		{
			$output = "";
			$categories = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('RootCategories');

			if (!isset($categories[0])) {
				return $output;
			}

			foreach($categories[0] as $rootCat) {
				// If we don't have permission to view this category then skip
				if(!CustomerGroupHasAccessToCategory($rootCat['categoryid'])) {
					continue;
				}

				$GLOBALS['SubCategoryList'] = $this->_getSubCategory($categories, $rootCat['categoryid']);
				$GLOBALS['LastChildClass']='';
				$GLOBALS['CategoryName'] = isc_html_escape($rootCat['catname']);
				$GLOBALS['CategoryLink'] = CatLink($rootCat['categoryid'], $rootCat['catname'], true);
				// @todo ul here is hacky but front end templates are limited, fix this when possible
				$output .= '<ul>' . $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList") . '</ul>';
			}

			return $output;
		}
Example #11
0
	public function Action_GetProduct()
	{
		if(empty($this->router->request->details->productId)) {
			$this->BadRequest('The details->productId node is missing');
		}

		$image = new ISC_PRODUCT_IMAGE(); // autoload helper so we can use exceptions defined in the product image class file
		unset($image);

		$productId = (int)$this->router->request->details->productId;
		$productClass = new ISC_PRODUCT($productId);
		$product = $productClass->_product;

		// stuff that comes directly from the database may be incomplete -- use the image library to make sure
		try {
			if (!$product['imageid']) {
				// no image present in data so throw an exception just to force the removal of data below in the catch{} block
				throw new ISC_PRODUCT_IMAGE_EXCEPTION();
			}

			$image = new ISC_PRODUCT_IMAGE();
			$image->populateFromDatabaseRow($product);

			// call the image library to make sure resized images are present and then add full urls so they're useful for remote users
			$product['imagefiletiny'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true, true, false);
			$product['imagefilethumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, true, false);
			$product['imagefilestd'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false);
			$product['imagefilezoom'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false);

			// call the image library to make sure resized images are present and the sizes are correct
			$product['imagefiletinysize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY));
			$product['imagefilethumbsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL));
			$product['imagefilestdsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_STANDARD));
			$product['imagefilezoomsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM));

		} catch (Exception $exception) {
			// some sort of problem when dealing with product images - remove image info from the response
			unset(
				$product['imagefiletiny'],
				$product['imagefilethumb'],
				$product['imagefilestd'],
				$product['imagefilezoom'],
				$product['imagefiletinysize'],
				$product['imagefilethumbsize'],
				$product['imagefilestdsize'],
				$product['imagefilezoomsize'],
				$product['imagedesc'],
				$product['imagedateadded']
			);
		}

		// direct data feed also includes some fields that are irrelevant or unwanted
		unset(
			$product['imagefile'],	// don't provide a link to the non-water-marked image
			$product['imageprodid'],
			$product['imageprodhash'],
			$product['imageisthumb'],
			$product['imagesort']
		);

		if(empty($product)) {
			return array();
		}

		$product['prodlink'] = ProdLink($product['prodname']);

		// Fetch any images for the product

		$images = new ISC_PRODUCT_IMAGE_ITERATOR(ISC_PRODUCT_IMAGE::generateGetProductImagesFromDatabaseSql((int)$productId));
		foreach ($images as $image) {
			/** @var $image ISC_PRODUCT_IMAGE */
			$imageisthumb = 0;
			if ($image->getIsThumbnail()) {
				$imageisthumb = 1;
			}

			try {
				$product['images']['item'][] = array(
					'imageid' => $image->getProductImageId(),
					'imagefiletiny' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true, true, false),
					'imagefilethumb' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, true, false),
					'imagefilestd' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false),
					'imagefilezoom' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false),
					'imagefiletinysize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY)),
					'imagefilethumbsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL)),
					'imagefilestdsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_STANDARD)),
					'imagefilezoomsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM)),
					'imageisthumb' => $imageisthumb,
					'imagesort' => $image->getSort(),
					'imagedesc' => $image->getDescription(),
					'imagedateadded' => $image->getDateAdded(),
				);
			} catch (Exception $exception) {
				// skip this image and bring down the count of product images obtained from ISC_PRODUCT
				$product['numimages']--;
			}
		}

		// Fetch the categories this product belongs to
		$trailCategories = array();
		$crumbList = array();
		$query = "
			SELECT c.categoryid, c.catparentlist
			FROM [|PREFIX|]categoryassociations ca
			JOIN [|PREFIX|]categories c ON (c.categoryid=ca.categoryid)
			WHERE ca.productId='".(int)$productId."'
		";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			if ($row['catparentlist'] == '') {
				$row['catparentlist'] = $row['categoryid'];
			}
			$cats = explode(",", $row['catparentlist']);
			$trailCategories = array_merge($trailCategories, $cats);
			$crumbList[$row['categoryid']] = $row['catparentlist'];
		}

		$trailCategories = implode(",", array_unique($trailCategories));
		$categories = array();
		if ($trailCategories != '') {
			// Now load the names for the parent categories from the database
			$query = "
				SELECT categoryid, catname
				FROM [|PREFIX|]categories
				WHERE categoryid IN (".$trailCategories.")
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$categories[$row['categoryid']] = $row['catname'];
			}
		}

		// Now we have all of the information we need to build the trails, lets actually build them
		foreach ($crumbList as $productcatid => $trail) {
			$cats = explode(',', $trail);
			$catName = '';
			$catLink = CatLink($productcatid, $categories[$productcatid]);
			foreach ($cats as $categoryid) {
				if(isset($categories[$categoryid])) {
					if($catName) {
						$catName .= ' &raquo; ';
					}
					$catName .= $categories[$categoryid];
				}
			}
			$product['categories']['item'][] = array(
				'name' => $catName,
				'link' => $catLink,
				'id' => $productcatid
			);
		}

		if($product['prodvariationid'] > 0) {
			if ($product['prodsaleprice'] != 0) {
				$variationBasePrice = $product['prodsaleprice'];
			}
			else {
				$variationBasePrice = $product['prodprice'];
			}

			$vop = $productClass->_prodvariationoptions;
			$vval = $productClass->_prodvariationvalues;
			foreach($productClass->_prodvariationcombinations as $variation) {
				$variationPrice = CurrencyConvertFormatPrice(CalcProductVariationPrice($variationBasePrice, $variation['vcpricediff'], $variation['vcprice'], $product));
				$variationWeight = FormatWeight(CalcProductVariationWeight($product['prodweight'], $variation['vcweightdiff'], $variation['vcweight']), true);

				$variationName = array();
				$options = explode(',', $variation['vcoptionids']);
				foreach($options as $k => $optionId) {
					$label = $vop[$k];
					$variationName[] = $label.': '.$vval[$label][$optionId];
				}
				$variationName = implode(', ', $variationName);
				$variationRow = array(
					'name' => $variationName,
					'id' => $variation['combinationid'],
					'price' => $variationPrice,
					'sku' => $variation['vcsku'],
					'weight' => $variationWeight,
				);

				if($product['prodinvtrack'] == 2) {
					$variationRow['stock'] = $variation['vcstock'];
				}

				if ($variation['vcimage']) {
					try {
						$image = new ISC_PRODUCT_IMAGE;
						$image->setSourceFilePath($variation['vcimage']);

						if($variation['vcimagethumb']) {
							$image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, $variation['vcimagethumb']);
							$variationRow['thumb'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, false);
						}

						if($variation['vcimagestd']) {
							$image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, $variation['vcimagestd']);
							$variationRow['standard'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, false);
						}

						if($variation['vcimagezoom']) {
							$image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, $variation['vcimagezoom']);
							$variationRow['image'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false);
						}
					} catch (Exception $exception) {
						// nothing
					}
				}

				$product['variations']['item'][] = $variationRow;
			}
		}

		return $product;
	}
Example #12
0
		public function _BuildBreadCrumbs()
		{
			if($this->hideBreadCrumbs()) {
				$GLOBALS['HideBreadCrumbs'] = 'style="display:none"';
				return;
			}

			$GLOBALS['HideBreadCrumbs'] = "";

			/*
				Build a list of one or more breadcrumb trails for this
				product based on which categories it appears in
			*/

			// Build the arrays that will contain the category names to build the trails
			$count = 0;

			$GLOBALS['BreadCrumbs'] = "";
			$GLOBALS['FindByCategory'] = "";

			// First we need to fetch the parent lists of all of the categories
			$trailCategories = array();
			$crumbList = array();
			$query = sprintf("
				SELECT c.categoryid, c.catparentlist
				FROM [|PREFIX|]categoryassociations ca
				INNER JOIN [|PREFIX|]categories c ON (c.categoryid=ca.categoryid)
				WHERE ca.productid='%d' AND c.catvisible='1'",
				$GLOBALS['ISC_CLASS_DB']->Quote($this->GetProductId())
			);

			if($maxBreadcrumbs = $this->maxBreadcrumbs()) {
				$query .= ' LIMIT '.$maxBreadcrumbs;
			}

			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				if ($row['catparentlist'] == '') {
					$row['catparentlist'] = $row['categoryid'];
				}
				$cats = explode(",", $row['catparentlist']);
				$trailCategories = array_merge($trailCategories, $cats);
				$crumbList[$row['categoryid']] = $row['catparentlist'];
			}

			$trailCategories = implode(",", array_unique($trailCategories));
			$categories = array();
			if ($trailCategories != '') {
				// Now load the names for the parent categories from the database
				$query = sprintf("SELECT categoryid, catname FROM [|PREFIX|]categories WHERE categoryid IN (%s)", $trailCategories);
				$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
				while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					$categories[$row['categoryid']] = $row['catname'];
				}
			}

			// Now we have all of the information we need to build the trails, lets actually build them
			foreach ($crumbList as $productcatid => $trail) {
				$GLOBALS['CatTrailLink'] = $GLOBALS['ShopPath'];
				$GLOBALS['CatTrailName'] = GetLang('Home');
				$GLOBALS['BreadcrumbItems'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItem");
				$GLOBALS['FindByCategoryItems'] = "";

				$cats = explode(",", $trail);
				$breadcrumbitems = "";
				$findbycategoryitems = "";
				$hasAccess = true;

				foreach ($cats as $categoryid) {
					if(!CustomerGroupHasAccessToCategory($categoryid)) {
						/*
						if customer doesn't have access to this category and this category is the category of the product,
						dont print the trail, otherwise just exclude the category from the trail
						*/
						if ($categoryid == $productcatid) {
							$hasAccess = false;
							break;
						}
						continue;
					}
					if (isset($categories[$categoryid])) {
						$catname = $categories[$categoryid];
						$GLOBALS['CatTrailLink'] = CatLink($categoryid, $catname);
						$GLOBALS['CatTrailName'] = isc_html_escape($catname);
						$breadcrumbitems .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItem");
						$findbycategoryitems .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductFindByCategoryItem");
					}
				}

				if ($hasAccess) {
					$GLOBALS['CatTrailName'] = isc_html_escape($this->GetProductName());
					$GLOBALS['BreadcrumbItems'] .= $breadcrumbitems . $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItemCurrent");
					$GLOBALS['BreadCrumbs'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductBreadCrumb");
					$GLOBALS['FindByCategoryItems'] = $findbycategoryitems;
					$GLOBALS['FindByCategory'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductFindByCategory");
				}
			}
		}
Example #13
0
		public function SetPanelSettings()
		{
			$GLOBALS['ISC_CLASS_CATEGORY'] = GetClass('ISC_CATEGORY');

			// Output breadcrumb trail
			$GLOBALS['SNIPPETS']['CatTrail'] = "";

			if ($GLOBALS['EnableSEOUrls'] == 1) {
				$baseLink = sprintf("%s/categories", $GLOBALS['ShopPath']);
			} else {
				$baseLink = sprintf("%s/categories.php?category=", $GLOBALS['ShopPath']);
			}

			$count = 0;
			$catPath = '';
			if (isset($GLOBALS['CatTrail']) && is_array($GLOBALS['CatTrail'])) {
				foreach($GLOBALS['CatTrail'] as $trail) {
					$baseLink .= "/" . MakeURLSafe($trail[1]);
					$catPath .= MakeURLSafe($trail[1])."/";

					$GLOBALS['CatTrailName'] = isc_html_escape($trail[1]);
					$GLOBALS['CatTrailLink'] = $baseLink;

					if($count++ == count($GLOBALS['CatTrail'])-1) {
						$GLOBALS['SNIPPETS']['CatTrail'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItemCurrent");
					}
					else {
						$GLOBALS['SNIPPETS']['CatTrail'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItem");
					}
				}
			}

			$catPath = rtrim($catPath, "/");

			// Output sub-categories
			$GLOBALS['SNIPPETS']['SubCategories'] = "";
			$query = sprintf("select * from [|PREFIX|]categories where catparentid='%d' and catvisible=1 order by catsort asc, catname asc", $GLOBALS['ISC_CLASS_DB']->Quote($GLOBALS['CatId']));
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			if($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {

				// Check to see if we need to add in place holder images or if we are just displaying text
				if (!($rtn = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['ISC_CLASS_DB']->Query("SELECT COUNT(*) AS Total FROM [|PREFIX|]categories WHERE catparentid='" . (int)$GLOBALS['CatId'] . "' AND catimagefile != ''"))) || !$rtn['Total']) {
					$useImages = false;
				} else {
					$useImages = true;
					if (GetConfig('CategoryDefaultImage') !== '') {
						$defaultImage = GetConfig('ShopPath') . '/' . GetConfig('CategoryDefaultImage');
					} else {
						$defaultImage = $GLOBALS['IMG_PATH'].'/CategoryDefault.gif';
					}
				}

				$i = 0;
				while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					$i++;
					if (!CustomerGroupHasAccessToCategory($row['categoryid'])) {
						continue;
					}

					$GLOBALS['SubCatName'] = isc_html_escape($row['catname']);
					$GLOBALS['SubCatLink'] = CatLink($row['categoryid'], $row['catname']);
					if ($useImages) {
						if ($row['catimagefile'] !== '') {
							$GLOBALS['SubCatImage'] = GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $row['catimagefile'];
						} else {
							$GLOBALS['SubCatImage'] = $defaultImage;
						}

						$GLOBALS['ISC_CLASS_TEMPLATE']->assign('width', getConfig('CategoryImageWidth'));
						$GLOBALS['ISC_CLASS_TEMPLATE']->assign('height', getConfig('CategoryImageHeight') + 50);

						$GLOBALS['SNIPPETS']['SubCategories'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCatItemImage");

						if ($i % GetConfig('CategoryPerRow') == 0) {
							$GLOBALS['SNIPPETS']['SubCategories'] .= '<li class="RowDivider" style="float:none; clear:both;"></li>';
						}

					} else {
						$GLOBALS['SNIPPETS']['SubCategories'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCatItem");
					}
				}

				if ($useImages) {
					if ($i % GetConfig('CategoryPerRow') > 0) {
						$GLOBALS['SNIPPETS']['SubCategories'] .= '<li style="float: none; clear: both;"/>';
					}
					$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoriesGrid");
				} else {
					$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategories");
				}

				$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
				$GLOBALS['SNIPPETS']['SubCategories'] = $output;
			}

			if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() > 1) {
				// Parse the sort select box snippet
				$queryStringAppend = array();
				if(!empty($_GET['price_min'])) {
					$queryStringAppend['price_min'] = (float)$_GET['price_min'];
				}

				if(!empty($_GET['price_max'])) {
					$queryStringAppend['price_max'] = (float)$_GET['price_max'];
				}


				if($GLOBALS['EnableSEOUrls'] == 1) {
					$GLOBALS['URL'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false);
				}
				else {
					$GLOBALS['URL'] = $GLOBALS['ShopPath']."/categories.php";
					$queryStringAppend['category'] = $catPath;
				}

				$GLOBALS['HiddenSortField'] = '';
				foreach($queryStringAppend as $k => $v) {
					$GLOBALS['HiddenSortField'] .= "<input type=\"hidden\" name=\"".$k."\" value=\"".isc_html_escape($v)."\" />";
				}

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

			// Is the category empty?
			if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() == 0) {
				$GLOBALS['ExtraCategoryClass'] = "Wide WideWithLeft";
				if($GLOBALS['SNIPPETS']['SubCategories'] != '') {
					$GLOBALS['CategoryProductListing'] = '';
				}
				$GLOBALS['HideRightColumn'] = "none";
			}
		}
Example #14
0
    $limit--;
    // We can't just pass ENT_QUOTES to htmlspecialchars because that converts a ' to &#39; rather than &apos;
    // Google sitemaps requires ' to be encoded as &apos; so we have to do things a little differently
    $url = htmlspecialchars(ProdLink($row['prodname']), ENT_COMPAT, 'UTF-8');
    $url = str_replace("'", '&apos;', $url);
    echo '<url>', "\n";
    echo '<loc>', $url, '</loc>', "\n";
    echo '</url>', "\n";
}
$query = "\n\t\tSELECT categoryid, catname\n\t\tFROM [|PREFIX|]categories\n\t\tWHERE categoryid != catparentid\n\t\tLIMIT " . $GLOBALS['ISC_CLASS_DB']->Quote((int) $limit);
$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
    $limit--;
    // We can't just pass ENT_QUOTES to htmlspecialchars because that converts a ' to &#39; rather than &apos;
    // Google sitemaps requires ' to be encoded as &apos; so we have to do things a little differently
    $url = htmlspecialchars(CatLink($row['categoryid'], $row['catname']), ENT_COMPAT, 'UTF-8');
    $url = str_replace("'", '&apos;', $url);
    echo '<url>', "\n";
    echo '<loc>', $url, '</loc>', "\n";
    echo '</url>', "\n";
}
$query = "\n\t\tSELECT brandname\n\t\tFROM [|PREFIX|]brands\n\t\tLIMIT " . $GLOBALS['ISC_CLASS_DB']->Quote((int) $limit);
$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
    $limit--;
    // We can't just pass ENT_QUOTES to htmlspecialchars because that converts a ' to &#39; rather than &apos;
    // Google sitemaps requires ' to be encoded as &apos; so we have to do things a little differently
    $url = htmlspecialchars(BrandLink($row['brandname']), ENT_COMPAT, 'UTF-8');
    $url = str_replace("'", '&apos;', $url);
    echo '<url>', "\n";
    echo '<loc>', $url, '</loc>', "\n";
Example #15
0
		echo '<url>',"\n";
		echo '<loc>',$url,'</loc>',"\n";
		echo '</url>',"\n";
	}

	$query = "
		SELECT categoryid, catname
		FROM [|PREFIX|]categories
		WHERE categoryid != catparentid
		LIMIT ".$GLOBALS['ISC_CLASS_DB']->Quote((int)$limit);

	$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

	while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
		$limit--;
		$url = makeSafeUrl(CatLink($row['categoryid'], $row['catname']));
		echo '<url>',"\n";
		echo '<loc>',$url,'</loc>',"\n";
		echo '</url>',"\n";
	}


	$query = "
		SELECT brandname
		FROM [|PREFIX|]brands
		LIMIT ".$GLOBALS['ISC_CLASS_DB']->Quote((int)$limit);

	$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

	while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
		$limit--;
 private function _BuildCategoryRows($parentid = 0)
 {
     static $categorycache, $product_counts;
     if (!is_array($categorycache)) {
         $query = "SELECT * FROM [|PREFIX|]categories ORDER BY catsort ASC, catname ASC";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $categorycache[$row['catparentid']][] = $row;
         }
         $query = "select categoryid, count(productid) as total from [|PREFIX|]categoryassociations group by categoryid";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $product_counts[$row['categoryid']] = $row['total'];
         }
     }
     if (!isset($categorycache[$parentid])) {
         return '';
     }
     $categoryList = '';
     foreach ($categorycache[$parentid] as $category) {
         $GLOBALS['SubCats'] = $this->_BuildCategoryRows($category['categoryid']);
         if ($GLOBALS['SubCats']) {
             $GLOBALS['SubCats'] = sprintf('<ul class="SortableList">%s</ul>', $GLOBALS['SubCats']);
         }
         $GLOBALS['CatId'] = (int) $category['categoryid'];
         $GLOBALS['CatName'] = isc_html_escape($category['catname']);
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Categories)) {
             if ($category['catvisible'] == 1) {
                 $GLOBALS['CatVisible'] = "<a id='CatVisible_" . $category['categoryid'] . "' title='" . GetLang('ClickToHideCategory') . "' href='index.php?ToDo=editCategoryVisibility&amp;catId=" . $category['categoryid'] . "&amp;visible=0' onclick=\"quickToggle(this); return false;\"><img border='0' src='images/tick.gif' alt='Visible'></a>";
             } else {
                 $GLOBALS['CatVisible'] = "<a id='CatVisible_" . $category['categoryid'] . "' title='" . GetLang('ClickToShowCategory') . "' href='index.php?ToDo=editCategoryVisibility&amp;catId=" . $category['categoryid'] . "&amp;visible=1' onclick=\"quickToggle(this); return false;\"><img border='0' src='images/cross.gif' alt='Invisible'></a>";
             }
         } else {
             if ($category['catvisible'] == 1) {
                 $GLOBALS['CatVisible'] = '<img border="0" src="images/tick.gif" alt="Visible">';
             } else {
                 $GLOBALS['CatVisible'] = '<img border="0" src="images/cross.gif" alt="Invisible">';
             }
         }
         if (isset($product_counts[$category['categoryid']])) {
             $GLOBALS['Products'] = (int) $product_counts[$category['categoryid']];
         } else {
             $GLOBALS['Products'] = 0;
         }
         $GLOBALS['ViewLink'] = sprintf("<a title='%s' href=\"%s\" class=\"bodylink\" target='_blank'>%s</a>", GetLang('ViewCategory'), CatLink($category['categoryid'], $category['catname']), GetLang('View'));
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Create_Category)) {
             $GLOBALS['NewLink'] = sprintf("<a title='%s' href=\"index.php?ToDo=createCategory&amp;parentId=%s\" class=\"bodylink\">%s</a>", GetLang('NewCategory'), $category['categoryid'], GetLang('New'));
         } else {
             $GLOBALS['NewLink'] = sprintf("<a disabled class=\"bodylink\">%s</a>", GetLang('New'));
         }
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Categories)) {
             $GLOBALS['EditLink'] = sprintf("<a title='%s' href=\"index.php?ToDo=editCategory&amp;catId=%s\" class=\"bodylink\">%s</a>", GetLang('EditCategory'), $category['categoryid'], GetLang('Edit'));
         } else {
             $GLOBALS['EditLink'] = sprintf("<a disabled class=\"bodylink\">%s</a>", GetLang('Edit'));
         }
         if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Delete_Categories)) {
             $GLOBALS['DisableDelete'] = "DISABLED";
         }
         $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("qvaluecat.manage.row");
         //$GLOBALS['CategoryGrid'] .= $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate(true);
         $categoryList .= $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
     }
     return $categoryList;
 }
Example #17
0
	public static function generatePagingPanel()
	{
		// Do we need to show paging, etc?
		if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() <= GetConfig('CategoryProductsPerPage')) {
			return false;
		}

		// Workout the paging data
		$GLOBALS['SNIPPETS']['PagingData'] = "";

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

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

		$queryStringAppend = array(
			'sort' => $GLOBALS['ISC_CLASS_CATEGORY']->getSort(),
		);

		if(!empty($_GET['price_min'])) {
			$queryStringAppend['price_min'] = (float)$_GET['price_min'];
		}

		if(!empty($_GET['price_max'])) {
			$queryStringAppend['price_max'] = (float)$_GET['price_max'];
		}


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

			$pageQueryStringAppend = $queryStringAppend;
			$pageQueryStringAppend['page'] = $page;
			$GLOBALS['PageLink'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false, $pageQueryStringAppend);
			$GLOBALS['PageNumber'] = $page;
			$GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
		}

		// Parse the paging snippet
		if($GLOBALS['ISC_CLASS_CATEGORY']->GetPage() > 1) {
			// Do we need to output a "Previous" link?
			$pageQueryStringAppend = $queryStringAppend;
			$pageQueryStringAppend['page'] = $GLOBALS['ISC_CLASS_CATEGORY']->getPage() - 1;
			$GLOBALS['PrevLink'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false, $pageQueryStringAppend);
			$GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
		}

		if($GLOBALS['ISC_CLASS_CATEGORY']->GetPage() < $GLOBALS['ISC_CLASS_CATEGORY']->GetNumPages()) {
			// Do we need to output a "Next" link?
			$pageQueryStringAppend = $queryStringAppend;
			$pageQueryStringAppend['page'] = $GLOBALS['ISC_CLASS_CATEGORY']->getPage() + 1;
			$GLOBALS['NextLink'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false, $pageQueryStringAppend);
			$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']['CategoryPaging'] = $output;
		return true;
	}