Subversion Repositories Applications.papyrus

Rev

Rev 1034 | Rev 1062 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
// +------------------------------------------------------------------------------------------------------+
1052 jp_milcent 24
// CVS : $Id: more_recherche_papyrus_menu.class.php,v 1.10 2006-11-20 09:36:59 jp_milcent Exp $
217 jpm 25
/**
26
* Classe permettant d'effectuer des recherches sur les informations des menus de Papyrus.
27
*
28
* Permet de rechercher et classer les menus en fonction d'une chaine.
339 jpm 29
* Utilisation des bibliothèques inclue par Papyrus :
30
* - Papyrus pap_meta.fonct.php
31
* - Papyrus pap_menu.fonct.php
32
* - Papyrus pap_url.class.php
217 jpm 33
*
34
*@package Applette
35
*@subpackage Moteur_Recherche
36
//Auteur original :
37
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
38
//Autres auteurs :
39
*@author        aucun
40
*@copyright     Tela-Botanica 2000-2004
1052 jp_milcent 41
*@version       $Revision: 1.10 $ $Date: 2006-11-20 09:36:59 $
217 jpm 42
// +------------------------------------------------------------------------------------------------------+
43
*/
44
 
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                            ENTETE du PROGRAMME                                       |
47
// +------------------------------------------------------------------------------------------------------+
339 jpm 48
///** Inclusion du fichier contenant les fonctions de manipulations des menus de Papyrus.*/
49
//require_once GEN_CHEMIN_BIBLIO.'pap_menu.fonct.php';
217 jpm 50
 
51
// +------------------------------------------------------------------------------------------------------+
52
// |                                            CORPS du PROGRAMME                                        |
53
// +------------------------------------------------------------------------------------------------------+
54
 
55
class Recherche_Papyrus_Menu extends Recherche{
56
 
57
    // Constructeur
58
    function Recherche_Menu_Meta($motif) {
59
        $this->setMotif($motif);
60
    }
61
 
62
    // Accesseurs
63
    function getMotif() {
64
        return $this->motif;
65
    }
66
    function setMotif($motif) {
67
        $this->motif = $motif;
68
    }
69
 
70
    // Méthodes
71
    function rechercherMotif($motif) {
72
        $db = $GLOBALS['_MOTEUR_RECHERCHE_']['bd']['papyrus'];
73
        $tab_menus = GEN_retournerMenus($db);
74
        foreach ($tab_menus as $cle => $menu_id) {
75
            // Initialisation du tableau de résultat vide
339 jpm 76
            $aso_resultat = array(  'poids' => 0, 'url' => '', 'titre' => '',
77
                                    'hreflang' => '', 'accesskey' => '', 'title' => '',
78
                                    'date_creation' => '', 'description' => '');
79
 
1034 jp_milcent 80
            // Récupération des infos du menu courant : transtypage pour éviter les erreur avec array_merge
81
            $aso_menu_info = (array) GEN_lireInfoMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
339 jpm 82
 
1034 jp_milcent 83
            // Récupération du contenu du menu courant : transtypage pour éviter les erreur avec array_merge
84
            $aso_menu_contenu = (array) GEN_lireContenuMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
1032 jp_milcent 85
 
86
			// Fusion des deux tableaux de champs à analyser
87
			$aso_menu = array_merge($aso_menu_info, $aso_menu_contenu);
88
 
89
            // Analyse du poids de cette page vis à vis des méta informations et du contenu
217 jpm 90
            $tab_champs_a_visiter = array(  'gm_nom', 'gm_titre', 'gm_titre_alternatif', 'gm_mots_cles',
91
                                            'gm_description_libre', 'gm_description_resume', 'gm_description_table_matieres',
92
                                            'gm_source', 'gm_auteur', 'gm_contributeur', 'gm_editeur', 'gm_categorie',
1032 jp_milcent 93
                                            'gm_public', 'gmc_contenu');
1034 jp_milcent 94
			foreach ($tab_champs_a_visiter as $val) {
95
                // Vérification que le champ existe et contient quelque chose
96
                if (isset($aso_menu[$val]) && $aso_menu[$val] != '') {
97
					$aso_resultat['poids'] += $this->retournerOccurenceMotif($motif, $aso_menu[$val]);
1032 jp_milcent 98
                }
217 jpm 99
            }
373 jpm 100
 
1032 jp_milcent 101
            // Si le menu contient les mots recherchés nous poursuivons
1034 jp_milcent 102
			if ($aso_resultat['poids'] > 0) {
1032 jp_milcent 103
                // Création de l'url
104
	            // TODO : utiliser comme pour spip un fichier de config spécifique pour virer PAP_URL d'ici
105
	            $une_url =& new Pap_URL(PAP_URL);
106
	            $une_url->setId($menu_id);
1052 jp_milcent 107
	            $aso_resultat['url_simple'] = $une_url->getURL();
1032 jp_milcent 108
	            $aso_resultat['url'] = $une_url->getURL();
109
 
110
	            // Récupération du titre de la page
111
	            if (trim($aso_menu_info['gm_nom']) != '') {
112
	                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_nom']);
113
	            } else if (trim($aso_menu_info['gm_titre']) != '') {
114
	                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_titre']);
115
	            } else if (trim($aso_menu_info['gm_titre_alternatif']) != '') {
116
	                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_titre_alternatif']);
117
	            }
118
	            $aso_resultat['hreflang'] = htmlentities($aso_menu_info['gm_ce_i18n']);
119
	            $raccourci_txt = '';
120
	            $aso_resultat['accesskey'] = htmlentities($aso_menu_info['gm_raccourci_clavier']);
121
	            if ($aso_resultat['accesskey'] != '') {
122
	                $raccourci_txt =    MORE_LG_RESULTAT_CADRE_OUVRIR.
123
	                                    MORE_LG_RESULTAT_RACCOURCI.$aso_resultat['accesskey'].' '.
124
	                                    MORE_LG_RESULTAT_CADRE_FERMER.MORE_LG_RESULTAT_POINT.' ';
125
	            }
126
	            $aso_resultat['title'] = htmlentities($raccourci_txt.$aso_menu_info['gm_description_resume']);
127
 
128
	            $aso_resultat['description'] = htmlentities($aso_menu_info['gm_description_libre']);
129
	            if (($jour = date('d', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
130
	                $aso_resultat['date_creation'] .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
131
	            }
132
	            if (($mois = $this->traduireMois(date('m', strtotime($aso_menu_info['gm_date_creation'] ))) ) != '' ) {
133
	                $aso_resultat['date_creation'] .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
134
	            }
135
	            if (($annee = date('Y', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
136
	                $aso_resultat['date_creation'] .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
137
	            }
138
 
217 jpm 139
                $this->setResultat($aso_resultat);
140
            }
141
        }
142
        return $this->getResultats();
143
    }
144
}
145
 
146
/* +--Fin du code ----------------------------------------------------------------------------------------+
147
*
148
* $Log: not supported by cvs2svn $
1052 jp_milcent 149
* Revision 1.9  2006/10/17 09:21:40  jp_milcent
150
* Mise en commun des spécifications de la recherche.
151
*
1034 jp_milcent 152
* Revision 1.8  2006/10/16 14:11:30  jp_milcent
153
* Amélioration du moteur de recherche.
154
* Utilisation de l'opérateur "et" entre les mots recherchés.
155
*
1032 jp_milcent 156
* Revision 1.7  2006/10/10 13:28:13  jp_milcent
157
* Suppression d'une variable et utilisation de la constante PAP_URL
158
*
1027 jp_milcent 159
* Revision 1.6  2006/05/19 10:04:55  jp_milcent
160
* Ajout d'un moteur de recherche analysant les articles des sites sous Spip.
161
*
846 jp_milcent 162
* Revision 1.5  2006/04/28 12:41:49  florian
163
* corrections erreurs chemin
164
*
832 florian 165
* Revision 1.4  2005/05/25 13:49:22  jpm
166
* Corection erreur pour la recherche dans le contenu.
167
*
373 jpm 168
* Revision 1.3  2005/05/19 12:46:12  jpm
169
* Correction bogue accesskey.
170
* Ajout d'un id à la liste.
171
* Arrondissement des score.
172
*
368 jpm 173
* Revision 1.2  2005/04/14 17:39:34  jpm
174
* Amélioration du moteur de rechercher :
175
*  - pourcentage
176
*  - ajout d'info
177
*
339 jpm 178
* Revision 1.1  2004/12/07 10:24:06  jpm
179
* Moteur de recherche version de départ.
180
*
217 jpm 181
*
182
* +-- Fin du code ----------------------------------------------------------------------------------------+
183
*/
184
?>