Subversion Repositories Applications.papyrus

Rev

Rev 339 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Papyrus.                                                                        |
// |                                                                                                      |
// | Foobar is free software; you can redistribute it and/or modify                                       |
// | it under the terms of the GNU General Public License as published by                                 |
// | the Free Software Foundation; either version 2 of the License, or                                    |
// | (at your option) any later version.                                                                  |
// |                                                                                                      |
// | Foobar is distributed in the hope that it will be useful,                                            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
// | GNU General Public License for more details.                                                         |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public License                                    |
// | along with Foobar; if not, write to the Free Software                                                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: more_recherche_papyrus_menu.class.php,v 1.1 2004-12-07 10:24:06 jpm Exp $
/**
* Classe permettant d'effectuer des recherches sur les informations des menus de Papyrus.
*
* Permet de rechercher et classer les menus en fonction d'une chaine.
*
*@package Applette
*@subpackage Moteur_Recherche
//Auteur original :
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author        aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.1 $ $Date: 2004-12-07 10:24:06 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+
/** Inclusion du fichier contenant les fonctions de manipulations des menus de Papyrus.*/
    require_once GEN_CHEMIN_BIBLIO.'pap_menu.fonct.php';

// +------------------------------------------------------------------------------------------------------+
// |                                            CORPS du PROGRAMME                                        |
// +------------------------------------------------------------------------------------------------------+

class Recherche_Papyrus_Menu extends Recherche{
    
    // Constructeur
    function Recherche_Menu_Meta($motif) {
        $this->setMotif($motif);
    }
    
    // Accesseurs
    function getMotif() {
        return $this->motif;
    }
    function setMotif($motif) {
        $this->motif = $motif;
    }
    
    // Méthodes
    function rechercherMotif($motif) {
        $db = $GLOBALS['_MOTEUR_RECHERCHE_']['bd']['papyrus'];
        // Préparation de l'url de l'entrée
        $objet_pear_url = & new Net_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
        $champs_code_menu = (GEN_URL_ID_TYPE_MENU == 'int') ? 'gm_code_num' : 'gm_code_alpha';
        $tab_menus = GEN_retournerMenus($db);
        foreach ($tab_menus as $cle => $menu_id) {
            // Initialisation du tableau de résultat vide
            $aso_resultat = array('poids' => 0, 'url' => '', 'titre' => '');
            // Récupération des infos du menu courant
            $aso_menu_info = GEN_lireInfoMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
            // Récupération du contenu du menu courant
            $aso_menu_contenu = GEN_lireContenuMenu($db, $menu_id, DB_FETCHMODE_ASSOC);
            // Construction de l'url de ce menu
            $objet_pear_url->addQueryString(GEN_URL_CLE_MENU, $aso_menu_info[$champs_code_menu]);
            $aso_resultat['url'] = $objet_pear_url->getURL();
            // Récupération du titre de la page
            if ($aso_menu_info['gm_nom'] != '') {
                $aso_resultat['titre'] = $aso_menu_info['gm_nom'];
            } else if ($aso_menu_info['gm_titre'] != '') {
                $aso_resultat['titre'] = $aso_menu_info['gm_titre'];
            } else if ($aso_menu_info['gm_titre_alternatif'] != '') {
                $aso_resultat['titre'] = $aso_menu_info['gm_titre_alternatif'];
            }
            // Analyse du poids de cette page
            $tab_champs_a_visiter = array(  'gm_nom', 'gm_titre', 'gm_titre_alternatif', 'gm_mots_cles', 
                                            'gm_description_libre', 'gm_description_resume', 'gm_description_table_matieres', 
                                            'gm_source', 'gm_auteur', 'gm_contributeur', 'gm_editeur', 'gm_categorie', 
                                            'gm_public');
            foreach ($tab_champs_a_visiter as $val) {
                if (stristr($aso_menu_info[$val] , $motif)) {
                    $aso_resultat['poids']++;
                }
            }
            $nbre_correspondance = preg_match_all('/'.$motif.'/i', $aso_menu_contenu['gmc_contenu'], $tab_morceaux);
            $aso_resultat['poids'] = $aso_resultat['poids'] + $nbre_correspondance;
              
            if ($aso_resultat['poids'] > 0) {
                $this->setResultat($aso_resultat);
            }
        }
        return $this->getResultats();
    }
}

/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* 
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>