/trunk/bibliotheque/bazar.fonct.formulaire.php |
---|
19,7 → 19,7 |
// | 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.formulaire.php,v 1.19 2006-03-02 20:36:52 florian Exp $ |
// CVS : $Id: bazar.fonct.formulaire.php,v 1.20 2006-04-28 12:46:14 florian Exp $ |
/** |
* Formulaire |
* |
31,7 → 31,7 |
//Autres auteurs : |
*@author Aleandre GRANIER <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.19 $ $Date: 2006-03-02 20:36:52 $ |
*@version $Revision: 1.20 $ $Date: 2006-04-28 12:46:14 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
61,7 → 61,7 |
$select[$ligne[1]] = $ligne[2] ; |
} |
$option=array('style'=>'width: '.$limite1.'px;'); |
require_once 'HTML/QuickForm/select.php'; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/select.php'; |
$select= new HTML_QuickForm_select('liste'.$id_liste, $label, $select, $option); |
$select->setSize($limite2); |
$select->setMultiple(0); |
86,24 → 86,30 |
* @return void |
*/ |
function checkbox(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire) { |
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"'; |
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'" ORDER BY blv_label'; |
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
require_once 'HTML/QuickForm/checkbox.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ; |
$i=0; |
if (isset($defaut)) $tab=split(', ', $defaut); |
while ($ligne = $resultat->fetchRow()) { |
if ($i==0) $labelchkbox=$label ; else $labelchkbox=' ' ; |
if ($i==0) $labelchkbox=$label ; else $labelchkbox=' '; |
$checkbox[$i]= & HTML_Quickform::createElement('checkbox', $ligne[1], $labelchkbox, $ligne[2], |
array ('style'=>'display:inline;margin-left:2px;')) ; |
array ('style'=>'display:inline;margin:2px;')) ; |
foreach ($tab as $val) { |
if ($ligne[1]==$val) $checkbox[$i]->setChecked(1); |
} |
$i++; |
} |
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, $label, '<br />'."\n"); |
$squelette_checkbox =& $formtemplate->defaultRenderer(); |
$squelette_checkbox->setElementTemplate( '<tr><td colspan="2" style="text-align:left;">'."\n".'<fieldset class="bazar_fieldset">'."\n".'<legend>{label}'. |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n". |
'</legend>'."\n".'{element}'."\n".'</fieldset> '."\n".'</td></tr>'."\n", 'checkbox'.$id_liste); |
$squelette_checkbox->setGroupElementTemplate( "\n".'<div class="bazar_checkbox">'."\n".'{element}'."\n".'</div>'."\n", 'checkbox'.$id_liste); |
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, $label, "\n"); |
if (isset($obligatoire)and($obligatoire==1)) { |
$formtemplate->addGroupRule('checkbox'.$id_liste, $label.' obligatoire', 'required', null, 1, 'client'); |
} |
127,11 → 133,11 |
'minYear' => date('Y'), |
'maxYear'=> (date('Y')+10), |
'format' => 'd m Y', |
'addEmptyOption' => true, |
'addEmptyOption' => BAZ_DATE_VIDE, |
); |
$formtemplate->addElement('date', $nom_bdd, $label, $optiondate) ; |
//gestion des valeurs par défaut (date du jour) |
if (isset($defaut)) $formtemplate->setDefaults(array($nom_bdd => $defaut)); |
if (isset($defaut) && $defaut!='') $formtemplate->setDefaults(array($nom_bdd => $defaut)); |
else { |
$defauts=array($nom_bdd => array ('d'=>date('d'), 'm'=>date('m'), 'Y'=>date('Y'))); |
$formtemplate->setDefaults($defauts); |
219,8 → 225,42 |
* @return void |
*/ |
function url(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) { |
//recherche des URLs deja entrees dans la base |
$html_url= ''; |
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) { |
$requete = 'SELECT bu_id_url, 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 ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$html_url= '<tr>'."\n".'<td colspan="2">'."\n".'<strong>'.BAZ_LISTE_URL.'</strong>'."\n"; |
$tableAttr = array("class" => "bazar_table") ; |
$table = new HTML_Table($tableAttr) ; |
$entete = array (BAZ_LIEN , BAZ_SUPPRIMER) ; |
$table->addRow($entete) ; |
$table->setRowType(0, "th") ; |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$lien_supprimer->addQueryString('id_url', $ligne->bu_id_url); |
$table->addRow (array( |
'<a href="'.$ligne->bu_url.'" target="_blank"> '.$ligne->bu_descriptif_url.'</a>', // col 1 : le lien |
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_LIEN.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer |
$lien_supprimer->removeQueryString('id_url'); |
} |
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire")); |
$table->updateColAttributes(1, array("align" => "center")); |
$html_url.= $table->toHTML()."\n".'</td>'."\n".'</tr>'."\n" ; |
} |
} |
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n"; |
$formtemplate->addElement('html', $html) ; |
if ($html_url!='') $formtemplate->addElement('html', $html_url) ; |
$formtemplate->addElement('text', 'url_lien'.$nom_bdd, BAZ_URL_LIEN) ; |
$formtemplate->addElement('text', 'url_texte'.$nom_bdd, BAZ_URL_TEXTE) ; |
//gestion du champs obligatoire |
243,8 → 283,41 |
* @return void |
*/ |
function fichier(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) { |
//AJOUTER DES FICHIERS JOINTS |
$html_fichier= ''; |
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) { |
$requete = 'SELECT * FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']["id_fiche"]; |
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ; |
if (DB::isError ($resultat)) { |
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$html_fichier = '<tr>'."\n".'<td colspan="2">'."\n".'<strong>'.BAZ_LISTE_FICHIERS_JOINTS.'</strong>'."\n"; |
$tableAttr = array("class" => "bazar_table") ; |
$table = new HTML_Table($tableAttr) ; |
$entete = array (BAZ_FICHIER , BAZ_SUPPRIMER) ; |
$table->addRow($entete) ; |
$table->setRowType(0, "th") ; |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$lien_supprimer->addQueryString('id_fichier', $ligne->bfj_id_fichier); |
$table->addRow(array('<a href="client/bazar/upload/'.$ligne->bfj_fichier.'"> '.$ligne->bfj_description.'</a>', // col 1 : le fichier et sa description |
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_FICHIER.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer |
$lien_supprimer->removeQueryString('id_fichier'); |
} |
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire")); |
$table->updateColAttributes(1, array("align" => "center")); |
$html_fichier .= $table->toHTML()."\n".'</td>'."\n".'</tr>'."\n" ; |
} |
} |
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n"; |
$formtemplate->addElement('html', $html) ; |
if ($html_fichier!='') $formtemplate->addElement('html', $html_fichier) ; |
$formtemplate->addElement('text', 'texte_fichier'.$nom_bdd, BAZ_FICHIER_DESCRIPTION) ; |
$formtemplate->addElement('file', 'fichier'.$nom_bdd, BAZ_FICHIER_JOINT) ; |
$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, '', '', 'client') ; //a completer pour checker l'image |
269,14 → 342,41 |
* @return void |
*/ |
function image(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) { |
//AJOUTER UNE IMAGE |
$html_image= ''; |
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) { |
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ; |
if (DB::isError ($resultat)) { |
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$image=$ligne->bf_url_image; |
} |
if ($image!=NULL) { |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
$lien_supprimer->addQueryString('image', 1); |
$html_image = '<tr>'."\n". |
'<td>'."\n".'<img src="client/bazar/upload/'.$image.'" alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n".'</td>'."\n". |
'<td>'."\n".'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_IMAGE.'\');" >'.BAZ_SUPPRIMER.'</a><br /><br />'."\n". |
'<strong>'.BAZ_POUR_CHANGER_IMAGE.'</strong><br />'."\n".'</td>'."\n".'</tr>'."\n"; |
} |
} |
} |
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n"; |
$formtemplate->addElement('html', $html) ; |
$formtemplate->addElement('file', 'image'.$nom_bdd, BAZ_IMAGE) ; |
if ($html_image!='') $formtemplate->addElement('html', $html_image) ; |
$formtemplate->addElement('file', 'image', BAZ_IMAGE) ; |
//TODO: controler si c'est une image |
$formtemplate->setMaxFileSize($limite1); |
//gestion du champs obligatoire |
if (isset($obligatoire)and($obligatoire==1)) { |
$formtemplate->addRule('image'.$nom_bdd, BAZ_IMAGE_VALIDE_REQUIS, 'required', '', 'client') ; |
$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, 'required', '', 'client') ; |
} |
} |
295,8 → 395,8 |
* @return void |
*/ |
function labelhtml(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) { |
require_once 'HTML/QuickForm/html.php'; |
$formhtml= new HTML_QuickForm_html('<tr>'."\n".'<td colspan="2">'."\n".constant($label)."\n".'</td>'."\n".'</tr>'."\n"); |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php'; |
$formhtml= new HTML_QuickForm_html('<tr>'."\n".'<td colspan="2">'."\n".$label."\n".'</td>'."\n".'</tr>'."\n"); |
$formtemplate->addElement($formhtml) ; |
} |
303,6 → 403,9 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.19 2006/03/02 20:36:52 florian |
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme. |
* |
* Revision 1.18 2006/03/01 16:01:46 florian |
* correction bug déclaration variable $html |
* |
/trunk/bibliotheque/bazar.abonnement.inc.php |
---|
New file |
0,0 → 1,56 |
<?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$ |
/** |
* Fonctions d'abonnement a afficher dans la fiche du bottin |
* |
* |
*@package inscription |
//Auteur original : |
*@author Florian Schmitt <florian@ecole-et-nature.org> |
//Autres auteurs : |
* |
*@copyright Outils-Reseaux 2006-2010 |
*@version $Revision$ $Date$ |
*@version $Revision$ $Date$ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PAP_CHEMIN_RACINE.'client/bazar/configuration/baz_config.inc.php' ; |
include_once PAP_CHEMIN_RACINE.'client/bazar/bibliotheque/bazar.fonct.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
$GLOBALS['id_user']=$id; |
$abonnement = baz_s_inscrire(); |
//-- Fin du code source ------------------------------------------------------------ |
/* |
* $Log$ |
* |
*/ |
?> |
/trunk/bibliotheque/bazar.fonct.rss.php |
---|
69,10 → 69,10 |
} |
/** baz_voir_fiche() - Permet de visualiser en détail une fiche au format XHTML |
/** baz_voir_fiche() - Permet de visualiser en detail une 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) si à 1 |
* @global integer Identifiant de la fiche à afficher |
* @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 |
*/ |
79,14 → 79,30 |
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; |
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 un commentaire a été entré |
//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']). |
131,12 → 147,9 |
} |
//affiche le texte sinon |
else { |
$res .= '<h1 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h1>'."\n"; |
$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n"; |
} |
$res .= '<div class="BAZ_cadre_fiche">'."\n"; |
$res .= '<div class="BAZ_cadre_fiche_haut">'."\n"; |
$res .= ' </div>'."\n"; |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n"; |
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError ($resultat)) { |
154,7 → 167,7 |
//cas d'une image personalisée |
if (isset($ligne['bf_url_image'])) { |
$res .= '<div id="fiche_image">'."\n"; |
$res .= '<img src="client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\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 |
167,7 → 180,7 |
$res .= '<div id="BAZ_description">'.$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']])) { |
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', 'bf_date_debut_validite_fiche', |
'bf_date_fin_validite_fiche'))) { |
177,7 → 190,7 |
} |
} |
} |
elseif (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) { |
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'].'"'; |
222,7 → 235,7 |
$res .= '<span class="description">'."\n"; |
$res .= '<ul>'."\n"; |
while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n"; |
$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n"; |
} |
$res .= '</ul></span>'."\n"; |
} |
246,78 → 259,94 |
} |
//informations complementaires (id fiche, etat publication,... ) |
if ($danslappli==1) { |
$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n"; |
if ($ligne['bf_statut_fiche']==1) { |
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"; |
} |
else { |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<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"; |
} |
$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n"; |
$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_maj_fiche'])).'<br />'."\n"; |
if ($est_admin or |
$GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)) { |
//affichage des infos pouvant interesser les admins |
if ( $est_admin ) { |
$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n"; |
$res .= '<span class="rubrique">'.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">'.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().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n"; |
$res .= ' <a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n"; |
} |
} |
$res .= '</div>'."\n"; |
$res .= '</div>'."\n"; |
$res .= '<div class="BAZ_cadre_fiche_bas"> </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 .= '<div class="BAZ_cadre_fiche_haut"> </div>'."\n"; |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n"; |
$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\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_COMMENTAIRE.'<br />'."\n"; |
else $res .= BAZ_COMMENTAIRES.'<br />'."\n"; |
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 .= '<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 identifiés 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"; |
$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"; |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\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 .= '<div class="BAZ_cadre_fiche_haut"> </div>'."\n"; |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\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) ; |
336,7 → 365,7 |
$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 identifiés seulement, administrateurs de la rubrique ou superadmins |
//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); |
350,26 → 379,26 |
else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n"; |
//formulaire des commentaires |
$form_commentaire = new HTML_QuickForm('commentaire', 'post', $url); |
$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} </label><br />'."\n".'{element}<br />'."\n"); |
$squelette->setRequiredNoteTemplate("\n".'{requiredNote} '."\n"); |
$option=array('style'=>'width:300px;', 'maxlength'=>100); |
$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:100%;height:100px;white-space: pre;padding:3px;'); |
$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) ; |
$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER); |
$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"; |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n"; |
$res .= '</div>'."\n"; |
} |
return $res ; |
497,7 → 526,7 |
BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ; |
if (DB::isError($resultat)) { |
echo ($resultat->getMessage().$resultat->getDebugInfo()) ; |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')'; |
654,34 → 683,34 |
//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($_POST['nature']) || isset($GLOBALS['_BAZAR_']['categorie_nature'])) { |
if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') { |
$champs_requete = 'bn_ce_id_menu' ; |
$_POST['nature'] = $GLOBALS['_BAZAR_']['categorie_nature']; |
} else { |
$champs_requete = 'bn_id_nature' ; |
} |
// Récupération du template |
$requete = 'select bn_template from bazar_nature where '.$champs_requete.'='.$_POST['nature']; |
$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
$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) { |
if ($tableau[$i]['type'] == 'checkbox') { |
$formtemplate->addElement ('html', '<br />'.$tableau[$i]['label'].'<br />') ; |
} |
$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']) ; |
} |
} |
} |
// |
// // Ajout des options si un type de fiche a ete choisie |
// if (isset($_POST['nature']) || isset($GLOBALS['_BAZAR_']['categorie_nature'])) { |
// if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') { |
// $champs_requete = 'bn_ce_id_menu' ; |
// $_POST['nature'] = $GLOBALS['_BAZAR_']['categorie_nature']; |
// } else { |
// $champs_requete = 'bn_id_nature' ; |
// } |
// // Récupération du template |
// $requete = 'select bn_template from bazar_nature where '.$champs_requete.'='.$_POST['nature']; |
// $resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ; |
// if (DB::isError($resultat)) { |
// die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
// } |
// |
// $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) { |
// if ($tableau[$i]['type'] == 'checkbox') { |
// $formtemplate->addElement ('html', '<br />'.$tableau[$i]['label'].'<br />') ; |
// } |
// $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']) ; |
// } |
// } |
// } |
//Bouton de validation du formulaire |
$option=array('style'=>'border:1px solid #000;width:80px;font:12px Myriad, Arial, sans-serif;'); |
$bouton[] = &HTML_QuickForm::createElement('submit', 'rechercher', BAZ_RECHERCHER, $option); |
696,28 → 725,27 |
$requeteWhere = '' ; |
$requeteWhereListe = '' ; |
for ($i = 0; $i < count ($tableau); $i++) { |
if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') { |
$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ; |
if (is_array($_POST[$nom_liste])) { |
foreach ($_POST[$nom_liste] as $cle =>$valeur) { |
echo $valeur ; |
if ($valeur == 1) { |
$case_coche = true ; |
$requeteWhereListe .= ' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'] ; // Numéro de la liste |
} |
} |
} |
} |
} |
if ($case_coche) { |
$requeteFrom = ', bazar_fiche_valeur_liste ' ; |
$requeteWhereListe .= ' AND bfvl_valeur IN ()' ; |
$requeteWhere = ' bfvl_ce_fiche=bf_id_fiche'.$requeteWhereListe; |
} |
// for ($i = 0; $i < count ($tableau); $i++) { |
// if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') { |
// $nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ; |
// |
// if (is_array($_POST[$nom_liste])) { |
// foreach ($_POST[$nom_liste] as $cle =>$valeur) { |
// if ($valeur == 1) { |
// $case_coche = true ; |
// $requeteWhereListe .= ' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'] ; // Numéro de la liste |
// |
// } |
// } |
// } |
// } |
// } |
// if ($case_coche) { |
// $requeteFrom = ', bazar_fiche_valeur_liste ' ; |
// $requeteWhereListe .= ' AND bfvl_valeur IN ()' ; |
// $requeteWhere = ' bfvl_ce_fiche=bf_id_fiche'.$requeteWhereListe; |
// } |
// |
//affichage des resultats de la recherche si le formulaire a ete envoye |
$requeteSQL=''; |
if (isset($_REQUEST['recherche_effectuee'])) { |
/trunk/bibliotheque/bazar.fonct.php |
---|
19,7 → 19,7 |
// | 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.php,v 1.46 2006-03-29 13:04:35 alexandre_tb Exp $ |
// CVS : $Id: bazar.fonct.php,v 1.47 2006-04-28 12:46:14 florian Exp $ |
/** |
* |
* Fonctions du module bazar |
31,7 → 31,7 |
*@author Florian Schmitt <florian@ecole-et-nature.org> |
//Autres auteurs : |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.46 $ $Date: 2006-03-29 13:04:35 $ |
*@version $Revision: 1.47 $ $Date: 2006-04-28 12:46:14 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
38,10 → 38,10 |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
require_once 'HTML/QuickForm.php' ; |
require_once 'HTML/QuickForm/checkbox.php' ; |
require_once 'HTML/QuickForm/textarea.php' ; |
require_once 'HTML/Table.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/Table.php' ; |
require_once 'bazar.fonct.formulaire.php'; |
require_once 'bazar.fonct.rss.php'; |
144,7 → 144,7 |
$res .= $table->toHTML() ; |
} |
else { |
$res .= BAZ_PAS_DE_FICHE_A_VALIDER ; |
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE_A_VALIDER.'</p>'."\n" ; |
} |
return $res; |
212,7 → 212,7 |
$res .= $table->toHTML() ; |
} |
else { |
$res .= BAZ_PAS_DE_FICHE ; |
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE.'</p>'."\n" ; |
} |
} |
else $res=BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR; |
219,16 → 219,6 |
return $res; |
} |
/** baz_administrer_annonces() interface de modification de type d'annonces |
* |
* return string le code HTML |
*/ |
function baz_administrer_annonces() { |
$res= '<h2>'.BAZ_ADMIN_ANNONCES.'</h2>'."\n"; |
return $res; |
} |
/** baz_gestion_droits() interface de gestion des droits |
* |
* return string le code HTML |
418,6 → 408,7 |
* @return string HTML |
*/ |
function baz_formulaire($mode) { |
$res = ''; |
if ($GLOBALS['AUTH']->getAuth()) { |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
451,14 → 442,16 |
//contruction du squelette du formulaire |
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL()) ); |
$squelette =& $formtemplate->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n"); |
$squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:150px;text-align:right;">'."\n".'{label} :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n". |
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n". |
$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" class="bouton">{label}{element}</td></tr>'."\n", 'valider'); |
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n"); |
//Traduction de champs requis |
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ; |
468,43 → 461,54 |
//AFFICHAGE DU FORMULAIRE GENERAL DE CHOIX DU TYPE D'ANNONCE |
//------------------------------------------------------------------------------------------------ |
if ($mode == BAZ_DEPOSER_ANNONCE) { |
$res = ''; |
$res = ''; |
//requete pour obtenir le nom et la description des types d'annonce |
$requete = "SELECT bn_id_nature, bn_label_nature, bn_description, bn_condition, bn_image_titre ". |
"FROM bazar_nature WHERE bn_ce_id_menu=".$GLOBALS['_BAZAR_']['categorie_nature']. |
" ORDER BY bn_label_nature ASC"; |
$requete = 'SELECT * 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()) ; |
} |
$res.='<h2>'.BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE.'</h2>'."\n"; |
$res.='<br />'.BAZ_CHOIX_TYPEANNONCE.'<br /><br />'."\n"; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) { |
$droitspers=niveau_droit($ligne["bn_id_nature"],$GLOBALS["id_user"]); |
if (($droitspers=='redacteur') or ($droitspers=='administrateur') |
or ($droitspers=='superadministrateur' or !BAZ_RESTREINDRE_DEPOT)) { |
if ($ligne['bn_image_titre']!='') { |
$titre=' <img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'. |
constant($ligne['bn_label_nature']).'" />'.'<br />'."\n"; |
} else { |
$titre='<h3>'.$ligne['bn_label_nature'].' : </h3>'."\n"; |
} |
$formtemplate->addElement('radio', 'typeannonce', '', |
$titre.$ligne['bn_description'].'<br /><br />'."\n", |
$ligne['bn_id_nature'], array("id" => 'select'.$ligne['bn_id_nature'], |
"style" => 'float:left;')); |
} |
if ($resultat->numRows()==1) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC); |
$GLOBALS['_BAZAR_']['id_typeannonce']=$ligne['bn_id_nature']; |
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature']; |
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition']; |
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template']; |
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire']; |
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation']; |
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre']; |
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo']; |
$mode = BAZ_ACTION_NOUVEAU; |
} else { |
$res.='<br />'.BAZ_CHOIX_TYPEANNONCE.'<br /><br />'."\n"; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) { |
$droitspers=niveau_droit($ligne["bn_id_nature"],$GLOBALS["id_user"]); |
if (($droitspers=='redacteur') or ($droitspers=='administrateur') |
or ($droitspers=='superadministrateur' or !BAZ_RESTREINDRE_DEPOT)) { |
if ($ligne['bn_image_titre']!='') { |
$titre=' <img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'. |
constant($ligne['bn_label_nature']).'" />'.'<br />'."\n"; |
} else { |
$titre='<h3>'.$ligne['bn_label_nature'].' : </h3>'."\n"; |
} |
$formtemplate->addElement('radio', 'typeannonce', '', |
$titre.$ligne['bn_description'].'<br /><br />'."\n", |
$ligne['bn_id_nature'], array("id" => 'select'.$ligne['bn_id_nature'], |
"style" => 'float:left;')); |
} |
} |
$squelette->setElementTemplate( '<div class="listechoix">'."\n".'{element}'."\n".'</div>'."\n"); |
//Mettre les annonces en choix par defaut |
$formtemplate->setdefaults(array('typeannonce'=>'1')); |
//Bouton de validation du formulaire |
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER); |
//Affichage a l'ecran |
$res.= $formtemplate->toHTML()."\n".'<br />'."\n".mes_fiches(); ; |
} |
$squelette->setElementTemplate( '<div class="listechoix">'."\n".'{element}'."\n".'</div>'."\n"); |
//Mettre les annonces en choix par defaut |
$formtemplate->setdefaults(array('typeannonce'=>'1')); |
//Bouton de validation du formulaire |
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER); |
//Affichage a l'ecran |
$res.= $formtemplate->toHTML()."\n".'<br />'."\n".mes_fiches(); ; |
} |
//------------------------------------------------------------------------------------------------ |
543,11 → 547,13 |
} |
} |
} |
else $res = BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR; |
else { |
$res .= '<h2>'.BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE.'</h2><br />'."\n"; |
$res .= '<p class="zone_info">'.BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR.'</p>'."\n" ; |
} |
return $res; |
} |
/** baz_afficher_formulaire_annonce() - Genere le formulaire de saisie d'une annonce |
* |
* @param string type de formulaire: insertion ou modification |
556,24 → 562,26 |
* @return string code HTML avec formulaire |
*/ |
function baz_afficher_formulaire_annonce($mode='insertion',$formtemplate) { |
//verification de la modification des fichiers, des url ou des images |
if (isset($_GET['url'])) { |
if ($_GET['url']==1) baz_insertion_url($_POST['url_lien'],$_POST['url_texte'],$GLOBALS['_BAZAR_']['id_fiche']); |
if ($_GET['url']==2) baz_suppression_url($_GET['id_url']); |
if ($mode=='modification') { |
//initialisation de la variable globale id_fiche |
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST['id_fiche']; |
//suppression eventuelle d'une url, d'un fichier ou d'une image |
if (isset($_GET['id_url'])) { |
baz_suppression_url($_GET['id_url']); |
} |
if (isset($_GET['id_fichier'])) { |
baz_suppression_fichier($_GET['id_fichier']); |
} |
if (isset($_GET['image'])) { |
baz_suppression_image($GLOBALS['_BAZAR_']['id_fiche']); |
} |
} |
if (isset($_GET['fichier'])) { |
if ($_GET['fichier']==1) baz_insertion_fichier($_POST['fichier_description'], $GLOBALS['_BAZAR_']["id_fiche"]); |
if ($_GET['fichier']==2) baz_suppression_fichier($_GET['id_fichier']); |
} |
if (isset($_GET['image'])) { |
if ($_GET['image']==1) baz_insertion_image($GLOBALS['_BAZAR_']['id_fiche']); |
if ($_GET['image']==2) baz_suppression_image($GLOBALS['_BAZAR_']['id_fiche']); |
} |
//titre de la rubrique |
$res= '<h2>'.BAZ_TITRE_SAISIE_ANNONCE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2><br />'."\n"; |
if (($GLOBALS['_BAZAR_']['condition']!='')AND(!isset($_POST['accept_condition']))AND(!isset($_GET['url'])OR(!isset($_GET['fichier']))OR(!isset($_GET['image'])))) { |
require_once 'HTML/QuickForm/html.php'; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php'; |
$conditions= new HTML_QuickForm_html('<tr><td colspan="2" style="padding:5px; margin:5px; width: 90%; background: #C1CBA7;">'.$GLOBALS['_BAZAR_']['condition'].'</td>'."\n".'</tr>'."\n"); |
$formtemplate->addElement($conditions); |
$formtemplate->addElement('checkbox', 'accept_condition',BAZ_ACCEPTE_CONDITIONS) ; |
581,191 → 589,36 |
$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ; |
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER); |
} |
//affichage du formulaire si conditions acceptées |
//affichage du formulaire si conditions acceptees |
else { |
//Parcours du fichier de templates, pour mettre les valeurs des champs |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']); |
if ($mode=='modification') { |
//Ajout des valeurs par defaut |
$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ; |
for ($i=0; $i<count($tableau); $i++) { |
if (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) { |
$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd']; |
//Parcours du fichier de templates, pour mettre les valeurs des champs |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']); |
if ($mode=='modification') { |
//Ajout des valeurs par defaut |
$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ; |
for ($i=0; $i<count($tableau); $i++) { |
if ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) { |
$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd']; |
} |
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) { |
$def=$tableau[$i]['nom_bdd']; |
} |
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'], |
$tableau[$i]['limite2'], $valeurs_par_defaut[$def], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ; |
} |
else { |
$def=$tableau[$i]['nom_bdd']; |
} |
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'], |
$tableau[$i]['limite2'], $valeurs_par_defaut[$def], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ; |
} |
} |
else { |
for ($i=0; $i<count($tableau); $i++) { |
$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']) ; |
} |
} |
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']); |
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER); |
if ($mode=='modification') { |
//initialisation de la variable globale id_fiche |
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST['id_fiche']; |
//preparation des formulaires supplementaires |
//AJOUTER UNE IMAGE |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER); |
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
$lien_formulaire->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']); |
$lien_formulaire->addQueryString('image', '1'); |
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche']; |
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ; |
if (DB::isError ($resultat)) { |
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$image=$ligne->bf_url_image; |
} |
if ($image!=NULL) { |
$html='<hr /><img src="client/bazar/images/'.$image.'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n"; |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
$lien_supprimer->addQueryString('image', '2'); |
$html.= '<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n"; |
$formimage = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL()) ) ; |
$formimage->addElement('html', $html) ; |
} |
else { |
$formimage = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL()) ) ; |
$formimage->addElement('html', '<hr /><h3>'.BAZ_AJOUTER_IMAGE.'</h3>') ; |
$formimage->addElement('file', 'image', BAZ_IMAGE) ; |
$formimage->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, '', '', 'client') ; //a completer pour checker l'image |
$formimage->setMaxFileSize(BAZ_TAILLE_MAX_FICHIER); |
$formimage->addElement('submit', 'valider', BAZ_VALIDER); |
} |
} |
else { |
$formimage = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL()) ) ; |
$formimage->addElement('html', '<hr /><h3>'.BAZ_AJOUTER_IMAGE.'</h3>'."\n") ; |
$formimage->addElement('file', 'image', BAZ_IMAGE) ; |
$formimage->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, '', '', 'client') ; //a completer pour checker l'image |
$formimage->setMaxFileSize(BAZ_TAILLE_MAX_FICHIER); |
$formimage->addElement('submit', 'valider', BAZ_VALIDER); |
for ($i=0; $i<count($tableau); $i++) { |
$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']) ; |
} |
} |
//AJOUTER DES URL |
//recherche des URLs déjà entrées dans la base |
$requete = 'SELECT bu_id_url, 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 ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$html= '<hr /><h3>'.BAZ_LISTE_URL.'</h3>'."\n"; |
$tableAttr = array("id" => "table_bazar") ; |
$table = new HTML_Table($tableAttr) ; |
$entete = array (BAZ_LIEN , BAZ_SUPPRIMER) ; |
$table->addRow($entete) ; |
$table->setRowType(0, "th") ; |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
$lien_supprimer->addQueryString('url', '2'); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$lien_supprimer->addQueryString('id_url', $ligne->bu_id_url); |
$table->addRow (array( |
'<a href="'.$ligne->bu_url.'" target="_blank"> '.$ligne->bu_descriptif_url.'</a>', // col 1 : le lien |
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer |
$lien_supprimer->removeQueryString('id_url'); |
} |
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire")); |
$table->updateColAttributes(1, array("align" => "center")); |
$html.= $table->toHTML()."\n" ; |
} |
else { |
$html= '<hr /><h3>'.BAZ_PAS_URL.'</h3>'."\n"; |
} |
$html.='<h4>'.BAZ_AJOUTER_URL.'</h4>'."\n"; |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
$lien_formulaire->addQueryString('action', $_GET['action']); |
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_formulaire->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']); |
$lien_formulaire->addQueryString('url', '1'); |
$formurl = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL())) ; |
$formurl->addElement('html', $html) ; |
$formurl->addElement('text', 'url_lien', BAZ_URL_LIEN) ; |
$formurl->addElement('text', 'url_texte', BAZ_URL_TEXTE) ; |
$formurl->addRule('url_lien', BAZ_URL_LIEN_REQUIS, 'required', '', 'client') ; |
$formurl->addRule('url_texte', BAZ_URL_TEXTE_REQUIS, 'required', '', 'client') ; |
//AJOUTER DES FICHIERS JOINTS |
$requete = 'SELECT * FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']["id_fiche"]; |
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ; |
if (DB::isError ($resultat)) { |
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$html= '<hr /><h3>'.BAZ_LISTE_FICHIERS_JOINTS.'</h3>'."\n"; |
$tableAttr = array("id" => "table_bazar") ; |
$table = new HTML_Table($tableAttr) ; |
$entete = array (BAZ_FICHIER , BAZ_SUPPRIMER) ; |
$table->addRow($entete) ; |
$table->setRowType(0, "th") ; |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
$lien_supprimer->addQueryString('fichier', '2'); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$lien_supprimer->addQueryString('id_fichier', $ligne->bfj_id_fichier); |
$table->addRow (array( |
'<a href="/client/bazar/upload/'.$ligne->bfj_fichier.'"> '.$ligne->bfj_description.'</a>', // col 1 : le fichier et sa description |
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer |
$lien_supprimer->removeQueryString('id_fichier'); |
} |
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire")); |
$table->updateColAttributes(1, array("align" => "center")); |
$html.= $table->toHTML()."\n" ; |
} |
else { |
$html= '<hr /><h3>'.BAZ_PAS_DE_FICHIERS_JOINTS.'</h3>'."\n"; |
} |
$html.='<h4>'.BAZ_AJOUTER_FICHIER_JOINT.'</h4>'."\n"; |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
$lien_formulaire->addQueryString('action', $_GET['action']); |
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']); |
$lien_formulaire->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']); |
$lien_formulaire->addQueryString('fichier', '1'); |
$formfichiers = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL())) ; |
$formfichiers->addElement('html', $html) ; |
$formfichiers->addElement('file', 'fichier_joint', BAZ_FICHIER_JOINT) ; |
$formfichiers->addElement('text', 'fichier_description', BAZ_FICHIER_DESCRIPTION) ; |
$formfichiers->addRule('fichier_joint', BAZ_FICHIER_JOINT_REQUIS, 'required', '', 'client') ; |
$formfichiers->addRule('fichier_description', BAZ_FICHIER_LABEL_REQUIS, 'required', '', 'client') ; |
$formfichiers->setMaxFileSize(BAZ_TAILLE_MAX_FICHIER); |
//Ajout de 'http://' comme valeur par default d'une url |
$formurl->setDefaults(array('url_lien'=>'http://')); |
//Bouton de validation du formulaire |
$formurl->addElement('submit', 'valider', BAZ_VALIDER); |
$formfichiers->addElement('submit', 'valider', BAZ_VALIDER); |
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']); |
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER); |
} |
} |
//Affichage a l'ecran |
$res .= $formtemplate->toHTML()."\n"; |
if (isset($formimage)) $res .= $formimage->toHTML()."\n".$formurl->toHTML()."\n".$formfichiers->toHTML()."\n"; |
$res .= $formtemplate->toHTML()."\n"; |
return $res; |
} |
787,11 → 640,15 |
} |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']); |
for ($i=0; $i<count($tableau); $i++) { |
if ($tableau[$i]['type']!='labelhtml') { |
//cas des checkbox et des listes |
if (($tableau[$i]['type']=='checkbox')or($tableau[$i]['type']=='liste')) { |
//on supprime les anciennes valeurs de la table bazar_fiche_valeur_liste |
$requetesuppression='DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd']; |
//cas des checkbox et des listes |
if ($tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='liste') { |
//on supprime les anciennes valeurs de la table bazar_fiche_valeur_liste |
$requetesuppression='DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetesuppression) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
if (isset($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) { |
//on insere les nouvelles valeurs |
$requeteinsertion='INSERT INTO bazar_fiche_valeur_liste (bfvl_ce_fiche, bfvl_ce_liste, bfvl_valeur) VALUES '; |
//pour les checkbox, les différentes valeurs sont dans un tableau |
798,6 → 655,7 |
if (is_array($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) { |
$nb=0; |
while (list($cle, $val) = each($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) { |
if ($nb>0) $requeteinsertion .= ', '; |
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$cle.') '; |
$nb++; |
807,33 → 665,42 |
else { |
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']].')'; |
} |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetesuppression) ; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requeteinsertion) ; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requeteinsertion) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
} |
} |
//cas des fichiers |
elseif ($tableau[$i]['type']=='fichier') { |
if (isset($valeur['texte_fichier'.$tableau[$i]['nom_bdd']]) && $valeur['texte_fichier'.$tableau[$i]['nom_bdd']]!='') { |
baz_insertion_fichier($valeur['texte_fichier'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche'], 'fichier'.$tableau[$i]['nom_bdd']); |
} |
} |
//cas des urls |
elseif ($tableau[$i]['type']=='url') { |
if (isset($valeur['url_lien'.$tableau[$i]['nom_bdd']]) && $valeur['url_lien'.$tableau[$i]['nom_bdd']]!='' ) { |
baz_insertion_url($valeur['url_lien'.$tableau[$i]['nom_bdd']], $valeur['url_texte'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche']); |
} |
//cas des fichiers |
elseif ($tableau[$i]['type']=='fichier') { |
baz_insertion_fichier($valeur['texte_fichier'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche'], 'fichier'.$tableau[$i]['nom_bdd']); |
} |
//cas des urls |
elseif ($tableau[$i]['type']=='url') { |
baz_insertion_url($valeur['url_texte'.$tableau[$i]['nom_bdd']], $valeur['url_lien'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche']); |
} |
//cas des images |
elseif ($tableau[$i]['type']=='image') { |
if (isset($_FILES['image']['name']) && $_FILES['image']['name']!='') { |
baz_insertion_image($GLOBALS['_BAZAR_']['id_fiche']); |
} |
else { |
//cas des dates |
if (($tableau[$i]['type']=='listedatedeb')or($tableau[$i]['type']=='listedatefin')) { |
$val=$valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ; |
} |
elseif (($tableau[$i]['type']=='texte')or($tableau[$i]['type']=='textelong')) { |
//on mets les slashes pour les saisies dans les champs texte et textearea |
$val=addslashes($valeur[$tableau[$i]['nom_bdd']]) ; |
} |
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ; |
} |
} |
} |
//cas des dates |
elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) { |
$val=$valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ; |
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ; |
} |
//cas des champs texte |
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) { |
//on mets les slashes pour les saisies dans les champs texte et textearea |
$val=addslashes($valeur[$tableau[$i]['nom_bdd']]) ; |
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ; |
} |
} |
$requete.=' bf_date_maj_fiche=NOW()'; |
return $requete; |
} |
863,7 → 730,7 |
} |
/** baz_insertion_url() - inserer un lien URL à une fiche |
/** baz_insertion_url() - inserer un lien URL a une fiche |
* |
* @global string L'url du lien |
* @global string Le texte du lien |
902,7 → 769,6 |
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name']; |
move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination); |
} |
//else echo BAZ_FICHIER_EXISTANT; |
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ; |
$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche. |
', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"'; |
914,7 → 780,7 |
} |
/** baz_insertion_image() - insérer une image à une fiche |
/** baz_insertion_image() - inserer une image a une fiche |
* |
* @global integer L'identifiant de la fiche |
* @return void |
927,11 → 793,10 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()==0) { |
$chemin_destination=BAZ_CHEMIN_APPLI.'images/'.$_FILES['image']['name']; |
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name']; |
move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination); |
} |
else echo BAZ_FICHIER_EXISTANT; |
//vérification de l'existence de la fiche |
//verification de l'existence de la fiche |
$requete = 'SELECT bf_id_fiche FROM bazar_fiche WHERE bf_id_fiche='.$idfiche; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
1009,9 → 874,6 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
baz_suppression_fichier($ligne['bfj_id_fichier']); |
} |
//suppression de l'image associée |
baz_suppression_image($_GET['id_fiche']); |
return ; |
} |
1045,10 → 907,10 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$ligne['bfj_fichier'].'"'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
//si le fichier n'est que utilisé dans cette fiche, on le supprime, on le laisse sinon |
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon |
if ($resultat->numRows()==1) { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
unlink($ligne['bfj_fichier']); |
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bfj_fichier']); |
} |
//suppression dans la table bazar_fichier |
1073,10 → 935,10 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_url_image="'.$ligne['bf_url_image'].'"'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
//si le fichier n'est que utilisé dans cette fiche, on le supprime, on le laisse sinon |
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon |
if ($resultat->numRows()==1) { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
unlink(BAZ_CHEMIN_APPLI.'images/'.$ligne['bf_url_image']); |
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bf_url_image']); |
} |
//suppression dans la table bazar_fiche |
1120,6 → 982,7 |
* @return string le code HTML |
*/ |
function baz_s_inscrire() { |
$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2><br />'."\n"; |
if (isset($_GET['inscrip'])) { |
//cas d'une desinscription |
if ($_GET['inscrip']==0) { |
1136,7 → 999,6 |
} |
if ($GLOBALS['AUTH']->getAuth()) { |
$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2><br />'."\n"; |
$res .= BAZ_LAIUS_S_ABONNER.'<br /><br />'."\n"; |
//requete pour obtenir l'id et le label des types d'annonces |
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre '. |
1203,7 → 1065,7 |
$table->updateColAttributes(3, array('style' => 'text-align:center;')); |
$res.=$table->toHTML() ; |
} |
else $res=BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR; |
else $res .= '<p class="zone_info">'.BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR.'</p>'."\n"; |
return $res; |
} |
1225,26 → 1087,24 |
$valeurs_fiche = array() ; |
$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']); |
for ($i=0; $i<count($tableau); $i++) { |
if ($tableau[$i]['type']!='labelhtml') { |
if (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) { |
$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche. |
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
$nb=0;$val=''; |
while ($result = $resultat->fetchRow()) { |
if ($nb>0) $val .= ', '; |
$val .= $result[0]; |
$nb++; |
} |
$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val; |
} |
else { |
$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]); |
} |
} |
if ($tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') { |
$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche. |
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd']; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
$nb=0;$val=''; |
while ($result = $resultat->fetchRow()) { |
if ($nb>0) $val .= ', '; |
$val .= $result[0]; |
$nb++; |
} |
$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val; |
} |
elseif ($tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin') { |
$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]); |
} |
} |
return $valeurs_fiche; |
} |
1313,6 → 1173,9 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.46 2006/03/29 13:04:35 alexandre_tb |
* utilisation de la classe Administrateur_bazar |
* |
* Revision 1.45 2006/03/24 09:28:02 alexandre_tb |
* utilisation de la variable globale $GLOBALS['_BAZAR_']['filtre'] |
* |