1 | <?php |
---|
2 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
3 | |
---|
4 | // insert le css et le js externes pour boutonstexte dans le <head> du document (#INSERT_HEAD) |
---|
5 | function boutonstexte_insert_head_css($flux) |
---|
6 | { |
---|
7 | $metacfg = array( |
---|
8 | 'cssFile' => 'boutonstexte', |
---|
9 | ); |
---|
10 | meta_boutonstexte($metacfg); |
---|
11 | $cssFile = find_in_path($metacfg['cssFile'].".css"); |
---|
12 | |
---|
13 | $dir = $GLOBALS['lang_dir']=="ltr"?"left":"right"; |
---|
14 | $imgto = find_in_path("images/textonly.png"); |
---|
15 | $imgtsd = find_in_path("images/fontsizedown.png"); |
---|
16 | $imgtsu = find_in_path("images/fontsizeup.png"); |
---|
17 | $flux .= |
---|
18 | '<link rel="stylesheet" href="'.$cssFile.'" type="text/css" media="all" />' |
---|
19 | . "<style type='text/css'> |
---|
20 | .boutonstexte button.textonly {background-image:url($imgto);} |
---|
21 | .boutonstexte button.textsizedown {background-image:url($imgtsd);} |
---|
22 | .boutonstexte button.textsizeup {background-image:url($imgtsu);} |
---|
23 | div.onlytext {text-align:$dir;} |
---|
24 | </style>" |
---|
25 | ; |
---|
26 | |
---|
27 | |
---|
28 | return $flux; |
---|
29 | } |
---|
30 | |
---|
31 | function boutonstexte_insert_head($flux) |
---|
32 | { |
---|
33 | $metacfg = array( |
---|
34 | 'selector' => '#content .texte', |
---|
35 | 'jsFile' => 'boutonstexte.js', |
---|
36 | 'imgPath' => 'images/fontsizeup.png', |
---|
37 | 'txtOnly' => 'boutonstexte:texte_seulement', |
---|
38 | 'txtBackSpip' => 'boutonstexte:retour_a_spip', |
---|
39 | 'txtSizeUp' => 'boutonstexte:augmenter_police', |
---|
40 | 'txtSizeDown' => 'boutonstexte:diminuer_police' |
---|
41 | ); |
---|
42 | meta_boutonstexte($metacfg); |
---|
43 | |
---|
44 | $selector = $metacfg['selector']; |
---|
45 | $jsFile = find_in_path($metacfg['jsFile']); |
---|
46 | $imgPath = dirname(find_in_path($metacfg['imgPath'])); |
---|
47 | |
---|
48 | $txtOnly = txt_boutonstexte($metacfg['txtOnly']); |
---|
49 | $txtBackSpip = txt_boutonstexte($metacfg['txtBackSpip']); |
---|
50 | $txtSizeUp = txt_boutonstexte($metacfg['txtSizeUp']); |
---|
51 | $txtSizeDown = txt_boutonstexte($metacfg['txtSizeDown']); |
---|
52 | |
---|
53 | $flux .= <<<EOH |
---|
54 | <script src="{$jsFile}" type="text/javascript"></script> |
---|
55 | <script type="text/javascript"><!-- |
---|
56 | var boutonstexte = new boutonsTexte({ |
---|
57 | 'selector':'{$selector}', |
---|
58 | 'imgPath':'{$imgPath}', |
---|
59 | 'txtOnly':'{$txtOnly}', |
---|
60 | 'txtBackSpip':'{$txtBackSpip}', |
---|
61 | 'txtSizeUp':'{$txtSizeUp}', |
---|
62 | 'txtSizeDown':'{$txtSizeDown}' |
---|
63 | }); |
---|
64 | //--> |
---|
65 | </script > |
---|
66 | EOH; |
---|
67 | return $flux; |
---|
68 | } |
---|
69 | |
---|
70 | function txt_boutonstexte($txt) |
---|
71 | { |
---|
72 | if (!$txt || $txt == '_') { |
---|
73 | return ''; |
---|
74 | } |
---|
75 | return addslashes(unicode_to_javascript(html2unicode(_T($txt)))); |
---|
76 | } |
---|
77 | |
---|
78 | function meta_boutonstexte(&$metacfg) |
---|
79 | { |
---|
80 | include_spip('inc/meta'); |
---|
81 | lire_metas(); |
---|
82 | global $meta; |
---|
83 | if (empty($meta['boutonstexte'])) { |
---|
84 | return 0; |
---|
85 | } |
---|
86 | $return = 0; |
---|
87 | $metabtxt = unserialize($meta['boutonstexte']); |
---|
88 | foreach ($metabtxt as $o=>$v) { |
---|
89 | if (isset($metacfg[$o])) { |
---|
90 | $metacfg[$o] = $v; |
---|
91 | ++$return; |
---|
92 | } |
---|
93 | } |
---|
94 | return $return; |
---|
95 | } |
---|
96 | ?> |
---|