Browse Source

Use a single file to render every list

LaurentTreguier 9 years ago
parent
commit
8ab2dec613

+ 1
- 1
controllers/data.php View File

7
     set("title", "Titre");
7
     set("title", "Titre");
8
     set("data", Data::getAll());
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
 function data_extract()
13
 function data_extract()

+ 11
- 3
controllers/files.php View File

1
 <?php
1
 <?php
2
 
2
 
3
+require_once(dirname(__DIR__)."/models/file.class.php");
4
+
3
 function files()
5
 function files()
4
 {
6
 {
5
     set("title", "Titre");
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
 function add_file()
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
 function alter_file()
23
 function alter_file()
19
 
27
 
20
 function delete_file()
28
 function delete_file()
21
 {
29
 {
22
-    // TODO
30
+    (new File($_POST["id"]))->erase();
23
 }
31
 }

+ 4
- 9
controllers/login.php View File

16
     $identifiers = getAdminIdentifiers();
16
     $identifiers = getAdminIdentifiers();
17
     
17
     
18
     if($_POST["login"] != $identifiers[0] || $_POST["password"] != $identifiers[1])
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 View File

1
 <?php
1
 <?php
2
 
2
 
3
+require_once(dirname(__DIR__)."/models/promo.class.php");
4
+
3
 function promo()
5
 function promo()
4
 {
6
 {
5
     set("title", "Titre");
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
 function add_promo()
13
 function add_promo()

+ 13
- 0
views/data.html.php View File

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 View File


+ 1
- 0
views/home.html.php View File

1
+<p>Home sweet home</p>

+ 13
- 0
views/list.html.php View File

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 View File