1 | <?php |
---|
2 | /** |
---|
3 | * Utilisations de pipelines par Formulaire upload html5 |
---|
4 | * |
---|
5 | * @plugin Formulaire upload html5 |
---|
6 | * @copyright 2014 |
---|
7 | * @author Phenix |
---|
8 | * @licence GNU/GPL |
---|
9 | * @package SPIP\Uploadhtml5\Pipelines |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('_ECRIRE_INC_VERSION')) return; |
---|
13 | |
---|
14 | function uploadhtml5_jquery_plugins($scripts) { |
---|
15 | include_spip('inc/config'); |
---|
16 | $config = lire_config('uploadhtml5'); |
---|
17 | if ( |
---|
18 | (isset($config['charger_public']) and $config['charger_public']) // Si on doit charger dans l'espace publique |
---|
19 | or test_espace_prive() // Ou que l'on est dans l'espace privé |
---|
20 | ) { |
---|
21 | $scripts[] = 'lib/dropzone/dropzone.js'; // Charger Dropzone |
---|
22 | } |
---|
23 | |
---|
24 | return $scripts; |
---|
25 | } |
---|
26 | |
---|
27 | function uploadhtml5_insert_head_css($flux) { |
---|
28 | include_spip('inc/config'); |
---|
29 | $config = lire_config('uploadhtml5'); |
---|
30 | if ( |
---|
31 | (isset($config['charger_public']) and $config['charger_public']) // Si on doit charger dans l'espace publique |
---|
32 | or test_espace_prive() // Ou que l'on est dans l'espace privé |
---|
33 | ) { |
---|
34 | $flux .= '<link rel="stylesheet" href="'.find_in_path('lib/dropzone/dropzone.css').'" type="text/css" media="screen" />'; |
---|
35 | |
---|
36 | $flux .= '<link rel="stylesheet" href="'.find_in_path('css/saisie_upload.css').'" type="text/css" media="screen" />'; |
---|
37 | } |
---|
38 | |
---|
39 | return $flux; |
---|
40 | } |
---|
41 | |
---|
42 | function uploadhtml5_header_prive($flux) { |
---|
43 | $flux .= '<link rel="stylesheet" href="'.find_in_path('lib/dropzone/dropzone.css').'" type="text/css" media="screen" />'; |
---|
44 | |
---|
45 | $flux .= '<link rel="stylesheet" href="'.find_in_path('prive/css/dropzone_prive.css').'" type="text/css" media="screen" />'; |
---|
46 | |
---|
47 | |
---|
48 | return $flux; |
---|
49 | } |
---|
50 | |
---|
51 | function uploadhtml5_formulaire_fond($flux) { |
---|
52 | include_spip('inc/config'); |
---|
53 | $config = lire_config('uploadhtml5'); |
---|
54 | |
---|
55 | // Simplification de variable |
---|
56 | $objet = isset($flux['args']['contexte']['objet']) ? $flux['args']['contexte']['objet'] : ''; |
---|
57 | $id_objet = isset($flux['args']['contexte']['id_objet']) ? $flux['args']['contexte']['id_objet'] : 0; |
---|
58 | |
---|
59 | if ( |
---|
60 | $flux['args']['form'] == 'joindre_document' |
---|
61 | and ( |
---|
62 | isset($config['charger_public']) |
---|
63 | and $config['charger_public'] |
---|
64 | and !test_espace_prive() |
---|
65 | ) |
---|
66 | ) { |
---|
67 | |
---|
68 | // Récupérer le formulaire d'upload en html5 et lui passer une partie du contexte de joindre_document |
---|
69 | $uploadhtml5 = recuperer_fond( |
---|
70 | 'prive/squelettes/inclure/uploadhtml5', |
---|
71 | array( |
---|
72 | 'type' => $objet, |
---|
73 | 'id' => $id_objet |
---|
74 | ) |
---|
75 | ); |
---|
76 | |
---|
77 | // Injecter uloadhtml5 au dessus du formulaire joindre_document. |
---|
78 | $flux['data'] = $uploadhtml5.$flux['data']; |
---|
79 | } |
---|
80 | |
---|
81 | elseif ( |
---|
82 | $flux['args']['form'] == 'editer_logo' |
---|
83 | and ( |
---|
84 | isset($config['charger_public']) |
---|
85 | and $config['charger_public'] |
---|
86 | and !test_espace_prive() |
---|
87 | ) |
---|
88 | ) { |
---|
89 | |
---|
90 | $chercher_logo = charger_fonction('chercher_logo','inc'); |
---|
91 | if (!$chercher_logo($id_objet, id_table_objet($objet))) { |
---|
92 | |
---|
93 | |
---|
94 | // Bloc ajax par défaut |
---|
95 | $ajaxReload = 'navigation'; |
---|
96 | |
---|
97 | // Cas spécial: si on édite le logo du site, il faut recharger le contenu et non la navigation |
---|
98 | if ($id_objet == 0 and $objet == 'site') |
---|
99 | $ajaxReload = 'contenu'; |
---|
100 | |
---|
101 | // Récupérer le formulaire d'upload en html5 et lui passer une partie du contexte |
---|
102 | $uploadhtml5 = recuperer_fond( |
---|
103 | 'prive/squelettes/inclure/uploadhtml5_logo', |
---|
104 | array( |
---|
105 | 'type' => $objet, |
---|
106 | 'id' => $id_objet, |
---|
107 | 'ajaxReload' => $ajaxReload |
---|
108 | ) |
---|
109 | ); |
---|
110 | |
---|
111 | $config = lire_config('uploadhtml5'); |
---|
112 | // Injecter uloadhtml5 au dessus du formulaire joindre_document. |
---|
113 | if (isset($config['remplacer_editer_logo']) |
---|
114 | and $config['remplacer_editer_logo']) |
---|
115 | $flux['data'] = $uploadhtml5; |
---|
116 | else |
---|
117 | $flux['data'] = $uploadhtml5.$flux['data']; |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | return $flux; |
---|
122 | } |
---|
123 | |
---|
124 | |
---|
125 | /** |
---|
126 | * Lacher le cron de nettoyage des fichiers media temporaire toute les 24 heures |
---|
127 | * |
---|
128 | * @param mixed $taches |
---|
129 | * @access public |
---|
130 | * @return mixed |
---|
131 | */ |
---|
132 | function uploadhtml5_taches_generales_cron($taches) { |
---|
133 | $taches['nettoyer_document_temporaire'] = 24*3600; |
---|
134 | return $taches; |
---|
135 | } |
---|