public function __toString()
 {
     //return ' Recipe(wrapper) [ title: '.$this->getTitle().'; quantities: '.$this->getQuantities().'; instructions: '.$this->getInstructions().'; ingredients: '.$this->getIngredients().' ] ';
     $str = '<article class="recipe">' . PHP_EOL;
     $str .= '	<h1>' . $this->getTitle() . '</h1>' . PHP_EOL;
     if (FavoriteDAO::isFavorite($this)) {
         $str .= '	<a class="favorite-button remove" href="favorites/remove/' . $this->getId() . '" title="Je n\'aime plus !">Supprimer des favoris</a>';
     } else {
         $str .= '	<a class="favorite-button add" href="favorites/add/' . $this->getId() . '" title="J\'aime !">Ajouter aux favoris</a>';
     }
     $str .= '	<section class="content">';
     if (file_exists($this->getPrivateImagePath())) {
         $str .= '<figure><img src="' . $this->getImagePath() . '" alt="" /></figure>';
     }
     $str .= '		<h2> Ingrédients : </h2>' . "\n\t" . '<ul>';
     foreach (explode('|', $this->getQuantities()) as $quantity) {
         $str .= '	<li>' . $quantity . '</li>';
     }
     $str .= '		</ul>' . PHP_EOL;
     $str .= '		<h2> Préparation : </h2>' . PHP_EOL;
     $str .= '		<p>' . $this->getInstructions() . '</p>' . PHP_EOL;
     $str .= '	</section>';
     $str .= '	<ul>' . PHP_EOL;
     foreach ($this->getIngredients() as $ingredient) {
         $str .= '		<li class="tag"><a href="ingredient/' . urlencode($ingredient->getId()) . '">' . $ingredient->getLabel() . '</a></li>';
     }
     $str .= '	</ul>' . PHP_EOL;
     $str .= '</article>' . PHP_EOL;
     return $str;
 }
 public function testFavByOwner()
 {
     $item = $this->getJSONStringFromFile("fav_by_owner.json");
     $this->json_parser->parseJSON($item);
     $posts = $this->favs_dao->getAllFavoritePosts(2768241, 'twitter', 10);
     $this->assertEqual(sizeof($posts), 1);
     // test users added
     $user = $this->user_dao->getDetails(9207632, 'twitter');
     $this->assertEqual($user->user_id, 9207632);
     $user = $this->user_dao->getDetails(2768241, 'twitter');
     $this->assertEqual($user->user_id, 2768241);
 }
}
if (isset($_SESSION['cocktailsUser']) && get_class($_SESSION['cocktailsUser']) == 'User') {
    $request->redirect('index');
} elseif (isset($_POST['submit'])) {
    if ($_POST['user'] == '' || $_POST['password'] == '') {
        $badInput = true;
    } elseif (!$bot) {
        //require MODELS_INC.'UserDAO.class.php';
        //require 'passwordHash.inc.php';
        $user = UserDAO::getByLogin($_POST['user']);
        if ($user != NULL) {
            if (empty($user) || !Transitive\Utils\Passwords::validate_password($_POST['password'], $user->getPassword())) {
                $badInput = true;
                sleep(1);
            } else {
                $_SESSION['cocktailsUser'] = $user;
                FavoriteDAO::sync();
                if (!empty($_SESSION['referrer']) && $_SESSION['referrer'] != 'login' && $_SESSION['referrer'] != 'logout') {
                    $request->redirect($_SESSION['referrer']);
                } else {
                    $request->redirect('index');
                }
                exit;
            }
        } else {
            $badInput = true;
        }
    }
}
$presenter->data['bot'] = $bot;
$presenter->data['badInput'] = $badInput;
<?php

require_once MODELS_INC . 'Favorite.class.php';
if (isset($_GET['remove'])) {
    FavoriteDAO::removeById($_GET['remove']);
}
if (isset($_GET['add'])) {
    FavoriteDAO::addById($_GET['add']);
}
if (!isset($_SESSION['cocktailsFavorites'])) {
    $_SESSION['cocktailsFavorites'] = array();
}