Pour l'usage : insertion dans un formulaire existant => OK
il y a meme un champ titre possible lire le readme pour le fonctionnement
This commit is contained in:
parent
0e0a703800
commit
431dc0bb8c
7 changed files with 59 additions and 18 deletions
17
README.md
17
README.md
|
@ -1,9 +1,24 @@
|
||||||
# Plugin bigform
|
# Plugin bigform
|
||||||
> plugin proposant un formulaire CVT pour le plugin bigup
|
> plugin proposant un formulaire CVT pour le plugin bigup
|
||||||
|
|
||||||
Usage :
|
## Usage 1 : en formulaire autonome (comme html5_upload)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
#FORMULAIRE_BIGFORM{objet, id_objet, mode, args}
|
#FORMULAIRE_BIGFORM{objet, id_objet, mode, args}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Usage 2 : en inclure dans un formulaire
|
||||||
|
> Ajoute dynamiquement un champ **titre** pour chaque image
|
||||||
|
1. dans le formulaire html:
|
||||||
|
```html
|
||||||
|
<INCLURE{fond=inclure/bigform,env}>
|
||||||
|
```
|
||||||
|
2. dans le formulaire php
|
||||||
|
```php
|
||||||
|
// dans le charger :
|
||||||
|
$valeurs['_bigup_rechercher_fichiers'] = true;
|
||||||
|
|
||||||
|
// dans le traiter
|
||||||
|
$bigform = charger_fonction('bigform','inc');
|
||||||
|
$bigform($id_objet, $objet);
|
||||||
|
```
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[(#ENV{objet_ok})
|
[(#ENV{objet_ok}|oui)
|
||||||
<div class="formulaire_spip formulaire_#FORM">
|
<div class="formulaire_spip formulaire_#FORM">
|
||||||
|
|
||||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
|
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
|
||||||
|
@ -18,14 +18,4 @@
|
||||||
</div></form>
|
</div></form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
$('input.bigup').bigup({}, {
|
|
||||||
complete: function(){
|
|
||||||
$('#valider_bigup').trigger('click');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,7 +11,9 @@ function formulaires_bigform_charger_dist($objet, $id_objet, $mode = 'auto', $ar
|
||||||
'_bigup_rechercher_fichiers' => true,
|
'_bigup_rechercher_fichiers' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (intval($id_objet) and $objet) {
|
$valeurs['objet_ok'] = '';
|
||||||
|
|
||||||
|
if (intval($id_objet) > 0 and $objet) {
|
||||||
$valeurs['objet_ok'] = 'ok';
|
$valeurs['objet_ok'] = 'ok';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +28,7 @@ function formulaires_bigform_verifier_dist($objet, $id_objet, $mode = 'auto', $a
|
||||||
function formulaires_bigform_traiter_dist($objet = 'article', $id_objet = 0, $mode = 'auto', $args = array()) {
|
function formulaires_bigform_traiter_dist($objet = 'article', $id_objet = 0, $mode = 'auto', $args = array()) {
|
||||||
|
|
||||||
$bigform = charger_fonction('bigform','inc');
|
$bigform = charger_fonction('bigform','inc');
|
||||||
|
|
||||||
$bigform($id_objet,$objet,$mode);
|
$bigform($id_objet,$objet,$mode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,26 @@ if (!defined('_ECRIRE_INC_VERSION')){
|
||||||
* @param $mode
|
* @param $mode
|
||||||
* @return array tableau des id_document $Tid_doc
|
* @return array tableau des id_document $Tid_doc
|
||||||
*/
|
*/
|
||||||
function inc_bigform_dist($id_objet,$objet,$mode) {
|
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();
|
||||||
|
|
||||||
$Tid_doc = [];
|
$Tid_doc = [];
|
||||||
if (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)) {
|
||||||
|
foreach ($Tid_doc as $i => $id_doc) {
|
||||||
|
$titre = $html_titre[$i];
|
||||||
|
if ($titre) {
|
||||||
|
sql_updateq('spip_documents', array("titre" => $titre), 'id_document='.intval($id_doc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $Tid_doc;
|
return $Tid_doc;
|
||||||
}
|
}
|
||||||
|
|
7
inclure/bigform.html
Normal file
7
inclure/bigform.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[(#SAISIE{bigup, fichiers,
|
||||||
|
form, formulaire_args,
|
||||||
|
previsualiser=oui,
|
||||||
|
accept=image/*,
|
||||||
|
multiple=oui})]
|
||||||
|
|
||||||
|
<INCLURE{fond=js/bigform.js,env}>
|
16
js/bigform.js.html
Normal file
16
js/bigform.js.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
jQuery(function () {
|
||||||
|
bigform();
|
||||||
|
|
||||||
|
function bigform() {
|
||||||
|
$('input.bigup').bigup({}, {
|
||||||
|
fileSuccess: function (a, b) {
|
||||||
|
var html_titre = '<label><:bigform:html_titre:> <input type="text" value="" name="html_titre\[\]"/></label>';
|
||||||
|
$(html_titre).insertAfter($(b.emplacement[0]).children().children('.infos'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
|
@ -15,6 +15,9 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||||
'cfg_exemple_explication' => 'Explication de cet exemple',
|
'cfg_exemple_explication' => 'Explication de cet exemple',
|
||||||
'cfg_titre_parametrages' => 'Paramétrages',
|
'cfg_titre_parametrages' => 'Paramétrages',
|
||||||
|
|
||||||
|
//H
|
||||||
|
'html_titre' => 'Titre',
|
||||||
|
|
||||||
// T
|
// T
|
||||||
'titre_page_configurer_bigform' => 'BigForm',
|
'titre_page_configurer_bigform' => 'BigForm',
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue