Merge branch '10600' into 11000

This commit is contained in:
fredtempez 2021-04-12 18:14:02 +02:00
commit ba06a9f69a
10 changed files with 149 additions and 143 deletions

View File

@ -16,7 +16,7 @@
## version 10.6.00
Cette version apporte aux modules une autonomie complète par rapport au noyau.
- mise à jour interne (fonction update)
- feuille de style propres aux instances (fonction initCss)
- feuille de style propres aux instances (fonction init)
- Modifications :
- Nombre d'éléments ou d'articles par page : l'option est propre aux modules et n'est plus gérées dans la configuration du CMS.
- Module Search : en l'absence de texte dans le bouton Rechercher, une loupe est affichée.

View File

@ -61,22 +61,23 @@ Pour revenir à la version 8, renommez ce fichier "data.json".
[R] vendor Librairies extérieures
[F] core.js.php Cœur javascript
[F] core.php Cœur PHP
[R] module Modules de page
[R] blog Blog
[R] form Gestionnaire de formulaires
[R] gallery Galerie
[R] news Nouvelles
[R] redirection Redirection
[R] site Contenu du site
[R] backup Sauvegardes automatiques
[R] data Répertoire des données
[R] fr Dossier localisé
[F] page.json Données des pages
[F] module.json Données des modules de pages
[R] modules Personnalisation des modules ou données propres
[F] admin.css Thème des pages d'administration
[F] admin.json Données de thème des pages d'administration
[F] admin.json Données de thème des pages d'administration
[F] blacklist.json Journalisation des tentatives de connexion avec des comptes inconnus
[F] config.json Configuration du site
[F] core.json Configuration du noyau
@ -90,7 +91,7 @@ Pour revenir à la version 8, renommez ce fichier "data.json".
[R] source Ressources diverses
[R] thumb Miniatures des images
[R] tmp Répertoire temporaire
[F] index.php Fichier d'initialisation de ZwiiCMS
[F] robots.txt Filtrage des répertoires accessibles aux robots des moteurs de recherche
[F] sitemap.xml Plan du site

View File

@ -677,12 +677,7 @@ class init extends common {
'config' => [
'feeds' => true,
'feedsLabel' => "Syndication RSS",
"editConsent" => "all",
"commentMaxlength" => "500",
"commentApproved" => false,
"commentClose" => false,
"commentNotification" => false,
"commentGroupNotification" => 1
'itemsperPage' => 4
],
'posts' => [
'mon-premier-article' => [
@ -700,6 +695,7 @@ class init extends common {
'picture' => 'galerie/landscape/meadow.jpg',
'hidePicture' => false,
'pictureSize' => 20,
'picturePosition' => 'left',
'publishedOn' => 1548790902,
'state' => true,
'title' => 'Mon premier article',
@ -718,6 +714,7 @@ class init extends common {
'picture' => 'galerie/landscape/desert.jpg',
'hidePicture' => false,
'pictureSize' => 40,
'picturePosition' => 'right',
'publishedOn' => 1550432502,
'state' => true,
'title' => 'Mon deuxième article',
@ -736,6 +733,7 @@ class init extends common {
'picture' => 'galerie/landscape/iceberg.jpg',
'hidePicture' => false,
'pictureSize' => 100,
'picturePosition' => 'left',
'publishedOn' => 1550864502,
'state' => true,
'title' => 'Mon troisième article',
@ -790,7 +788,7 @@ class init extends common {
]
],
],
'config' => [
'theme' => [
'thumbAlign' => 'center',
'thumbWidth' => '18em',
'thumbHeight' => '15em',
@ -805,9 +803,11 @@ class init extends common {
'legendAlign' => 'center',
'legendTextColor' => 'rgba(255, 255, 255, 1)',
'legendBgColor' => 'rgba(0, 0, 0, .6)',
'versionData' => '3.0',
'style' => 'site/data/modules/gallery/galeries.css'
],
'config' => [
'versionData' => '3.0'
],
],
'site-de-zwii' => [
'url' => 'https://zwiicms.fr/',

View File

@ -259,6 +259,13 @@ class page extends common {
}
// Suppression
else {
// Effacer le dossier du module
$moduleId = $this->getData(['page',$url[0],'moduleId']);
$modulesData = helper::getModules();
if (is_dir($modulesData[$moduleId]['dataDirectory'])) {
$this->removeDir( $modulesData[$moduleId]['dataDirectory'] );
}
// Effacer la page
$this->deleteData(['page', $url[0]]);
$this->deleteData(['module', $url[0]]);
@ -313,6 +320,16 @@ class page extends common {
if ($this->getData(['module', $this->getUrl(2)]) !== null ) {
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
$this->deleteData(['module', $this->getUrl(2)]);
// Renommer le dossier du module
$moduleId = $this->getData(['page',$this->getUrl(2),'moduleId']);
$modulesData = helper::getModules();
if (is_dir($modulesData[$moduleId]['dataDirectory'])) {
// Renommer la feuille de style
rename( $modulesData[$moduleId]['dataDirectory'],str_replace($this->geturl(2),$pageId, $modulesData[$moduleId]['dataDirectory']));
$this->removeDir($modulesData[$moduleId]['dataDirectory']);
// Mettre à jour le nom de la feuille de site
$this->setData(['module',$pageId,'theme','style',str_replace($this->geturl(2),$pageId, $modulesData[$moduleId]['dataDirectory'])]);
}
}
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) {

View File

@ -20,11 +20,11 @@
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])));
echo $date . ' à ' . $heure;
echo $date . ' à ' . $heure;
?>
<!-- Bloc edition -->
<?php if (
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
AND
( // Propriétaire
@ -55,7 +55,7 @@
<div id="rssFeed">
<a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" target="_blank">
<img src='module/news/ressource/feed-icon-16.gif' />
<?php
<?php
echo '<p>' . $this->getData(['module',$this->getUrl(0), 'config', 'feedsLabel']) . '</p>' ;
?>
</a>

View File

@ -21,7 +21,6 @@
<?php echo template::submit('blogEditSubmit', [
'value' => 'Publier'
]); ?>
</div>
</div>
<div class="row">

View File

@ -171,10 +171,7 @@ class gallery extends common {
$this->deleteData(['theme','gallery']);
$this->setData(['module', $this->getUrl(0), 'theme', $data]);
// Nom de la feuille de style
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $moduleId . '.css']);
} else {
// Theme par défaut
$this->init($this->geturl(0));
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']);
}
// Nouvelle version
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.0']);
@ -187,49 +184,50 @@ class gallery extends common {
* Config
* Content
*/
private function init($moduleId) {
private function init() {
// Variable commune
$fileCSS = self::DATADIRECTORY . $moduleId . '.css' ;
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ;
// Check la présence du thème
if ( $this->getData(['module', $moduleId, 'theme']) === null ) {
if ( $this->getData(['module', $this->getUrl(0), 'theme']) === null ) {
require_once('module/gallery/ressource/defaultdata.php');
$this->setData(['module', $moduleId, 'theme', theme::$defaultTheme]);
$this->setData(['module', $this->getUrl(0), 'theme', theme::$defaultTheme]);
// Nom de la feuille de style
$this->setData(['module', $this->getUrl(0), 'theme', 'style', $fileCSS]);
}
// Check la présence de la feuille de style
if ( !file_exists(self::DATADIRECTORY . $moduleId . '.css')) {
if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) {
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY )) {
mkdir (self::DATADIRECTORY, 0777, true);
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true);
}
// Nom de la feuille de style
$this->setData(['module', $moduleId, 'theme', 'style', $fileCSS]);
// Générer la feuille de CSS
$content = file_get_contents('module/gallery/ressource/vartheme.css');
$themeCss = file_get_contents('module/gallery/ressource/theme.css');
// Injection des variables
$content = str_replace('#thumbAlign#',$this->getData(['module', $moduleId, 'theme', 'thumbAlign']),$content );
$content = str_replace('#thumbWidth#',$this->getData(['module', $moduleId, 'theme', 'thumbWidth']),$content );
$content = str_replace('#thumbHeight#',$this->getData(['module', $moduleId, 'theme', 'thumbHeight']),$content );
$content = str_replace('#thumbMargin#',$this->getData(['module', $moduleId, 'theme', 'thumbMargin']),$content );
$content = str_replace('#thumbBorder#',$this->getData(['module', $moduleId, 'theme', 'thumbBorder']),$content );
$content = str_replace('#thumbBorderColor#',$this->getData(['module', $moduleId, 'theme', 'thumbBorderColor']),$content );
$content = str_replace('#thumbOpacity#',$this->getData(['module', $moduleId, 'theme', 'thumbOpacity']),$content );
$content = str_replace('#thumbShadows#',$this->getData(['module', $moduleId, 'theme', 'thumbShadows']),$content );
$content = str_replace('#thumbShadowsColor#',$this->getData(['module', $moduleId, 'theme', 'thumbShadowsColor']),$content );
$content = str_replace('#thumbRadius#',$this->getData(['module', $moduleId, 'theme', 'thumbRadius']),$content );
$content = str_replace('#legendAlign#',$this->getData(['module', $moduleId, 'theme', 'legendAlign']),$content );
$content = str_replace('#legendHeight#',$this->getData(['module', $moduleId, 'theme', 'legendHeight']),$content );
$content = str_replace('#legendTextColor#',$this->getData(['module', $moduleId, 'theme', 'legendTextColor']),$content );
$content = str_replace('#legendBgColor#',$this->getData(['module', $moduleId, 'theme', 'legendBgColor']),$content );
$content = str_replace('#thumbAlign#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbAlign']),$content );
$content = str_replace('#thumbWidth#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbWidth']),$content );
$content = str_replace('#thumbHeight#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbHeight']),$content );
$content = str_replace('#thumbMargin#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbMargin']),$content );
$content = str_replace('#thumbBorder#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbBorder']),$content );
$content = str_replace('#thumbBorderColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbBorderColor']),$content );
$content = str_replace('#thumbOpacity#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbOpacity']),$content );
$content = str_replace('#thumbShadows#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbShadows']),$content );
$content = str_replace('#thumbShadowsColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbShadowsColor']),$content );
$content = str_replace('#thumbRadius#',$this->getData(['module', $this->getUrl(0), 'theme', 'thumbRadius']),$content );
$content = str_replace('#legendAlign#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendAlign']),$content );
$content = str_replace('#legendHeight#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendHeight']),$content );
$content = str_replace('#legendTextColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendTextColor']),$content );
$content = str_replace('#legendBgColor#',$this->getData(['module', $this->getUrl(0), 'theme', 'legendBgColor']),$content );
// Ecriture de la feuille de style
file_put_contents(self::DATADIRECTORY . $moduleId . '.css' , $content . $themeCss);
file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $content . $themeCss);
// Nom de la feuille de style
$this->setData(['module', $this->getUrl(0), 'theme', 'style', $fileCSS]);
}
// Check Config
if ( $this->getData(['module', $moduleId, 'config']) === null ) {
if ( $this->getData(['module', $this->getUrl(0), 'config']) === null ) {
require_once('module/gallery/ressource/defaultdata.php');
$this->setData(['module', $moduleId, 'config', theme::$defaultData]);
$this->setData(['module', $this->getUrl(0), 'config', theme::$defaultData]);
}
// Contenu vide de la galerie
@ -301,9 +299,7 @@ class gallery extends common {
$this->update();
// Initialisation d'un nouveau module
if ($this->getData(['module', $this->getUrl(0)]) === null) {
$this->init($this->getUrl(0));
}
$this->init();
//Affichage de la galerie triée
$g = $this->getData(['module', $this->getUrl(0), 'content']);
@ -589,9 +585,7 @@ class gallery extends common {
$this->update();
// Initialisation d'un nouveau module
if ($this->getData(['module', $this->getUrl(0)]) === null) {
$this->init($this->getUrl(0));
}
$this->init();
// Images d'une galerie
if($this->getUrl(1)) {
@ -733,29 +727,26 @@ class gallery extends common {
}
// Soumission du formulaire
if($this->isPost()) {
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY )) {
mkdir (self::DATADIRECTORY, 0777, true);
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true);
}
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ;
// Fin feuille de style
$this->getData(['module', $this->getUrl(0), 'theme', [
'thumbAlign' => $this->getinput('galleryThemeThumbAlign'),
'thumbWidth' => $this->getinput('galleryThemeThumbWidth'),
'thumbHeight' => $this->getinput('galleryThemeThumbHeight'),
'thumbMargin' => $this->getinput('galleryThemeThumbMargin'),
'thumbBorder' => $this->getinput('galleryThemeThumbBorder'),
'thumbBorderColor' => $this->getinput('galleryThemeThumbBorderColor'),
'thumbOpacity' => $this->getinput('galleryThemeThumbOpacity'),
'thumbShadows' => $this->getinput('galleryThemeThumbShadows'),
'thumbShadowsColor' => $this->getinput('galleryThemeThumbShadowsColor'),
'thumbRadius' => $this->getinput('galleryThemeThumbRadius'),
'legendHeight' => $this->getinput('galleryThemeLegendHeight'),
'legendAlign' => $this->getinput('galleryThemeLegendAlign'),
'legendTextColor' => $this->getinput('galleryThemeLegendTextColor'),
'legendBgColor' => $this->getinput('galleryThemeLegendBgColor'),
'style' => $fileCSS,
$this->setData(['module', $this->getUrl(0), 'theme', [
'thumbAlign' => $this->getinput('galleryThemeThumbAlign', helper::FILTER_STRING_SHORT),
'thumbWidth' => $this->getinput('galleryThemeThumbWidth', helper::FILTER_STRING_SHORT),
'thumbHeight' => $this->getinput('galleryThemeThumbHeight', helper::FILTER_STRING_SHORT),
'thumbMargin' => $this->getinput('galleryThemeThumbMargin', helper::FILTER_STRING_SHORT),
'thumbBorder' => $this->getinput('galleryThemeThumbBorder', helper::FILTER_STRING_SHORT),
'thumbBorderColor' => $this->getinput('galleryThemeThumbBorderColor', helper::FILTER_STRING_SHORT),
'thumbOpacity' => $this->getinput('galleryThemeThumbOpacity', helper::FILTER_STRING_SHORT),
'thumbShadows' => $this->getinput('galleryThemeThumbShadows', helper::FILTER_STRING_SHORT),
'thumbShadowsColor' => $this->getinput('galleryThemeThumbShadowsColor', helper::FILTER_STRING_SHORT),
'thumbRadius' => $this->getinput('galleryThemeThumbRadius', helper::FILTER_STRING_SHORT),
'legendHeight' => $this->getinput('galleryThemeLegendHeight', helper::FILTER_STRING_SHORT),
'legendAlign' => $this->getinput('galleryThemeLegendAlign', helper::FILTER_STRING_SHORT),
'legendTextColor' => $this->getinput('galleryThemeLegendTextColor', helper::FILTER_STRING_SHORT),
'legendBgColor' => $this->getinput('galleryThemeLegendBgColor', helper::FILTER_STRING_SHORT),
'style' => self::DATADIRECTORY . $this->getUrl(0) . '/theme.css'
]]);
// Création des fichiers CSS
$content = file_get_contents('module/gallery/ressource/vartheme.css');
@ -775,7 +766,7 @@ class gallery extends common {
$content = str_replace('#legendHeight#',$this->getinput('galleryThemeLegendHeight'),$content );
$content = str_replace('#legendTextColor#',$this->getinput('galleryThemeLegendTextColor'),$content );
$content = str_replace('#legendBgColor#',$this->getinput('galleryThemeLegendBgColor'),$content );
$success = file_put_contents($fileCSS, $content . $themeCss);
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', $content . $themeCss);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '/theme',

View File

@ -177,29 +177,27 @@ class news extends common {
$this->update();
// Initialisation d'un nouveau module
if ($this->getData(['module', $this->getUrl(0)]) === null) {
$this->init($this->getUrl(0));
}
$this->init();
// Soumission du formulaire
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 .= '.newsBlur {background: linear-gradient(#333 ' . $this->getInput('newsConfigItemsBlur',helper::FILTER_STRING_SHORT) . ',#FFF );';
$style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}';
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATADIRECTORY, 0777, true);
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) {
mkdir (self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', 0777, true);
}
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style );
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', $style );
// Fin feuille de style
$this->setData(['module', $this->getUrl(0), 'theme',[
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '.css' : '',
'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)
]]);
@ -360,10 +358,7 @@ class news extends common {
$this->update();
// Initialisation d'un nouveau module
if ($this->getData(['module', $this->getUrl(0)]) === null) {
$this->init($this->getUrl(0));
}
$this->init();
// Affichage d'un article
if(
@ -454,37 +449,41 @@ class news extends common {
// Version 3.0
if ($this->getData(['module', $this->getUrl(0), 'config']) === NULL ) {
// Données config et theme absentes du précédent module
$this->init($this->getUrl(0));
$this->init();
}
}
/**
* Initialisation du thème d'un nouveau module
*/
private function init($moduleId) {
// Variable commune
$fileCSS = self::DATADIRECTORY . $moduleId . '.css' ;
private function init() {
// Données du module
require_once('module/news/ressource/defaultdata.php');
$this->setData(['module', $moduleId, 'config',init::$defaultData ]);
// Données de thème
$this->setData(['module', $moduleId, 'theme',init::$defaultTheme ]);
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css';
// Générer la feuille de CSS
$style = '.newsContent {height: ' . $this->getData([ 'module', $moduleId, 'theme', 'itemsHeight' ]) .';}';
$style .= '.newsBlur {background: linear-gradient(#333 ' . $this->getData([ 'module', $moduleId, 'theme', 'itemsBlur' ]) . ',#FFF );';
$style .= ' background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}';
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATADIRECTORY, 0777, true);
// Données du module
if ($this->getData(['module', $this->getUrl(0) ]) === null) {
require_once('module/news/ressource/defaultdata.php');
$this->setData(['module', $this->getUrl(0), 'config', init::$defaultData]);
// Données de thème
$this->setData(['module', $this->getUrl(0), 'theme', init::$defaultTheme]);
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ]);
}
// Sauver la feuille de style
file_put_contents(self::DATADIRECTORY .$moduleId . '.css' , $style );
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
mkdir (self::DATADIRECTORY . $this->getUrl(0) , 0777, true);
}
// Stocker le nom de la feuille de style
$this->setData(['module', $moduleId, 'theme', 'style', self::DATADIRECTORY . $moduleId . '.css']);
// Check la présence de la feuille de style
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' ]) .';}';
$style .= '.newsBlur {background: linear-gradient(#333 ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'itemsBlur' ]) . ',#FFF );';
$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 );
// Stocker le nom de la feuille de style
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css']);
}
}
}

View File

@ -1,6 +1,6 @@
<?php
class init extends search {
public static $defaultData = [
public static $defaultConfig = [
'previewLength' => 100,
'resultHideContent' => false,
'placeHolder' => 'Un ou plusieurs mots-clés séparés par un espace ou par +',

View File

@ -56,7 +56,7 @@ class search extends common {
if ($this->getData(['module', $this->getUrl(0), 'previewLength']) ) {
$data = $this->getData(['module', $this->getUrl(0)]);
// Feuille de style
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '.css' ;
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ;
$this->setData(['module', $this->getUrl(0), 'config', [
'submitText' => $this->getData(['module', $this->getUrl(0), 'submitText']),
'placeHolder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']),
@ -70,8 +70,8 @@ class search extends common {
]]);
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATADIRECTORY, 0777, true);
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true);
}
// Générer la feuille de CSS
$style = '.keywordColor {background: ' . $this->getData(['module', $this->getUrl(0), 'theme', 'keywordColor']) . ';}';
@ -91,29 +91,34 @@ class search extends common {
/**
* Initialisation du module
*/
private function init($moduleId){
// Variable commune
$fileCSS = self::DATADIRECTORY . $moduleId . '.css' ;
private function init(){
// Données du module
require_once('module/search/ressource/defaultdata.php');
$this->setData(['module', $moduleId, 'config',init::$defaultData ]);
// Données de thème
$this->setData(['module', $moduleId, 'theme',init::$defaultTheme ]);
// Générer la feuille de CSS
$style = '.keywordColor {background: ' . $this->getData([ 'module', $moduleId, 'theme', 'keywordColor' ]) . ';}';
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ;
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATADIRECTORY, 0777, true);
if ($this->getData(['module', $this->getUrl(0)]) === null) {
// Données du module
require_once('module/search/ressource/defaultdata.php');
$this->setData(['module', $this->getUrl(0), 'config',init::$defaultConfig ]);
// Données de thème
$this->setData(['module', $this->getUrl(0), 'theme',init::$defaultTheme ]);
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ]);
}
// Sauver la feuille de style
file_put_contents(self::DATADIRECTORY .$moduleId . '.css' , $style );
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) {
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0777, true);
}
// Stocker le nom de la feuille de style
$this->setData(['module', $moduleId, 'theme', 'style', self::DATADIRECTORY . $moduleId . '.css']);
// Check la présence de la feuille de style
if ( !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')) {
// Générer la feuille de CSS
$style = '.keywordColor {background: ' . $this->getData([ 'module', $this->getUrl(0), 'theme', 'keywordColor' ]) . ';}';
// Sauver la feuille de 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', $fileCSS]);
}
}
@ -124,20 +129,15 @@ class search extends common {
$this->update();
// Initialisation d'un nouveau module
if ($this->getData(['module', $this->getUrl(0)]) === null) {
$this->init($this->getUrl(0));
}
$this->init();
if($this->isPost()) {
// Générer la feuille de CSS
$style = '.keywordColor {background:' . $this->getInput('searchKeywordColor') . ';}';
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY)) {
mkdir (self::DATADIRECTORY , 0777, true);
}
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '.css' , $style );
$success = file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $style );
// Fin feuille de style
// Soumission du formulaire
@ -150,7 +150,7 @@ class search extends common {
]]);
$this->setData(['module', $this->getUrl(0), 'theme',[
'keywordColor' => $this->getInput('searchKeywordColor'),
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '.css' : '',
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
]]);
@ -178,9 +178,8 @@ class search extends common {
$this->update();
// Initialisation d'un nouveau module
if ($this->getData(['module', $this->getUrl(0)]) === null) {
$this->init($this->getUrl(0));
}
$this->init();
if($this->isPost()) {
//Initialisations variables