Subversion Repositories Applications.papyrus

Rev

Rev 373 | Rev 846 | 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
// +------------------------------------------------------------------------------------------------------+
832 florian 24
// CVS : $Id: more_recherche_papyrus_menu.class.php,v 1.5 2006-04-28 12:41:49 florian 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
832 florian 41
*@version       $Revision: 1.5 $ $Date: 2006-04-28 12:41:49 $
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
 
217 jpm 80
            // Récupération des infos du menu courant
81
            $aso_menu_info = GEN_lireInfoMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
339 jpm 82
 
217 jpm 83
            // Récupération du contenu du menu courant
84
            $aso_menu_contenu = GEN_lireContenuMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
339 jpm 85
 
86
            // Création de l'url
87
            $une_url =& new Pap_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
88
            $une_url->setId($menu_id);
89
            $aso_resultat['url'] = $une_url->getURL();
90
 
217 jpm 91
            // Récupération du titre de la page
339 jpm 92
            if (trim($aso_menu_info['gm_nom']) != '') {
93
                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_nom']);
94
            } else if (trim($aso_menu_info['gm_titre']) != '') {
95
                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_titre']);
96
            } else if (trim($aso_menu_info['gm_titre_alternatif']) != '') {
97
                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_titre_alternatif']);
217 jpm 98
            }
339 jpm 99
            $aso_resultat['hreflang'] = htmlentities($aso_menu_info['gm_ce_i18n']);
100
            $raccourci_txt = '';
101
            $aso_resultat['accesskey'] = htmlentities($aso_menu_info['gm_raccourci_clavier']);
368 jpm 102
            if ($aso_resultat['accesskey'] != '') {
103
                $raccourci_txt =    MORE_LG_RESULTAT_CADRE_OUVRIR.
104
                                    MORE_LG_RESULTAT_RACCOURCI.$aso_resultat['accesskey'].' '.
105
                                    MORE_LG_RESULTAT_CADRE_FERMER.MORE_LG_RESULTAT_POINT.' ';
106
            }
339 jpm 107
            $aso_resultat['title'] = htmlentities($raccourci_txt.$aso_menu_info['gm_description_resume']);
108
 
109
            $aso_resultat['description'] = htmlentities($aso_menu_info['gm_description_libre']);
110
            if (($jour = date('d', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
111
                $aso_resultat['date_creation'] .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
112
            }
113
            if (($mois = $this->traduireMois(date('m', strtotime($aso_menu_info['gm_date_creation'] ))) ) != '' ) {
114
                $aso_resultat['date_creation'] .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
115
            }
116
            if (($annee = date('Y', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
117
                $aso_resultat['date_creation'] .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
118
            }
119
 
373 jpm 120
            // Analyse du poids de cette page vis à vis des méta informations
217 jpm 121
            $tab_champs_a_visiter = array(  'gm_nom', 'gm_titre', 'gm_titre_alternatif', 'gm_mots_cles',
122
                                            'gm_description_libre', 'gm_description_resume', 'gm_description_table_matieres',
123
                                            'gm_source', 'gm_auteur', 'gm_contributeur', 'gm_editeur', 'gm_categorie',
124
                                            'gm_public');
125
            foreach ($tab_champs_a_visiter as $val) {
373 jpm 126
                if (stristr($aso_menu_info[$val], $motif)) {
217 jpm 127
                    $aso_resultat['poids']++;
128
                }
129
            }
373 jpm 130
 
131
            // Analyse du poids de cette page vis à vis du contenu
832 florian 132
            $tab_morceaux='';
217 jpm 133
            $nbre_correspondance = preg_match_all('/'.$motif.'/i', $aso_menu_contenu['gmc_contenu'], $tab_morceaux);
134
            $aso_resultat['poids'] = $aso_resultat['poids'] + $nbre_correspondance;
373 jpm 135
 
217 jpm 136
            if ($aso_resultat['poids'] > 0) {
137
                $this->setResultat($aso_resultat);
138
            }
139
        }
140
        return $this->getResultats();
141
    }
142
}
143
 
144
/* +--Fin du code ----------------------------------------------------------------------------------------+
145
*
146
* $Log: not supported by cvs2svn $
832 florian 147
* Revision 1.4  2005/05/25 13:49:22  jpm
148
* Corection erreur pour la recherche dans le contenu.
149
*
373 jpm 150
* Revision 1.3  2005/05/19 12:46:12  jpm
151
* Correction bogue accesskey.
152
* Ajout d'un id à la liste.
153
* Arrondissement des score.
154
*
368 jpm 155
* Revision 1.2  2005/04/14 17:39:34  jpm
156
* Amélioration du moteur de rechercher :
157
*  - pourcentage
158
*  - ajout d'info
159
*
339 jpm 160
* Revision 1.1  2004/12/07 10:24:06  jpm
161
* Moteur de recherche version de départ.
162
*
217 jpm 163
*
164
* +-- Fin du code ----------------------------------------------------------------------------------------+
165
*/
166
?>