Hello Jacques,
j'ai vu passé les dernieres modifs pour coller à la branche stable, il manque une fonction : afficher_textarea_barre
=> il y a une erreur sur les breves (et sans doute les forums)
sinon, j'ai finalement reporté mes modif de la barre typo extensible sur la derniere version de la BTE.
En fait, il y a 2 modifs :
- ajout de pipelines dans /inc/barre.php (ce qui ne coute pas cher et permet de rajouter des boutons)
- extension des tags : la, c'est beaucoup plus discutable.
Dans un premier temps, j'avais placé le traitement des raccourcis ajoutés dans un autre plugin.
Mais à la reflexion, je trouve ca dommage de ralonger le spip_path et de mettre en place toute une mecanique pour faire qqchose d'assez standard (je ne traite que du "avant_propre").
pour ajouter un bouton, j'ai donc juste à faire dans mon plugin :
function paginart3_BarreTypoEnrichie_avancees($paramArray){
$p=explode(basename(_DIR_PLUGINS)."/",str_replace('\\','/',realpath(dirname(__FILE__))));
return " ".bouton_barre_racc ("barre_raccourci('\n\n{p{','}p}\n\n',".$paramArray[0].")", _DIR_PLUGINS.end($p).'/img_pack/icones_barre/intertitre_p.png', _T('paginart3:barre_intertitre_p'), $paramArray[1])." "; }
et pour ajouter le traitement qui va avec :
tester_variable('BarreTypoEnrichie',
array(
'intertitre_p_debut'=>array(
"chercher"=>"/(^|[^{])\{p\{/S",
"remplacer"=>"\$1\n\n<h3 class=\"paginart3\">"),
'intertitre_p_fin'=>array(
"chercher"=>"/\}p\}($|[^}])/S",
"remplacer"=>"</h3>\n\n\$1")
)
);
et bien sur, ajouter la fonction nettoyer_raccourcis_typo qui va avec.
voila le diff, à toi de voir ce que tu integres ou non dans la BTE.
Amha, les pipelines ont leur place ici, mais pas les traitements.
Ca permettrait de faire des plugins pour etendre la BTE sans trop se prendre la tete avec les traitements (charge à chaque plugin de faire son boulot).
Si qqun veut optimiser comme moi, il peut forker typo_enrichie.php.
Ou alors, il faudrait faire la aussi des "pipelines" pour permettre la modification/ajout des tableaux de traitement avant de les lancer (?)
inc/barre.php :
279,287d278
< ////////////////////////////
< //MODIFICATION
< ///////////////////////////
< //un pipeline pour ajouter une toolbox
< $params=array($champ,$champhelp,$spip_lang);
< $add=pipeline("BarreTypoEnrichie_toolbox",$params);
< if ($params!=$add)
< $toolbox .= $add;
< ///////////////////////////
298,306d288
< ////////////////////////////
< //MODIFICATION
< ///////////////////////////
< $params = array($champ,$champhelp,$spip_lang);
< $add = pipeline("BarreTypoEnrichie_tous",array($champ,$champhelp,$spip_lang));
< if ($params!=$add)
< $ret .= $add;
< ///////////////////////////
<
308,315d289
< ////////////////////////////
< //MODIFICATION
< ///////////////////////////
< $params = array($champ,$champhelp,$spip_lang);
< $add = pipeline("BarreTypoEnrichie_avancees",array($champ,$champhelp,$spip_lang));
< if ($params!=$add)
< $ret .= $add;
< ///////////////////////////
321,328d294
< ////////////////////////////
< //MODIFICATION
< ///////////////////////////
< $params = array($champ,$champhelp,$spip_lang);
< $add = pipeline("BarreTypoEnrichie_ecrire",array($champ,$champhelp,$spip_lang));
< if ($params!=$add)
< $ret .= $add;
< ///////////////////////////
349,356d314
< ////////////////////////////
< //MODIFICATION
< ///////////////////////////
< $params = array($champ,$champhelp,$spip_lang);
< $add = pipeline("BarreTypoEnrichie_forum",array($champ,$champhelp,$spip_lang));
< if ($params!=$add)
< $ret .= $add;
< ///////////////////////////
437,451d394
< // http://doc.spip.org/@afficher_textarea_barre
< function afficher_textarea_barre($texte, $forum=false)
< {
< global $spip_display, $spip_ecran;
<
< $rows = ($spip_ecran == "large") ? 28 : 15;
<
< return (($spip_display == 4) ? '' :
< afficher_barre('document.formulaire.texte', $forum))
< . "<textarea name='texte' id='texte' "
< . $GLOBALS['browser_caret']
< . " rows='$rows' class='formo' cols='40'>"
< . entites_html($texte)
< . "</textarea>\n";
< }
typo_enrichie.php :
63,125c63,117
< ///////////////////////////
< //MODIFICATION
< //////////////////////////
< $chercher_raccourcis=array();
< $remplacer_raccourcis=array();
< global $BarreTypoEnrichie;
< if (is_array($BarreTypoEnrichie))
< foreach($BarreTypoEnrichie as $item) {
< $chercher_raccourcis[]=$item['chercher']; < $remplacer_raccourcis[]=$item['remplacer'];
< }
<
< /* 1 */ $chercher_raccourcis[]="/(^|[^{])[{][{][{]/S";
< /* 2 */ $chercher_raccourcis[]="/[}][}][}]($|[^}])/S";
< /* 3 */ $chercher_raccourcis[]="/(^|[^{])\{1\{/S";
< /* 4 */ $chercher_raccourcis[]="/\}1\}($|[^}])/S";
< /* 5 */ $chercher_raccourcis[]="/(^|[^{])\{2\{/S";
< /* 6 */ $chercher_raccourcis[]="/\}2\}($|[^}])/S";
< /* 7 */ $chercher_raccourcis[]="/(^|[^{])\{3\{/S";
< /* 8 */ $chercher_raccourcis[]="/\}3\}($|[^}])/S";
< /* 9 */ $chercher_raccourcis[]="/(^|[^{])\{4\{/S";
< /* 10 */ $chercher_raccourcis[]="/\}4\}($|[^}])/S";
< /* 9b */ $chercher_raccourcis[]="/(^|[^{])\{5\{/S";
< /* 10b */ $chercher_raccourcis[]="/\}5\}($|[^}])/S";
< /* 11 */ $chercher_raccourcis[]="/\{(�|§)\{/S"; # § Pour g�rer l'unicode aussi !
< /* 12 */ $chercher_raccourcis[]="/\}(�|§)\}/S";
< /* 13 */ $chercher_raccourcis[]="/<-->/S";
< /* 14 */ $chercher_raccourcis[]="/-->/S";
< /* 15 */ $chercher_raccourcis[]="/<--/S";
< /* 16 */ $chercher_raccourcis[]="/<==>/S";
< /* 17 */ $chercher_raccourcis[]="/==>/S";
< /* 18 */ $chercher_raccourcis[]="/<==/S";
< /* 19 */ $chercher_raccourcis[]="/\([cC]\)/S";
< /* 20 */ $chercher_raccourcis[]="/\([rR]\)/S";
< /* 21 */ $chercher_raccourcis[]="/\([tT][mM]\)/S";
< /* 22 */ $chercher_raccourcis[]="/\.\.\./S";
< /* 23 */ $chercher_raccourcis[]="/\[([^|?][^][]*)\|((?:[^][](?!->))*)\]/S";
<
< /* 1 */ $remplacer_raccourcis[]="/$1\n\n$debut_intertitre";
< /* 2 */ $remplacer_raccourcis[]="$fin_intertitre\n\n\$1";
< /* 3 */ $remplacer_raccourcis[]="/$1\n\n$debut_intertitre";
< /* 4 */ $remplacer_raccourcis[]="$fin_intertitre\n\n\$1";
< /* 5 */ $remplacer_raccourcis[]="/$1\n\n$debut_intertitre_2";
< /* 6 */ $remplacer_raccourcis[]="$fin_intertitre_2\n\n\$1";
< /* 7 */ $remplacer_raccourcis[]="/$1\n\n$debut_intertitre_3";
< /* 8 */ $remplacer_raccourcis[]="$fin_intertitre_3\n\n\$1";
< /* 9 */ $remplacer_raccourcis[]="/$1\n\n$debut_intertitre_4";
< /* 10 */ $remplacer_raccourcis[]="$fin_intertitre_4\n\n\$1";
< /* 9b */ $remplacer_raccourcis[]="/$1\n\n$debut_intertitre_5";
< /* 10b */ $remplacer_raccourcis[]="$fin_intertitre_5\n\n\$1";
< /* 11 */ $remplacer_raccourcis[]="<span style=\"font-variant: small-caps\">";
< /* 12 */ $remplacer_raccourcis[]="</span>";
< /* 13 */ $remplacer_raccourcis[]="↔";
< /* 14 */ $remplacer_raccourcis[]="→";
< /* 15 */ $remplacer_raccourcis[]="←";
< /* 16 */ $remplacer_raccourcis[]="⇔";
< /* 17 */ $remplacer_raccourcis[]="⇒";
< /* 18 */ $remplacer_raccourcis[]="⇐";
< /* 19 */ $remplacer_raccourcis[]="©";
< /* 20 */ $remplacer_raccourcis[]="®";
< /* 21 */ $remplacer_raccourcis[]="™";
< /* 22 */ $remplacer_raccourcis[]="…";
< /* 23 */ $remplacer_raccourcis[]="@@acro@@$2@@$1@@acro@@";
---
> $chercher_raccourcis = array(
> /* 1 */ "/(^|[^{])[{][{][{]/S",
> /* 2 */ "/[}][}][}]($|[^}])/S",
> /* 3 */ "/(^|[^{])\{1\{/S",
> /* 4 */ "/\}1\}($|[^}])/S",
> /* 5 */ "/(^|[^{])\{2\{/S",
> /* 6 */ "/\}2\}($|[^}])/S",
> /* 7 */ "/(^|[^{])\{3\{/S",
> /* 8 */ "/\}3\}($|[^}])/S",
> /* 9 */ "/(^|[^{])\{4\{/S",
> /* 10 */ "/\}4\}($|[^}])/S",
> /* 9b */ "/(^|[^{])\{5\{/S",
> /* 10b */ "/\}5\}($|[^}])/S",
> /* 11 */ "/\{(§|§)\{/S", # § Pour gérer l'unicode aussi !
> /* 12 */ "/\}(§|§)\}/S",
> /* 13 */ "/<-->/S",
> /* 14 */ "/-->/S",
> /* 15 */ "/<--/S",
> /* 16 */ "/<==>/S",
> /* 17 */ "/==>/S",
> /* 18 */ "/<==/S",
> /* 19 */ "/\([cC]\)/S",
> /* 20 */ "/\([rR]\)/S",
> /* 21 */ "/\([tT][mM]\)/S",
> /* 22 */ "/\.\.\./S",
> /* 23 */ "/\[([^|?][^][]*)\|((?:[^][](?!->))*)\]/S"
> );
>
> $remplacer_raccourcis = array(
> /* 1 */ "\$1\n\n$debut_intertitre",
> /* 2 */ "$fin_intertitre\n\n\$1",
> /* 3 */ "\$1\n\n$debut_intertitre",
> /* 4 */ "$fin_intertitre\n\n\$1",
> /* 5 */ "\$1\n\n$debut_intertitre_2",
> /* 6 */ "$fin_intertitre_2\n\n\$1",
> /* 7 */ "\$1\n\n$debut_intertitre_3",
> /* 8 */ "$fin_intertitre_3\n\n\$1",
> /* 9 */ "\$1\n\n$debut_intertitre_4",
> /* 10 */ "$fin_intertitre_4\n\n\$1",
> /* 9b */ "\$1\n\n$debut_intertitre_5",
> /* 10b */ "$fin_intertitre_5\n\n\$1",
> /* 11 */ "<span style=\"font-variant: small-caps\">",
> /* 12 */ "</span>",
> /* 13 */ "↔",
> /* 14 */ "→",
> /* 15 */ "←",
> /* 16 */ "⇔",
> /* 17 */ "⇒",
> /* 18 */ "⇐",
> /* 19 */ "©",
> /* 20 */ "®",
> /* 21 */ "™",
> /* 22 */ "…",
> /* 23 */ "@@acro@@$2@@$1@@acro@@"
> );