From b3b9f68cd8bc39b728ce27824bea488592a9788c Mon Sep 17 00:00:00 2001 From: clem Date: Wed, 9 Dec 2020 02:44:12 +0100 Subject: [PATCH] =?UTF-8?q?d=C3=A9marrage=20de=20la=20branche=20pour=20pre?= =?UTF-8?q?ndre=20en=20compte=20le=20mode=20pass=C3=A9=20au=20formulaire?= =?UTF-8?q?=20bigform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formulaires/bigform.php | 4 ++- inc/bigform_traiter.php | 40 +++++++++++++------------- inclure/bigform_doc.html | 61 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 80 insertions(+), 25 deletions(-) diff --git a/formulaires/bigform.php b/formulaires/bigform.php index 796ec7b..8da974f 100644 --- a/formulaires/bigform.php +++ b/formulaires/bigform.php @@ -10,7 +10,8 @@ function formulaires_bigform_charger_dist($objet, $id_objet, $mode = 'auto', $ar $valeurs = [ '_bigup_rechercher_fichiers' => true, 'id_objet' => $id_objet, - 'objet' => $objet + 'objet' => $objet, + 'mode' => $mode ]; $valeurs['objet_ok'] = ''; @@ -23,6 +24,7 @@ function formulaires_bigform_charger_dist($objet, $id_objet, $mode = 'auto', $ar } function formulaires_bigform_verifier_dist($objet, $id_objet, $mode = 'auto', $args = array()) { + $erreurs = array(); return $erreurs; } diff --git a/inc/bigform_traiter.php b/inc/bigform_traiter.php index b584e18..b2f2122 100644 --- a/inc/bigform_traiter.php +++ b/inc/bigform_traiter.php @@ -3,7 +3,6 @@ if (!defined('_ECRIRE_INC_VERSION')){ return; } - /** * fonction de recuperation et liaison image / objet * @@ -28,12 +27,6 @@ function inc_bigform_traiter_dist($id_objet, $objet = 'article', $mode = 'auto', } } - // en mode logoon, on va supprimer le (ou les) anciens logos. on récupère d'abord leurs id - //if ($mode == 'logoon'){ - //$T_docs_objet = sql_allfetsel('id_document','spip_documents_liens',"id_objet=".intval($id_objet)." AND objet='" . $objet . "'"); - //} - // - /* * On peut utiliser une fonction SPIP * pour supprimer les logos @@ -59,8 +52,26 @@ function inc_bigform_traiter_dist($id_objet, $objet = 'article', $mode = 'auto', autoriser_exception('associerdocuments', $objet, $id_objet); $autorisation_temp = true; } - $ajouter_document = charger_fonction('ajouter_documents', 'action'); - $Tid_doc = $ajouter_document('new', $files, $objet, $id_objet, $mode); + + // traitement vignette (pompé sur medias/formulaires/illustrer_document.php) + if ($mode === 'vignette') { + $id_vignette = sql_getfetsel('id_vignette', 'spip_documents', 'id_document=' . intval($id_objet)); + $ajouter_documents = charger_fonction('ajouter_documents', 'action'); + $ajoute = $ajouter_documents($id_vignette, $files, '', 0, 'vignette'); + + if (is_numeric(reset($ajoute)) + and $id_vignette = reset($ajoute) + ) { + include_spip('action/editer_document'); + document_modifier($id_objet, array('id_vignette' => $id_vignette, 'mode' => 'document')); + } + } + // traitement doc ou logo + else { + $ajouter_document = charger_fonction('ajouter_documents', 'action'); + $Tid_doc = $ajouter_document('new', $files, $objet, $id_objet, $mode); + } + if ($autorisation_temp) { autoriser_exception('associerdocuments', $objet, $id_objet, false); } @@ -71,17 +82,6 @@ function inc_bigform_traiter_dist($id_objet, $objet = 'article', $mode = 'auto', } } - // si tout s'est bien passé, on supprime le/les anciens logos - //if ($mode == 'logoon'){ - //foreach ($T_docs_objet as $i => $ligne) { - //$id_doc = $ligne['id_document']; - //if (sql_getfetsel('mode','spip_documents','id_document=' . intval($id_doc)) == 'logoon'){ - //sql_delete('spip_documents', 'id_document='.intval($id_doc)); - //sql_delete('spip_documents_liens', 'id_document='.intval($id_doc)); - //} - //} - //} - if (!empty($html_titre) and count($Tid_doc)) { foreach ($Tid_doc as $i => $id_doc) { $titre = $lesTitres[$i]; diff --git a/inclure/bigform_doc.html b/inclure/bigform_doc.html index a527f83..1bf1a71 100644 --- a/inclure/bigform_doc.html +++ b/inclure/bigform_doc.html @@ -14,8 +14,13 @@ flex-grow: 1; } +[(#REM) + affichage selon le mode : logoon logoff image vignette document + défaut = document + +] #SET{mode, #ENV{mode,document}}
- +
[(#EXTENSION|match{jpg|png|gif}|oui) @@ -46,10 +51,34 @@
+ + +
+ +
+
+ [(#AUTORISER{modifier, #ENV{objet}, #ENV{id_objet}}) +
+ + + +
+ ] +
+
+
+ + - - -
+ +
+ + mode2: #MODE +
+ +
+
+ [
(#TITRE|sinon{[(#AUTORISER{modifier, #ENV{objet}, #ENV{id_objet}})]})
] +
[(#FICHIER|basename)]
+
+ [(#AUTORISER{modifier, #ENV{objet}, #ENV{id_objet}}) + + + + ] +
+
+