New file |
0,0 → 1,211 |
<?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: moteur_recherche.php,v 1.1 2004-12-07 10:24:01 jpm Exp $ |
/** |
* Applette : moteur de recherche |
* |
* Génère un formulaire contenant une zone de saisie permettant de taper un texte à rechercher sur l'ensemble |
* des sites gérés par Papyrus. |
* |
*@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:01 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
$_GEN_commun['info_applette_nom_fonction'] = 'afficherMoteurRecherche'; |
$_GEN_commun['info_applette_balise'] = 'MOTEUR_RECHERCHE'; |
|
// -------------------------------------------------------------------------------------------------------- |
/** Inclusion du fichier de configuration de cette application.*/ |
require_once GEN_CHEMIN_APPLETTE.'moteur_recherche/configuration/more_configuration.inc.php'; |
/** Inclusion de la bibliotheque permettant d'accéder aux fonctions sur les balises Meta.*/ |
//require_once GEN_CHEMIN_BIBLIO.'pap_meta.fonct.php'; |
//Utilisation de la bibliothèque PEAR NET_URL |
/** Inclusion de la bibliothèque PEAR de conception de formulaire.*/ |
require_once MORE_CHEMIN_BIBLIOTHEQUE_PEAR.'HTML/QuickForm.php'; |
|
// Inclusion des fichiers de traduction de l'appli ADME dePapyrus |
if (file_exists(MORE_CHEMIN_LANGUE.'more_langue_'.$_GEN_commun['i18n'].'.inc.php')) { |
/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/ |
require_once MORE_CHEMIN_LANGUE.'more_langue_'.$_GEN_commun['i18n'].'.inc.php'; |
} else { |
/** Inclusion du fichier de traduction par défaut.*/ |
require_once MORE_CHEMIN_LANGUE.'more_langue_'.MORE_I18N_DEFAUT.'.inc.php'; |
} |
|
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
if (isset($_POST['more_motif']) && $_POST['more_motif'] != '') { |
// Initialisation de variable extérieures |
$GLOBALS['_VEI_']['usurpation'] = 'Recherche de '.$_POST['more_motif']; |
$GLOBALS['_GEN_commun']['info_menu'] = null; |
$GLOBALS['_PAPYRUS_']['general']['application_chemin'] = null; |
// Titre de la page |
$GLOBALS['_PAPYRUS_']['rendu']['TITRE_PAGE'] = 'Résultat de la recherche de '.$_POST['more_motif']; |
// Modification des meta de l'entête de la page |
GEN_modifierMetaHttpEquiv('Content-Type', 'text/html; charset=iso-8859-15'); |
GEN_modifierMetaHttpEquiv('Content-style-type', 'text/css'); |
GEN_modifierMetaHttpEquiv('Content-script-type', 'text/javascript'); |
GEN_modifierMetaHttpEquiv('Content-language', $_GEN_commun['i18n']); |
|
GEN_modifierMetaName('revisit-after', '15 days'); |
GEN_modifierMetaName('robots', 'index,follow'); |
GEN_modifierMetaName('author', 'Tela Botanica'); |
GEN_modifierMetaName('keywords', 'Recherche, résultat.'); |
GEN_modifierMetaName('description', 'Page de résultats du moteur de recherche de Papyrus.'); |
|
GEN_viderMeta('dc'); |
} |
|
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
|
/** Fonnction afficherMoteurRecherche() - Fournit un formulaire de recherche. |
* |
* Renvoie un formulaire permettant de rechercher une chaine de caractères dans les sites |
* gérés par Papyrus. |
* Necessite l'utilisation de Pear Net_URL par le programme appelant cette fonction. |
* |
* @param array tableau d'éventuel arguments présent dans la balise transmis à la fonction. |
* @param array tableau global de Papyrus. |
* @return string formulaire XHTML de recherche. |
*/ |
function afficherMoteurRecherche($tab_applette_arguments, $_GEN_commun) |
{ |
// -------------------------------------------------------------------------------------------------------- |
// Initialisation de variable de configuration. |
$liste_type_site = '102, 103';// Les id des types des sites pouvant apparaître dans le sélecteur |
$objet_pear_db = $_GEN_commun['pear_db'];//objet Pear créé par DB contenant la connexion à la base de données. |
$code_site = $_GEN_commun['url_site'];//identifiant du site courant. |
$id_langue = $_GEN_commun['url_i18n'];//identifiant de la langue principale du site courant. |
$GLOBALS['_MOTEUR_RECHERCHE_']['bd']['papyrus'] = $_GEN_commun['pear_db'];// Connexion à la BD de Papyrus |
$url = $_GEN_commun['url']; |
$url_base = PAP_URL; |
$url_cle_site = GEN_URL_CLE_SITE; |
$url_cle_i18n = GEN_URL_CLE_I18N; |
$url_id_type_site = GEN_URL_ID_TYPE_SITE; |
$indent_origine = 12;// Indentation de départ en nombre d'espace |
$indent_pas = 4;// Pas d'indentation en nombre d'espace |
$retour = ''; |
$retour_resultats = ''; |
|
// -------------------------------------------------------------------------------------------------------- |
// Lancement de la recherche si nécessaire |
|
$_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif'] = ''; |
if (!isset($_POST['more_motif']) || $_POST['more_motif'] == '') { |
$_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif'] = MORE_LG_FORM_MOTIF_VALUE; |
} else { |
$_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif'] = $_POST['more_motif']; |
/** Inclusion de la classe Recherche.*/ |
require_once MORE_CHEMIN_BIBLIO.'more_recherche.class.php'; |
/** Inclusion de la classe Recherche_Menu_Meta.*/ |
require_once MORE_CHEMIN_BIBLIO.'more_recherche_papyrus_menu.class.php'; |
$moteur = new Recherche($_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif']); |
$recherche_papyrus_menu = new Recherche_Papyrus_Menu($_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif']); |
$moteur->ajouterRecherche($recherche_papyrus_menu); |
$aso_resultats = $moteur->rechercherMotif(); |
//$GLOBALS['_DEBOGAGE_'] = '<pre>'.print_r($aso_resultats, true).'</pre>'; |
$retour_resultats .= '<h1>'.MORE_LG_RESULTAT_TITRE.'</h1>'."\n"; |
$retour_resultats .= '<ul>'."\n"; |
foreach ($aso_resultats as $val) { |
if (!empty($val['url'])) { |
$retour_resultats .= '<li>'."\n"; |
$retour_resultats .= '<a href="'.$val['url'].'">'.$val['titre'].'</a> '.MORE_LG_RESULTAT_SEPARATEUR.' '; |
$retour_resultats .= MORE_LG_RESULTAT_POIDS.$val['poids']."\n"; |
$retour_resultats .= '</li>'."\n"; |
} |
} |
$retour_resultats .= '</ul>'."\n"; |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = ''; |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = ''; |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = $retour_resultats; |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_PIED'] = ''; |
$GLOBALS['_GEN_commun']['info_menu'] = ''; |
} |
|
// -------------------------------------------------------------------------------------------------------- |
// Création du formulaire de l'applette |
|
// Notes : Quickform semble remplacer les & des & à nouveau par des & solution utiliser str_replace()... |
$form =& new HTML_QuickForm('form_more_recherche', 'post', str_replace('&', '&', $url->getUrl())); |
$tab_index = MORE_FORM_MOTIF_TAB; |
$squelette =& $form->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>'); |
$squelette->setElementTemplate( '{label}'."\n". |
'{element}'."\n". |
'<!-- BEGIN required --><span class="symbole_obligatoire">'.MORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span><!-- END required -->'."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n"); |
//$squelette->setRequiredNoteTemplate("\n".'<p><span class="symbole_obligatoire">'.MORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span> {requiredNote}</p>'."\n"); |
|
$partie_menu_debut = '<fieldset>'."\n".'<legend>'.MORE_LG_FORM_TITRE.'</legend>'."\n"; |
$form->addElement('html', $partie_menu_debut); |
|
$id = 'more_motif'; |
$aso_attributs = array( 'id'=>$id, 'tabindex' => $tab_index++, 'size' => MORE_FORM_MOTIF_SIZE, 'maxlength' => MORE_FORM_MOTIF_MAXLENGTH, |
'onclick' => "javascript: this.value='';"); |
$label = '<label for="'.$id.'">'.MORE_LG_FORM_MOTIF.'</label>'; |
$form->addElement('text', $id, $label, $aso_attributs); |
|
$id = 'more_ok'; |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++); |
$form->addElement('submit', $id, MORE_LG_FORM_VALIDER, $aso_attributs); |
|
$partie_entete_fin = "\n".'</fieldset>'; |
$form->addElement('html', $partie_entete_fin); |
|
// Instanciation avec les valeur par défaut |
$form->setDefaults($_SESSION['_MOTEUR_RECHERCHE_']['rechercher']); |
|
// Transformation en XHTML du formulaire |
$retour .= $form->toHTML()."\n"; |
// -------------------------------------------------------------------------------------------------------- |
|
return $retour; |
} |
|
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |