6af9205583b9bde1933d2a76554ffb259a7a2117
[velocampus/web/www.git] / www / extensions / porte_plume / porte_plume_start.js_fonctions.php
1 <?php
2
3 if (!defined("_ECRIRE_INC_VERSION")) return;
4
5 /**
6 * Retourne la definition de la barre markitup designee.
7 * (cette declaration est au format json)
8 *
9 * Deux pipelines 'porte_plume_pre_charger' et 'porte_plume_charger'
10 * permettent de recuperer l'objet de classe Barre_outil
11 * avant son export en json pour modifier des elements.
12 *
13 * @return string : declaration json
14 */
15 function porte_plume_creer_json_markitup(){
16 // on recupere l'ensemble des barres d'outils connues
17 include_spip('inc/barre_outils');
18 if (!$sets = barre_outils_liste()) {
19 return null;
20 }
21
22 // 1 on initialise tous les jeux de barres
23 $barres = array();
24 foreach($sets as $set) {
25 if (($barre = barre_outils_initialiser($set)) AND is_object($barre))
26 $barres[$set] = $barre;
27 }
28
29 // 2 prechargement
30 // charge des nouveaux boutons au besoin
31 // exemples :
32 // $barre = &$flux['spip'];
33 // $barre->ajouterApres('bold',array(params));
34 // $barre->ajouterAvant('bold',array(params));
35 //
36 // $bold = $barre->get('bold');
37 // $bold['id'] = 'bold2';
38 // $barre->ajouterApres('italic',$bold);
39 $barres = pipeline('porte_plume_barre_pre_charger', $barres);
40
41
42 // 3 chargement
43 // permet de cacher ou afficher certains boutons au besoin
44 // exemples :
45 // $barre = &$flux['spip'];
46 // $barre->afficher('bold');
47 // $barre->cacher('bold');
48 //
49 // $barre->cacherTout();
50 // $barre->afficher(array('bold','italic','header1'));
51 $barres = pipeline('porte_plume_barre_charger', $barres);
52
53
54 // 4 on cree les jsons
55 $json = "";
56 foreach($barres as $set=>$barre) {
57 $json .= $barre->creer_json();
58 }
59 return $json;
60 }
61
62
63 ?>