Subversion Repositories Applications.papyrus

Rev

Rev 217 | 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
// +------------------------------------------------------------------------------------------------------+
339 jpm 24
// CVS : $Id: more_recherche_papyrus_menu.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 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
339 jpm 41
*@version       $Revision: 1.2 $ $Date: 2005-04-14 17:39:34 $
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']);
102
            $raccourci_txt =    MORE_LG_RESULTAT_CADRE_OUVRIR.
103
                                MORE_LG_RESULTAT_RACCOURCI.$menu_accesskey.' '.
104
                                MORE_LG_RESULTAT_CADRE_FERMER.MORE_LG_RESULTAT_POINT.' ';
105
            $aso_resultat['title'] = htmlentities($raccourci_txt.$aso_menu_info['gm_description_resume']);
106
 
107
            $aso_resultat['description'] = htmlentities($aso_menu_info['gm_description_libre']);
108
            if (($jour = date('d', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
109
                $aso_resultat['date_creation'] .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
110
            }
111
            if (($mois = $this->traduireMois(date('m', strtotime($aso_menu_info['gm_date_creation'] ))) ) != '' ) {
112
                $aso_resultat['date_creation'] .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
113
            }
114
            if (($annee = date('Y', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
115
                $aso_resultat['date_creation'] .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
116
            }
117
 
217 jpm 118
            // Analyse du poids de cette page
119
            $tab_champs_a_visiter = array(  'gm_nom', 'gm_titre', 'gm_titre_alternatif', 'gm_mots_cles',
120
                                            'gm_description_libre', 'gm_description_resume', 'gm_description_table_matieres',
121
                                            'gm_source', 'gm_auteur', 'gm_contributeur', 'gm_editeur', 'gm_categorie',
122
                                            'gm_public');
123
            foreach ($tab_champs_a_visiter as $val) {
124
                if (stristr($aso_menu_info[$val] , $motif)) {
125
                    $aso_resultat['poids']++;
126
                }
127
            }
128
            $nbre_correspondance = preg_match_all('/'.$motif.'/i', $aso_menu_contenu['gmc_contenu'], $tab_morceaux);
129
            $aso_resultat['poids'] = $aso_resultat['poids'] + $nbre_correspondance;
130
 
131
            if ($aso_resultat['poids'] > 0) {
132
                $this->setResultat($aso_resultat);
133
            }
134
        }
135
        return $this->getResultats();
136
    }
137
}
138
 
139
/* +--Fin du code ----------------------------------------------------------------------------------------+
140
*
141
* $Log: not supported by cvs2svn $
339 jpm 142
* Revision 1.1  2004/12/07 10:24:06  jpm
143
* Moteur de recherche version de départ.
144
*
217 jpm 145
*
146
* +-- Fin du code ----------------------------------------------------------------------------------------+
147
*/
148
?>