[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / couteau_suisse / couteau_suisse / outils / autobr.php
1 <?php
2
3 @define('_CS_AUTOBR_BR', '<br />');
4
5 // pipeline pre_typo, appel automatique si defined('_CS_AUTOBR_RACC')
6 function autobr_alinea($flux) {
7 while ($fin = strpos($flux, '</alinea>')) {
8 $zone = substr($flux, 0, $fin);
9 if(($deb = strpos($zone, '<alinea>'))!==false) $zone = substr($zone, $deb + 8);
10 $flux = substr($flux, 0, $deb)
11 // protection des echappement eventuels
12 . str_replace('@ABR@', 'base64', post_autobr(trim(str_replace('base64', '@ABR@', $zone)), _CS_AUTOBR_BR))
13 . substr($flux, $fin + strlen('</alinea>'));
14 }
15 return $flux;
16 }
17
18 // traitements sur la balise #TEXTE
19 function autobr_pre_propre($flux) {
20 // post_autobr() est une fonction de traitement qui possede son propre systeme d'echappement
21 // on traite, sauf si la balise alinea est detectee
22 if(defined('_CS_AUTOBR_TRAIT') && (!defined('_CS_AUTOBR_RACC') || strpos($flux, '<alinea>')===false))
23 $flux = cs_echappe_balises('html|code|cadre|frame|script|jeux', 'post_autobr', $flux, _CS_AUTOBR_BR);
24 return $flux;
25 }
26
27 if(defined('_CS_AUTOBR_RACC')) {
28 // liste des nouveaux raccourcis ajoutes par l'outil
29 // si cette fonction n'existe pas, le plugin cherche alors _T('couteauprive:un_outil:aide');
30 function autobr_raccourcis() {
31 return _T('couteauprive:autobr_racc');
32 }
33 }
34
35 function autobr_nettoyer_raccourcis($texte) {
36 return str_replace(array('<alinea>','</alinea>'), '', $texte);
37 }
38
39 function autobr_PP_icones($flux) {
40 if(defined('_CS_AUTOBR_RACC')) $flux['autobr'] = 'autobr.png';
41 return $flux;
42 }
43
44 function autobr_CS_pre_charger($flux) {
45 if(!defined('_CS_AUTOBR_RACC')) return $flux;
46 $r = array(array(
47 "id" => 'autobr',
48 "name" => _T('couteau:pp_autobr'),
49 "className" => 'autobr',
50 "openWith" => "\n&lt;alinea&gt;",
51 "closeWith" => "&lt;/alinea&gt;\n",
52 "selectionType" => "line",
53 "display" => true));
54 foreach(cs_pp_liste_barres('autobr') as $b)
55 $flux[$b] = isset($flux[$b])?array_merge($flux[$b], $r):$r;
56 return $flux;
57 }
58
59 ?>