From 0feee84a238d7f7e420304522c3ebcb61b34dd6c Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 13 Jan 2021 18:45:39 +0100 Subject: [PATCH] =?UTF-8?q?Blog=201.4=20initialisation=20et=20couleur=20de?= =?UTF-8?q?s=20mots=20cl=C3=A9s=20par=20instance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 6 ++++ module/search/ressource/defaultdata.php | 10 ++----- module/search/ressource/theme.css | 11 ------- module/search/ressource/vartheme.css | 3 -- module/search/search.php | 40 ++++++++++--------------- module/search/view/config/config.php | 2 +- module/search/view/index/index.css | 8 ++--- module/search/view/index/index.php | 6 ++-- 8 files changed, 30 insertions(+), 56 deletions(-) delete mode 100755 module/search/ressource/theme.css delete mode 100755 module/search/ressource/vartheme.css diff --git a/core/core.php b/core/core.php index f335fbfb..4ecb5b1e 100755 --- a/core/core.php +++ b/core/core.php @@ -1577,6 +1577,12 @@ class common { } } + // Supprimer les fichiers CSS devenus inutiles du module search + if (file_exists('module/search/ressource/theme.css') ) + unlink('module/search/ressource/theme.css'); + if (file_exists('module/search/ressource/vartheme.css') ) + unlink('module/search/ressource/vartheme.css'); + $this->setData(['core', 'dataVersion', 10400]); /** diff --git a/module/search/ressource/defaultdata.php b/module/search/ressource/defaultdata.php index 4eb9eaa6..d9d5a2a2 100755 --- a/module/search/ressource/defaultdata.php +++ b/module/search/ressource/defaultdata.php @@ -1,14 +1,10 @@ 'rgba(229, 229, 1, 1)' - ]; -} -class data extends search { +class init extends search { public static $defaultData = [ 'previewLength' => 100, 'resultHideContent' => false, 'placeHolder' => 'Un ou plusieurs mots-clés séparés par un espace ou par +', - 'submitText' => 'Rechercher' + 'submitText' => 'Rechercher', + 'keywordColor' => 'rgba(229, 229, 1, 1)' ]; } \ No newline at end of file diff --git a/module/search/ressource/theme.css b/module/search/ressource/theme.css deleted file mode 100755 index 63462103..00000000 --- a/module/search/ressource/theme.css +++ /dev/null @@ -1,11 +0,0 @@ -.searchTitle { - font: caption; - font-style: italic; - margin-left: 1em; -} -.searchKeyword { - background: var(--keywordColor); -} -.searchResult { - margin: .3em 0 .3em 1em; -} \ No newline at end of file diff --git a/module/search/ressource/vartheme.css b/module/search/ressource/vartheme.css deleted file mode 100755 index 9a5c4cdb..00000000 --- a/module/search/ressource/vartheme.css +++ /dev/null @@ -1,3 +0,0 @@ -.searchKeyword { - --keywordColor: #keywordColor#; -} diff --git a/module/search/search.php b/module/search/search.php index 4ad083e5..f84dfdeb 100755 --- a/module/search/search.php +++ b/module/search/search.php @@ -38,37 +38,31 @@ class search extends common { 400 => '400 caractères', ]; - // Message par défaut - public static $messagePlaceHolder = 'Un ou plusieurs mots-clés entre des espaces ou des guillemets'; - public static $messageButtontext = 'Rechercher'; - - const SEARCH_VERSION = '1.1'; + const SEARCH_VERSION = '1.2'; // Configuration vide public function config() { - // Initialisation des données de thème de la galerie dasn theme.json + // Création des valeurs de réglage par défaut + if ( $this->getData(['module', $this->getUrl(0)]) === null ) { + require_once('module/search/ressource/defaultdata.php'); + $this->setData(['module', $this->getUrl(0), init::$defaultData]); + } + if($this->isPost()) { // Soumission du formulaire - $this->setData(['theme', 'search', [ - 'keywordColor' => $this->getInput('searchKeywordColor') - ]]); $this->setData(['module', $this->getUrl(0), [ 'submitText' => $this->getInput('searchSubmitText'), 'placeHolder' => $this->getInput('searchPlaceHolder'), 'resultHideContent' => $this->getInput('searchResultHideContent',helper::FILTER_BOOLEAN), - 'previewLength' => $this->getInput('searchPreviewLength',helper::FILTER_INT) + 'previewLength' => $this->getInput('searchPreviewLength',helper::FILTER_INT), + 'keywordColor' => $this->getInput('searchKeywordColor') ]]); - // Création des fichiers CSS - $content = file_get_contents('module/search/ressource/vartheme.css'); - $themeCss = file_get_contents('module/search/ressource/theme.css'); - // Injection des variables - $content = str_replace('#keywordColor#',$this->getinput('searchKeywordColor'),$content ); - $success = file_put_contents('module/search/view/index/index.css',$content . $themeCss); + // Valeurs en sortie, affichage du formulaire $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), - 'notification' => $success !== FALSE ? 'Modifications enregistrées' : 'Modifications non enregistées !', + 'notification' => $success !== FALSE ? 'Modifications enregistrées' : 'Modifications non enregistrées !', 'state' => $success !== FALSE ]); @@ -84,15 +78,11 @@ class search extends common { } public function index() { - // Création des valeurs de thème par défaut - if ( $this->getData(['theme', 'search']) === null ) { - require_once('module/search/ressource/defaultdata.php'); - $this->setData(['theme', 'search', theme::$defaultData]); - } + // Création des valeurs de réglage par défaut - if ( $this->getData(['module', 'search']) === null ) { + if ( $this->getData(['module', $this->getUrl(0)]) === null ) { require_once('module/search/ressource/defaultdata.php'); - $this->setData(['module', $this->getUrl(0), data::$defaultData]); + $this->setData(['module', $this->getUrl(0), init::$defaultData]); } if($this->isPost()) { @@ -241,7 +231,7 @@ class search extends common { // Découper l'aperçu $t = substr($contenu, $d ,$this->getData(['module',$this->getUrl(0),'previewLength'])); // Applique une mise en évidence - $t = preg_replace($keywords, '\1',$t); + $t = preg_replace($keywords, '\1',$t); // Sauver résultat $resultat .= '

'.$t.'...

'; $resultat .= '

' . count($matches[0]) . (count($matches[0]) === 1 ? ' correspondance

' : ' correspondances

'); diff --git a/module/search/view/config/config.php b/module/search/view/config/config.php index 8280ee9a..37a60653 100755 --- a/module/search/view/config/config.php +++ b/module/search/view/config/config.php @@ -59,7 +59,7 @@ 'class' => 'colorPicker', 'help' => 'Le curseur horizontal règle le niveau de transparence, le placer tout à la gauche pour un surlignement invisible.', 'label' => 'Surlignement', - 'value' => $this->getData(['theme', 'search', 'keywordColor']) + 'value' => $this->getData(['module', $this->getUrl(0), 'keywordColor']) ]); ?> diff --git a/module/search/view/index/index.css b/module/search/view/index/index.css index 8e5dc743..f3b5d574 100755 --- a/module/search/view/index/index.css +++ b/module/search/view/index/index.css @@ -1,14 +1,10 @@ -.searchKeyword { - --keywordColor: rgba(229, 229, 1, 1); -} + .searchTitle { font: caption; font-style: italic; margin-left: 1em; } -.searchKeyword { - background: var(--keywordColor); -} + .searchResult { margin: .3em 0 .3em 1em; } \ No newline at end of file diff --git a/module/search/view/index/index.php b/module/search/view/index/index.php index 4399c591..c766e21c 100755 --- a/module/search/view/index/index.php +++ b/module/search/view/index/index.php @@ -3,14 +3,14 @@

- $this->getData(['module', $this->getUrl(0), 'placeHolder']) ? $this->getData(['module', $this->getUrl(0), 'placeHolder']) : $module::$messagePlaceHolder, + "; echo isset($module::$motclef); echo "";echo template::text('searchMotphraseclef', [ + 'placeholder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']), 'value' => $module::$motclef ]); ?>
$this->getData(['module', $this->getUrl(0), 'submitText']) ? $this->getData(['module', $this->getUrl(0), 'submitText']) : $module::$messageButtontext + 'value' => $this->getData(['module', $this->getUrl(0), 'submitText']) ]); ?>