Rev 373 | Rev 846 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*vim: set expandtab tabstop=4 shiftwidth=4: */// +------------------------------------------------------------------------------------------------------+// | PHP version 4.1 |// +------------------------------------------------------------------------------------------------------+// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |// +------------------------------------------------------------------------------------------------------+// | This file is part of Papyrus. |// | |// | Foobar is free software; you can redistribute it and/or modify |// | it under the terms of the GNU General Public License as published by |// | the Free Software Foundation; either version 2 of the License, or |// | (at your option) any later version. |// | |// | Foobar is distributed in the hope that it will be useful, |// | but WITHOUT ANY WARRANTY; without even the implied warranty of |// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |// | GNU General Public License for more details. |// | |// | You should have received a copy of the GNU General Public License |// | along with Foobar; if not, write to the Free Software |// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |// +------------------------------------------------------------------------------------------------------+// CVS : $Id: more_recherche.class.php,v 1.5 2005-09-20 17:01:22 ddelon Exp $/*** Classe permettant d'effectuer des recherches sur les métas informations des menus.** Permet de rechercher et classer les menus en fonction d'une chaine.**@package Applette*@subpackage Moteur_Recherche//Auteur original :*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>//Autres auteurs :*@author aucun*@copyright Tela-Botanica 2000-2004*@version $Revision: 1.5 $ $Date: 2005-09-20 17:01:22 $// +------------------------------------------------------------------------------------------------------+*/// +------------------------------------------------------------------------------------------------------+// | ENTETE du PROGRAMME |// +------------------------------------------------------------------------------------------------------+// +------------------------------------------------------------------------------------------------------+// | CORPS du PROGRAMME |// +------------------------------------------------------------------------------------------------------+class Recherche {var $motif = '';var $moteurs_recherches = array();var $resultats = array();// Constructeurfunction Recherche($motif) {$this->setMotif($motif);}// Accesseursfunction getMotif() {return $this->motif;}function setMotif($motif) {$this->motif = $motif;}function getMoteurs() {return $this->moteurs_recherches;}function getMoteur($id) {return $this->moteurs_recherches[$id];}function setMoteur($val) {$id_nouveau = count($this->moteurs_recherches);$this->moteurs_recherches[$id_nouveau] = $val;}function getResultats() {return $this->resultats;}function setResultats($val) {$this->resultats = $val;}function setResultat($aso_page) {$id_nouveau = count($this->resultats);$this->resultats[$id_nouveau] = $aso_page;}// Méthodesfunction ajouterRecherche(&$objet_recherche) {return $this->setMoteur($objet_recherche);}/*function supprimerRecherche($id_objet_recherche) {if (isset($this->getMoteur($id_objet_recherche))) {$this->setMoteur($id_objet_recherche, null);return true;} else {return false;}}*/function rechercherMotif() {foreach ($this->getMoteurs() as $cle => $val) {$this->setResultats(array_merge((array)$this->getResultats(),(array) $val->rechercherMotif($this->getMotif())));}$aso_resultats = $this->getResultats();function comparer($a, $b) {if ($a['poids'] > $b['poids']) {return -1;}if ($a['poids'] < $b['poids']) {return +1;}if ($a['poids'] = $b['poids']) {return 0;}}usort($aso_resultats, 'comparer');$pds_max = 0;if (isset($aso_resultats[0]['poids'])) {$pds_max = $aso_resultats[0]['poids'];}for ($i = 0 ; $i < count($aso_resultats) ; $i++) {$aso_resultats[$i]['score'] = round((100 / $pds_max) * $aso_resultats[$i]['poids'], 1);}return $aso_resultats;}function traduireMois($mois_numerique){switch ($mois_numerique) {case '01' :return 'janvier';break;case '02' :return 'février';break;case '03' :return 'mars';break;case '04' :return 'avril';break;case '05' :return 'mai';break;case '06' :return 'juin';break;case '07' :return 'juillet';break;case '08' :return 'août';break;case '09' :return 'septembre';break;case '10' :return 'octobre';break;case '11' :return 'novembre';break;case '12' :return 'décembre';break;default:return '';break;}}}/* +--Fin du code ----------------------------------------------------------------------------------------+** $Log: not supported by cvs2svn $* Revision 1.4 2005/05/25 13:49:22 jpm* Corection erreur pour la recherche dans le contenu.** Revision 1.3 2005/05/19 12:46:12 jpm* Correction bogue accesskey.* Ajout d'un id à la liste.* Arrondissement des score.** Revision 1.2 2005/04/14 17:39:34 jpm* Amélioration du moteur de rechercher :* - pourcentage* - ajout d'info** Revision 1.1 2004/12/07 10:24:06 jpm* Moteur de recherche version de départ.*** +-- Fin du code ----------------------------------------------------------------------------------------+*/?>