diff --git a/module/news/news.php b/module/news/news.php index 2e4aa1be..cd4eeabd 100755 --- a/module/news/news.php +++ b/module/news/news.php @@ -66,6 +66,9 @@ class news extends common { '400px' => 'Grand' ]; + // Signature de l'article + public static $articleSignature = ''; + /** * Mise à jour du module @@ -331,35 +334,63 @@ class news extends common { * Accueil */ public function index() { - // Mise à jour + // Mise à jour des données de module $this->update(); - // Ids des news par ordre de publication - $newsIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); - $newsIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); - $newsIds = []; - foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) { - if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) { - $newsIds[] = $newsId; + // Affichage d'un article + if( + $this->getUrl(1) + // Protection pour la pagination, un ID ne peut pas être un entier, une page oui + AND intval($this->getUrl(1)) === 0 + ) { + // L'article n'existe pas + if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); } + // L'article existe + else { + self::$articleSignature = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'userId'])); + // Valeurs en sortie + $this->addOutput([ + 'showBarEditButton' => true, + 'title' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']), + 'view' => 'article' + ]); + + } + } else { + // Affichage index + // Ids des news par ordre de publication + $newsIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); + $newsIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); + $newsIds = []; + foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) { + if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) { + $newsIds[] = $newsId; + } + } + // Pagination + //$pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['config','itemsperPage'])); + $pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])); + // Nombre de colonnes + self::$nbrCol = $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']); + // Liste des pages + self::$pages = $pagination['pages']; + // News en fonction de la pagination + for($i = $pagination['first']; $i < $pagination['last']; $i++) { + self::$news[$newsIds[$i]] = $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i]]); + self::$news[$newsIds[$i]]['userId'] = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'userId'])); + } + // Valeurs en sortie + $this->addOutput([ + 'showBarEditButton' => true, + 'showPageContent' => true, + 'view' => 'index' + ]); + } - // Pagination - //$pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['config','itemsperPage'])); - $pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])); - // Nombre de colonnes - self::$nbrCol = $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']); - // Liste des pages - self::$pages = $pagination['pages']; - // News en fonction de la pagination - for($i = $pagination['first']; $i < $pagination['last']; $i++) { - self::$news[$newsIds[$i]] = $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i]]); - self::$news[$newsIds[$i]]['userId'] = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'userId'])); - } - // Valeurs en sortie - $this->addOutput([ - 'showBarEditButton' => true, - 'showPageContent' => true, - 'view' => 'index' - ]); } /** diff --git a/module/news/view/article/article.css b/module/news/view/article/article.css new file mode 100644 index 00000000..604e6d6f --- /dev/null +++ b/module/news/view/article/article.css @@ -0,0 +1,20 @@ + +/** +* @author Frédéric Tempez +* @copyright Copyright (C) 2018-2021, Frédéric Tempez +* @license GNU General Public License, version 3 +* @link http://zwiicms.fr/ +*/ + +/* +* Module news +*/ + +#rssFeed { + text-align: right; + float: right; +} +#rssFeed p { + display: inline; + vertical-align: top; +} diff --git a/module/news/view/article/article.php b/module/news/view/article/article.php new file mode 100644 index 00000000..075c52e3 --- /dev/null +++ b/module/news/view/article/article.php @@ -0,0 +1,43 @@ +
+
+ getData(['module', $this->getUrl(0),'posts', $this->getUrl(1), 'content']); ?> +
+
+
+
+ + + + getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true) + ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])) + : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))); + $heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true) + ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])) + : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))); + echo $date . ' à ' . $heure; + ?> + + getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + AND + ( // Propriétaire + ( $this->getUser('group') === self::GROUP_ADMIN ) + ) + ): ?> + + Editer + + + + getData(['module',$this->getUrl(0), 'config', 'feeds'])): ?> + + +
+
\ No newline at end of file diff --git a/module/news/view/index/index.css b/module/news/view/index/index.css index 57c80b1f..7b0a2fb9 100755 --- a/module/news/view/index/index.css +++ b/module/news/view/index/index.css @@ -31,13 +31,8 @@ margin: -10px; height: 20%; width: 110%; - -webkit-filter: blur(5px); - -moz-filter: blur(5px); - -o-filter: blur(5px); - -ms-filter: blur(5px); - filter: blur(5px); - - background-color: rgba(253, 254, 255, 0.90); + backdrop-filter: blur(1px); + -webkit-backdrop-filter: blur(1px); } diff --git a/module/news/view/index/index.php b/module/news/view/index/index.php index 31d2821f..9a22558b 100755 --- a/module/news/view/index/index.php +++ b/module/news/view/index/index.php @@ -3,7 +3,7 @@ $news): ?>

- + getUrl(0) . '/' . $newsId . '">' . $news['title'] . ''; ?>