217 |
jpm |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of Papyrus. |
|
|
|
9 |
// | |
|
|
|
10 |
// | Foobar is free software; you can redistribute it and/or modify |
|
|
|
11 |
// | it under the terms of the GNU General Public License as published by |
|
|
|
12 |
// | the Free Software Foundation; either version 2 of the License, or |
|
|
|
13 |
// | (at your option) any later version. |
|
|
|
14 |
// | |
|
|
|
15 |
// | Foobar is distributed in the hope that it will be useful, |
|
|
|
16 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
17 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
18 |
// | GNU General Public License for more details. |
|
|
|
19 |
// | |
|
|
|
20 |
// | You should have received a copy of the GNU General Public License |
|
|
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
|
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
339 |
jpm |
24 |
// CVS : $Id: more_recherche.class.php,v 1.2 2005-04-14 17:39:34 jpm Exp $
|
217 |
jpm |
25 |
/**
|
|
|
26 |
* Classe permettant d'effectuer des recherches sur les métas informations des menus.
|
|
|
27 |
*
|
|
|
28 |
* Permet de rechercher et classer les menus en fonction d'une chaine.
|
|
|
29 |
*
|
|
|
30 |
*@package Applette
|
|
|
31 |
*@subpackage Moteur_Recherche
|
|
|
32 |
//Auteur original :
|
|
|
33 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
34 |
//Autres auteurs :
|
|
|
35 |
*@author aucun
|
|
|
36 |
*@copyright Tela-Botanica 2000-2004
|
339 |
jpm |
37 |
*@version $Revision: 1.2 $ $Date: 2005-04-14 17:39:34 $
|
217 |
jpm |
38 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
39 |
*/
|
|
|
40 |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
// | ENTETE du PROGRAMME |
|
|
|
43 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
47 |
// | CORPS du PROGRAMME |
|
|
|
48 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
49 |
|
|
|
50 |
class Recherche {
|
|
|
51 |
var $motif = '';
|
|
|
52 |
var $moteurs_recherches = array();
|
|
|
53 |
var $resultats = array();
|
|
|
54 |
|
|
|
55 |
// Constructeur
|
|
|
56 |
function Recherche($motif) {
|
|
|
57 |
$this->setMotif($motif);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
// Accesseurs
|
|
|
61 |
function getMotif() {
|
|
|
62 |
return $this->motif;
|
|
|
63 |
}
|
|
|
64 |
function setMotif($motif) {
|
|
|
65 |
$this->motif = $motif;
|
|
|
66 |
}
|
|
|
67 |
function getMoteurs() {
|
|
|
68 |
return $this->moteurs_recherches;
|
|
|
69 |
}
|
|
|
70 |
function getMoteur($id) {
|
|
|
71 |
return $this->moteurs_recherches[$id];
|
|
|
72 |
}
|
|
|
73 |
function setMoteur($val) {
|
|
|
74 |
$id_nouveau = count($this->moteurs_recherches);
|
|
|
75 |
$this->moteurs_recherches[$id_nouveau] = $val;
|
|
|
76 |
}
|
|
|
77 |
function getResultats() {
|
|
|
78 |
return $this->resultats;
|
|
|
79 |
}
|
|
|
80 |
function setResultats($val) {
|
|
|
81 |
$this->resultats = $val;
|
|
|
82 |
}
|
|
|
83 |
function setResultat($aso_page) {
|
|
|
84 |
$id_nouveau = count($this->resultats);
|
|
|
85 |
$this->resultats[$id_nouveau] = $aso_page;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
// Méthodes
|
|
|
89 |
|
|
|
90 |
function ajouterRecherche(&$objet_recherche) {
|
|
|
91 |
return $this->setMoteur($objet_recherche);
|
|
|
92 |
}
|
|
|
93 |
/*
|
|
|
94 |
function supprimerRecherche($id_objet_recherche) {
|
|
|
95 |
if (isset($this->getMoteur($id_objet_recherche))) {
|
|
|
96 |
$this->setMoteur($id_objet_recherche, null);
|
|
|
97 |
return true;
|
|
|
98 |
} else {
|
|
|
99 |
return false;
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
*/
|
|
|
103 |
function rechercherMotif() {
|
|
|
104 |
foreach ($this->getMoteurs() as $cle => $val) {
|
|
|
105 |
$this->setResultats(array_merge($this->getResultats(), $val->rechercherMotif($this->getMotif())));
|
|
|
106 |
}
|
|
|
107 |
$aso_resultats = $this->getResultats();
|
|
|
108 |
function comparer($a, $b) {
|
|
|
109 |
if ($a['poids'] > $b['poids']) {
|
|
|
110 |
return -1;
|
|
|
111 |
}
|
|
|
112 |
if ($a['poids'] < $b['poids']) {
|
|
|
113 |
return +1;
|
|
|
114 |
}
|
|
|
115 |
if ($a['poids'] = $b['poids']) {
|
|
|
116 |
return 0;
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
usort($aso_resultats, 'comparer');
|
339 |
jpm |
120 |
$pds_max = $aso_resultats[0]['poids'];
|
|
|
121 |
for ($i = 0 ; $i < count($aso_resultats) ; $i++) {
|
|
|
122 |
$aso_resultats[$i]['score'] = (100 / $pds_max) * $aso_resultats[$i]['poids'];
|
|
|
123 |
}
|
|
|
124 |
|
217 |
jpm |
125 |
return $aso_resultats;
|
|
|
126 |
}
|
339 |
jpm |
127 |
|
|
|
128 |
function traduireMois($mois_numerique)
|
|
|
129 |
{
|
|
|
130 |
switch ($mois_numerique) {
|
|
|
131 |
case '01' :
|
|
|
132 |
return 'janvier';
|
|
|
133 |
break;
|
|
|
134 |
case '02' :
|
|
|
135 |
return 'février';
|
|
|
136 |
break;
|
|
|
137 |
case '03' :
|
|
|
138 |
return 'mars';
|
|
|
139 |
break;
|
|
|
140 |
case '04' :
|
|
|
141 |
return 'avril';
|
|
|
142 |
break;
|
|
|
143 |
case '05' :
|
|
|
144 |
return 'mai';
|
|
|
145 |
break;
|
|
|
146 |
case '06' :
|
|
|
147 |
return 'juin';
|
|
|
148 |
break;
|
|
|
149 |
case '07' :
|
|
|
150 |
return 'juillet';
|
|
|
151 |
break;
|
|
|
152 |
case '08' :
|
|
|
153 |
return 'août';
|
|
|
154 |
break;
|
|
|
155 |
case '09' :
|
|
|
156 |
return 'septembre';
|
|
|
157 |
break;
|
|
|
158 |
case '10' :
|
|
|
159 |
return 'octobre';
|
|
|
160 |
break;
|
|
|
161 |
case '11' :
|
|
|
162 |
return 'novembre';
|
|
|
163 |
break;
|
|
|
164 |
case '12' :
|
|
|
165 |
return 'décembre';
|
|
|
166 |
break;
|
|
|
167 |
default:
|
|
|
168 |
return '';
|
|
|
169 |
break;
|
|
|
170 |
}
|
|
|
171 |
}
|
217 |
jpm |
172 |
}
|
|
|
173 |
|
|
|
174 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
175 |
*
|
|
|
176 |
* $Log: not supported by cvs2svn $
|
339 |
jpm |
177 |
* Revision 1.1 2004/12/07 10:24:06 jpm
|
|
|
178 |
* Moteur de recherche version de départ.
|
|
|
179 |
*
|
217 |
jpm |
180 |
*
|
|
|
181 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
182 |
*/
|
|
|
183 |
?>
|