module News

This commit is contained in:
Deltacms 2022-12-27 18:36:50 +01:00
parent 39e7dcd2f3
commit 5644caa0c0
5 changed files with 60 additions and 49 deletions

View File

@ -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.

View File

@ -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'
];
?>
?>

View File

@ -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'
];
?>
?>

View File

@ -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 <p></p>, A : autre
// Détermination du type IM : image , IF : iframe, V: video, P : paragraphe avec balises <p></p>, A : autre
foreach($arrayContent as $key=>$value){
$arrayType[$key] = 'A';
//Paragraphe avec image ou iframe
if( (strpos($value, '<img') !== false && strpos($value, '/>') !== false) || (strpos($value, '<iframe') !== false && strpos($value, '</iframe>') !== false)){
$arrayType[$key] = 'I';
// Type de contenu pour les paragraphes
if( strpos($value, '<img') !== false && strpos($value, '/>') !== false){
$arrayType[$key] = 'IM';
} elseif( strpos($value, '<iframe') !== false && strpos($value, '</iframe>') !== false) {
$arrayType[$key] = 'IF';
} elseif( strpos($value, '<video') !== false && strpos($value, '</video>') !== false) {
$arrayType[$key] = 'V';
} elseif( strpos($value, '<figure') !== false && strpos($value, '</figure>') !== false) {
$arrayType[$key] = 'F';
} elseif( strpos($value, '<p') !== false && strpos($value, '</p>') !== false ){
$arrayType[$key] = 'P';
} else {
//Paragraphe simple avec possibilité d'abréviation
if( strpos($value, '<p') !== false && strpos($value, '</p>') !== false ){
$arrayType[$key] = 'P';
}
$arrayType[$key] = 'A';
}
}
self::$news[$newsIds[$i]]['content'] = '';
$charDisplay = 0; $mediaDisplay=0;
for( $key=0; $key<count($arrayContent); $key++){
$value = $arrayContent[$key];
$step = 0;
//Paragraphe avec image ou iframe
if( $arrayType[$key] === 'I'){
//Paragraphe avec media autorisé ( img, iframe, video, figure)
if( ($arrayType[$key] === 'IM' || $arrayType[$key] === 'IF' || $arrayType[$key] === 'V' || $arrayType[$key] === 'F' )
&& $mediaDisplay === 0 && $this->getData(['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('</p>', '', $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] = '<p>'.substr( $arrayContent[$key], 0, $charRemain).'</p>';
$arrayContent[$key] .= '<p> ... <a href="'. helper::baseUrl(true) . $this->getUrl(0) . '/' . $newsIds[$i] . '"><span class="newsSuite">'.$text['news_view']['index'][0].'</span></a></p>' ;
}
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], '<p>'). '</p>';
$arrayContent[$key] .= '<p> ... <a href="'. helper::baseUrl(true) . $this->getUrl(0) . '/' . $newsIds[$i] . '"><span class="newsSuite">'.$text['news_view']['index'][0].'</span></a></p>' ;
}
}
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

View File

@ -76,19 +76,25 @@ echo template::formOpen('newsConfig'); ?>
</div>
</div>
<div class="row">
<div class="col4">
<div class="col3">
<?php echo template::checkbox('newsThemeTitle', true, $text['news_view']['config'][25], [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'hiddeTitle']),
'help' => $text['news_view']['config'][24]
]); ?>
</div>
<div class="col4">
<div class="col3">
<?php echo template::checkbox('newsThemeMedia', true, $text['news_view']['config'][34], [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'hideMedia']),
'help' => $text['news_view']['config'][35]
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('newsThemeSameHeight', true, $text['news_view']['config'][26], [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'sameHeight']),
'help' => $text['news_view']['config'][27]
]); ?>
</div>
<div class="col4">
<div class="col3">
<?php echo template::checkbox('newsThemeNoMargin', true, $text['news_view']['config'][30], [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'noMargin']),
'help' => $text['news_view']['config'][31]