Subversion Repositories Applications.papyrus

Rev

Rev 373 | Rev 846 | 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.5 2006-04-28 12:41:49 florian 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.
* Utilisation des bibliothèques inclue par Papyrus :
* - Papyrus pap_meta.fonct.php
* - Papyrus pap_menu.fonct.php
* - Papyrus pap_url.class.php
*
*@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.5 $ $Date: 2006-04-28 12:41:49 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            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'];
        $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' => '',
                                    'hreflang' => '', 'accesskey' => '', 'title' => '',
                                    'date_creation' => '', 'description' => '');
            
            // 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);
            
            // Création de l'url
            $une_url =& new Pap_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
            $une_url->setId($menu_id);
            $aso_resultat['url'] = $une_url->getURL();
            
            // Récupération du titre de la page
            if (trim($aso_menu_info['gm_nom']) != '') {
                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_nom']);
            } else if (trim($aso_menu_info['gm_titre']) != '') {
                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_titre']);
            } else if (trim($aso_menu_info['gm_titre_alternatif']) != '') {
                $aso_resultat['titre'] = htmlentities($aso_menu_info['gm_titre_alternatif']);
            }
            $aso_resultat['hreflang'] = htmlentities($aso_menu_info['gm_ce_i18n']);
            $raccourci_txt = '';
            $aso_resultat['accesskey'] = htmlentities($aso_menu_info['gm_raccourci_clavier']);
            if ($aso_resultat['accesskey'] != '') {
                $raccourci_txt =    MORE_LG_RESULTAT_CADRE_OUVRIR.
                                    MORE_LG_RESULTAT_RACCOURCI.$aso_resultat['accesskey'].' '.
                                    MORE_LG_RESULTAT_CADRE_FERMER.MORE_LG_RESULTAT_POINT.' ';
            }
            $aso_resultat['title'] = htmlentities($raccourci_txt.$aso_menu_info['gm_description_resume']);
            
            $aso_resultat['description'] = htmlentities($aso_menu_info['gm_description_libre']);
            if (($jour = date('d', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
                $aso_resultat['date_creation'] .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
            }
            if (($mois = $this->traduireMois(date('m', strtotime($aso_menu_info['gm_date_creation'] ))) ) != '' ) {
                $aso_resultat['date_creation'] .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
            }
            if (($annee = date('Y', strtotime($aso_menu_info['gm_date_creation'] )) ) != 0 ) {
                $aso_resultat['date_creation'] .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
            }
            
            // Analyse du poids de cette page vis à vis des méta informations
            $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']++;
                }
            }
            
            // Analyse du poids de cette page vis à vis du contenu
            $tab_morceaux='';
            $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 $
* Revision 1.4  2005/05/25 13:49:22  jpm
* Corection erreur pour la recherche dans le contenu.
*
* Revision 1.3  2005/05/19 12:46:12  jpm
* Correction bogue accesskey.
* Ajout d'un id à la liste.
* Arrondissement des score.
*
* Revision 1.2  2005/04/14 17:39:34  jpm
* Amélioration du moteur de rechercher :
*  - pourcentage
*  - ajout d'info
*
* Revision 1.1  2004/12/07 10:24:06  jpm
* Moteur de recherche version de départ.
*
* 
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>