コード例 #1
0
ファイル: recipes.php プロジェクト: michaelgumtow/oop-basics
<?php

$recipe1 = new Recipe("Belgium Waffles");
$recipe1->setIngredients([["ingredient" => "egg", "amount" => "1", "measure" => null], ["ingredient" => "sugar", "amount" => "1/2", "measure" => "Cup"]]);
$recipe1->addIngredient("melted butter", "1", "Cup");
$recipe1->addIngredient("vanilla", "2", "tsp");
$recipe1->addIngredient("baking powder", "1", "Tbs");
$recipe1->addIngredient("flour", "2", "Cups");
$recipe1->addIngredient("milk", "1 1/2", "Cups");
$recipe1->addInstruction("Separate eggs. Whip egg whites until stiff peaks form. Set asside.");
$recipe1->addInstruction("Melt butter. Combine the rest of the ingredients except milk and mix well. Slowly add milk until combined.");
$recipe1->addInstruction("Fold in egg whites. Follow instructions on waffle maker or add 1/2 cup of batter to waffle iron and cook for 4 minutes.");
$recipe1->setYield("4 one cup servings");
$recipe1->setTags("breakfast");
$recipe2 = new Recipe("Italian Lemon Chicken");
$recipe2->addIngredient("Pasta, boiled", "1", "lbs");
$recipe2->addIngredient("Chicken Breast", "2", "lbs");
$recipe2->addIngredient("olive oil", "1/2", "Cup");
$recipe2->addIngredient("chopped garlic", "2", "Tbls");
$recipe2->addIngredient("lemon juice", "1/4", "Cup");
$recipe2->addIngredient("sugar", "1/2", "tsp");
$recipe2->addIngredient("parsley", "2", "tsp");
$recipe2->addIngredient("oregano", "2", "tsp");
$recipe2->addIngredient("basil", "1", "Tbls");
$recipe2->addIngredient("parmesian cheese to taste");
$recipe2->addInstruction("In a large skillet on medium high heat, saute garlic in olive oil for 3 minutes. Cut chicken into bite sized pieces.");
$recipe2->addInstruction("Add additional ingredients to sauce pan and cover for 5 minutes or untill chicken is almost completely white.");
$recipe2->addInstruction("Remove lid and cook until reduced to a thick sauce.");
$recipe2->addInstruction("Serve over pasta with " . $recipe2->getLastIngredient());
$recipe2->setYield("6 Servings");
$recipe2->setTags(["Main Dish", "Dinner"]);
コード例 #2
0
ファイル: Recipe.php プロジェクト: elecnix/smellyfish
 function build($line) {
 
     $r = new Recipe();
     
     $r->id = $line['id'];
     $r->setTitle($line['title']);
     $r->setOrigin($line['origin']);
     $r->setSize($line['size']);
     $r->setIngredients($line['ingredients']);
     $r->setSteps($line['steps']);
     $r->dateAdded = $line['date_added_ts'];
     $r->hasPhoto = $line['has_photo'];
     $r->rating = $line['rating'];
     $r->authorId = $line['author_user_id'];
     
     $catId = $line['category_id'];
     if (strlen($catId) > 0) {
         $cat = Category::getById($catId);
         $r->setCategory($cat);
     }
     
     return $r;
 }
コード例 #3
0
ファイル: add.php プロジェクト: elecnix/smellyfish
<? require_once("classes/Recipe.php"); ?>
<? require_once("classes/Text.php"); ?>
<?

$r = new Recipe();
$r->setTitle($_REQUEST['title']);
$r->setOrigin($_REQUEST['origin']);
$r->setSize($_REQUEST['size']);
$r->setIngredients($_REQUEST['ingredients']);
$r->setSteps($_REQUEST['steps']);

$cat = $_REQUEST['cat'];
if (strlen($cat) > 0) {
    $c = Category::getById($cat);
    $r->setCategory($c);
}

if (!Recipe::havePermission("ADD")) {
  $errMsg=Text::getText("You are not allowed to add recipes.");
  include("error.php");
  exit;
}

$action = $_REQUEST['action'];
if ($action == "save" && Recipe::havePermission("ADD")) {
    if ($_REQUEST['title'] != "") {
        if ($_FILES['photo']['size'] != 0) {
            $filename = $_FILES['photo']['name'];
            $extension = strrchr($filename, '.');
            if ($extension != ".jpg") {
                $r->insert();