diff --git a/module/news/changes.md b/module/news/changes.md deleted file mode 100644 index f09261d8..00000000 --- a/module/news/changes.md +++ /dev/null @@ -1,4 +0,0 @@ -# Version 4 - - Config : le nombre d'objet est fixe, constante dans news.php - - Ecran layout réservé à la configuration et au thème - - Bug avec l'initialisation, fichier css déclaré mais absent \ No newline at end of file diff --git a/module/news/news.php b/module/news/news.php index 1bb0ae6a..c2dbdabd 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -15,7 +15,7 @@ class news extends common { - const VERSION = '4.0'; + const VERSION = '3.7'; const REALNAME = 'News'; const DELETE = true; const UPDATE = '0.0'; @@ -23,8 +23,7 @@ class news extends common { public static $actions = [ 'add' => self::GROUP_MODERATOR, - 'config' => self::GROUP_MODERATOR, // Edition des news - 'layout' => self::GROUP_MODERATOR, // paramétrage des news + 'config' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR, 'edit' => self::GROUP_MODERATOR, 'index' => self::GROUP_VISITOR, @@ -89,8 +88,7 @@ class news extends common { // Signature de l'article public static $articleSignature = ''; - // Nombre d'articles dans la page de config: - public static $itemsperPage = 8; + /** * Flux RSS @@ -191,63 +189,10 @@ class news extends common { // Mise à jour des données de module $this->update(); - // Ids des news par ordre de publication - $newsIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); - // Pagination fixe - $pagination = helper::pagination($newsIds, $this->getUrl(),self::$itemsperPage ); - // Liste des pages - self::$pages = $pagination['pages']; - // News en fonction de la pagination - for($i = $pagination['first']; $i < $pagination['last']; $i++) { - // Met en forme le tableau - $dateOn = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true) - ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])) - : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))); - $dateOn .= ' à '; - $dateOn .= mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true) - ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])) - : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))); - if ($this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) { - $dateOff = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])), 'UTF-8', true) - ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) - : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff']))); - $dateOff .= ' à '; - $dateOff .= mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])), 'UTF-8', true) - ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) - : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff']))); - } else { - $dateOff = 'Permanent'; - } - self::$news[] = [ - $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'title']), - $dateOn, - $dateOff, - self::$states[$this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'state'])], - template::button('newsConfigEdit' . $newsIds[$i], [ - 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsIds[$i]. '/' . $_SESSION['csrf'], - 'value' => template::ico('pencil') - ]), - template::button('newsConfigDelete' . $newsIds[$i], [ - 'class' => 'newsConfigDelete buttonRed', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $newsIds[$i] . '/' . $_SESSION['csrf'], - 'value' => template::ico('cancel') - ]) - ]; - } - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Configuration du module', - 'view' => 'config', - 'vendor' => [ - 'tinycolorpicker' - ] - ]); - } - - public function layout() { // Soumission du formulaire if($this->isPost()) { + // Générer la feuille de CSS $style = '.newsFrame {'; $style .= 'border:' . $this->getInput('newsThemeBorderStyle',helper::FILTER_STRING_SHORT) . ' ' . $this->getInput('newsThemeBorderColor') . ' ' . $this->getInput('newsThemeBorderWidth',helper::FILTER_STRING_SHORT) . ';'; @@ -272,26 +217,69 @@ class news extends common { ]]); $this->setData(['module', $this->getUrl(0), 'config',[ - 'feeds' => $this->getInput('newsLayoutShowFeeds',helper::FILTER_BOOLEAN), - 'feedsLabel' => $this->getInput('newsLayoutFeedslabel',helper::FILTER_STRING_SHORT), - 'itemsperPage' => $this->getInput('newsLayoutItemsperPage', helper::FILTER_INT,true), - 'itemsperCol' => $this->getInput('newsLayoutItemsperCol', helper::FILTER_INT,true), - 'height' => $this->getInput('newsLayoutHeight', helper::FILTER_INT,true), + 'feeds' => $this->getInput('newsConfigShowFeeds',helper::FILTER_BOOLEAN), + 'feedsLabel' => $this->getInput('newsConfigFeedslabel',helper::FILTER_STRING_SHORT), + 'itemsperPage' => $this->getInput('newsConfigItemsperPage', helper::FILTER_INT,true), + 'itemsperCol' => $this->getInput('newsConfigItemsperCol', helper::FILTER_INT,true), + 'height' => $this->getInput('newsConfigHeight', helper::FILTER_INT,true), 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) ]]); // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/layout', + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', 'notification' => 'Modifications enregistrées', 'state' => true ]); } else { + // Ids des news par ordre de publication + $newsIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); + // Pagination + $pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0), 'config', 'itemsperPage']) ); + // Liste des pages + self::$pages = $pagination['pages']; + // News en fonction de la pagination + for($i = $pagination['first']; $i < $pagination['last']; $i++) { + // Met en forme le tableau + $dateOn = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true) + ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])) + : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))); + $dateOn .= ' à '; + $dateOn .= mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true) + ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])) + : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))); + if ($this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) { + $dateOff = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])), 'UTF-8', true) + ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) + : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff']))); + $dateOff .= ' à '; + $dateOff .= mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])), 'UTF-8', true) + ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) + : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff']))); + } else { + $dateOff = 'Permanent'; + } + self::$news[] = [ + $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'title']), + $dateOn, + $dateOff, + self::$states[$this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'state'])], + template::button('newsConfigEdit' . $newsIds[$i], [ + 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsIds[$i]. '/' . $_SESSION['csrf'], + 'value' => template::ico('pencil') + ]), + template::button('newsConfigDelete' . $newsIds[$i], [ + 'class' => 'newsConfigDelete buttonRed', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $newsIds[$i] . '/' . $_SESSION['csrf'], + 'value' => template::ico('cancel') + ]) + ]; + } // Valeurs en sortie $this->addOutput([ - 'title' => 'Mise en page', - 'view' => 'layout', + 'title' => 'Configuration du module', + 'view' => 'config', 'vendor' => [ 'tinycolorpicker' ] @@ -447,7 +435,8 @@ class news extends common { $newsIds[] = $newsId; } } - // Pagination selon le layout + // 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']); diff --git a/module/news/view/config/config.php b/module/news/view/config/config.php index 70b14434..873c9a66 100644 --- a/module/news/view/config/config.php +++ b/module/news/view/config/config.php @@ -16,14 +16,87 @@ ]); ?>
- helper::baseUrl() . $this->getUrl(0) . '/layout', - 'ico' => 'puzzle', - 'value' => 'Mise en page' - ]); ?> + +
+ +
+
+
+

Paramètres du module

+
+
+ $this->getData(['module', $this->getUrl(0), 'config', 'feeds']), + 'help' => 'Flux limité aux articles de la première page.' + ]); ?> +
+
+ 'Etiquette RSS', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) + ]); ?> +
+
+
+
+ 'Nombre de colonnes', + 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']) + ]); ?> +
+
+ 'Articles par page', + 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']) + ]); ?> +
+
+ 'Abrégé de l\'article', + 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'height']) + ]); ?> +
+
+
+
+
+
+
+
+

Thème du module

+
+
+ 'Bordure', + 'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderStyle']) + ]); ?> +
+
+ 'Epaisseur', + 'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderWidth']) + ]); ?> +
+
+ 'colorPicker', + 'help' => 'Couleur visible en l\'absence d\'une image.
Le curseur horizontal règle le niveau de transparence.', + 'label' => 'Couleur de la bordure', + 'value' => $this->getData(['module', $this->getUrl(0),'theme', 'borderColor']) + ]); ?> +
+
+ 'colorPicker', + 'help' => 'Couleur visible en l\'absence d\'une image.
Le curseur horizontal règle le niveau de transparence.', + 'label' => 'Couleur du fond', + 'value' => $this->getData(['module', $this->getUrl(0),'theme', 'backgroundColor']) + ]); ?> +
+
+
- diff --git a/module/news/view/layout/layout.css b/module/news/view/layout/layout.css deleted file mode 100644 index 52709ea6..00000000 --- a/module/news/view/layout/layout.css +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file is part of Zwii. - * - * For full copyright and license information, please see the LICENSE - * file that was distributed with this source code. - * - * @author Rémi Jean - * @copyright Copyright (C) 2008-2018, Rémi Jean - * @author Frédéric Tempez - * @copyright Copyright (C) 2018-2022, Frédéric Tempez - * @license GNU General Public License, version 3 - * @link http://zwiicms.fr/ - */ - - -/** NE PAS EFFACER -* admin.css -*/ \ No newline at end of file diff --git a/module/news/view/layout/layout.php b/module/news/view/layout/layout.php deleted file mode 100644 index 06499a15..00000000 --- a/module/news/view/layout/layout.php +++ /dev/null @@ -1,93 +0,0 @@ - -
-
- 'buttonGrey', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'ico' => 'left', - 'value' => 'Retour' - ]); ?> -
-
- -
-
-
-
-
-

Paramètres du module

-
-
- $this->getData(['module', $this->getUrl(0), 'config', 'feeds']), - 'help' => 'Flux limité aux articles de la première page.' - ]); ?> -
-
- 'Etiquette RSS', - 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) - ]); ?> -
-
-
-
- 'Nombre de colonnes', - 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']) - ]); ?> -
-
- 'Articles par page', - 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']) - ]); ?> -
-
- 'Abrégé de l\'article', - 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'height']) - ]); ?> -
-
-
-
-
-
-
-
-

Thème du module

-
-
- 'Bordure', - 'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderStyle']) - ]); ?> -
-
- 'Epaisseur', - 'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderWidth']) - ]); ?> -
-
- 'colorPicker', - 'help' => 'Couleur visible en l\'absence d\'une image.
Le curseur horizontal règle le niveau de transparence.', - 'label' => 'Couleur de la bordure', - 'value' => $this->getData(['module', $this->getUrl(0),'theme', 'borderColor']) - ]); ?> -
-
- 'colorPicker', - 'help' => 'Couleur visible en l\'absence d\'une image.
Le curseur horizontal règle le niveau de transparence.', - 'label' => 'Couleur du fond', - 'value' => $this->getData(['module', $this->getUrl(0),'theme', 'backgroundColor']) - ]); ?> -
-
-
-
-
- \ No newline at end of file