<?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.14 2008-08-08 16:04:41 jp_milcent Exp $
/**
* Classe permettant d'effectuer des recherches sur les fiches de bazar.
*
*
*@package Applette
*@subpackage Moteur_Recherche
//Auteur original :
*@author        Aurélien Peronnet <aurelien@tela-botanica.org>
//Autres auteurs :
*@author        aucun
*@copyright     Tela-Botanica 2000-2004
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

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

class More_Recherche_Bazar extends More_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) {
        
        foreach ($GLOBALS['_MOTEUR_RECHERCHE_']['bazar'] as $bazar) {
	        $db = DB::connect($bazar['bdd_dsn']);       
	        $requete = 'SELECT bf_id_fiche, bf_description, bf_titre '. 
		           	   'FROM bazar_fiche ';
		           			
		    $resultat = $db->query($requete) ;
			if (DB::isError($resultat)) {
				return ($resultat->getMessage().$resultat->getDebugInfo()) ;
			}
			
			$nb_fiches = $resultat->numRows();
			$aso_resultat = array();
			
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
				
				$aso_ligne = array('poids' => 0, 'url' => '', 'titre' => '',
	                           'hreflang' => '', 'accesskey' => '', 'title' => '',
	                           'date_creation' => '', 'description' => '',
	                           'url_simple' => '');
				
				$aso_ligne['poids'] += $this->retournerOccurenceMotif($motif, $ligne['bf_titre']);
				$aso_ligne['poids'] += $this->retournerOccurenceMotif($motif, $ligne['bf_description']);
				
				if ($aso_ligne['poids'] != 0) {
					
					$aso_ligne['url'] = sprintf($bazar['url'],$ligne['bf_id_fiche']);
					$aso_ligne['url_simple'] = $aso_ligne['url'] ;
					$aso_ligne['titre'] = htmlentities($ligne['bf_titre']);
					$aso_ligne['description'] = htmlentities($this->couperTexte($ligne['bf_description'], MORE_RESULTAT_TAILLE_DESCRIPTION));
					$aso_resultat[] = $aso_ligne;	
				}
			}
			
			return $aso_resultat;
        }
    }
}

?>