Subversion Repositories Applications.papyrus

Rev

Rev 217 | Rev 272 | 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
// +------------------------------------------------------------------------------------------------------+
268 jpm 24
// CVS : $Id: moteur_recherche.php,v 1.2 2005-02-22 17:44:03 jpm Exp $
217 jpm 25
/**
26
* Applette : moteur de recherche
27
*
28
* Génère un formulaire contenant une zone de saisie permettant de taper un texte à rechercher sur l'ensemble
29
* des sites gérés par Papyrus.
30
*
31
*@package Applette
32
*@subpackage Moteur_recherche
33
//Auteur original :
34
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
35
//Autres auteurs :
36
*@author        Aucun
37
*@copyright     Tela-Botanica 2000-2004
268 jpm 38
*@version       $Revision: 1.2 $ $Date: 2005-02-22 17:44:03 $
217 jpm 39
// +------------------------------------------------------------------------------------------------------+
40
*/
41
 
42
// +------------------------------------------------------------------------------------------------------+
43
// |                                            ENTETE du PROGRAMME                                       |
44
// +------------------------------------------------------------------------------------------------------+
45
$_GEN_commun['info_applette_nom_fonction'] = 'afficherMoteurRecherche';
46
$_GEN_commun['info_applette_balise'] = 'MOTEUR_RECHERCHE';
47
 
48
// --------------------------------------------------------------------------------------------------------
49
/** Inclusion du fichier de configuration de cette application.*/
50
require_once GEN_CHEMIN_APPLETTE.'moteur_recherche/configuration/more_configuration.inc.php';
51
/** Inclusion de la bibliotheque permettant d'accéder aux fonctions sur les balises Meta.*/
52
//require_once GEN_CHEMIN_BIBLIO.'pap_meta.fonct.php';
53
//Utilisation de la bibliothèque PEAR NET_URL
54
/** Inclusion de la bibliothèque PEAR de conception de formulaire.*/
55
require_once MORE_CHEMIN_BIBLIOTHEQUE_PEAR.'HTML/QuickForm.php';
56
 
57
// Inclusion des fichiers de traduction de l'appli ADME dePapyrus
58
if (file_exists(MORE_CHEMIN_LANGUE.'more_langue_'.$_GEN_commun['i18n'].'.inc.php')) {
59
    /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
60
    require_once MORE_CHEMIN_LANGUE.'more_langue_'.$_GEN_commun['i18n'].'.inc.php';
61
} else {
62
    /** Inclusion du fichier de traduction par défaut.*/
63
    require_once MORE_CHEMIN_LANGUE.'more_langue_'.MORE_I18N_DEFAUT.'.inc.php';
64
}
65
 
66
// +------------------------------------------------------------------------------------------------------+
67
// |                                            CORPS du PROGRAMME                                        |
68
// +------------------------------------------------------------------------------------------------------+
69
 
70
if (isset($_POST['more_motif']) && $_POST['more_motif'] != '') {
71
    // Initialisation de variable extérieures
72
    $GLOBALS['_VEI_']['usurpation'] = 'Recherche de '.$_POST['more_motif'];
73
    $GLOBALS['_GEN_commun']['info_menu'] = null;
74
    $GLOBALS['_PAPYRUS_']['general']['application_chemin'] = null;
75
    // Titre de la page
76
    $GLOBALS['_PAPYRUS_']['rendu']['TITRE_PAGE'] = 'Résultat de la recherche de '.$_POST['more_motif'];
77
    // Modification des meta de l'entête de la page
78
    GEN_modifierMetaHttpEquiv('Content-Type', 'text/html; charset=iso-8859-15');
79
    GEN_modifierMetaHttpEquiv('Content-style-type', 'text/css');
80
    GEN_modifierMetaHttpEquiv('Content-script-type', 'text/javascript');
81
    GEN_modifierMetaHttpEquiv('Content-language', $_GEN_commun['i18n']);
82
 
83
    GEN_modifierMetaName('revisit-after', '15 days');
84
    GEN_modifierMetaName('robots', 'index,follow');
85
    GEN_modifierMetaName('author', 'Tela Botanica');
86
    GEN_modifierMetaName('keywords', 'Recherche, résultat.');
87
    GEN_modifierMetaName('description', 'Page de résultats du moteur de recherche de Papyrus.');
88
 
89
    GEN_viderMeta('dc');
90
}
91
 
92
// +------------------------------------------------------------------------------------------------------+
93
// |                                           LISTE de FONCTIONS                                         |
94
// +------------------------------------------------------------------------------------------------------+
95
 
96
/** Fonnction afficherMoteurRecherche() - Fournit un formulaire de recherche.
97
*
98
* Renvoie un formulaire permettant de rechercher une chaine de caractères dans les sites
99
* gérés par Papyrus.
100
* Necessite l'utilisation de Pear Net_URL par le programme appelant cette fonction.
101
*
102
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction.
103
* @param  array  tableau global de Papyrus.
104
* @return string  formulaire XHTML de recherche.
105
*/
106
function afficherMoteurRecherche($tab_applette_arguments, $_GEN_commun)
107
{
108
    // --------------------------------------------------------------------------------------------------------
109
    // Initialisation de variable de configuration.
110
    $liste_type_site = '102, 103';// Les id des types des sites pouvant apparaître dans le sélecteur
111
    $objet_pear_db = $_GEN_commun['pear_db'];//objet Pear créé par DB contenant la connexion à la base de données.
112
    $code_site = $_GEN_commun['url_site'];//identifiant du site courant.
113
    $id_langue = $_GEN_commun['url_i18n'];//identifiant de la langue principale du site courant.
114
    $GLOBALS['_MOTEUR_RECHERCHE_']['bd']['papyrus'] = $_GEN_commun['pear_db'];// Connexion à la BD de Papyrus
115
    $url = $_GEN_commun['url'];
116
    $url_base = PAP_URL;
117
    $url_cle_site = GEN_URL_CLE_SITE;
118
    $url_cle_i18n = GEN_URL_CLE_I18N;
119
    $url_id_type_site = GEN_URL_ID_TYPE_SITE;
120
    $indent_origine = 12;// Indentation de départ en nombre d'espace
121
    $indent_pas     = 4;// Pas d'indentation en nombre d'espace
122
    $retour = '';
123
    $retour_resultats = '';
124
 
125
    // --------------------------------------------------------------------------------------------------------
126
    // Lancement de la recherche si nécessaire
127
 
128
    $_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif'] = '';
129
    if (!isset($_POST['more_motif']) || $_POST['more_motif'] == '') {
130
        $_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif'] = MORE_LG_FORM_MOTIF_VALUE;
131
    } else {
132
        $_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif'] = $_POST['more_motif'];
133
        /** Inclusion de la classe Recherche.*/
134
        require_once MORE_CHEMIN_BIBLIO.'more_recherche.class.php';
135
        /** Inclusion de la classe Recherche_Menu_Meta.*/
136
        require_once MORE_CHEMIN_BIBLIO.'more_recherche_papyrus_menu.class.php';
137
        $moteur = new Recherche($_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif']);
138
        $recherche_papyrus_menu = new Recherche_Papyrus_Menu($_SESSION['_MOTEUR_RECHERCHE_']['rechercher']['more_motif']);
139
        $moteur->ajouterRecherche($recherche_papyrus_menu);
140
        $aso_resultats = $moteur->rechercherMotif();
141
        //$GLOBALS['_DEBOGAGE_'] = '<pre>'.print_r($aso_resultats, true).'</pre>';
142
        $retour_resultats .= '<h1>'.MORE_LG_RESULTAT_TITRE.'</h1>'."\n";
143
        $retour_resultats .= '<ul>'."\n";
144
        foreach ($aso_resultats as $val) {
145
            if (!empty($val['url'])) {
146
                $retour_resultats .= '<li>'."\n";
147
                $retour_resultats .= '<a href="'.$val['url'].'">'.$val['titre'].'</a> '.MORE_LG_RESULTAT_SEPARATEUR.' ';
148
                $retour_resultats .= MORE_LG_RESULTAT_POIDS.$val['poids']."\n";
149
                $retour_resultats .= '</li>'."\n";
150
            }
151
        }
152
        $retour_resultats .= '</ul>'."\n";
153
        $GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = '';
154
        $GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = '';
155
        $GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = $retour_resultats;
156
        $GLOBALS['_PAPYRUS_']['rendu']['CONTENU_PIED'] = '';
157
        $GLOBALS['_GEN_commun']['info_menu'] = '';
158
    }
159
 
160
    // --------------------------------------------------------------------------------------------------------
161
    // Création du formulaire de l'applette
162
 
163
    // Notes : Quickform semble remplacer les & des &amp; à nouveau par des &amp; solution utiliser str_replace()...
268 jpm 164
    $form = new HTML_QuickForm('form_more_recherche', 'post', str_replace('&amp;', '&', $url->getUrl()));
217 jpm 165
    $tab_index = MORE_FORM_MOTIF_TAB;
166
    $squelette =& $form->defaultRenderer();
167
    $squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>');
168
    $squelette->setElementTemplate( '{label}'."\n".
169
                                    '{element}'."\n".
170
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">'.MORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span><!-- END required -->'."\n".
171
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n");
172
    //$squelette->setRequiredNoteTemplate("\n".'<p><span class="symbole_obligatoire">'.MORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span> {requiredNote}</p>'."\n");
173
 
174
    $partie_menu_debut = '<fieldset>'."\n".'<legend>'.MORE_LG_FORM_TITRE.'</legend>'."\n";
175
    $form->addElement('html', $partie_menu_debut);
176
 
177
    $id = 'more_motif';
178
    $aso_attributs = array( 'id'=>$id, 'tabindex' => $tab_index++, 'size' => MORE_FORM_MOTIF_SIZE, 'maxlength' => MORE_FORM_MOTIF_MAXLENGTH,
179
                            'onclick' => "javascript: this.value='';");
180
    $label = '<label for="'.$id.'">'.MORE_LG_FORM_MOTIF.'</label>';
181
    $form->addElement('text', $id, $label, $aso_attributs);
182
 
183
    $id = 'more_ok';
184
    $aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++);
185
    $form->addElement('submit', $id, MORE_LG_FORM_VALIDER, $aso_attributs);
186
 
187
    $partie_entete_fin = "\n".'</fieldset>';
188
    $form->addElement('html', $partie_entete_fin);
189
 
190
    // Instanciation avec les valeur par défaut
191
    $form->setDefaults($_SESSION['_MOTEUR_RECHERCHE_']['rechercher']);
192
 
193
    // Transformation en XHTML du formulaire
194
    $retour .= $form->toHTML()."\n";
195
    // --------------------------------------------------------------------------------------------------------
196
 
197
    return $retour;
198
}
199
 
200
// +------------------------------------------------------------------------------------------------------+
201
// |                                            PIED du PROGRAMME                                         |
202
// +------------------------------------------------------------------------------------------------------+
203
 
204
 
205
/* +--Fin du code ----------------------------------------------------------------------------------------+
206
*
207
* $Log: not supported by cvs2svn $
268 jpm 208
* Revision 1.1  2004/12/07 10:24:01  jpm
209
* Moteur de recherche version de départ.
217 jpm 210
*
268 jpm 211
*
217 jpm 212
* +-- Fin du code ----------------------------------------------------------------------------------------+
213
*/
214
?>