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.14 2005-11-07 08:48:02 florian Exp $ |
// CVS : $Id: bazar.fonct.php,v 1.15 2005-11-07 17:05:45 florian Exp $ |
/** |
* |
* Fonctions du module bazar |
30,7 → 30,7 |
*@author Florian Schmitt <florian@ecole-et-nature.org> |
//Autres auteurs : |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.14 $ $Date: 2005-11-07 08:48:02 $ |
*@version $Revision: 1.15 $ $Date: 2005-11-07 17:05:45 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
243,7 → 243,7 |
* @return string code HTML avec formulaire |
*/ |
function baz_afficher_formulaire_annonce($mode='insertion',$formtemplate) { |
//vérification de la modification des fichiers, des url ou des images |
//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']); |
259,50 → 259,49 |
|
//titre de la rubrique |
$res= '<h2>'.BAZ_TITRE_SAISIE_ANNONCE.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'; |
//Ajout des boutons |
$bouton[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER, ' '); |
//Traduction de champs requis |
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ; |
|
//Parcours du fichier de templates, pour mettre les champs spécifiques |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['typeannonce'].'.tpl'); |
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']) ; |
} |
|
//ajout des conditions pour l'annonce si elles existent |
//ajout d'une page sur les conditions pour l'annonce si elles existent |
$requete = 'SELECT bn_condition FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"'; |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
if ($ligne['bn_condition']!='') { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
if (($ligne['bn_condition']!='')AND(!isset($_POST['accept_condition']))AND(!isset($_GET['url'])OR(!isset($_GET['fichier']))OR(!isset($_GET['image'])))) { |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
$lien_formulaire->addQueryString('action', $_REQUEST['action']); |
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL()) ); |
require_once 'HTML/QuickForm/html.php'; |
$conditions= new HTML_QuickForm_html('<tr><td colspan="2"><p style="padding:4px; margin:5px; width: 100%; background: #C1CBA7;">'.$ligne['bn_condition'].'</p></td></tr>'); |
$formtemplate->addElement('hidden','typeannonce', $_REQUEST['typeannonce']); |
if (isset($_REQUEST['id_fiche'])) $formtemplate->addElement('hidden','id_fiche', $_REQUEST['id_fiche']); |
$formtemplate->addElement($conditions); |
$formtemplate->addElement('checkbox', 'accept_condition',BAZ_ACCEPTE_CONDITIONS) ; |
$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ; |
$formtemplate->addGroup($bouton, null, null, ' '); |
} |
//affichage du formulaire si conditions acceptées |
else { |
//Parcours du fichier de templates, pour mettre les champs specifiques |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['typeannonce'].'.tpl'); |
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']) ; |
} |
|
//Ajout des boutons |
$bouton[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER, ' '); |
$formtemplate->addGroup($bouton, null, null, ' '); |
|
//Traduction de champs requis |
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ; |
if ($mode=='modification') { |
//initialisation de la variable globale id_fiche |
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST['id_fiche']; |
|
if ($mode=='modification') { |
//Ajout des valeurs par défaut |
//Ajout des valeurs par defaut |
$formtemplate->setDefaults(baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche'])) ; |
} |
|
//Affichage à l'écran |
$res.= $formtemplate->toHTML()."\n"; |
|
if ($mode=='modification') { |
//initialisation de la variable globale id_fiche |
if ($mode=='modification') $GLOBALS['_BAZAR_']['id_fiche'] = $_GET['id_fiche']; |
|
//préparation des formulaires supplémentaires |
//preparation des formulaires supplementaires |
//AJOUTER UNE IMAGE |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER); |
325,7 → 324,7 |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_GET['typeannonce']); |
$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></td></tr>'."\n"; |
$formimage = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&/', '&', $lien_formulaire->getURL()) ) ; |
367,7 → 366,7 |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_GET['typeannonce']); |
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']); |
$lien_supprimer->addQueryString('url', '2'); |
|
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
415,7 → 414,7 |
$lien_supprimer=$GLOBALS['_BAZAR_']['url']; |
$lien_supprimer->addQueryString('action', $_GET['action']); |
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]); |
$lien_supprimer->addQueryString('typeannonce', $_GET['typeannonce']); |
$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); |
448,14 → 447,15 |
|
//Ajout de 'http://' comme valeur par default d'une url |
$formurl->setDefaults(array('url_lien'=>'http://')); |
|
//Bouton de validation du formulaire |
$formurl->addGroup($bouton, null, null, ''); |
$formfichiers->addGroup($bouton, null, null, ''); |
} |
} |
//Affichage a l'ecran |
$res .= $formtemplate->toHTML()."\n"; |
if (isset($formimage)) $res .= $formimage->toHTML()."\n".$formurl->toHTML()."\n".$formfichiers->toHTML()."\n"; |
|
//Affichage à l'écran |
$res .= $formimage->toHTML()."\n".$formurl->toHTML()."\n".$formfichiers->toHTML()."\n"; |
} |
return $res; |
} |
|
468,8 → 468,8 |
*/ |
function baz_formulaire($mode = 'inscription') { |
if ($GLOBALS['AUTH']->getAuth()) { |
//Récupérer les éventuelles variables passées en GET ou en POST |
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche']; |
//Recuperer les eventuelles variables passees en GET ou en POST |
if (isset($_REQUEST['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_REQUEST['id_fiche']; |
if (isset($_REQUEST['typeannonce'])) { |
$GLOBALS['_BAZAR_']['typeannonce']=$_REQUEST['typeannonce']; |
// Pour éviter qu'un formulaire soit revalidé si l'utilisateur |
490,7 → 490,7 |
} |
} |
$lien_formulaire=$GLOBALS['_BAZAR_']['url']; |
//Définir le lien du formulaire en fonction du mode de formulaire choisi |
//Definir le lien du formulaire en fonction du mode de formulaire choisi |
if ($mode == 'inscription') $lien_formulaire->addQueryString('action', BAZ_ACTION_NOUVEAU_V); |
if ($mode == BAZ_DEPOSER_ANNONCE) $lien_formulaire->addQueryString('action', BAZ_DEPOSER_ANNONCE); |
if ($mode == BAZ_ACTION_NOUVEAU) $lien_formulaire->addQueryString('action', BAZ_ACTION_NOUVEAU_V); |
1333,6 → 1333,9 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.14 2005/11/07 08:48:02 florian |
* correction pb guillemets pour saisie et modif de fiche |
* |
* Revision 1.13 2005/10/21 16:15:04 florian |
* mise a jour appropriation |
* |