From 9a552c6b751f25bac9e816cf605fb972da8b9e27 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 3 Sep 2021 01:16:43 +0200 Subject: albums2 --- controller/visitor.php | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'controller/visitor.php') diff --git a/controller/visitor.php b/controller/visitor.php index 936eb35..239c139 100644 --- a/controller/visitor.php +++ b/controller/visitor.php @@ -49,9 +49,9 @@ function discoVisitor() $title = "Discographie"; // modèle - $Albums = new Album($page_actuelle); - $Albums->makeFileList(); - $albumsJSON = array_reverse($Albums->readAll()); // lourd + $AllAlbums = new Album($page_actuelle); + $AllAlbums->makeFileList(); + $albumsJSON = array_reverse($AllAlbums->readAll()); // lourd // $albums est un tableau de chaines JSON, // chacune renferme 3 variables: titre, année, pochette @@ -65,39 +65,36 @@ function discoVisitor() } // on passe maintenant au contenu HTML - $albumNamesJSON = array_reverse($Albums->getFileNames()); - $Albums->setFormat('html'); - $Albums->makeFileList(); - $albumNamesHTML = array_reverse($Albums->getFileNames()); + $albumNamesJSON = array_reverse($AllAlbums->getFileNames()); + $AllAlbums->setFormat('html'); + $AllAlbums->makeFileList(); + $albumNamesHTML = array_reverse($AllAlbums->getFileNames()); + // lien vers le HTML ou ancre? // pour chaque album, détecter le fichier html - // si il y en a un, proposer un lien // si non, ne fournir qu'un lien d'ancre pour la liste d'album $i = 0; - //print_r($albumNamesJSON); exit(); - + $avecLien = []; foreach($albumNamesJSON as $oneAlbum) { + // nom sans extension $chemin = pathinfo($oneAlbum); $nomJSONsansExt = $chemin['filename']; $chemin = pathinfo($albumNamesHTML[0]); - $nomHTMLsansExt = $chemin['filename']; - // détecter un fichier du même nom - if(isset($nomJSONsansExt . '.html')) // c'est pas ça!! + // détection + if(file_exists($chemin['dirname'] . '/' . $nomJSONsansExt . '.html')) { - //$lienAlbum[$i] = $titreAlbum; + $lienAlbum[$i] = 'album&album_code=' . $nomJSONsansExt . '&album_name=' . $albumsJSON[$i][0]; + $avecLien[$i] = true; } else { - //$lienAlbum[$i] = 'discographie#' . $oneAlbum[0]; + $lienAlbum[$i] = 'discographie#' . $albumsJSON[$i][0]; + $avecLien[$i] = false; } $i++; } - //exit(); - - - //echo($lienAlbum); // variables $css, $js et $content require('view/discographie.php'); @@ -105,6 +102,20 @@ function discoVisitor() require('view/template.php'); } +function album($albumCode, $albumName) +{ + $page_actuelle = 'discographie'; + $title = $albumName; + + //$Album = new OneArticle ($page_actuelle); + $album = OneArticle::readOneAlbum($albumCode); + + // variables $css, $header et $content + require('view/album.php'); + // HTML + require('view/template.php'); +} + function presse() {} -- cgit v1.2.3