summaryrefslogtreecommitdiff
path: root/controller/visitor.php
diff options
context:
space:
mode:
Diffstat (limited to 'controller/visitor.php')
-rw-r--r--controller/visitor.php55
1 files changed, 20 insertions, 35 deletions
diff --git a/controller/visitor.php b/controller/visitor.php
index 0e79ee2..6c6146b 100644
--- a/controller/visitor.php
+++ b/controller/visitor.php
@@ -1,7 +1,7 @@
1<?php 1<?php
2// controller/visitor.php 2// controller/visitor.php
3// 3//
4// simple affichage du site au visiteur 4// affichage du site en lecture seul (visiteur ou admin)
5 5
6// pages du sites 6// pages du sites
7function accueil() 7function accueil()
@@ -50,63 +50,48 @@ function discoVisitor()
50 $title = "Discographie"; 50 $title = "Discographie";
51 51
52 // modèle 52 // modèle
53 $AllAlbums = new Album($page_actuelle); 53 $Albums = new Album($page_actuelle);
54 $AllAlbums->makeFileList(); 54 $Albums->makeFileList();
55 55
56 // contenu de tous les fichiers JSON (= tableau de chaines) 56 // contenu de tous les fichiers JSON (= tableau de chaines)
57 $albumsJSON = array_reverse($AllAlbums->readAll()); 57 $albumsJSON = $Albums->readAll();
58 // noms des fichiers JSON 58 // noms des fichiers JSON
59 $albumNamesJSON = $AllAlbums->fileList; 59 $albumNamesJSON = $Albums->fileList;
60 60
61 // changer les chaines JSON en tableaux: titre, année, pochette 61 $annees = [];
62 $i = 0; 62 for($i = 0; $i < count($albumsJSON); $i++)
63 $annees = array();
64 foreach($albumsJSON as $oneAlbum)
65 { 63 {
66 $albumsJSON[$i] = json_decode($oneAlbum, true); 64 // une case supplémentaire contient le "albumCode"
67 $annees[$i] = $albumsJSON[$i][1]; 65 $albumsJSON[$i][3] = pathinfo($albumNamesJSON[$i])['filename'];
68 66
69 // ajout des noms des fichiers JSON 67 $annees[$i] = $albumsJSON[$i][1];
70 $albumsJSON[$i][3] = $albumNamesJSON[$i];
71
72 $i++;
73 } 68 }
69
74 // tri d'un tableau multidimensionnel 70 // tri d'un tableau multidimensionnel
75 array_multisort($annees, $albumsJSON); 71 array_multisort($annees, $albumsJSON);
76 72
77 // on passe maintenant au contenu HTML
78 $AllAlbums->format = 'html';
79 $AllAlbums->makeFileList();
80 $albumNamesHTML = $AllAlbums->fileList;
81
82 // lien vers le HTML ou ancre? 73 // lien vers le HTML ou ancre?
83 // pour chaque album, détecter le fichier html 74 $lienAlbum = [];
84 // si non, ne fournir qu'un lien d'ancre pour la liste d'album
85 $i = 0;
86 $avecLien = []; 75 $avecLien = [];
87 $linkDiscoChrono = []; 76 $linkDiscoChrono = [];
88 foreach($albumsJSON as $oneAlbum) 77 for($i = 0; $i < count($albumsJSON); $i++)
89 { 78 {
90 // nom sans extension 79 // cas particulier où le dossier "html" est vide
91 $chemin = pathinfo($oneAlbum[3]); 80 if(!empty($Albums->fileList))
92 $nomJSONsansExt = $chemin['filename'];
93
94 // au cas où la discographie ne contient aucun html
95 if(!empty($albumNamesHTML))
96 { 81 {
97 if(file_exists('data/discographie/html/' . $nomJSONsansExt . '.html')) 82 if(file_exists('data/discographie/html/' . $albumsJSON[$i][3] . '.html'))
98 { 83 {
99 $lienAlbum[$i] = 'album&album_code=' . $nomJSONsansExt . '&album_name=' . $albumsJSON[$i][0]; 84 $lienAlbum[$i] = 'page=album&album_name=' . $albumsJSON[$i][0] . '&album_code=' . $albumsJSON[$i][3];
100 $avecLien[$i] = true; 85 $avecLien[$i] = true;
101 $linkDiscoChrono[$i] = 'linkChrono'; // css 86 $linkDiscoChrono[$i] = 'linkChrono'; // css
102 } 87 }
103 else 88 else
104 { 89 {
105 $lienAlbum[$i] = 'discographie#' . $albumsJSON[$i][0]; 90 $lienAlbum[$i] = 'page=discographie#' . $albumsJSON[$i][0];
106 $avecLien[$i] = false; 91 $avecLien[$i] = false;
107 $linkDiscoChrono[$i] = 'noLinkChrono'; // css 92 $linkDiscoChrono[$i] = 'noLinkChrono'; // css
108 } 93 }
109 $i++; 94 $lienBoutonModif[$i] = 'page=discographie&action=edition&album_code=' . $albumsJSON[$i][3];
110 } 95 }
111 } 96 }
112 97
@@ -122,7 +107,7 @@ function album($albumCode, $albumName)
122 $page_actuelle = 'discographie'; 107 $page_actuelle = 'discographie';
123 $title = $albumName; 108 $title = $albumName;
124 109
125 $album = Album::readOneAlbum($albumCode); // simple, efficace 110 $album = Album::readOneHTML($albumCode); // simple, efficace
126 111
127 // variables $css, $header et $content 112 // variables $css, $header et $content
128 require('view/album.php'); 113 require('view/album.php');