From 76c8669f09f1b18316e27700c8a37367bb8c2d01 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Thu, 22 Jul 2021 23:11:55 +0200 Subject: [PATCH] Initialisation --- module/news/news.php | 69 +++++++++++++++++------------- module/news/view/config/config.php | 17 +++----- module/news/view/index/index.css | 11 +---- module/news/view/index/index.php | 5 ++- 4 files changed, 50 insertions(+), 52 deletions(-) mode change 100644 => 100755 module/news/news.php mode change 100644 => 100755 module/news/view/config/config.php diff --git a/module/news/news.php b/module/news/news.php old mode 100644 new mode 100755 index d96b6657..1da41d94 --- a/module/news/news.php +++ b/module/news/news.php @@ -15,8 +15,8 @@ class news extends common { - const VERSION = '3.3'; - const REALNAME = 'Actualités'; + const VERSION = '3.4'; + const REALNAME = 'News'; const DELETE = true; const UPDATE = '0.0'; const DATADIRECTORY = self::DATA_DIR . 'news/'; @@ -60,18 +60,11 @@ class news extends common { ]; public static $nbrCol = 1; - public static $itemsHeight = [ - '200px' => 'Petite', - '300px' => 'Moyenne', - '400px' => 'Grande', - 'auto' => 'Article complet' - ]; - - public static $itemsBlur = [ - '0%' => 'Aucun', - '15%' => 'Faible', - '30%' => 'Modéré', - '45%' => 'Important', + public static $height = [ + 200 => 'Petite', + 400 => 'Moyenne', + 600 => 'Grande', + 1000 => 'Article complet' ]; // Signature de l'article @@ -184,12 +177,12 @@ class news extends common { if($this->isPost()) { // Générer la feuille de CSS - $style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}'; - if ($this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) !== '100%') { - $style .= '.newsBlur {height: ' . $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) . ';}'; + //$style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}'; + //if ($this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) !== '100%') { + // $style = '.newsBlur {height: ' . $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) . ';}'; //$style .= '.newsBlur {background: linear-gradient(' . $this->getData(['theme', 'text', 'textColor']) . ' ' . $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) . ',rgba(255,255,255,0) );'; //$style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}'; - } + //} // Dossier de l'instance if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) { @@ -202,8 +195,8 @@ class news extends common { $this->setData(['module', $this->getUrl(0), 'theme',[ 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '', - 'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT), - 'itemsBlur' => $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) + //'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT), + //'itemsBlur' => $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) ]]); $this->setData(['module', $this->getUrl(0), 'config',[ @@ -211,6 +204,7 @@ class news extends common { '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 @@ -432,7 +426,13 @@ class news extends common { // 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'])); + // Longueur de la news affichée + if ($this->getData(['module', $this->getUrl(0), 'config', 'height']) !== 1000) { + self::$news[$newsIds[$i]]['content'] = substr($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'content']), 0, + $this->getData(['module', $this->getUrl(0), 'config', 'height'])) ; + } + // Mise en forme de la signature + self::$news[$newsIds[$i]]['userId'] = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'userId'])); } // Valeurs en sortie $this->addOutput([ @@ -504,6 +504,16 @@ class news extends common { // Mettre à jour la version $this->setData(['module',$this->getUrl(0),'config', 'versionData', '3.3' ]); } + // Mise à jour 3.4 + if (version_compare($versionData, '3.4', '<') ) { + $this->deleteData(['module',$this->getUrl(0),'theme']); + unlink(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css'); + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + $this->removeDir(self::DATADIRECTORY . $this->getUrl(0)); + } + // Mettre à jour la version + $this->setData(['module',$this->getUrl(0),'config', 'versionData', '3.4' ]); + } } /** @@ -524,21 +534,22 @@ class news extends common { } // Dossier de l'instance - if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { - mkdir (self::DATADIRECTORY . $this->getUrl(0) , 0777, true); - } + //if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + // mkdir (self::DATADIRECTORY . $this->getUrl(0) , 0777, true); + //} // Check la présence de la feuille de style - if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) { + //if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) { // Générer la feuille de CSS - $style = '.newsContent {height: ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'itemsHeight' ]) .';}'; + // Supprimé dans 3.4 + // $style = '.newsContent {height: ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'itemsHeight' ]) .';}'; // Pas d'effet flou à l'initialisation //$style .= '.newsBlur {background: linear-gradient(' . $this->getData(['theme', 'text', 'textColor']) . ' ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'itemsBlur' ]) . ',rgba(255,255,255,0) );'; //$style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}'; // Sauver la feuille de style - file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $style ); + //file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $style ); // Stocker le nom de la feuille de style - $this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']); - } + //$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']); + //} } } diff --git a/module/news/view/config/config.php b/module/news/view/config/config.php old mode 100644 new mode 100755 index 8dff68ee..f274d8b1 --- a/module/news/view/config/config.php +++ b/module/news/view/config/config.php @@ -38,33 +38,26 @@
-
+
'Pagination', 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']), 'help' => 'Nombre de colonnes par page' ]); ?>
-
+
'Articles par page', 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']) ]); ?>
-
- + 'Hauteur', - 'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'itemsHeight']), + 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'height']), 'help' => 'Limite la hauteur de l\'article, cette option est utile lorsque la pagination en colonnes est activée.' ]); ?>
-
- 'Effet flou', - 'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'itemsBlur']), - 'help' => 'Effet appliqué en bas de l\'article afin d\'éviter une coupure brutale quand la hauteur de l\'article n\'est pas définie sur Article Complet' - ]); ?> -
diff --git a/module/news/view/index/index.css b/module/news/view/index/index.css index cea8c936..51577d9a 100755 --- a/module/news/view/index/index.css +++ b/module/news/view/index/index.css @@ -29,17 +29,10 @@ margin-bottom: 30px; } -.newsBlur { - width: 100%; - height: 50%; - position: absolute; - bottom: 0; - left: -20px; - z-index: 10; - backdrop-filter: blur(1px); +.newsSuite { + font-style: italic; } - .newsSignature { margin-right: 10px; float: right; diff --git a/module/news/view/index/index.php b/module/news/view/index/index.php index 4a09c865..86b26904 100644 --- a/module/news/view/index/index.php +++ b/module/news/view/index/index.php @@ -7,8 +7,9 @@
-
-
+ getData(['module', $this->getUrl(0), 'config', 'height']) !== 1000):?> + getUrl(0) . '/' . $newsId . '">lire la suite'; ?> +