1 | <?php |
---|
2 | /* |
---|
3 | * Plugin Porte Plume pour SPIP 2 |
---|
4 | * Licence GPL |
---|
5 | * Auteur Matthieu Marcillaud |
---|
6 | */ |
---|
7 | #define('PORTE_PLUME_PUBLIC', true); |
---|
8 | |
---|
9 | function porte_plume_autoriser($flux){return $flux;} |
---|
10 | |
---|
11 | /** |
---|
12 | * Autoriser l'action de previsu : la fermer aux non identifies |
---|
13 | * si pas de porte plume dans le public |
---|
14 | * @param string $faire |
---|
15 | * @param string $type |
---|
16 | * @param int $id |
---|
17 | * @param array $qui |
---|
18 | * @param array $opt |
---|
19 | * @return bool |
---|
20 | */ |
---|
21 | function autoriser_porteplume_previsualiser_dist($faire, $type, $id, $qui, $opt){ |
---|
22 | return |
---|
23 | (test_espace_prive() AND autoriser('ecrire')) |
---|
24 | OR (!test_espace_prive() AND autoriser('afficher_public','porteplume')); |
---|
25 | } |
---|
26 | |
---|
27 | // autoriser le porte plume dans le public ? |
---|
28 | function autoriser_porteplume_afficher_public_dist($faire, $type, $id, $qui, $opt) { |
---|
29 | // compatibilite d'avant le formulaire de configuration |
---|
30 | if (defined('PORTE_PLUME_PUBLIC')) { |
---|
31 | return PORTE_PLUME_PUBLIC; |
---|
32 | } |
---|
33 | return ($GLOBALS['meta']['barre_outils_public'] !== 'non'); |
---|
34 | |
---|
35 | // n'autoriser qu'aux identifies : |
---|
36 | # return $qui['id_auteur'] ? PORTE_PLUME_PUBLIC : false; |
---|
37 | } |
---|
38 | |
---|
39 | function porte_plume_insert_head_public($flux){ |
---|
40 | include_spip('inc/autoriser'); |
---|
41 | if (autoriser('afficher_public', 'porteplume')) { |
---|
42 | $flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang']); |
---|
43 | } |
---|
44 | return $flux; |
---|
45 | } |
---|
46 | |
---|
47 | function porte_plume_insert_head_prive($flux){ |
---|
48 | $js = find_in_path('javascript/porte_plume_forcer_hauteur.js'); |
---|
49 | $flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang'], $prive=true) |
---|
50 | . "<script type='text/javascript' src='$js'></script>\n"; |
---|
51 | |
---|
52 | return $flux; |
---|
53 | } |
---|
54 | |
---|
55 | function porte_plume_inserer_head($flux, $lang, $prive = false){ |
---|
56 | $xregexp = find_in_path('javascript/xregexp-min.js'); |
---|
57 | $markitup = find_in_path('javascript/jquery.markitup_pour_spip.js'); |
---|
58 | $js_previsu = find_in_path('javascript/jquery.previsu_spip.js'); |
---|
59 | $js_start = parametre_url(generer_url_public('porte_plume_start.js'), 'lang', $lang); |
---|
60 | if (_VAR_MODE=="recalcul") |
---|
61 | $js_start = parametre_url($js_start, 'var_mode', 'recalcul'); |
---|
62 | |
---|
63 | $flux |
---|
64 | .= porte_plume_insert_head_css('', $prive) // compat SPIP 2.0 |
---|
65 | . "<script type='text/javascript' src='$xregexp'></script>\n" |
---|
66 | . "<script type='text/javascript' src='$markitup'></script>\n" |
---|
67 | . "<script type='text/javascript' src='$js_previsu'></script>\n" |
---|
68 | . "<script type='text/javascript' src='$js_start'></script>\n"; |
---|
69 | |
---|
70 | return $flux; |
---|
71 | } |
---|
72 | |
---|
73 | // pour charger tous les CSS avant les JS |
---|
74 | // uniquement dans le public. (SPIP 2.1+) |
---|
75 | // ici aussi appele depuis le prive avec le parametre $prive a true. |
---|
76 | function porte_plume_insert_head_css($flux='', $prive = false){ |
---|
77 | static $done = false; |
---|
78 | if ($done) return $flux; |
---|
79 | $done = true; |
---|
80 | include_spip('inc/autoriser'); |
---|
81 | // toujours autoriser pour le prive. |
---|
82 | if ($prive or autoriser('afficher_public', 'porteplume')) { |
---|
83 | if ($prive) { |
---|
84 | $cssprive = find_in_path('css/barre_outils_prive.css'); |
---|
85 | $flux .= "<link rel='stylesheet' type='text/css' media='all' href='$cssprive' />\n"; |
---|
86 | } |
---|
87 | $css = direction_css(find_in_path('css/barre_outils.css'), lang_dir()); |
---|
88 | $css_icones = generer_url_public('barre_outils_icones.css'); |
---|
89 | if (_VAR_MODE=="recalcul") |
---|
90 | $css_icones = parametre_url($css_icones, 'var_mode', 'recalcul'); |
---|
91 | $flux |
---|
92 | .= "<link rel='stylesheet' type='text/css' media='all' href='$css' />\n" |
---|
93 | . "<link rel='stylesheet' type='text/css' media='all' href='$css_icones' />\n"; |
---|
94 | } |
---|
95 | return $flux; |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | // valeur par defaut des configurations |
---|
100 | function porte_plume_configurer_liste_metas($metas){ |
---|
101 | $metas['barre_outils_public'] = 'oui'; |
---|
102 | return $metas; |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | function porte_plume_affiche_milieu($flux){ |
---|
107 | if ($flux['args']['exec']=='configurer_avancees') |
---|
108 | $flux['data'] .= recuperer_fond('prive/squelettes/inclure/configurer',array('configurer'=>'configurer_porte_plume')); |
---|
109 | |
---|
110 | return $flux; |
---|
111 | } |
---|
112 | ?> |
---|