Search fonction initialisation
This commit is contained in:
parent
cba87d3295
commit
9a8592cb68
@ -6,6 +6,7 @@ class init extends search {
|
|||||||
'placeHolder' => 'Un ou plusieurs mots-clés séparés par un espace ou par +',
|
'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)',
|
'keywordColor' => 'rgba(229, 229, 1, 1)',
|
||||||
'versionData' => '2.0'
|
'versionData' => '2.0',
|
||||||
|
'style' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
@ -51,35 +51,65 @@ class search extends common {
|
|||||||
* Appelée par les fonctions index et config
|
* Appelée par les fonctions index et config
|
||||||
*/
|
*/
|
||||||
private function update() {
|
private function update() {
|
||||||
// Création des valeurs de réglage par défaut
|
|
||||||
if ( !is_array($this->getData(['module', $this->getUrl(0), 'config']) ) ) {
|
|
||||||
require_once('module/search/ressource/defaultdata.php');
|
|
||||||
$this->setData(['module', $this->getUrl(0), 'config', init::$defaultData]);
|
|
||||||
}
|
|
||||||
// Version 2.0
|
// Version 2.0
|
||||||
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '2.0', '<') ) {
|
if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '2.0', '<') ) {
|
||||||
|
|
||||||
// Distinguer la config des autres données
|
$class = get_called_class();
|
||||||
|
$moduleId = $this->getUrl(0);
|
||||||
|
// Données de l'instance
|
||||||
$data = $this->getData(['module', $this->getUrl(0)]);
|
$data = $this->getData(['module', $this->getUrl(0)]);
|
||||||
$this->setData(['module', $this->getUrl(0), 'config', [
|
$this->setData(['module', $this->getUrl(0), 'config', [
|
||||||
'submitText' => $this->getData(['module', $this->getUrl(0), 'submitText']),
|
'submitText' => $this->getData(['module', $this->getUrl(0), 'submitText']),
|
||||||
'placeHolder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']),
|
'placeHolder' => $this->getData(['module', $this->getUrl(0), 'placeHolder']),
|
||||||
'resultHideContent' => $this->getData(['module', $this->getUrl(0), 'resultHideContent']),
|
'resultHideContent' => $this->getData(['module', $this->getUrl(0), 'resultHideContent']),
|
||||||
'previewLength' => $this->getData(['module', $this->getUrl(0), 'previewLength']),
|
'previewLength' => $this->getData(['module', $this->getUrl(0), 'previewLength']),
|
||||||
'keywordColor' => $this->getData(['module', $this->getUrl(0), 'keywordColor'])
|
'keywordColor' => $this->getData(['module', $this->getUrl(0), 'keywordColor']),
|
||||||
|
'style' => self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css',
|
||||||
|
'versionData' => '2.0'
|
||||||
]]);
|
]]);
|
||||||
$this->deleteData(['module', $this->getUrl(0), 'submitText']);
|
$this->deleteData(['module', $this->getUrl(0), 'submitText']);
|
||||||
$this->deleteData(['module', $this->getUrl(0), 'placeHolder']);
|
$this->deleteData(['module', $this->getUrl(0), 'placeHolder']);
|
||||||
$this->deleteData(['module', $this->getUrl(0), 'resultHideContent']);
|
$this->deleteData(['module', $this->getUrl(0), 'resultHideContent']);
|
||||||
$this->deleteData(['module', $this->getUrl(0), 'previewLength']);
|
$this->deleteData(['module', $this->getUrl(0), 'previewLength']);
|
||||||
$this->deleteData(['module', $this->getUrl(0), 'keywordColor']);
|
$this->deleteData(['module', $this->getUrl(0), 'keywordColor']);
|
||||||
$this->setData(['module', $this->getUrl(0), 'config', 'versionData','2.0']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialisation du module
|
||||||
|
* Appelée par les fonctions index et config
|
||||||
|
*/
|
||||||
|
private function init(){
|
||||||
|
// Création des valeurs de réglage par défaut
|
||||||
|
if ( !is_array($this->getData(['module', $this->getUrl(0), 'config']) ) ) {
|
||||||
|
require_once('module/search/ressource/defaultdata.php');
|
||||||
|
|
||||||
|
$class = get_called_class();
|
||||||
|
$moduleId = $this->getUrl(0);
|
||||||
|
// Sauver les données par défaut
|
||||||
|
init::$defaultData['style'] = self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css';
|
||||||
|
$this->setData(['module', $this->getUrl(0), 'config', init::$defaultData]);
|
||||||
|
|
||||||
|
$style = '.searchItem {background:' . $this->getData(['module', $this->getUrl(0), 'config', 'keywordColor']). ';}';
|
||||||
|
|
||||||
|
// Dossier de l'instance
|
||||||
|
if (!is_dir(self::DATA_DIR . 'modules/' . $class)) {
|
||||||
|
mkdir (self::DATA_DIR . 'modules/' . $class, 0777, true);
|
||||||
|
}
|
||||||
|
$success = file_put_contents(self::DATA_DIR . 'modules/' . $class . '/' . $moduleId . '.css' , $style );
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Configuration vide
|
// Configuration vide
|
||||||
public function config() {
|
public function config() {
|
||||||
|
|
||||||
|
// Initialisation d'un nouveau module
|
||||||
|
$this->init();
|
||||||
|
|
||||||
// Mise à jour des données de module
|
// Mise à jour des données de module
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
@ -128,6 +158,10 @@ class search extends common {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
|
|
||||||
|
// Initialisation d'un nouveau module
|
||||||
|
$this->init();
|
||||||
|
|
||||||
// Mise à jour des données de module
|
// Mise à jour des données de module
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col9 verticalAlignMiddle">
|
<div class="col9 verticalAlignMiddle">
|
||||||
<?php echo template::text('searchMotphraseclef', [
|
<?php echo template::text('searchMotphraseclef', [
|
||||||
'placeholder' => isset($_COOKIE['ZWII_I18N_SITE'] ) ? $this->getData(['module', $this->getUrl(0), 'placeHolder']):'Un ou plusieurs mots clef séparés par un espace',
|
'placeholder' => isset($_COOKIE['ZWII_I18N_SITE'] ) ? $this->getData(['module', $this->getUrl(0), 'config', 'placeHolder']):'Un ou plusieurs mots clef séparés par un espace',
|
||||||
'value' => $module::$motclef
|
'value' => $module::$motclef
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col3 verticalAlignMiddle">
|
<div class="col3 verticalAlignMiddle">
|
||||||
<?php echo template::submit('pageEditSubmit', [
|
<?php echo template::submit('pageEditSubmit', [
|
||||||
'value' => $this->getData(['module', $this->getUrl(0), 'submitText'])
|
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'submitText'])
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user