Ver código fonte

Use a single file to render every list

LaurentTreguier 9 anos atrás
pai
commit
8ab2dec613

+ 1
- 1
controllers/data.php Ver arquivo

@@ -7,7 +7,7 @@ function data()
7 7
     set("title", "Titre");
8 8
     set("data", Data::getAll());
9 9
     
10
-    return html("data.html.php", "layout.html.php");
10
+    return html("list.html.php", "layout.html.php");
11 11
 }
12 12
 
13 13
 function data_extract()

+ 11
- 3
controllers/files.php Ver arquivo

@@ -1,15 +1,23 @@
1 1
 <?php
2 2
 
3
+require_once(dirname(__DIR__)."/models/file.class.php");
4
+
3 5
 function files()
4 6
 {
5 7
     set("title", "Titre");
8
+    set("data", File::getAll());
6 9
     
7
-    return html("files.html.php", "layout.html.php");
10
+    return html("list.html.php", "layout.html.php");
8 11
 }
9 12
 
10 13
 function add_file()
11 14
 {
12
-    // TODO
15
+    $options = [];
16
+    
17
+    foreach(["rang", "promo", "libelle"] as $field)
18
+        $options[$field] = $_POST[$field];
19
+    
20
+    File::addDocument($_FILES["document"], $options);
13 21
 }
14 22
 
15 23
 function alter_file()
@@ -19,5 +27,5 @@ function alter_file()
19 27
 
20 28
 function delete_file()
21 29
 {
22
-    // TODO
30
+    (new File($_POST["id"]))->erase();
23 31
 }

+ 4
- 9
controllers/login.php Ver arquivo

@@ -16,14 +16,9 @@ function check_login()
16 16
     $identifiers = getAdminIdentifiers();
17 17
     
18 18
     if($_POST["login"] != $identifiers[0] || $_POST["password"] != $identifiers[1])
19
-    {
20
-        set("title", "Erreur");
21
-        set("error", true);
22
-    } else
23
-    {
24
-        set("title", "Accueil");
25
-        set("error", false);
26
-    }
19
+        return login();
27 20
     
28
-    return html("login.html.php", "layout.html.php");
21
+    set("title", "Home");
22
+    
23
+    return html("home.html.php", "layout.html.php");
29 24
 }

+ 4
- 1
controllers/promo.php Ver arquivo

@@ -1,10 +1,13 @@
1 1
 <?php
2 2
 
3
+require_once(dirname(__DIR__)."/models/promo.class.php");
4
+
3 5
 function promo()
4 6
 {
5 7
     set("title", "Titre");
8
+    set("data", Promo::getAll());
6 9
     
7
-    return html("promo.html.php", "layout.html.php");
10
+    return html("list.html.php", "layout.html.php");
8 11
 }
9 12
 
10 13
 function add_promo()

+ 13
- 0
views/data.html.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<ul>
2
+    <?php
3
+        foreach($data as $student)
4
+        {
5
+            echo "<li><ul>";
6
+            
7
+            foreach($student as $field => $value)
8
+                echo "<li>".$field." : ".$value."</li>";
9
+            
10
+            echo "</li></ul>";
11
+        }
12
+    ?>
13
+</ul>

+ 0
- 0
views/files.html.php Ver arquivo


+ 1
- 0
views/home.html.php Ver arquivo

@@ -0,0 +1 @@
1
+<p>Home sweet home</p>

+ 13
- 0
views/list.html.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<ul>
2
+    <?php
3
+        foreach($data as $item)
4
+        {
5
+            echo "<li><ul>";
6
+            
7
+            foreach($item as $field => $value)
8
+                echo "<li>".$field." : ".$value."</li>";
9
+            
10
+            echo "</li></ul>";
11
+        }
12
+    ?>
13
+</ul>

+ 0
- 0
views/promo.html.php Ver arquivo