Example #1
0
 /**
  * Handle the simple search and advanced search
  * 
  * @return string
  */
 public function handleSearch($action)
 {
     switch ($action) {
         case 'Advanced':
             //Advanced search
             if (@$_REQUEST["btnSubmit"]) {
                 $this->smarty->assign('Name', @$_REQUEST["Name"]);
                 $this->smarty->assign('Category', @$_REQUEST["Category"]);
                 $this->smarty->assign('Supplier', @$_REQUEST["Supplier"]);
                 $this->smarty->assign('ProductType', @$_REQUEST["ProductType"]);
                 $this->smarty->assign('PriceOp', @$_REQUEST["PriceOp"]);
                 $this->smarty->assign('Price1', @$_REQUEST["Price1"]);
                 $this->smarty->assign('Price2', @$_REQUEST["Price2"]);
                 $returnURL = "/Store/Search/&action=Advanced&btnSubmit=Search&Name=" . @$_REQUEST["Name"] . "&Category=" . @$_REQUEST["Category"] . "&Supplier=" . @$_REQUEST["Supplier"] . "&ProductType=" . @$_REQUEST["ProductType"] . "&PriceOp=" . @$_REQUEST["PriceOp"] . "&Price1=" . @$_REQUEST["Price1"] . "&Price2=" . @$_REQUEST["Price2"];
                 $returnURL = urlencode($returnURL);
                 $returnURL = str_replace("%", "%25", $returnURL);
                 //The % sign should be replaced with %25 so Apache rewrite rules will work properly
                 $this->smarty->assign('returnURL', $returnURL);
                 $products = Product::searchProducts($_REQUEST);
                 $this->smarty->assign('products', $products);
                 $this->smarty->assign('btnSubmit', "1");
                 return $this->smarty->fetch("SearchResults.tpl");
             }
             return $this->smarty->fetch("SearchFormAdvanced.tpl");
         case 'Simple':
             //Simple search
         //Simple search
         default:
             if (@$_REQUEST["btnSubmit"]) {
                 $this->smarty->assign('searchPhrase', @$_REQUEST["searchPhrase"]);
                 $returnURL = "/Store/Search/&action=Simple&btnSubmit=Search&searchPhrase=" . @$_REQUEST["searchPhrase"];
                 $returnURL = urlencode($returnURL);
                 $returnURL = str_replace("%", "%25", $returnURL);
                 //The % sign should be replaced with %25 so Apache rewrite rules will work properly
                 $this->smarty->assign('returnURL', $returnURL);
                 $products = Product::searchProductsSimple(@$_REQUEST["searchPhrase"]);
                 $this->smarty->assign('products', $products);
                 $this->smarty->assign('btnSubmit', "1");
             }
             return $this->smarty->fetch("SearchFormSimple.tpl");
     }
     break;
 }