Initialisation

This commit is contained in:
Fred Tempez 2021-07-22 23:11:55 +02:00
parent b23ed7e94b
commit 76c8669f09
4 changed files with 50 additions and 52 deletions

69
module/news/news.php Normal file → Executable file
View File

@ -15,8 +15,8 @@
class news extends common { class news extends common {
const VERSION = '3.3'; const VERSION = '3.4';
const REALNAME = 'Actualités'; const REALNAME = 'News';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; const UPDATE = '0.0';
const DATADIRECTORY = self::DATA_DIR . 'news/'; const DATADIRECTORY = self::DATA_DIR . 'news/';
@ -60,18 +60,11 @@ class news extends common {
]; ];
public static $nbrCol = 1; public static $nbrCol = 1;
public static $itemsHeight = [ public static $height = [
'200px' => 'Petite', 200 => 'Petite',
'300px' => 'Moyenne', 400 => 'Moyenne',
'400px' => 'Grande', 600 => 'Grande',
'auto' => 'Article complet' 1000 => 'Article complet'
];
public static $itemsBlur = [
'0%' => 'Aucun',
'15%' => 'Faible',
'30%' => 'Modéré',
'45%' => 'Important',
]; ];
// Signature de l'article // Signature de l'article
@ -184,12 +177,12 @@ class news extends common {
if($this->isPost()) { if($this->isPost()) {
// Générer la feuille de CSS // Générer la feuille de CSS
$style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}'; //$style = '.newsContent {height:' . $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT) . ';}';
if ($this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) !== '100%') { //if ($this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) !== '100%') {
$style .= '.newsBlur {height: ' . $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) . ';}'; // $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 .= '.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;}'; //$style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}';
} //}
// Dossier de l'instance // Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) { if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) {
@ -202,8 +195,8 @@ class news extends common {
$this->setData(['module', $this->getUrl(0), 'theme',[ $this->setData(['module', $this->getUrl(0), 'theme',[
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '', 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT), //'itemsHeight' => $this->getInput('newsConfigItemsHeight',helper::FILTER_STRING_SHORT),
'itemsBlur' => $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) //'itemsBlur' => $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT)
]]); ]]);
$this->setData(['module', $this->getUrl(0), 'config',[ $this->setData(['module', $this->getUrl(0), 'config',[
@ -211,6 +204,7 @@ class news extends common {
'feedsLabel' => $this->getInput('newsConfigFeedslabel',helper::FILTER_STRING_SHORT), 'feedsLabel' => $this->getInput('newsConfigFeedslabel',helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('newsConfigItemsperPage', helper::FILTER_INT,true), 'itemsperPage' => $this->getInput('newsConfigItemsperPage', helper::FILTER_INT,true),
'itemsperCol' => $this->getInput('newsConfigItemsperCol', 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']) 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
@ -432,7 +426,13 @@ class news extends common {
// News en fonction de la pagination // News en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) { 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]] = $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 // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -504,6 +504,16 @@ class news extends common {
// Mettre à jour la version // Mettre à jour la version
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '3.3' ]); $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 // Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { //if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
mkdir (self::DATADIRECTORY . $this->getUrl(0) , 0777, true); // mkdir (self::DATADIRECTORY . $this->getUrl(0) , 0777, true);
} //}
// Check la présence de la feuille de style // 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 // 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 // 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 .= '.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;}'; //$style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}';
// Sauver la feuille de style // 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 // 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']);
} //}
} }
} }

17
module/news/view/config/config.php Normal file → Executable file
View File

@ -38,33 +38,26 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col3"> <div class="col4">
<?php echo template::select('newsConfigItemsperCol', $module::$columns, [ <?php echo template::select('newsConfigItemsperCol', $module::$columns, [
'label' => 'Pagination', 'label' => 'Pagination',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']), 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']),
'help' => 'Nombre de colonnes par page' 'help' => 'Nombre de colonnes par page'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col4">
<?php echo template::select('newsConfigItemsperPage', $module::$itemsList, [ <?php echo template::select('newsConfigItemsperPage', $module::$itemsList, [
'label' => 'Articles par page', 'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']) 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col4">
<?php echo template::select('newsConfigItemsHeight', $module::$itemsHeight, [ <?php echo template::select('newsConfigHeight', $module::$height, [
'label' => 'Hauteur', 'label' => '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.' 'help' => 'Limite la hauteur de l\'article, cette option est utile lorsque la pagination en colonnes est activée.'
]); ?> ]); ?>
</div> </div>
<div class="col3">
<?php echo template::select('newsConfigItemsBlur', $module::$itemsBlur, [
'label' => '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'
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -29,17 +29,10 @@
margin-bottom: 30px; margin-bottom: 30px;
} }
.newsBlur { .newsSuite {
width: 100%; font-style: italic;
height: 50%;
position: absolute;
bottom: 0;
left: -20px;
z-index: 10;
backdrop-filter: blur(1px);
} }
.newsSignature { .newsSignature {
margin-right: 10px; margin-right: 10px;
float: right; float: right;

View File

@ -7,8 +7,9 @@
</h2> </h2>
<div class="newsContent"> <div class="newsContent">
<?php echo $news['content']; ?> <?php echo $news['content']; ?>
<div class="newsBlur"> <?php if ($this->getData(['module', $this->getUrl(0), 'config', 'height']) !== 1000):?>
</div> <?php echo ' ... <a href="'. helper::baseUrl(true) . $this->getUrl(0) . '/' . $newsId . '"><span class="newsSuite">lire la suite</span></a>'; ?>
<?php endif; ?>
</div> </div>
<div class="newsSignature"> <div class="newsSignature">
<i class="far fa-calendar-alt"></i> <i class="far fa-calendar-alt"></i>