Subversion Repositories Applications.papyrus

Rev

Rev 339 | Go to most recent revision | Details | 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
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: more_recherche_papyrus_menu.class.php,v 1.1 2004-12-07 10:24:06 jpm Exp $
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.
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
37
*@version       $Revision: 1.1 $ $Date: 2004-12-07 10:24:06 $
38
// +------------------------------------------------------------------------------------------------------+
39
*/
40
 
41
// +------------------------------------------------------------------------------------------------------+
42
// |                                            ENTETE du PROGRAMME                                       |
43
// +------------------------------------------------------------------------------------------------------+
44
/** Inclusion du fichier contenant les fonctions de manipulations des menus de Papyrus.*/
45
    require_once GEN_CHEMIN_BIBLIO.'pap_menu.fonct.php';
46
 
47
// +------------------------------------------------------------------------------------------------------+
48
// |                                            CORPS du PROGRAMME                                        |
49
// +------------------------------------------------------------------------------------------------------+
50
 
51
class Recherche_Papyrus_Menu extends Recherche{
52
 
53
    // Constructeur
54
    function Recherche_Menu_Meta($motif) {
55
        $this->setMotif($motif);
56
    }
57
 
58
    // Accesseurs
59
    function getMotif() {
60
        return $this->motif;
61
    }
62
    function setMotif($motif) {
63
        $this->motif = $motif;
64
    }
65
 
66
    // Méthodes
67
    function rechercherMotif($motif) {
68
        $db = $GLOBALS['_MOTEUR_RECHERCHE_']['bd']['papyrus'];
69
        // Préparation de l'url de l'entrée
70
        $objet_pear_url = & new Net_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
71
        $champs_code_menu = (GEN_URL_ID_TYPE_MENU == 'int') ? 'gm_code_num' : 'gm_code_alpha';
72
        $tab_menus = GEN_retournerMenus($db);
73
        foreach ($tab_menus as $cle => $menu_id) {
74
            // Initialisation du tableau de résultat vide
75
            $aso_resultat = array('poids' => 0, 'url' => '', 'titre' => '');
76
            // Récupération des infos du menu courant
77
            $aso_menu_info = GEN_lireInfoMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
78
            // Récupération du contenu du menu courant
79
            $aso_menu_contenu = GEN_lireContenuMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
80
            // Construction de l'url de ce menu
81
            $objet_pear_url->addQueryString(GEN_URL_CLE_MENU, $aso_menu_info[$champs_code_menu]);
82
            $aso_resultat['url'] = $objet_pear_url->getURL();
83
            // Récupération du titre de la page
84
            if ($aso_menu_info['gm_nom'] != '') {
85
                $aso_resultat['titre'] = $aso_menu_info['gm_nom'];
86
            } else if ($aso_menu_info['gm_titre'] != '') {
87
                $aso_resultat['titre'] = $aso_menu_info['gm_titre'];
88
            } else if ($aso_menu_info['gm_titre_alternatif'] != '') {
89
                $aso_resultat['titre'] = $aso_menu_info['gm_titre_alternatif'];
90
            }
91
            // Analyse du poids de cette page
92
            $tab_champs_a_visiter = array(  'gm_nom', 'gm_titre', 'gm_titre_alternatif', 'gm_mots_cles',
93
                                            'gm_description_libre', 'gm_description_resume', 'gm_description_table_matieres',
94
                                            'gm_source', 'gm_auteur', 'gm_contributeur', 'gm_editeur', 'gm_categorie',
95
                                            'gm_public');
96
            foreach ($tab_champs_a_visiter as $val) {
97
                if (stristr($aso_menu_info[$val] , $motif)) {
98
                    $aso_resultat['poids']++;
99
                }
100
            }
101
            $nbre_correspondance = preg_match_all('/'.$motif.'/i', $aso_menu_contenu['gmc_contenu'], $tab_morceaux);
102
            $aso_resultat['poids'] = $aso_resultat['poids'] + $nbre_correspondance;
103
 
104
            if ($aso_resultat['poids'] > 0) {
105
                $this->setResultat($aso_resultat);
106
            }
107
        }
108
        return $this->getResultats();
109
    }
110
}
111
 
112
/* +--Fin du code ----------------------------------------------------------------------------------------+
113
*
114
* $Log: not supported by cvs2svn $
115
*
116
* +-- Fin du code ----------------------------------------------------------------------------------------+
117
*/
118
?>