From 5644caa0c0e9e800eb11718804000281f1f413b8 Mon Sep 17 00:00:00 2001 From: Deltacms Date: Tue, 27 Dec 2022 18:36:50 +0100 Subject: [PATCH] module News --- CHANGES.md | 1 + module/news/lang/en/lex_news.php | 14 +++--- module/news/lang/fr/lex_news.php | 12 ++--- module/news/news.php | 70 +++++++++++++++--------------- module/news/view/config/config.php | 12 +++-- 5 files changed, 60 insertions(+), 49 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7db88a9..9fd812c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - Modifications : - Thème / bannière : nouvelle option : une bannière animée avec Swiper, - Configuration / connexion : nouvelle option permettant de dévoiler le mot de passe, + - Module News : amélioration de l'affichage de l'aperçu - Corrections : - Theme / footer : sélection du template sur une colonne et différents aperçus. diff --git a/module/news/lang/en/lex_news.php b/module/news/lang/en/lex_news.php index 75a7ff6..b486905 100644 --- a/module/news/lang/en/lex_news.php +++ b/module/news/lang/en/lex_news.php @@ -22,17 +22,19 @@ $text['news_view']['config'][19] = 'State'; $text['news_view']['config'][20] = 'No news'; $text['news_view']['config'][21] = 'Version no.'; $text['news_view']['config'][22] = 'Rounding of corners'; -$text['news_view']['config'][23] = 'Shadow on edges'; +$text['news_view']['config'][23] = 'Shadow on edges'; $text['news_view']['config'][24] = 'Hide news titles'; $text['news_view']['config'][25] = 'Hidden titles'; $text['news_view']['config'][26] = 'Same height'; $text['news_view']['config'][27] = 'Columns in the same row will have the same height'; $text['news_view']['config'][28] = "Are you sure you want to delete this news ?"; -$text['news_view']['config'][29] = "This setting only concerns paragraphs or groups of simple paragraphs (p tag). A title, an image or an iframe are not concerned. In a truncated paragraph all html tags disappear (no formatting, no links). For links use images or h2, h3,... "; -$text['news_view']['config'][30] = "Image or iframe without margin"; -$text['news_view']['config'][31] = "An image or iframe will appear without margin, otherwise the margins are identical to those of a paragraph"; +$text['news_view']['config'][29] = "This setting concerns the number of characters displayed in the news preview. In the last paragraph, which is often truncated, the different html tags are removed."; +$text['news_view']['config'][30] = "Media without margin"; +$text['news_view']['config'][31] = "In the preview only the first media is displayed (image, iframe, video, figure). With this option the media will appear without margin."; $text['news_view']['config'][32] = 'Help'; -$text['news_view']['config'][33] = 'module/news/view/config/config.help_en.html'; +$text['news_view']['config'][33] = 'module/news/view/config/config.help.html'; +$text['news_view']['config'][34] = 'Media hidden in preview'; +$text['news_view']['config'][35] = 'In the preview only the first media is displayed, this option hides it'; $text['news_view']['index'][0] = 'read more'; $text['news_view']['index'][1] = 'No news.'; $text['news_view']['index'][2] = ' Edit'; @@ -123,4 +125,4 @@ $newsShadows = [ '5px 5px 10px' => 'Important', '10px 10px 20px' => 'Very important' ]; -?> \ No newline at end of file +?> diff --git a/module/news/lang/fr/lex_news.php b/module/news/lang/fr/lex_news.php index 97afde2..d9f2125 100644 --- a/module/news/lang/fr/lex_news.php +++ b/module/news/lang/fr/lex_news.php @@ -22,17 +22,19 @@ $text['news_view']['config'][19] = 'Etat'; $text['news_view']['config'][20] = 'Aucune news.'; $text['news_view']['config'][21] = 'Version n°'; $text['news_view']['config'][22] = 'Arrondi des angles'; -$text['news_view']['config'][23] = 'Ombre sur les bords'; +$text['news_view']['config'][23] = 'Ombre sur les bords'; $text['news_view']['config'][24] = 'Masquer le titre des nouvelles'; $text['news_view']['config'][25] = 'Titres masqués'; $text['news_view']['config'][26] = 'Même hauteur'; $text['news_view']['config'][27] = 'Les colonnes sur une même ligne auront même hauteur'; $text['news_view']['config'][28] = "Êtes-vous sûr de vouloir supprimer cette news ?"; -$text['news_view']['config'][29] = "Ce réglage ne concerne que les paragraphes ou les groupes de paragraphes simples (balise p). Un titre, une image, un iframe ne sont pas concernés. Dans un paragraphe tronqué toutes les balises html disparaissent (pas de mise en forme, pas de liens). Pour les liens utilisez les images ou h2, h3,..."; -$text['news_view']['config'][30] = "Image ou iframe sans marge"; -$text['news_view']['config'][31] = "Une image ou un iframe apparaîtront sans marge, sinon les marges sont identiques à celles d'un paragraphe"; +$text['news_view']['config'][29] = "Ce réglage concerne le nombre de caractères affichés dans l'aperçu des nouvelles. Dans le dernier paragraphe, souvent tronqué, les différentes balises html sont supprimées."; +$text['news_view']['config'][30] = "Média sans marge"; +$text['news_view']['config'][31] = "Dans l'aperçu seul le premier média est affiché (image, iframe, video, figure). Avec cette option le média apparaîtra sans marge."; $text['news_view']['config'][32] = 'Aide'; $text['news_view']['config'][33] = 'module/news/view/config/config.help.html'; +$text['news_view']['config'][34] = 'Média caché dans l\'aperçu'; +$text['news_view']['config'][35] = 'Dans l\'aperçu seul le premier média est affiché, cette option le cache.'; $text['news_view']['index'][0] = 'lire la suite'; $text['news_view']['index'][1] = 'Aucune news.'; $text['news_view']['index'][2] = ' Editer'; @@ -122,4 +124,4 @@ $newsShadows = [ '5px 5px 10px' => 'Important', '10px 10px 20px' => 'Très important' ]; -?> \ No newline at end of file +?> diff --git a/module/news/news.php b/module/news/news.php index fea2b4c..88b565a 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -18,7 +18,7 @@ class news extends common { - const VERSION = '4.4'; + const VERSION = '4.5'; const REALNAME = 'News'; const DELETE = true; const UPDATE = '0.0'; @@ -194,6 +194,7 @@ class news extends common { 'height' => $this->getInput('newsConfigHeight', helper::FILTER_INT,true), 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']), 'hiddeTitle' => $this->getInput('newsThemeTitle',helper::FILTER_BOOLEAN), + 'hideMedia' => $this->getInput('newsThemeMedia',helper::FILTER_BOOLEAN), 'sameHeight' => $this->getInput('newsThemeSameHeight',helper::FILTER_BOOLEAN), 'noMargin' => $this->getInput('newsThemeNoMargin',helper::FILTER_BOOLEAN) ]]); @@ -455,25 +456,29 @@ class news extends common { } $arrayContent = array_merge($arrayContent); $arrayType = array(); - // Détermination du type I : image ou iframe, P : paragraphe avec balises

, A : autre + // Détermination du type IM : image , IF : iframe, V: video, P : paragraphe avec balises

, A : autre foreach($arrayContent as $key=>$value){ - $arrayType[$key] = 'A'; - //Paragraphe avec image ou iframe - if( (strpos($value, '') !== false) || (strpos($value, '') !== false)){ - $arrayType[$key] = 'I'; + // Type de contenu pour les paragraphes + if( strpos($value, '') !== false){ + $arrayType[$key] = 'IM'; + } elseif( strpos($value, '') !== false) { + $arrayType[$key] = 'IF'; + } elseif( strpos($value, '') !== false) { + $arrayType[$key] = 'V'; + } elseif( strpos($value, '') !== false) { + $arrayType[$key] = 'F'; + } elseif( strpos($value, '') !== false ){ + $arrayType[$key] = 'P'; } else { - //Paragraphe simple avec possibilité d'abréviation - if( strpos($value, '') !== false ){ - $arrayType[$key] = 'P'; - } + $arrayType[$key] = 'A'; } } self::$news[$newsIds[$i]]['content'] = ''; + $charDisplay = 0; $mediaDisplay=0; for( $key=0; $keygetData(['module', $this->getUrl(0), 'config', 'hideMedia']) === false ){ // Modification des balises pour supprimer les marges if( $this->getData(['module', $this->getUrl(0), 'config', 'noMargin']) === true){ $arrayContent[$key] = str_replace('

', '', $arrayContent[$key]); @@ -488,30 +493,25 @@ class news extends common { } } self::$news[$newsIds[$i]]['content'] .= $arrayContent[$key]; + $mediaDisplay++; } elseif( $arrayType[$key] === 'P') { //Paragraphe à abréger - if ( $this->getData(['module', $this->getUrl(0), 'config', 'height']) !== -1){ - // Plusieurs paragraphes se suivent ? - for( $ii = $key + 1; $ii < count($arrayContent); $ii++){ - if( $arrayType[$ii] === 'P'){ - $value .= $arrayContent[$ii]; - $step++; - } else break; + if ( $this->getData(['module', $this->getUrl(0), 'config', 'height']) !== -1){ + $charRemain = $this->getData(['module', $this->getUrl(0), 'config', 'height']) - $charDisplay; + if( $charRemain > 0){ + if ( strlen( $arrayContent[$key] ) >= $charRemain ) { + // paragraphe trop long à abréger + $arrayContent[$key] = strip_tags($arrayContent[$key]); + $arrayContent[$key] = '

'.substr( $arrayContent[$key], 0, $charRemain).'

'; + $arrayContent[$key] .= '

... '.$text['news_view']['index'][0].'

' ; + } + self::$news[$newsIds[$i]]['content'] .= $arrayContent[$key]; + $charDisplay = $charDisplay + strlen( strip_tags( $arrayContent[$key]) ); } - if ( strlen( $value ) >= $this->getData(['module', $this->getUrl(0), 'config', 'height']) ) { - $arrayContent[$key] = substr( $value, 0, $this->getData(['module', $this->getUrl(0), 'config', 'height'])); - $lastSpace = strrpos($arrayContent[$key], ' ', -1 ); - $arrayContent[$key] = substr($arrayContent[$key], 0, $lastSpace); - $arrayContent[$key] = strip_tags($arrayContent[$key], '

'). '

'; - $arrayContent[$key] .= '

... '.$text['news_view']['index'][0].'

' ; - } - } - self::$news[$newsIds[$i]]['content'] .= $arrayContent[$key]; - $key = $key + $step; - - } else { - self::$news[$newsIds[$i]]['content'] .= $arrayContent[$key]; - } + } else { + self::$news[$newsIds[$i]]['content'] .= $arrayContent[$key]; + } + } } // Mise en forme de la signature diff --git a/module/news/view/config/config.php b/module/news/view/config/config.php index 591974f..fc9ce1d 100644 --- a/module/news/view/config/config.php +++ b/module/news/view/config/config.php @@ -76,19 +76,25 @@ echo template::formOpen('newsConfig'); ?>
-
+
$this->getData(['module', $this->getUrl(0), 'config', 'hiddeTitle']), 'help' => $text['news_view']['config'][24] ]); ?>
-
+
+ $this->getData(['module', $this->getUrl(0), 'config', 'hideMedia']), + 'help' => $text['news_view']['config'][35] + ]); ?> +
+
$this->getData(['module', $this->getUrl(0), 'config', 'sameHeight']), 'help' => $text['news_view']['config'][27] ]); ?>
-
+
$this->getData(['module', $this->getUrl(0), 'config', 'noMargin']), 'help' => $text['news_view']['config'][31]