New file |
0,0 → 1,1053 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library 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 | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: bazar.fonct.rss.php,v 1.60 2006-10-05 08:53:50 florian Exp $ |
/** |
* |
*@package bazar |
//Auteur original : |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
*@author Florian Schmitt <florian@ecole-et-nature.org> |
//Autres auteurs : |
*@copyright Tela-Botanica 2000-2006 |
*@version $Revision: 1.60 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php'; |
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php'; |
|
|
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template |
* |
* @param string valeur du template de bazar_nature |
* |
* @return mixed tableau contenant les champs du fichier template |
*/ |
function baz_valeurs_template($valeur_template) { |
//Parcours du fichier de templates, pour mettre les champs specifiques |
$tableau= array(); |
$nblignes=0; |
$chaine = explode ("\n", $valeur_template); |
array_pop($chaine); |
foreach ($chaine as $ligne) { |
$souschaine = explode ("***", $ligne) ; |
$tableau[$nblignes]['type'] = trim($souschaine[0]) ; |
if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);} |
else {$tableau[$nblignes]['nom_bdd'] ='';} |
if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]); |
else {$tableau[$nblignes]['label'] ='';} |
if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]); |
else {$tableau[$nblignes]['limite1'] ='';} |
if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]); |
else {$tableau[$nblignes]['limite2'] ='';} |
if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]); |
else {$tableau[$nblignes]['defaut'] ='';} |
if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]); |
else {$tableau[$nblignes]['table_source'] ='';} |
if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]); |
else {$tableau[$nblignes]['id_source'] ='';} |
if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]); |
else {$tableau[$nblignes]['obligatoire'] ='';} |
if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]); |
else {$tableau[$nblignes]['recherche'] ='';} |
|
|
// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table |
// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***) |
// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table |
// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche |
|
if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) { |
$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ; |
$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ; |
$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ; |
$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ; |
} |
$nblignes++; |
} |
return $tableau; |
} |
|
/** baz_voir_fiches() - Permet de visualiser en detail une liste de fiche au format XHTML |
* |
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli) |
* @global integer Tableau d(Identifiant des fiches à afficher |
* |
* @return string HTML |
*/ |
function baz_voir_fiches($danslappli, $idfiches=array()) { |
$res=''; |
foreach($idfiches as $idfiche) { |
$res.=baz_voir_fiche($danslappli, $idfiche); |
} |
return $res; |
} |
|
|
/** baz_voir_fiche() - Permet de visualiser en detail une fiche au format XHTML |
* |
* @global boolean Rajoute des informations internes a l'application (date de modification, lien vers la page de départ de l'appli) si a 1 |
* @global integer Identifiant de la fiche a afficher |
* |
* @return string HTML |
*/ |
function baz_voir_fiche($danslappli, $idfiche='') { |
$res=''; |
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche']; |
if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche; |
$url= $GLOBALS['_BAZAR_']['url']; |
$url->addQueryString('action', BAZ_VOIR_FICHE); |
$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
$url = preg_replace ('/&/', '&', $url->getURL()) ; |
|
//cas ou la fiche a été validee |
if (isset($_GET['publiee'])) { |
publier_fiche($_GET['publiee']); |
} |
|
//cas on une structure s'approprie une ressource |
if (isset($_GET['appropriation'])) { |
if ($_GET['appropriation']==1) { |
$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
} |
elseif ($_GET['appropriation']==0) { |
$requete = 'DELETE FROM bazar_appropriation WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID); |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
} |
} |
|
//cas ou un commentaire a été entre |
if (isset($_POST['Nom'])) { |
$requete = 'INSERT INTO bazar_commentaires VALUES ('. |
baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']). |
', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire']. |
'", NOW() )'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
} |
//cas ou un commentaire va etre supprime |
elseif (isset($_GET['id_commentaire'])) { |
$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
} |
else { |
if (isset($_GET['action'])) { |
if ($_GET['action']==BAZ_VOIR_FICHE) { |
//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation |
$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
} |
} |
} |
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
|
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) |
: ''; |
|
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ; |
if (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce'] = $ligne['bf_ce_nature']; |
|
//on verifie si l'utilisateur est administrateur |
$est_admin=0; |
$requete='SELECT bn_id_nature, bn_template, bn_commentaire FROM bazar_nature WHERE bn_id_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$id_nature = $result['bn_id_nature']; |
if (!isset($GLOBALS['_BAZAR_']['template'])) $GLOBALS['_BAZAR_']['template'] = $result['bn_template']; |
if (!isset($GLOBALS['_BAZAR_']['commentaire'])) $GLOBALS['_BAZAR_']['commentaire'] = $result['bn_commentaire']; |
if ($GLOBALS['AUTH']->getAuth()) { |
if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur') |
or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')) |
{ |
$est_admin=1; |
} |
} |
//affiche le titre sous forme d'image |
if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') { |
$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n"; |
} |
//affiche le texte sinon |
else { |
//$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n"; |
} |
$res .= '<div class="BAZ_cadre_fiche">'."\n"; |
|
$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ; |
//si le template existe, on genere le template |
if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) { |
include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'); |
$res .=genere_fiche($ligne); |
} |
//on affiche ligne par ligne sinon |
else { |
//cas d'une image personalisée |
if (isset($ligne['bf_url_image'])) { |
$res .= '<div id="fiche_image">'."\n"; |
$res .= '<img src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n"; |
$res .= '</div>'."\n"; |
} |
//cas d'une image par défaut |
elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') { |
$res .= '<div id="fiche_image">'."\n"; |
$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n"; |
$res .= '</div>'."\n"; |
} |
$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n"; |
$res .= '<div id="BAZ_description">'.nl2br($ligne['bf_description']).'</div>'."\n"; |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']); |
for ($i=0; $i<count($tableau); $i++) { |
if (isset($ligne[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) ) { |
$val=$tableau[$i]['nom_bdd']; |
if (!in_array($val, array ('bf_titre', 'bf_description'))) { |
if ($ligne[$val] != '' and $ligne[$val] != BAZ_CHOISIR and $ligne[$val] != BAZ_NON_PRECISE) { |
$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n"; |
$res .= '<span class="description"> '.nl2br($ligne[$val]).'</span>'."\n".'<br />'."\n"; |
} |
} |
} |
elseif ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) { |
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id |
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche']. |
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$tableau[$i]['nom_bdd'].' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
$val='';$nb=0; |
while ($tab = $resultat->fetchRow()) { |
if ($nb>0) $val .= ', '; |
$val .= $tab[0]; |
$nb++; |
} |
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) { |
$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n"; |
$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n"; |
} |
} |
elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) { |
$val=$tableau[$i]['nom_bdd']; |
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) { |
if ($ligne[$val] != '') { |
$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n"; |
$res .= '<span class="description"> '.strftime('%d.%m.%Y',strtotime($ligne[$val])).'</span>'."\n".'<br />'."\n"; |
} |
} |
} |
elseif ( $tableau[$i]['type']=='wikini' ) { |
$res .= '<div class="lien_wikini"><a href="wikini/'.baz_titre_wiki($ligne["bf_titre"]).'">'.BAZ_ENTRER_PROJET.'</a></div>'."\n"; |
} |
} |
//afficher les liens pour l'annonce |
$requete = 'SELECT bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n"; |
$res .= '<span class="description">'."\n"; |
$res .= '<ul>'."\n"; |
while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n"; |
} |
$res .= '</ul></span>'."\n"; |
} |
|
//afficher les fichiers pour l'annonce |
$requete = 'SELECT bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n"; |
$res .= '<span class="description">'."\n"; |
$res .= '<ul>'."\n"; |
while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n"; |
} |
$res .= '</ul></span>'."\n"; |
} |
$res .= '<div class="bulle_haut"> </div>'."\n"; |
$res .= '<div class="bulle_corps">'."\n"; |
|
//affichage du redacteur de la fiche |
$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL. |
' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n"; |
} |
$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n"; |
$res .= '</div>'."\n"; |
$res .= '<div class="bulle_bas"> </div>'."\n"; |
$res .= '<div id="BAZ_bas_page">'; |
} |
|
//informations complementaires (id fiche, etat publication,... ) |
if ($danslappli==1) { |
if ($ligne['bf_statut_fiche']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1 ) { |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n"; |
} |
elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $ligne['bf_statut_fiche']!=1) { |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON; |
if ( $est_admin ) { |
$res .= ' <strong>'.BAZ_VALIDER_PUBLICATION.' : </strong>'."\n"; |
$lien_publie = &$GLOBALS['_BAZAR_']['url']; |
$lien_publie->addQueryString('action', BAZ_VOIR_FICHE); |
$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']); |
$lien_publie->addQueryString('publiee', 1); |
$res .= '<a href="'.$lien_publie->getURL().'">'.BAZ_OUI.'</a> / '; |
$lien_publie->removeQueryString('publiee'); |
$lien_publie->addQueryString('publiee', 0); |
$res .='<a href="'.$lien_publie->getURL().'">'.BAZ_NON.'</a>'."\n"; |
$lien_publie->removeQueryString('publiee'); |
} |
$res .= '<br />'."\n"; |
} |
//affichage des infos pouvant interesser les admins |
if ( $est_admin ) { |
$res .= '<span class="rubrique" id="numero_fiche">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n"; |
$res .= '<span class="rubrique" id="date_creation">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n"; |
} |
//affichage des infos et du lien pour la mise a jour de la fiche |
if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) { |
$res .= '<span class="rubrique" id="date_mise_a_jour">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n"; |
$lien_modifier=$GLOBALS['_BAZAR_']['url']; |
$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER); |
$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']); |
$res .= ' <a href="'.$lien_modifier->getURL().'" id="modifier_fiche">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n"; |
} |
} |
$res .= '</div>'."\n"; |
$res .= '</div>'."\n"; |
|
//on ajoute les appropriations, s'il le faut |
if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) { |
$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n"; |
$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n"; |
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.' FROM bazar_appropriation,'.BAZ_ANNUAIRE.' WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.BAZ_CHAMPS_ID.' ORDER BY '.BAZ_CHAMPS_NOM.' ASC'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
$possede_ressource=0; |
if ($resultat->numRows()>0) { |
$res .= BAZ_IL_Y_A.$resultat->numRows().' '; |
if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n"; |
else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n"; |
$res .= '<ul>'."\n"; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$res .= '<li><a href="'.BAZ_URL_ANNUAIRE.'&voir_fiche='.$ligne[BAZ_CHAMPS_ID].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[BAZ_CHAMPS_NOM].'</a></li>'."\n"; |
if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1; |
} |
$res .= '</ul><br />'."\n"; |
} |
else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n"; |
$res .='<p class="bulle_corps">'."\n"; |
$lien_appropriation = $GLOBALS['_BAZAR_']['url']; |
$lien_appropriation->addQueryString('action', BAZ_VOIR_FICHE); |
$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
if ($possede_ressource) { |
$lien_appropriation->addQueryString('appropriation', 0); |
$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n"; |
$lien_appropriation->removeQueryString('appropriation'); |
} |
elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) { |
$lien_appropriation->addQueryString('appropriation', 1); |
$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n"; |
$lien_appropriation->removeQueryString('appropriation'); |
} |
elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) { |
$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n"; |
} |
elseif (!$GLOBALS['AUTH']->getAuth()) { |
$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n"; |
} |
$res .='</p>'."\n"; |
$res .= '</div>'."\n"; |
} |
|
//on ajoute les commentaires, s'il le faut |
if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) { |
$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n"; |
$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n"; |
$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$res .= BAZ_IL_Y_A.$resultat->numRows().' '; |
if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n"; |
else $res .= BAZ_COMMENTAIRES.'<br />'."\n"; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$res .= '<div class="bulle_haut"> </div>'."\n"; |
$res .= '<div class="bulle_corps">'."\n"; |
//affichage du commentaire |
$res .= $ligne['bc_commentaire'].'<br />'."\n"; |
$res .= '</div>'."\n"; |
$res .= '<div class="bulle_bas">'."\n"; |
$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n"; |
//pour les identifies seulement, administrateurs de la rubrique ou superadmins |
if ($est_admin==1) { |
$url_comment= $GLOBALS['_BAZAR_']['url']; |
$url_comment->addQueryString('action', BAZ_VOIR_FICHE); |
$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']); |
$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n"; |
} |
$res .= '</div>'."\n"; |
} |
} |
else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n"; |
|
//formulaire des commentaires |
$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url); |
$squelette =& $form_commentaire->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n"); |
$squelette->setElementTemplate( '<label style="width:200px;">{label}'. |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n". |
'</label><br />'."\n".'{element}<br />'."\n"); |
$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n"); |
$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100); |
$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option); |
$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;'); |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php'; |
$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option); |
$form_commentaire->addElement($formtexte) ; |
$option=array('style'=>'border:1px solid #000;'); |
$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option); |
$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ; |
$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ; |
$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ; |
$res .= $form_commentaire->toHTML(); |
$res .= '</div>'."\n"; |
} |
|
return $res ; |
} |
|
|
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML |
* |
* On passe en paramètre le contenu du flux RSS, on affiche ou non la description, |
* et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher |
* |
* @param string le contenu du flux RSS |
* @param boolean afficher ou non la description |
* @param string choisir le format de date: jmah (12/02/2004 12h34) jmh (12/02 12h34) jma (12/02/2004) jm (12/02) ou rien |
* |
* @return string le code HTML |
*/ |
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) { |
if ($rss!='') { |
$rawitems='';$title='';$url='';$cat='';$date=''; |
$res=''; |
if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) { |
$items = explode('<item>', $rawitems[0]); |
$res.='<ul id="BAZ_liste_fiche">'."\n"; |
for( $i = 0; $i < count($items)-1; $i++ ) { |
eregi('<title>(.*)</title>',$items[$i+1], $title ); |
eregi('<link>(.*)</link>',$items[$i+1], $url ); |
eregi('<description>(.*)</description>',$items[$i+1], $cat); |
eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date); |
$res.='<li>'; |
if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';} |
if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';} |
if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';} |
if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';} |
$res.='<a href="'.preg_replace ('/&/', '&', $url[1]).'">'.$title[1].'</a>'; |
if ($voirdesc) {$res.=$cat[1];} |
// Ajout du bouton supprimer pour les superadministrateur |
if (($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')and($url[1]!='#')) { |
$mon_url = preg_replace ('/&/', '&', $url[1]) ; |
$url_suppr = new Net_URL(preg_replace ('/&/', '&', $mon_url)) ; |
$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ; |
$res .= ' ( <a href="'.$url_suppr->getURL(). |
'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'. |
BAZ_SUPPRIMER.'</a> )'."\n" ; |
} |
$res.='</li>'."\n"; |
} |
$res.='</ul>'."\n"; |
if ($affichenb==1) { |
//une annonce trouvee, on accorde au singulier |
if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) { |
$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res; |
} |
//plusieures annonces trouvees, on accorde au pluriel |
else { |
$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res; |
} |
} |
//cas des fiches pas trouvées |
if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) { |
$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n"; |
} |
} |
} |
else $res = BAZ_PAS_D_ANNONCES; |
|
return $res; |
} |
|
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce |
* |
* @param string Le type de l'annonce (laisser vide pour tout type d'annonce) |
* @param integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes) |
* @param integer L'identifiant de l'emetteur (laisser vide pour tous) |
* @param integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees) |
* @param string La requete SQL personnalisee |
* @param integer La categorie des fiches bazar |
* |
* @return string Le code du flux RSS |
*/ |
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='') { |
// generation de la requete MySQL personnalisee |
$req_where=0; |
$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description, bn_label_nature '. |
'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe; |
if ($valide!=2) { |
$requete .= 'bf_statut_fiche='.$valide; |
$req_where=1; |
} |
$nomflux=BAZ_DERNIERE_ACTU; |
if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= 'bf_ce_nature='.$typeannonce; |
$req_where=1; |
//le nom du flux devient le type d'annonce |
$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature='.$typeannonce ; |
$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ; |
} |
// Cas où il y plusieurs type d annonce demande |
if (is_array ($typeannonce)) { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= 'bf_ce_nature IN (' ; |
$chaine = ''; |
foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ; |
$requete .= substr ($chaine, 0, strlen ($chaine)-1) ; |
$requete .= ') '; |
} |
$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ; |
if ($valide!=0) { |
|
if ($utilisateur->isSuperAdmin()) { |
$req_where=1; |
} else { |
if ($req_where==1) { |
$requete .= ' AND '; |
} |
$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'. |
' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature'; |
} |
} |
else $nomflux .= BAZ_A_MODERER; |
if ($emetteur!='' && $emetteur!='tous') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= 'bf_ce_utilisateur='.$emetteur; |
$req_where=1; |
//requete pour afficher le nom de la structure |
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '. |
BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')'; |
} |
if ($requeteSQL!='') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= '('.$requeteSQL.')'; |
$req_where=1; |
} |
if ($categorie_nature!='') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= 'bn_ce_id_menu='.$categorie_nature.' '; |
$req_where=1; |
} |
|
$requete .= ' ORDER BY bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC'; |
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;} |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
// En-tete du flux RSS version 2.0 |
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n"; |
$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n"; |
$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n". |
'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n"; |
// Ajout de la date actuelle de publication (suivant la DTD RSS) |
$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n"; |
// En-tete suite et fin |
$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n". |
'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n"; |
$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n". |
'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n"; |
if ($resultat->numRows()>0) { |
// Creation des items : titre + lien + description + date de publication |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$xml .= '<item>'."\n"; |
$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n"; |
$lien=$GLOBALS['_BAZAR_']['url']; |
$lien->addQueryString('action', BAZ_VOIR_FICHE); |
$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']); |
$xml .= '<link>'.str_replace ('&', '&', $lien->getURL()).'</link>'."\n"; |
$xml .= '<description>'."\n".'<![CDATA[' ; |
if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) { |
//$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ; |
$xml .= $ligne['bf_description'] ; |
} |
$xml .= ']]>'."\n".'</description>'."\n"; |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n"; |
$xml .= '</item>'."\n"; |
} |
} |
else {//pas d'annonces |
$xml .= '<item>'."\n"; |
$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n"; |
$xml .= '<link>#</link>'."\n"; |
$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n"; |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n"; |
$xml .= '</item>'."\n"; |
} |
$xml .= '</channel>'."\n".'</rss>'."\n"; |
return $xml; |
} |
|
|
/** baz_liste() Formate la liste de toutes les annonces actuelles |
* |
* @return string le code HTML a afficher |
*/ |
function baz_liste($typeannonce='toutes') { |
//creation du lien pour le formulaire de recherche |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES); |
if (isset($_REQUEST['recherche_avancee'])) $GLOBALS['_BAZAR_']['url']->addQueryString ('recherche_avancee', $_REQUEST['recherche_avancee']); |
$lien_formulaire = preg_replace ('/&/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ; |
$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ; |
$squelette =& $formtemplate->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n"); |
$squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:120px;text-align:right;">'."\n".'{label}'. |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n". |
' :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
'</td>'."\n".'</tr>'."\n"); |
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label} {element}</strong>'."\n". |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition'); |
$squelette->setElementTemplate( '<tr><td colspan="2">{label}{element}</td></tr>'."\n", 'rechercher'); |
|
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n"); |
//Traduction de champs requis |
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ; |
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER); |
|
|
//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces |
//requete pour obtenir l'id et le label des types d'annonces |
$requete = 'SELECT bn_id_nature, bn_label_nature '. |
'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'].' '. |
'ORDER BY bn_label_nature ASC'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
//on récupère le nb de types de fiches, pour plus tard |
$nb_type_de_fiches=$resultat->numRows(); |
$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature']; |
$tableau_typeannonces[] = $ligne['bn_id_nature'] ; |
} |
if ($nb_type_de_fiches>1 && $GLOBALS['_BAZAR_']['typeannonce']=='toutes') { |
$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n"; |
$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;', |
'onchange' => 'javascript:this.form.submit();'); |
$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ; |
if (isset($_REQUEST['nature'])) { |
$defauts=array('nature'=>$_REQUEST['nature']); |
$formtemplate->setDefaults($defauts); |
} |
} |
//cas du type d'annonces prédéfini |
else { |
if ($nb_type_de_fiches==1) { |
$GLOBALS['_BAZAR_']['typeannonce']=end($type_annonce_select); |
$GLOBALS['_BAZAR_']['id_typeannonce']=key($type_annonce_select); |
} |
$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n"; |
} |
|
//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche |
// dans le but de construire l'élément de formulaire select avec les noms des émetteurs de fiche |
if (BAZ_RECHERCHE_PAR_EMETTEUR) { |
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '. |
'FROM bazar_fiche,'.BAZ_ANNUAIRE.' WHERE ' ; |
|
$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and'; |
|
$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' '; |
if (!isset($_REQUEST['nature'])) { |
if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) { |
$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" '; |
} |
} |
else { |
if ($_REQUEST['nature']!='toutes') { |
$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' '; |
} |
} |
|
$requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ; |
} |
$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;'); |
$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ; |
} else { |
$formtemplate->addElement ('hidden', 'personnes', 'tous') ; |
} |
|
//pour les super-administrateurs, on peut voir les annonces non validées |
//on verifie si l'utilisateur est administrateur |
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ; |
|
if ($utilisateur->isSuperAdmin()) { |
$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;'); |
$valide_select[0] = BAZ_FICHES_PAS_VALIDEES; |
$valide_select[1] = BAZ_FICHES_VALIDEES; |
$valide_select[2] = BAZ_LES_DEUX; |
$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; |
$defauts=array('valides'=>1); |
$formtemplate->setDefaults($defauts); |
} |
|
//champs texte pour entrer les mots cles |
$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:200px;font:12px Myriad, Arial, sans-serif;'); |
$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ; |
|
//option cachee pour savoir si le formulaire a ete appele deja |
$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ; |
|
// Ajout des options si un type de fiche a ete choisie |
if ( (isset($_REQUEST['nature']) && $_REQUEST['nature'] != 'toutes') || (isset($GLOBALS['_BAZAR_']['categorie_nature']) && $nb_type_de_fiches==1)) { |
if ( BAZ_MOTEUR_RECHERCHE_AVANCEE || ( isset($_REQUEST['recherche_avancee'])&&$_REQUEST['recherche_avancee']==1) ) { |
if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') { |
$champs_requete = '' ; |
if (!isset($_REQUEST['nature']) || $_REQUEST['nature'] == '') { |
$_REQUEST['nature'] = $tableau_typeannonces[0]; |
} |
} |
// Récupération du template |
$requete = 'SELECT bn_template FROM bazar_nature WHERE bn_id_nature="'.$_REQUEST['nature'].'"'; |
$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
|
if (isset($_REQUEST['recherche_avancee']) && $_REQUEST['recherche_avancee']==1) { |
foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur); |
$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '0'); |
$lien_recherche_de_base = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_DE_BASE.'</a><br />'; |
//lien recherche de base |
labelhtml($formtemplate,'',$lien_recherche_de_base,'','','','',''); |
} |
|
$tableau = baz_valeurs_template($resultat) ; |
for ($i=0; $i<count($tableau); $i++) { |
if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox') && $tableau[$i]['recherche'] == 1) { |
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'], |
$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire'], 1) ; |
} |
} |
|
} |
else { |
foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur); |
$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '1'); |
$lien_recherche_avancee = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_AVANCEE.'</a><br />'; |
} |
} |
|
//lien recherche avancee |
if (isset($lien_recherche_avancee)) { |
labelhtml($formtemplate,'',$lien_recherche_avancee,'','','','',''); |
} |
|
//Bouton de validation du formulaire |
$option=array('style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;'); |
$formtemplate->addElement('submit', 'rechercher', BAZ_RECHERCHER, $option); |
|
//affichage du formulaire |
$res.=$formtemplate->toHTML()."\n"; |
|
|
// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete |
$case_coche = false ; |
$nb_jointures=0; |
$requeteFrom = '' ; |
$requeteWhere = ' bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'].' AND bn_id_nature=bf_ce_nature AND ' ; |
$requeteWhereListe = '' ; |
|
if ( isset($tableau) ) { |
for ($i = 0; $i < count ($tableau); $i++) { |
if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') { |
$nb_jointures++; |
$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ; |
if (isset($_REQUEST[$nom_liste]) && is_array($_REQUEST[$nom_liste])) { |
$case_coche = true; |
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste |
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur IN (' ; |
$chaine = ''; |
//var_dump($_REQUEST[$nom_liste]); |
foreach ($_REQUEST[$nom_liste] as $cle =>$valeur) { |
if ($valeur == 1) { |
$chaine .= '"'.$cle.'",' ; |
} |
} |
$requeteWhereListe .= substr ($chaine, 0, strlen ($chaine)-1) ; |
$requeteWhereListe .= ') AND '; |
} else { |
if (isset ($_REQUEST[$nom_liste]) && $_REQUEST[$nom_liste]!=0) { |
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste |
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur='.$_REQUEST[$nom_liste].' AND '; |
$case_coche = true; |
} |
} |
} |
} |
} |
if ($case_coche) { |
for ($i = 0; $i < $nb_jointures ; $i++) { |
$requeteFrom .= ', bazar_fiche_valeur_liste as bfvl'.($i+1) ; |
$requeteWhere .= ' bfvl'.($i+1).'.bfvl_ce_fiche=bf_id_fiche AND '; |
} |
$requeteWhere .= $requeteWhereListe; |
} |
if (isset($_REQUEST['nature']) && $_REQUEST['nature']!='' && $_REQUEST['nature']!='toutes') { |
$requeteWhere = 'bf_ce_nature="'.$_REQUEST['nature'].'" AND '.$requeteWhere; |
} |
|
//affichage des resultats de la recherche si le formulaire a ete envoye |
$requeteSQL=''; |
if (isset($_REQUEST['recherche_effectuee'])) { |
//preparation de la requete pour trouver les mots cles |
if (($_REQUEST['recherche_mots_cles']!='')and($_REQUEST['recherche_mots_cles']!=BAZ_MOT_CLE)) { |
//decoupage des mots cles |
$recherche = split(' ', $_REQUEST['recherche_mots_cles']) ; |
$nbmots=count($recherche); |
$requeteSQL=''; |
for ($i=0; $i<$nbmots; $i++) { |
if ($i>0) $requeteSQL.=' OR '; |
$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" '; |
} |
} |
if (!isset($_REQUEST['nature'])) { |
if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces; |
else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ; |
} else { |
$typedefiches = $_REQUEST['nature'] ; |
if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ; |
} |
if ($typeannonce!='toutes') $typedefiches=$typeannonce; |
if (isset($_REQUEST['valides'])) {$valides=$_REQUEST['valides'];} |
else {$valides=1;} |
//generation de la liste de flux a afficher |
if (!isset($_REQUEST['personne'])) $_REQUEST['personne']='tous'; |
$res .= baz_liste_pagine_HTML($typedefiches, '', $_REQUEST['personne'], $valides, $requeteSQL, $requeteFrom, $requeteWhere); |
} |
else { |
//on affiche toutes les annonces |
$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n"; |
$GLOBALS['_BAZAR_']['url']->removeQueryString('action'); |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS); |
$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce); |
$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']); |
$res .= '{{Syndication titre="Les dernières fiches enregistrées" url="'.preg_replace ('/&/', '&', $GLOBALS['_BAZAR_']['url']->getURL()). |
'" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}'; |
} |
return $res; |
} |
|
/** |
* Cette fonction renvoie du HTML |
*/ |
function baz_liste_pagine_HTML($typeannonce, $nbitem, $emetteur, $valide, $requeteSQL = '', $requeteFrom = '', $requeteWhere = '') { |
// generation de la requete MySQL personnalisee |
$req_where=0; |
$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_ce_utilisateur, bf_date_debut_validite_fiche '. |
'FROM bazar_fiche, bazar_nature '.$requeteFrom.' WHERE '.$requeteWhere; |
if ($valide!=2) { |
if ($req_where==1) {$requete .= ' AND ';} |
$req_where=1; |
$requete .= 'bf_statut_fiche='.$valide; |
} else { |
$requete .= '1 ' ; |
} |
|
$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ; |
if ($valide!=0) { |
if ($utilisateur->isSuperAdmin()) { |
$req_where=1; |
} else { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'. |
' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature'; |
$req_where=1; |
} |
} |
if ($emetteur!='' && $emetteur!='tous') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= 'bf_ce_utilisateur='.$emetteur; |
$req_where=1; |
//requete pour afficher le nom de la structure |
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '. |
BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')'; |
} |
if ($requeteSQL!='') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= '('.$requeteSQL.')'; |
$req_where=1; |
} |
$requete .= ' ORDER BY bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC'; |
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;} |
|
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$res = '<br /><h4>'.BAZ_IL_Y_A.($resultat->numRows()).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n"; |
$res .= '<ul>' ; |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE); |
|
$donnees = array(); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne->bf_id_fiche) ; |
array_push ($donnees, array ($ligne->bf_id_fiche,$ligne->bf_titre,$ligne->bf_ce_utilisateur)); |
} |
// Mise en place du Pager |
include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php'; |
$params = array( |
'mode' => BAZ_MODE_DIVISION, |
'perPage' => BAZ_NOMBRE_RES_PAR_PAGE, |
'delta' => BAZ_DELTA, |
'httpMethod' => 'GET', |
'extraVars' => array_merge($_POST, $_GET), |
'altNext' => BAZ_SUIVANT, |
'altPrev' => BAZ_PRECEDENT, |
'nextImg' => BAZ_SUIVANT, |
'prevImg' => BAZ_PRECEDENT, |
'itemData' => $donnees |
); |
$pager = & Pager::factory($params); |
$data = $pager->getPageData(); |
$links = $pager->getLinks(); |
$res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n"; |
foreach ($data as $valeur) { |
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $valeur[0]) ; |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE) ; |
$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.$valeur[1].'</a>'."\n" ; |
if ($utilisateur->isSuperAdmin() || $GLOBALS['id_user']==$valeur[2]) { |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_MODIFIER); |
$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">('.BAZ_MODIFIER.')</a> ' ; |
$GLOBALS['_BAZAR_']['url']->removeQueryString('action'); |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_SUPPRESSION); |
$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>' ; |
$GLOBALS['_BAZAR_']['url']->removeQueryString('action'); |
} |
$res .= '</li>'; |
} |
$res .= '</ul>'; |
$res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n"; |
|
return $res ; |
} |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.59 2006/09/21 14:19:39 florian |
* amélioration des fonctions liés au wikini |
* |
* Revision 1.58 2006/09/15 12:31:40 alexandre_tb |
* correction du nom du flux RSS. |
* |
* Revision 1.57 2006/07/25 13:22:27 alexandre_tb |
* réorganisation du code, sans grand changement |
* |
* Revision 1.56 2006/07/18 14:13:35 alexandre_tb |
* Ajout d identifiant HTML |
* |
* Revision 1.55 2006/07/04 14:29:18 alexandre_tb |
* Ajout du bouton supprimer pour les administrateurs |
* |
* Revision 1.54 2006/07/03 09:51:21 alexandre_tb |
* correction du bug recherche sur fiches validés et invalidés. |
* |
* Revision 1.53 2006/06/29 10:29:51 florian |
* correction bug moteur de recherche |
* |
* Revision 1.52 2006/06/02 09:29:07 florian |
* debut d'integration de wikini |
* |
* Revision 1.51 2006/05/23 15:41:27 alexandre_tb |
* ajout de la numérotation des pages en haut et en bas ds résultats et ajout d'une div class=bazar_numero pour les entourer |
* |
* Revision 1.50 2006/05/22 09:55:12 alexandre_tb |
* ajout de la variable recherche_avancee dans l'action du formulaire |
* |
* Revision 1.49 2006/05/19 13:54:11 florian |
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee |
* |
* Revision 1.48 2006/05/17 09:50:13 alexandre_tb |
* Ajout du moteur de recherche évolué et du découpage par page |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |