Subversion Repositories Applications.papyrus

Rev

Rev 443 | Rev 846 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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