Last change
on this file since 88797 was
88797,
checked in by p@…, 6 years ago
|
On ajoute un test sur la fonction (trop de dispertion)
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php |
---|
2 | /** |
---|
3 | * Fonctions utiles au plugin Formulaire upload html5 |
---|
4 | * |
---|
5 | * @plugin Formulaire upload html5 |
---|
6 | * @copyright 2014 |
---|
7 | * @author Phenix |
---|
8 | * @licence GNU/GPL |
---|
9 | * @package SPIP\Uploadhtml5\Fonctions |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('_ECRIRE_INC_VERSION')) return; |
---|
13 | |
---|
14 | /** |
---|
15 | * Uploader et lier des documents à un objet SPIP |
---|
16 | * |
---|
17 | * @param mixed $files $_FILES envoyer par un formulaire had hoc |
---|
18 | * @param mixed $objet |
---|
19 | * @param mixed $id_objet |
---|
20 | * @param string $id_document Dans le cas ou l'on veux remplacer un document. |
---|
21 | * @access public |
---|
22 | */ |
---|
23 | if (!function_exists('uploader_document')) { |
---|
24 | function uploader_document($files, $objet, $id_objet, $id_document='new') { |
---|
25 | // On va créer le tableau des documents. |
---|
26 | $docs = array(); |
---|
27 | foreach ($files as $doc) { |
---|
28 | // pas de fichier vide |
---|
29 | if (!empty($doc['name'])) |
---|
30 | $docs[] = $doc; |
---|
31 | } |
---|
32 | |
---|
33 | // On fait un test au cas ou |
---|
34 | if (!empty($docs)) { |
---|
35 | // On ajoute les documents a un objet SPIP. |
---|
36 | $ajouter_documents = charger_fonction('ajouter_documents','action'); |
---|
37 | $ajouter_documents( |
---|
38 | $id_document, |
---|
39 | $docs, |
---|
40 | $objet, // Article, rubrique, autre objet |
---|
41 | $id_objet, |
---|
42 | 'document' |
---|
43 | ); |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.