Пример #1
0
	/**
	* Function for recipe search (From POST parameteres)
	*
	* If POST parameters are sent, then perform search
	* If no POST parameters exist in the HTTP request, display the search controls/form
	*
	* @param: None
	* @return: None
	*/
	public function search(){
		//Test if the POST parameters exist. If they don't present the user with the
		//search controls/form
		if(!isset($_POST["search"])){
			$this->template->display('search.html.php');			
		}
		
		//Get the recipe from the database
		$recipes = Recipe::search($_POST["search"]);
		//If successful and the count is equal to one (as desired)
		//set the recipe object in the template to be displayed
		$this->template->recipes = $recipes;
	
		$this->template->display('results.html.php');
	}
Пример #2
0
require_once("classes/Category.php");
require_once("classes/Recipe.php");

  $q = $_REQUEST['q'];
  $cat = $_REQUEST['cat'];
  if ($q != NULL) {
      $searched .= Text::getText("SearchedFor")." <b>".$q."</b>";
      if ($cat != NULL) {
          $c = Category::getById($cat);
          $searched .= " ".Text::getText("in")." <b>".$c->getName()."</b>";
      }
      $recipes = Recipe::search($q, $c);
  } else if ($cat != NULL) {
      $c = Category::getById($cat);
      $searched .= Text::getText("Category").": <b>".$c->getName()."</b>";
      $recipes = Recipe::search("", $c);
  }

if ($recipes != null && count($recipes) == 1) {
  header("Location: ".$recipes[0]->href());
  exit;
}

$output = $_REQUEST['output'];
if ($output != "json") {
  include("header.php");
  ?><h2><?php 
echo Text::getText("Search");
?>
</h2><?
}