forked from ZwiiCMS-Team/ZwiiCMS
Blog 1.4 initialisation et couleur des mots clés par instance
This commit is contained in:
parent
f86eee254c
commit
0feee84a23
@ -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]);
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,10 @@
|
||||
<?php
|
||||
class theme extends search {
|
||||
public static $defaultData = [
|
||||
'keywordColor' => '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)'
|
||||
];
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
.searchTitle {
|
||||
font: caption;
|
||||
font-style: italic;
|
||||
margin-left: 1em;
|
||||
}
|
||||
.searchKeyword {
|
||||
background: var(--keywordColor);
|
||||
}
|
||||
.searchResult {
|
||||
margin: .3em 0 .3em 1em;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
.searchKeyword {
|
||||
--keywordColor: #keywordColor#;
|
||||
}
|
@ -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, '<span class="searchKeyword">\1</span>',$t);
|
||||
$t = preg_replace($keywords, '<span style="background:' . $this->getData(['module',$this->getUrl(0),'keywordColor']). ';">\1</span>',$t);
|
||||
// Sauver résultat
|
||||
$resultat .= '<p class="searchResult">'.$t.'...</p>';
|
||||
$resultat .= '<p class="searchTitle">' . count($matches[0]) . (count($matches[0]) === 1 ? ' correspondance<p>' : ' correspondances<p>');
|
||||
|
@ -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'])
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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;
|
||||
}
|
@ -3,14 +3,14 @@
|
||||
<div class="col10 offset1">
|
||||
<div class="row">
|
||||
<div class="col9 verticalAlignMiddle">
|
||||
<?php echo template::text('searchMotphraseclef', [
|
||||
'placeholder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']) ? $this->getData(['module', $this->getUrl(0), 'placeHolder']) : $module::$messagePlaceHolder,
|
||||
<?php echo "<pre>"; echo isset($module::$motclef); echo "</pre>";echo template::text('searchMotphraseclef', [
|
||||
'placeholder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']),
|
||||
'value' => $module::$motclef
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col3 verticalAlignMiddle">
|
||||
<?php echo template::submit('pageEditSubmit', [
|
||||
'value' => $this->getData(['module', $this->getUrl(0), 'submitText']) ? $this->getData(['module', $this->getUrl(0), 'submitText']) : $module::$messageButtontext
|
||||
'value' => $this->getData(['module', $this->getUrl(0), 'submitText'])
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user