From 016790052cf6cb6ab8c67cf75b8ce885c60ccba8 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 20 Aug 2020 16:11:11 +0200 Subject: [PATCH] =?UTF-8?q?Dimension=20de=20l'aper=C3=A7u?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/search/search.php | 14 ++++++++++---- module/search/view/config/config.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/module/search/search.php b/module/search/search.php index c18a221f..9477be85 100755 --- a/module/search/search.php +++ b/module/search/search.php @@ -23,14 +23,20 @@ class search extends common { 'config' => self::GROUP_MODERATOR ]; - // Variable pour l'affichage des résultats + // Variables pour l'affichage des résultats public static $resultList = ''; public static $resultError = ''; public static $resultTitle = ''; - public static $nbResults = 0; + // Variables pour le dialogue avec le formulaire public static $motclef = ''; public static $motentier = ''; + public static $previewLength = [ + 100 => '100 caractères', + 200 => '200 caractères', + 300 => '300 caractères', + 400 => '400 caractères', + ]; const SEARCH_VERSION = '1.1'; @@ -51,6 +57,7 @@ class search extends common { 'submitText' => $this->getInput('searchSubmitText'), 'placeHolder' => $this->getInput('searchPlaceHolder'), 'resultHideContent' => $this->getInput('searchResultHideContent',helper::FILTER_BOOLEAN), + 'previewLength' => $this->getInput('searchPreviewLength',helper::FILTER_INT) ]]); // Création des fichiers CSS $content = file_get_contents('module/search/ressource/vartheme.css'); @@ -84,7 +91,6 @@ class search extends common { $result = []; $notification = ''; $total=''; - self::$nbResults = 0; // Récupération du mot clef passé par le formulaire de ...view/index.php, avec caractères accentués self::$motclef=$this->getInput('searchMotphraseclef'); @@ -221,7 +227,7 @@ class search extends common { // Rechercher l'espace le plus proche $d = $d > 1 ? strpos($contenu,' ',$d) : $d; // Découper l'aperçu - $t = substr($contenu,(int) $d ,300); + $t = substr($contenu,(int) $d ,$this->getData(['module',$this->getUrl(0),'previewLength'])); // Applique une mise en évidence $t = preg_replace($motclef, '\1',$t); // Sauver résultat diff --git a/module/search/view/config/config.php b/module/search/view/config/config.php index 4bf0ffe8..ba56088d 100755 --- a/module/search/view/config/config.php +++ b/module/search/view/config/config.php @@ -17,13 +17,21 @@

Paramètres du module

-
+
'Texte du bouton', 'value' => $this->getData(['module', $this->getUrl(0), 'submitText']) ? $this->getData(['module', $this->getUrl(0), 'submitText']) : 'Rechercher' ]); ?>
-
+
+ 'Dimension de l\'aperçu', + 'selected' => $this->getData(['module', $this->getUrl(0),'previewLength']) + ]); ?> +
+
+
+
'Aide dans la zone de saisie', 'value' => $this->getData(['module', $this->getUrl(0), 'placeHolder']) ? $this->getData(['module', $this->getUrl(0), 'placeHolder']) : 'Un ou plusieurs mots-clés séparés par un espace ou par +'