From 9a552c6b751f25bac9e816cf605fb972da8b9e27 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 3 Sep 2021 01:16:43 +0200 Subject: albums2 --- controller/admin.php | 42 ++++++++++++++++++++++++++++++------------ controller/visitor.php | 49 ++++++++++++++++++++++++++++++------------------- index.php | 6 ++++++ model/Classes.php | 4 ++++ public/accueil.css | 5 +++-- public/discographie.css | 37 ++++++++++++++++++++++++++++--------- view/album.php | 35 +++++++++++++++++++++++++++++++++++ view/discographie.php | 19 +++++++++++++++++-- view/melaine.php | 1 - view/nav.php | 2 +- 10 files changed, 154 insertions(+), 46 deletions(-) create mode 100644 view/album.php diff --git a/controller/admin.php b/controller/admin.php index 2588d36..3c2b613 100644 --- a/controller/admin.php +++ b/controller/admin.php @@ -98,7 +98,7 @@ function discoEdit($numArticle, $suppression) } } - $albums = array_reverse($Album->readAll()); // lourd + $albumsJSON = array_reverse($Album->readAll()); // lourd // $albums contient un tableau de chaines JSON, // on extrait de chacune 3 variables: titre, année, pochette @@ -113,25 +113,43 @@ function discoEdit($numArticle, $suppression) // changer les chaines JSON en tableaux $i = 0; - foreach($albums as $oneAlbum) + foreach($albumsJSON as $oneAlbum) { - $albums[$i] = json_decode($oneAlbum, true); + $albumsJSON[$i] = json_decode($oneAlbum, true); $i++; } + // on passe maintenant au contenu HTML + $albumNamesJSON = array_reverse($Album->getFileNames()); + $Album->setFormat('html'); + $Album->makeFileList(); + $albumNamesHTML = array_reverse($Album->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 - $titreAlbum = 'discographie'; - if(false) - { - $lienAlbum = $titreAlbum; - } - else + $i = 0; + $avecLien = []; + foreach($albumNamesJSON as $oneAlbum) { - $lienAlbum = 'discographie#' . $titreAlbum; + // nom sans extension + $chemin = pathinfo($oneAlbum); + $nomJSONsansExt = $chemin['filename']; + $chemin = pathinfo($albumNamesHTML[0]); + + // détection + if(file_exists($chemin['dirname'] . '/' . $nomJSONsansExt . '.html')) + { + $lienAlbum[$i] = 'album&album_code=' . $nomJSONsansExt . '&album_name=' . $albumsJSON[$i][0]; + $avecLien[$i] = true; + } + else + { + $lienAlbum[$i] = 'discographie#' . $albumsJSON[$i][0]; + $avecLien[$i] = false; + } + $i++; } - //echo($lienAlbum); // morceaux en HTML à assembler // variable $editeurHTML, contient $texte 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() {} diff --git a/index.php b/index.php index b9989fd..d8e0a58 100644 --- a/index.php +++ b/index.php @@ -202,6 +202,12 @@ if(isset($_GET['page'])) discoVisitor(); } } + // page d'un album de la discographie + elseif($_GET['page'] == 'album') + { + album($_GET['album_code'], $_GET['album_name']); + // page visiteur uniquement + } // page connexion elseif($_GET['page'] == 'connexion') { diff --git a/model/Classes.php b/model/Classes.php index 1349cd7..1846ce3 100644 --- a/model/Classes.php +++ b/model/Classes.php @@ -119,6 +119,10 @@ class OneArticle extends AllArticles { return(file_get_contents($this->fileName)); } + public static function readOneAlbum($albumCode) + { + return(file_get_contents('data/discographie/html/' . $albumCode . '.html')); + } // pour afficher des dates /*public function getDate($fileNumber) diff --git a/public/accueil.css b/public/accueil.css index 7f33393..dc79083 100644 --- a/public/accueil.css +++ b/public/accueil.css @@ -37,7 +37,8 @@ nav background-color: white; } -ul +/* agir sur ul et li directement affecte le ckeditor */ +#ul_menu { margin: 0px; padding: 5px; @@ -46,7 +47,7 @@ ul justify-content: center; } -li +#ul_menu li { list-style-type: none; white-space: nowrap; diff --git a/public/discographie.css b/public/discographie.css index cb0c9b5..adf5ac0 100644 --- a/public/discographie.css +++ b/public/discographie.css @@ -103,10 +103,6 @@ figure margin: 0px; display: inline-block; } -figure:hover -{ - border: 2px blue solid; -} figcaption { @@ -119,21 +115,26 @@ figcaption a { - display: inline-block; + /*border: 2px white solid;*/ } -/*article a:hover +article a:hover { border: 2px blue solid; -}*/ - +} a:hover figure figcaption { text-decoration: underline; } +/* page dédiée à un album */ +#albumHTML +{ + width: 100%; +} + @media screen and (min-width: 700px) { #titre @@ -148,6 +149,12 @@ a:hover figure figcaption position: relative; bottom: 35px; } + + #albumHTML + { + /* annuler le positionnement du contenu */ + margin-top: 55px; + } } @media screen and (max-width: 699px) @@ -165,6 +172,12 @@ a:hover figure figcaption position: relative; bottom: 24px; } + + #albumHTML + { + /* annuler le positionnement du contenu */ + margin-top: 42px; + } } @media screen and (max-width: 479px) @@ -201,7 +214,13 @@ a:hover figure figcaption #contenu { - position: relative; + /*position: relative;*/ bottom: 15px; } + + #albumHTML + { + /* annuler le positionnement du contenu */ + margin-top: 32px; + } } diff --git a/view/album.php b/view/album.php new file mode 100644 index 0000000..39d180a --- /dev/null +++ b/view/album.php @@ -0,0 +1,35 @@ + + + + +
+
+ +
+
+
+ +
+ +
+ +

Retour à la discographie

+ -

()

+

:

+ + + +

+
+
Modifier l'article " . $j . "

"); echo("

Modification d'un article

"); echo "\n"; diff --git a/view/nav.php b/view/nav.php index f7cb299..80d73b9 100644 --- a/view/nav.php +++ b/view/nav.php @@ -1,5 +1,5 @@