Skip to content
Snippets Groups Projects
Commit c36bc99b authored by SASSU Thomas's avatar SASSU Thomas
Browse files

Partie 3

parent ccc0c4c8
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ session_start();
use \Slim\Slim as Slim;
use Illuminate\Database\Capsule\Manager as DB;
use \gp\controleurs\ControleurPrincipal as ControleurPrincipal;
use \gp\controleurs\ControleurGame as ControleurGame;
use \gp\controleurs\ControleurScript as ControleurScript;
$db = new DB();
......@@ -13,17 +14,22 @@ $db->setAsGlobal();
$db->bootEloquent();
$app = new \Slim\Slim();
$app->response->headers->set('Content-Type', 'application/json');
$app->get('/',function () {
$app->get('/',function () use ($app) {
$c = new ControleurPrincipal();
// $c->afficherAccueil();
$c->afficherAccueil();
$app->response->headers->set('Content-Type', 'text/html');
});
$app->get('/script_TD1/',function () {
$c = new ControleurScript();
$c->td1();
$app->get('/api/games/:id',function ($id) {
$c = new ControleurGame();
$c->getGame($id);
});
$app->get('/api/games/',function () {
$c = new ControleurGame();
$c->getGames();
});
$app->run();
\ No newline at end of file
<?php
namespace gp\controleurs;
use gp\modeles\Game;
use gp\vues\VueGame;
class ControleurGame
{
public function getGame($id){
$game = Game::where('id', '=', $id)->first();
$v = new VueGame(json_encode($game));
$v->render('getGame');
}
public function getGames(){
$page = filter_var($_GET['page'], FILTER_SANITIZE_NUMBER_INT);
ini_set('memory_limit', '512M');
$response = Game::paginate(200, ['*'], 'page', $page);
$json = (json_decode(json_encode($response),true));
foreach ($json['data'] as $game) {
$results['games'][] = ["game" => $game, "links" => ["self" => ["href" => "/api/games/{$game['id']}"]]];
}
$links = ["prev" =>["href" => "/api/games{$json['prev_page_url']}"] , "next" =>["href" => "/api/games{$json['next_page_url']}"]];
$results['links'] = $links;
$v = new VueGame(json_encode($results));
$v->render('getGames');
}
}
\ No newline at end of file
<?php
namespace gp\modeles;
namespace gp\controleurs;
use \gp\vues\VuePrincipale as VuePrincipale;
class ControleurPrincipal
{
......
......
<?php
namespace gp\vues;
class VueGame
{
public $tab;
public function __construct($tableau) {
$this->tab = $tableau;
}
public function render($selecteur) {
// switch ($selecteur){
// case 'getGame' : {
// $json = $this->afficher_getGame();
// $cd = '';
// break;
// }
// case 'getGames' : {
// $json = $this->afficher_getGame();
// $cd = '';
// break;
// }
// }
echo $this->tab;
}
//
// private function afficher_getGame() {
// return $this->tab;
// }
}
\ No newline at end of file
......@@ -18,7 +18,6 @@ class VuePrincipale
break;
}
}
if (isset($_SESSION['Connexion']) == false) {
$html = <<<END
<!doctype html>
<html class="no-js" lang="fr" dir="ltr">
......@@ -26,48 +25,10 @@ class VuePrincipale
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fridgie</title>
<link rel="stylesheet" href="{$cd}css/style.css">
</head>
<header class="menu" role="banner">
<div id="logo"><a href="{$cd}./"><img src="{$cd}img/logo.png"></a></div>
<div id="menu_button">
<ul>
<li><a class="bouton" href="{$cd}./">Accueil</a></li>
<li><a class="bouton" href="{$cd}indexevenement">Evenement</a></li>
<li><a class="bouton" href="{$cd}indexrecette">Recette</a></li>
<li><a class="bouton" href="{$cd}connexion">Connexion</a></li>
</ul>
</div>
</header>
<body>
$content
</body>
</html>
END;
} else {
$html = <<<END
<!doctype html>
<html class="no-js" lang="fr" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fridgie</title>
<title>GamePedia</title>
<link rel="stylesheet" href="css/style.css">
</head>
<header class="menu" role="banner">
<div id="logo"><a href="{$cd}./"><img src="{$cd}img/logo.png"></a></div>
<div id="menu_button">
<ul>
<li><a class="bouton" href="{$cd}./">Accueil</a></li>
<li><a class="bouton" href="{$cd}indexevenement">Evenement</a></li>
<li><a class="bouton" href="{$cd}indexrecette">Recette</a></li>
<li><a class="bouton" href="{$cd}moncompte">Mon Compte</a></li>
</ul>
</div>
</header>
<body>
......@@ -76,37 +37,18 @@ END;
</body>
</html>
END;
}
echo $html;
}
private function afficherAccueil() {
if (isset($_SESSION['Connexion']) == false) {
$res="
<div id=\"first\">
<p><strong>Bienvenue sur Fridgie !</strong>
<br>Rejoignez-nous en vous inscrivant en appuyant ci-dessous.</p>
<a class=\"bouton\" href=\"inscription\">Inscription</a>
<p><strong>Bienvenue sur GamePedia !</strong>
</div>";
} else {
$res="
<div id=\"first\">
<p><strong>Bienvenue sur Fridgie !</strong>
<br>Recherchez une recette en appuyant ci-dessous.</p>
<a class=\"bouton\" href=\"recette\">Recherche</a>
</div>";
}
return $res."<div id='arrow01'></div><div id=\"second\">
<p>
Fridgie est une application web développée par quatre étudiants de 2ème de DUT Informatique.
Principe du site-web :
<br>Aujourd'hui, nous avons tellement de produits à consommer dans nos frigos qu'au final, nous ne savons même plus quoi manger.
C'est là que Fridgie intervient. En effet, il vous permet de trouver une liste de recette en fonction des ingrédients que vous avez dans votre frigo.
Mais Fridgie est plus grand que ça ! Vous pouvez aussi par exemple créer un évenement qui tourne autour d'une recette, suivant ce principe,
les membres qui s'inscrivent à l'évenement peuvent vous notifier qu'ils apportent tel ou tel ingrédient, et réalisez, facilement,
un plat collaboratif !
<br><br> S3C - KRELL SPICK PERCIN SASSU
Gamepedia est un projet du semestre 4.
<br> AI2 - SASSU PERCIN VONDERSCHER LAURENT
</p>
</div>";
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment