Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 216 → Rev 217

/trunk/papyrus/applettes/moteur_recherche/bibliotheque/more_recherche.class.php
New file
0,0 → 1,130
<?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.1 2004-12-07 10:24:06 jpm 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.1 $ $Date: 2004-12-07 10:24:06 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
class Recherche {
var $motif = '';
var $moteurs_recherches = array();
var $resultats = array();
// Constructeur
function Recherche($motif) {
$this->setMotif($motif);
}
// Accesseurs
function 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éthodes
function 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($this->getResultats(), $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');
return $aso_resultats;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>