on ajoute un input hidden avec le nom du fichier pour pouvoir recreer proprement l'ordre du files

This commit is contained in:
Christophe 2019-12-09 11:37:31 +01:00
parent 431dc0bb8c
commit 356f70aab5
3 changed files with 16 additions and 4 deletions

View file

@ -14,18 +14,28 @@ if (!defined('_ECRIRE_INC_VERSION')){
function inc_bigform_dist($id_objet,$objet = 'article',$mode='auto') { function inc_bigform_dist($id_objet,$objet = 'article',$mode='auto') {
include_spip('inc/joindre_document'); include_spip('inc/joindre_document');
set_request('joindre_upload','ok'); set_request('joindre_upload','ok');
$files = joindre_trouver_fichier_envoye(); $files = joindre_trouver_fichier_envoye();
$html_titre = _request('html_titre');
$html_ordre = _request('html_ordre');
// calcul ordre des titres des files uploades
$lesTitres = [];
foreach ($files as $i => $t) {
$index = array_search($t['name'], $html_ordre);
$lesTitres[] = $html_titre[$index];
}
$Tid_doc = []; $Tid_doc = [];
if (is_array($files) and count($files)) { if (is_array($files) and count($files)) {
$ajouter_document = charger_fonction('ajouter_documents', 'action'); $ajouter_document = charger_fonction('ajouter_documents', 'action');
$Tid_doc = $ajouter_document('new', $files, $objet, $id_objet,$mode); $Tid_doc = $ajouter_document('new', $files, $objet, $id_objet,$mode);
} }
$html_titre = _request('html_titre');
if (!empty($html_titre) and count($Tid_doc)) { if (!empty($html_titre) and count($Tid_doc)) {
foreach ($Tid_doc as $i => $id_doc) { foreach ($Tid_doc as $i => $id_doc) {
$titre = $html_titre[$i]; $titre = $lesTitres[$i];
if ($titre) { if ($titre) {
sql_updateq('spip_documents', array("titre" => $titre), 'id_document='.intval($id_doc)); sql_updateq('spip_documents', array("titre" => $titre), 'id_document='.intval($id_doc));
} }

View file

@ -6,7 +6,9 @@
function bigform() { function bigform() {
$('input.bigup').bigup({}, { $('input.bigup').bigup({}, {
fileSuccess: function (a, b) { fileSuccess: function (a, b) {
var html_titre = '<label><:bigform:html_titre:> <input type="text" value="" name="html_titre\[\]"/></label>'; var html_ordre = '<input type="hidden" value="'+b.file.name+'" name="html_ordre\[\]"/>';
var html_titre = '<div class="html_titre"><label><:bigform:html_titre:> <input type="text" value="" name="html_titre\[\]"/></label></div>';
$(html_ordre).insertAfter($(b.emplacement[0]).children().children('.infos'));
$(html_titre).insertAfter($(b.emplacement[0]).children().children('.infos')); $(html_titre).insertAfter($(b.emplacement[0]).children().children('.infos'));
} }
}); });

View file

@ -1,7 +1,7 @@
<paquet <paquet
prefix="bigform" prefix="bigform"
categorie="edition" categorie="edition"
version="1.0.0" version="1.0.1"
etat="dev" etat="dev"
compatibilite="[3.2.6-dev;3.3.*]" compatibilite="[3.2.6-dev;3.3.*]"
logo="prive/themes/spip/images/bigform-64.png" logo="prive/themes/spip/images/bigform-64.png"