forked from Achterfeld/MyWishList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
142 lines (93 loc) · 3.08 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as DB;
use wishlist\model\Liste;
use wishlist\model\Item;
$app = new \Slim\Slim ;
$str = '<head>
<meta charset="utf-8">
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./img/favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="/myWishList/style/style.css">
<title>My Wish List</title>
</head>';
echo $str;
$db = new DB();
$db->addConnection(parse_ini_file("src/conf/conf.ini"));
$db->setAsGlobal();
$db->bootEloquent();
echo('<div id="navBarre">
<div>Bonjour, bienvenue dans myWishList</div>
<div style="flex:1"></div>
<div><a href="./" >Se connecter</a></div>
<div><a href="./" >S\'inscrire</a></div>
</div>');
$app->get('/liste',function (){
echo "<h1>LISTE</h1>";
});
$app->get('/item/:id',function ($id){
echo "<h1>Item n° $id</h1>";
});
$app->get('/',function(){
$maxNo = Liste::max("no");
$maxNoItem = Item::max("id");
echo('
<div id = "formulaires">
<form action="test.php" method="get">
<h1>Affichage liste</h1>
<input type="number" placeholder="Numéro de la liste à afficher" min="1" max="' . $maxNo . '" name="liste"><br>
<input type="submit" value="Choisir sa liste"></input>
</form>
<form action="test.php" method="post">
<h1>Création liste</h1>
<input type="text" placeholder="Titre" name="titreNouvelleListe"><br>
<input type="text" placeholder="Description" name="descriptionNouvelleListe"><br>
<input type="text" placeholder="Titre" name="titreNouvelleListe"><br>
Limite de validité : <input type="date" name="dateLimiteNouvelleListe"><br>
<input type="submit" value="Ajouter une liste"></input>
</form>
<form action="test.php" method="post">
<h1>Ajout dans liste</h1>
<input type="number" placeholder="Liste dans laquelle ajouter" min="1" max="' . $maxNo . '" name="aAjouterDansListe"><br>
<input type="number" placeholder="Objet à ajouter" min="1" max="' . $maxNoItem . '" name="itemAAjouter"><br>
<input type="submit" value="Ajouter dans la liste"></input>
</form>
</div>
');
// Fonction de création d'un nouvel objet
/*
$i = new Item();
$i->nom = "test";
$i->liste_id = -1;
$i->save();
$i->liste_id = 1;
$i->save();
*/
$args = $_GET;
if (isset($args['liste'])) {
$listeDesc = Liste::where('no', '=', $args['liste'])->get()->first();
if (!is_null($listeDesc)) {
echo "<h1>Description de la liste " . $args['liste'] . " :</h1><br> " . $listeDesc;
}
}
if (isset($args['id'])) {
$it = Item::where('id', '=', $args['id'])->get()->first();
echo "<h1>L'item d'id " . $args['id'] . " est le suivant : </h1><br> " . $it;
}
//echo $args['val'];
echo "<br><br>";
echo "<h1>Liste des listes créées :</h1> <br> ";
$listes = Liste::get();
foreach ($listes as $liste) {
echo $liste . "<br><br>";
}
echo "<br>";
echo "<br>";
echo "<h1>Liste des items créés :</h1> <br> ";
$items = Item::get();
foreach ($items as $item) {
echo $item . "<br><br>";
}
});
$app->run();