} ?> $countdataProducts = count($dataProducts); if($countdataProducts >0 ){ ?>
require_once("_lib/lib.php");
$_pageCurrent="category";
$_pageSection="category";
$productCharObject = new ProductChars($db);
$catID=null;
$categoryTitle="";
$encodedCat="";
$encodedS="";
$topsection="";
$toplevelUrl="";
$sortstr="";
$parentCategoryID="0";
$parentCategoryTitle="";
$titleUrlGet="";
$selectedTitle="";
$varsGet="";
//instantiate object
$flasgDisplayCategories=false;//to display categories or products
$rArray=array();
$rString = $_SERVER['REQUEST_URI'];
$rArray=explode("/",$rString);
//printArray($rArray);
//$encodedS=$rArray[2];
if(isset($rArray[2]) && $rArray[2]!=""){// the s is on the second place of the array
$encodedS=cleanpost($rArray[2]);
$titleUrlGet ="";
$varsGet ="";
$pos = strpos($rArray[3], "?");
if ($pos === false) {
$titleUrlGet=cleanpost($rArray[3]);
} else {
list($titleUrlGet,$varsGet)=explode("?",$rArray[3]);
}
// list($titleUrlGet,$varsGet)=explode("?",$rArray[3]);
//$titleUrlGet=cleanpost($rArray[3]);
}else{
header("Location: ".HOME_PAGE);exit();
}
$catIDtemp=SaveSingleVar::restoreurl($encodedS);
list($leftc,$catID)=explode("=",$catIDtemp);
//var_dump($catIDtemp);
//var_dump($catID);die();
if(!ctype_digit($catID) ){
header("Location: ".HOME_PAGE);exit();
}
if(isset($_POST["f_all"]) && $_POST["f_all"]=="1"){
header("Location: /category/$encodedS/$titleUrlGet");exit();
}
//Find out if this category has subcategories ***************************** START
if($productCategoryObject->loadObject("id",$catID)){
$categoryTitle=($_lang==LANGUAGE_ENGLISH?$productCategoryObject->titleen:$productCategoryObject->title);
$categoryBody=($_lang==LANGUAGE_ENGLISH?$productCategoryObject->bodyen:$productCategoryObject->body);
$encodedCat=SaveSingleVar::storeurl("c=".$catID);
$topsection=$productCategoryObject->toplevel;
$parentCategoryID = $productCategoryObject->getCategoryParent($catID);
$parentCategoryTitle = $productCategoryObject->getCategoryTitle($parentCategoryID);
}else{
header("Location: /home");exit();
}
$categoryTitleUrlEN=fix_cat_name_for_url($productCategoryObject->titleen);
$countSubs =0;
$countSubs=$productCategoryObject->getsubs($catID);
if($countSubs ==0){
$wherestr=" categoryid='$catID' AND active='1' ";
$wherestrFilter=" p.categoryid='$catID' AND p.active='1' ";
$wherestrCount=" categoryid='$catID' AND active='1' ";
$sortstr="sortorder ASC";
$sortstrFilter="p.sortorder ASC";
$sortEnabled=false;
//print $_SERVER['REQUEST_URI'];
//var_dump($pos);
//printArray($_REQUEST);
/*if (isset($_REQUEST["f_sort"]) && $_REQUEST["f_sort"]=="1" ) {
$sot="";
$sortstr=" $titleFinal ASC";
$sortstrFilter="p.$titleFinal ASC";
$selectedTitle =$_string[$_lang]["ALPHAASCENDING"].", ";
}*/
if (isset($_REQUEST["orderprice"]) && $_REQUEST["orderprice"]!="" ) {
switch($_REQUEST["orderprice"]){
case "f_asc":
$sot="ASC";
$sortstr="price ASC";
$sortstrFilter="p.price ASC";
$selectedTitle =$_string[$_lang]["PRICEASCENDING"].", ";
break;
case "f_desc":
$sot="DESC";
$sortstr="price DESC";
$sortstrFilter="p.price DESC";
$selectedTitle =$_string[$_lang]["PRICEDESCENDING"].", ";
break;
default:
$sot="ASC";
$sortstr="price ASC";
$sortstrFilter="p.price ASC";
$selectedTitle =$_string[$_lang]["PRICEASCENDING"].", ";
break;
}
}
//get page if paging is enabled
if(isset($_GET["page"]) && $_GET["page"]!="" && ctype_digit($_GET["page"])){
$pageNum =cleanpost($_GET["page"]);
}else{
$pageNum="1";
}
$rowsPerPage =PAGING_ROWSPERPAGE;
//$rowsPerPage =2;
//echo $pageNum;
$dataProducts=array();
$dataProductsFilters=array();
$countDataProducts=0;
$countDataProducts= $productObject->get_count_all($wherestrCount);
if($countDataProducts > 0){
//get default rows per page
//$rowsPerPage=PAGING_ROWSPERPAGE;
//$rowsPerPage=2;
//$rowsPerPage=3;
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
// how many pages we have when using paging?
$maxPage = ceil($countDataProducts/$rowsPerPage);
//get data
//$dataProductsFilters =& $productObject->getAllProductsFilters("p.productid,c.idchar",$wherestrFilter,"","","",$sortstrFilter);//get these for filters only
$dataProductsFilters =& $productObject->getAllProductsFilters("p.productid,c.idchar",$wherestrFilter,"","","","");//get these for filters only
if(!isset($_REQUEST["f_all"]) || $_REQUEST["f_all"]!="1"){
if(isset($_REQUEST["filterSubmit"]) && $_REQUEST["filterSubmit"]==PRIVATE_PAGE){
//printArray($_POST);
//printArray($dataProductsFilters);
//get all filters from list
$countdataProductsFilter = count($dataProductsFilters);
$strIDS="";
$debugStr="";
$counterPostedFilters=0;
for($pp=0;$pp < $countdataProductsFilter;$pp++){
$encodedRequestedFilterID=SaveSingleVar::storeurl($dataProductsFilters[$pp]["idchar"]);
//print "f_".$encodedRequestedFilterID."
";
if(isset($_REQUEST["f_".$encodedRequestedFilterID]) && $_REQUEST["f_".$encodedRequestedFilterID]=="1"){
$strIDS.=$dataProductsFilters[$pp]["productid"].",";
$counterPostedFilters++;
$debugStr .="f_".$encodedRequestedFilterID."=".$_REQUEST["f_".$encodedRequestedFilterID]."\n";
}
}
//print "str=".$strIDS."---------";
if($strIDS!=""){
$strIDS=substr($strIDS,0,-1);
}
if($counterPostedFilters >0){
$wherestr .=" AND productid IN ($strIDS)";
$wherestrCount .=" AND productid IN ($strIDS)";
}
}
}
$offset = ($pageNum - 1) * $rowsPerPage;
$dataProducts =& $productObject->getAllProducts("productid,categoryid,title,titleen,$teaserFinal,$subtitleFinal,topsection,image1,price,priceen,discount,stock,code,brand,$charsFinal",$wherestr,"$offset",$rowsPerPage,"",$sortstr);
$countDataProducts= $productObject->get_count_all($wherestrCount);
// how many pages we have when using paging?
$maxPage = ceil($countDataProducts/$rowsPerPage);
//print "";
//print "";
//print "";
//print "";
//print "";
}//end if $countDataProducts
//Find out if this category has subcategories ***************************** END
}else{ // we do have subcategories from this category, show subs
//get subs
$dataCategories=array();
$dataCategories=$productCategoryObject->get_all("*","active='1' AND parent='$catID'","","","","sortorder ASC");
$flasgDisplayCategories=true;
}
$pathStringCats="";
$pathCats=$productCategoryObject->_getCategoriesPath("category",$catID);
$pathCats=array_reversed($pathCats); //reverse the arrays
//printArray($pathCats);
$pathStringCats=implode(" >",$pathCats);
//printArray($dataProducts);
?>