Unverified Commit d8decb25 authored by Julien Ait azzouzene's avatar Julien Ait azzouzene Committed by GitHub
Browse files

Merge pull request #24 from PetitGens/detail-recette

Détail recette
parents 5b7cd7fa c9e3514b
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -50,7 +50,9 @@ try{
            break;

        case 'detail-recette':
            $controleur = new PageRecetteControleur();
            $idRecette = getVariable_GET('idRecette');

            $controleur = new PageRecetteControleur($idRecette);
            break;

        default:
@@ -63,3 +65,11 @@ catch(Exception $e){
    $messageErreur = $e->getMessage();
    require 'templates/erreur.php';
}

function getVariable_GET($cle){
    if(! isset($_GET[$cle]) || empty($_GET[$cle])){
        header('Location: .');
        exit;
    }
    return $_GET[$cle];
}
 No newline at end of file
+12 −3
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

require_once 'src/controllers/controleur.php';

require_once 'src/model/recette.php';
@@ -8,9 +10,16 @@ require_once 'src/model/recetteManager.php';
require_once 'templates/pageRecette.php';

class PageRecetteControleur extends Controleur {
    public function executer() {
        $recette = (new RecetteManager)->getRecette('1');
    private Recette $recette;

    public function __construct(string $idRecette){
        $this->recette = (new RecetteManager)->getRecette($idRecette);
        if(! $this->recette){
            throw new Exception("cette recette n'existe pas");
        }
    }

        afficherPageRecette($recette);
    public function executer() {
        afficherPageRecette($this->recette);
    }
}
 No newline at end of file
+5 −6
Original line number Diff line number Diff line
@@ -13,17 +13,17 @@ function afficherPageRecette(Recette $recette){
    ?>

    <?php //TODO gérer les dimensions de l'image ?>
    <div data-bss-parallax-bg="true" style="height: 500px;padding-top: 100px;padding-right: 10px;padding-left: 10px;background: url(<?=$recette->getImage()?>)">
        <h1 style="width: 100%;margin-bottom: auto;text-align: center;height: auto;padding-top: 0;"><?=$recette->getTitre() ?></h1>
        <p style="margin-top: 50px;margin-bottom: 10%;padding: 0px;width: auto;text-align: center;"><?=$recette->getResume() ?></p>
    <div data-bss-bg="true" style="text-align:center;height: 500px;padding-top: 30px;padding-right: 10px;padding-left: 10px;background-image: url(<?=$recette->getImage()?>);background-repeat: no-repeat;background-size: contain;background-position: center">
        <h1 style="margin:auto;margin-top: 20px;margin-bottom: 10%;padding: 10px;width: fit-content;text-align: center;background:rgba(192,192,192,0.75);border-radius: 5px;"><?=$recette->getTitre() ?></h1>
    </div>
    <p style="margin:auto;margin-top: 10px;margin-bottom: 10px;padding: 10px;width: fit-content;text-align: center;background:rgba(192,192,192,0.75);border-radius: 5px;"><?=$recette->getResume() ?></p>
    <div class="row" style="width: inherit;padding-right: 4%;padding-left: 4%;">
        <div class="col">
            <section class="horitzontalScroll">
                <?php
                    foreach ($recette->getIngredients() as $ingredient){
                ?>
                <a class="custlnk" href="#" style="width: auto;padding-right: 15px;padding-left: 15px;">
                <a class="custlnk" style="width: auto;padding-right: 15px;padding-left: 15px;">
                    <div class="horitzontalScrollContent me-3 ms-2" style="width: 100%;margin: 0px;">
                        <div class="row" style="width: auto;">
                            <div class="col text-center" style="width: auto;padding: 0px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -32 576 576" width="1em" height="1em" fill="currentColor" class="border rounded-circle p-2" style="width: 45px;height: 45px;background-color: rgba(201,201,201,0.61);font-size: 30px;">
@@ -51,4 +51,3 @@ function afficherPageRecette(Recette $recette){

    require 'templates/layout.php';
}
 No newline at end of file
?>
 No newline at end of file