news en frontend + suppression des données de module de page à l'effacement

This commit is contained in:
deltacms 2024-06-23 18:04:21 +02:00
parent 09ff83712b
commit 81b9d8e485
10 changed files with 102 additions and 38 deletions

View File

@ -6,8 +6,11 @@
- Visibilité de la page pour tous les membres ou pour un membre particulier (les éditeurs, modérateurs, administrateurs ont accès à la page),
- Affichage de documents ou de liens dans la page, visibles uniquement par le ou les membres. Les fichiers sont à placer le dossier 'site/file/source/membersDirectory/identifiant_du_membre'.
- Commentaires de page : remplissage automatique du champ 'Nom ou pseudo' pour les utilisateurs connectés,
- Agenda 7.3, Album 4.7, Blog 7.2, News 5.2 : tous les textes affichés par le CMS, comme 'Retour', 'Lire la suite', sont traduisibles dans la langue de vos visiteurs.
Un drapeau du pays indique la langue ciblée.
- Correction :
- Commentaires de page / configuration : un label erroné,
- Modules : les données volumineuses produites par les modules de page, et spécifiques à la page, sont supprimées à son effacement,
- Statislite 5.2 : problème d'accès aux fichiers robots.json et sessionInvalide.json dû à une mauvaise mise à jour vers Statislite 5.0.,
- Sur le site :
-

View File

@ -3335,7 +3335,7 @@ class core extends common {
'style' => file_get_contents($stylePath)
]);
}
if ($output['style']) {
if ($output['style'] && is_file($output['style'])) {
$this->addOutput([
'style' => $this->output['style'] . file_get_contents($output['style'])
]);

View File

@ -297,12 +297,15 @@ class page extends common {
// Suppression
else {
// Effacer le dossier du module
// Effacer le dossier du module
// Attention ces données spécifiques à une page $url[0] devrait être dans un dossier data_module
// Si dans 2 langues on utilise un même nom de page, ces données seront perdues pour les 2 langues.
$moduleId = $this->getData(['page',$url[0],'moduleId']);
$modulesData = helper::getModules();
if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) {
$this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] );
}
if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) $this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0]);
// Effacer les données de la page dans data_module
$dirdata = self::DATA_DIR.self::$i18n.'/data_module/'.$moduleId.'/'. $url[0];
if (is_dir($dirdata)) $this->removeDir( $dirdata );
// Effacer la page
$this->deleteData(['page', $url[0]]);
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) {

View File

@ -39,8 +39,11 @@ $text['news_view']['config'][36] = 'Text color';
$text['news_view']['config'][37] = 'Heading color';
$text['news_view']['config'][38] = 'Link color';
$text['news_view']['config'][39] = 'Date and signature color';
$text['news_view']['index'][0] = 'read more';
$text['news_view']['index'][1] = 'No news.';
$text['news_view']['config'][40] = 'Adapt these texts into the language of your visitors';
$text['news_view']['config'][41] = 'Read more';
$text['news_view']['config'][42] = 'Back';
$text['news_view']['config'][43] = 'No news';
$text['news_view']['index'][2] = ' Edit';
$text['news_view']['add'][0] = 'Back';
$text['news_view']['add'][1] = 'Save as draft';
@ -56,9 +59,8 @@ $text['news_view']['add'][10] = 'Unpublish date';
// For Tinymce and Flatpickr
$text['news_view']['add'][12] = 'en_GB';
$text['news_view']['add'][13] = 'default';
$text['news_view']['article'][0] = ' at ';
$text['news_view']['article'][1] = 'Edit';
$text['news_view']['article'][2] = 'Back';
$text['news_view']['edit'][0] = 'Back';
$text['news_view']['edit'][1] = 'Save as draft';
$text['news_view']['edit'][2] = 'Publish';
@ -73,7 +75,6 @@ $text['news_view']['edit'][10] = 'Unpublish date';
// For Tinymce and Flatpickr
$text['news_view']['edit'][12] = 'en_GB';
$text['news_view']['edit'][13] = 'default';
$text['news']['add'][0] = 'New news created';
$text['news']['add'][1] = 'New news';
$text['news']['config'][0] = 'Changes saved';

View File

@ -19,7 +19,7 @@ $text['news_view']['config'][16] = 'Título';
$text['news_view']['config'][17] = 'Publicar';
$text['news_view']['config'][18] = 'Despublicar';
$text['news_view']['config'][19] = 'Estado';
$text['news_view']['config'][20] = 'Sin noticias.';
$text['news_view']['config'][20] = 'Sin noticias';
$text['news_view']['config'][21] = 'Número de versión';
$text['news_view']['config'][22] = 'Esquinas redondeadas';
$text['news_view']['config'][23] = 'Sombra en los bordes';
@ -39,8 +39,11 @@ $text['news_view']['config'][36] = 'Color del texto';
$text['news_view']['config'][37] = 'Color del encabezado';
$text['news_view']['config'][38] = 'Color del enlace';
$text['news_view']['config'][39] = 'Color de firma y fecha';
$text['news_view']['index'][0] = 'leer más';
$text['news_view']['index'][1] = 'Sin noticias.';
$text['news_view']['config'][40] = 'Adapte estos textos al idioma de sus visitantes';
$text['news_view']['config'][41] = 'Leer más';
$text['news_view']['config'][42] = 'Volver';
$text['news_view']['config'][43] = 'Sin noticias';
$text['news_view']['index'][2] = 'Editar';
$text['news_view']['add'][0] = 'Atrás';
$text['news_view']['add'][1] = 'Guardar como borrador';
@ -56,9 +59,8 @@ $text['news_view']['add'][10] = 'Fecha de anulación de la publicación';
// Pour Tinymce et Flatpickr
$text['news_view']['add'][12] = 'es';
$text['news_view']['add'][13] = 'es';
$text['news_view']['article'][0] = ' to ';
$text['news_view']['article'][1] = 'Editar';
$text['news_view']['article'][2] = 'Atrás';
$text['news_view']['edit'][0] = 'Atrás';
$text['news_view']['edit'][1] = 'Guardar como borrador';
$text['news_view']['edit'][2] = 'Publicar';

View File

@ -19,7 +19,7 @@ $text['news_view']['config'][16] = 'Titre';
$text['news_view']['config'][17] = 'Publication';
$text['news_view']['config'][18] = 'Dépublication';
$text['news_view']['config'][19] = 'Etat';
$text['news_view']['config'][20] = 'Aucune news.';
$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';
@ -39,8 +39,11 @@ $text['news_view']['config'][36] = 'Couleur du texte';
$text['news_view']['config'][37] = 'Couleur des titres';
$text['news_view']['config'][38] = 'Couleur des liens';
$text['news_view']['config'][39] = 'Couleur de la date et de la siganture';
$text['news_view']['index'][0] = 'lire la suite';
$text['news_view']['index'][1] = 'Aucune news.';
$text['news_view']['config'][40] = 'Adapter ces textes dans la langue de vos visiteurs';
$text['news_view']['config'][41] = 'Lire la suite';
$text['news_view']['config'][42] = 'Retour';
$text['news_view']['config'][43] = 'Aucune news';
$text['news_view']['index'][2] = ' Editer';
$text['news_view']['add'][0] = 'Retour';
$text['news_view']['add'][1] = 'Enregistrer en brouillon';
@ -56,9 +59,8 @@ $text['news_view']['add'][10] = 'Date de dépublication';
// Pour Tinymce et Flatpickr
$text['news_view']['add'][12] = 'fr_FR';
$text['news_view']['add'][13] = 'fr';
$text['news_view']['article'][0] = ' à ';
$text['news_view']['article'][1] = 'Editer';
$text['news_view']['article'][2] = 'Retour';
$text['news_view']['edit'][0] = 'Retour';
$text['news_view']['edit'][1] = 'Enregistrer en brouillon';
$text['news_view']['edit'][2] = 'Publier';

View File

@ -18,7 +18,7 @@
class news extends common {
const VERSION = '5.1';
const VERSION = '5.2';
const REALNAME = 'News';
const DELETE = true;
const UPDATE = '0.0';
@ -209,18 +209,15 @@ class news extends common {
$style_invert .= '.newsFrame h1,.newsFrame h2,.newsFrame h3,.newsFrame h4,.newsFrame h5,.newsFrame h6{ color:'. helper::invertColor($this->getInput('newsThemeTitleColor')) .'}';
$style_invert .= '.newsSignature { color:' . helper::invertColor($this->getInput('newsThemeSignatureColor')) . ';';
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) {
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0755, true);
}
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', $style );
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme_invert.css', $style_invert );
$dircss = self::DATA_DIR.self::$i18n.'/data_module/news/'. $this->getUrl(0);
if( !is_dir($dircss)) mkdir($dircss, 0755, true);
$success = file_put_contents($dircss . '/theme.css', $style );
$success = file_put_contents($dircss . '/theme_invert.css', $style_invert );
// Fin feuille de style
$this->setData(['module', $this->getUrl(0), 'theme',[
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
'style_invert' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme_invert.css' : '',
'style' => $success ? $dircss . '/theme.css' : '',
'style_invert' => $success ? $dircss . '/theme_invert.css' : '',
'borderColor' => $this->getInput('newsThemeBorderColor'),
'borderWidth' => $this->getInput('newsThemeBorderWidth',helper::FILTER_STRING_SHORT),
'backgroundColor' => $this->getInput('newsThemeBackgroundColor'),
@ -244,7 +241,11 @@ class news extends common {
'sameHeight' => $this->getInput('newsThemeSameHeight',helper::FILTER_BOOLEAN),
'noMargin' => $this->getInput('newsThemeNoMargin',helper::FILTER_BOOLEAN)
]]);
$this->setData(['module', $this->getUrl(0), 'config', 'texts',[
'readmore' => $this->getInput('newsConfigTextsReadmore',helper::FILTER_STRING_SHORT),
'back' => $this->getInput('newsConfigTextsBack',helper::FILTER_STRING_SHORT),
'noNews' => $this->getInput('newsConfigTextsNoNews',helper::FILTER_STRING_SHORT)
]]);
// Valeurs en sortie
$this->addOutput([
@ -431,7 +432,7 @@ class news extends common {
'state' => true
]);
}
// Mise à jour ou création du fichier site/data/news/themeNews.css
// Mise à jour ou création du fichier site/data/news/themeNews.css destiné à tinymce
$style = '.editorWysiwyg{';
$style .= 'background-color:' . $this->getData(['module', $this->getUrl(0), 'theme', 'backgroundColor']) . ';';
$style .= '}';
@ -582,7 +583,7 @@ class news extends common {
// 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>' ;
$arrayContent[$key] .= '<p> ... <a href="'. helper::baseUrl(true) . $this->getUrl(0) . '/' . $newsIds[$i] . '"><span class="newsSuite">'.$this->getData(['module', $this->getUrl(0), 'config','texts', 'readmore']).'</span></a></p>' ;
$charDisplay = $charDisplay + 1000;
}
self::$news[$newsIds[$i]]['content'] .= $arrayContent[$key];
@ -642,6 +643,8 @@ class news extends common {
* Appelée par les fonctions index et config
*/
private function update() {
// Lexique
include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_news.php');
$versionData = $this->getData(['module',$this->getUrl(0),'config', 'versionData' ]);
@ -690,9 +693,13 @@ class news extends common {
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '5.0' ]);
}
// Mise à jour 5.1
if (version_compare($versionData, '5.1', '<') ) {
if (version_compare($versionData, '5.2', '<') ) {
// Initialisation de nouvelles variables
$this->setData(['module', $this->getUrl(0), 'config', 'texts', 'readmore', $text['news_view']['config'][41] ]);
$this->setData(['module', $this->getUrl(0), 'config', 'texts', 'back', $text['news_view']['config'][42] ]);
$this->setData(['module', $this->getUrl(0), 'config', 'texts', 'noNews', $text['news_view']['config'][43] ]);
// Mettre à jour la version
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '5.1' ]);
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '5.2' ]);
}
}
}
@ -701,6 +708,9 @@ class news extends common {
* Initialisation du thème d'un nouveau module
*/
private function init() {
// Lexique
include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_news.php');
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css';
@ -744,5 +754,10 @@ class news extends common {
// Stocker le nom de la feuille de style
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']);
}
// Textes initialisés dans la langue d'administration
$this->setData(['module', $this->getUrl(0), 'config', 'texts', 'readmore', $text['news_view']['config'][41] ]);
$this->setData(['module', $this->getUrl(0), 'config', 'texts', 'back', $text['news_view']['config'][42] ]);
$this->setData(['module', $this->getUrl(0), 'config', 'texts', 'noNews', $text['news_view']['config'][43] ]);
}
}

View File

@ -36,7 +36,7 @@ include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) .
$heure = mb_detect_encoding(date('H:i', $this->getData(['data_module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
? date('H:i', $this->getData(['data_module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))
: utf8_encode(date('H:i', $this->getData(['data_module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])));
echo $date . $text['news_view']['article'][0] . $heure;
echo $date .' - '. $heure;
} ?>
<!-- Bloc edition -->
@ -70,7 +70,7 @@ include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) .
<?php echo template::button('newsArticleBack', [
'href' => helper::baseUrl() . $_SESSION['pageActive'],
'ico' => 'left',
'value' => $text['news_view']['article'][2]
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'texts', 'back'])
]); ?>
</div>

View File

@ -1,6 +1,13 @@
<?php
// Lexique
include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_news.php');
// drapeau pour la langue d'origine ou la langue en traduction rédigée
if( $this->getInput('DELTA_I18N_SITE') === '' || $this->getInput('DELTA_I18N_SITE')=== null || $this->getInput('DELTA_I18N_SITE') === 'base'){
$flag = $this->getData(['config', 'i18n', 'langBase']);
}
else{
$flag = $this->getInput('DELTA_I18N_SITE');
}
echo template::formOpen('newsConfig'); ?>
<div class="row">
@ -104,6 +111,35 @@ echo template::formOpen('newsConfig'); ?>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<div class="blockTitle"><?php echo $text['news_view']['config'][40].' '.template::flag($flag, '20px');?></div>
<div class="row">
<div class="col4">
<?php echo template::text('newsConfigTextsReadmore', [
'label' => $text['news_view']['config'][41],
'value' => $this->getData(['module', $this->getUrl(0), 'config','texts', 'readmore'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('newsConfigTextsBack', [
'label' => $text['news_view']['config'][42],
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'texts', 'back'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('newsConfigTextsNoNews', [
'label' => $text['news_view']['config'][43],
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'texts', 'noNews'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row <?php if($this->getUser('group') < self::GROUP_MODERATOR) echo 'displayNone'; ?> ">
<div class="col12">
<div class="block">

View File

@ -80,5 +80,7 @@ if($module::$news):
</div>
<?php endif; ?>
<?php else: ?>
<?php echo template::speech($text['news_view']['index'][1]); ?>
<?php
$textNoNews = null === $this->getData(['module', $this->getUrl(0), 'config', 'texts', 'noNews']) ? $text['news_view']['config'][20] : $this->getData(['module', $this->getUrl(0), 'config', 'texts', 'noNews']);
echo template::speech($textNoNews); ?>
<?php endif; ?>