[PLUGINS] ~maj des plugins
[lhc/web/www.git] / www / plugins / enluminures_typographiques_v3 / typoenluminee.php
index 82bcfc9..377da47 100644 (file)
@@ -96,8 +96,8 @@ function typoenluminee_pre_propre($texte) {
                /* 5 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*\*(.*)[}][}][}]($|[^}])/SUms";\r
                /* 3 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*(.*)[}][}][}]($|[^}])/SUms";\r
                /* 1 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{](.*)[}][}][}]($|[^}])/SUms";\r
-               /* 11 */        $chercher_raccourcis[]="/\{(§|§)\{/S"; # § Pour gerer l'unicode aussi !\r
-               /* 12 */        $chercher_raccourcis[]="/\}(§|§)\}/S"; # ne pas sauvergarder ce fichier en utf8 !\r
+               /* 11 */        $chercher_raccourcis[]="/\{(|§)\{/S"; # § Pour gerer l'unicode aussi !\r
+               /* 12 */        $chercher_raccourcis[]="/\}(|§)\}/S"; # ne pas sauvergarder ce fichier en utf8 !\r
 \r
                /* 9b */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre_5\$2$fin_intertitre_5\n\n\$3";\r
                /*  9 */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre_4\$2$fin_intertitre_4\n\n\$3";\r
@@ -113,7 +113,8 @@ function typoenluminee_pre_propre($texte) {
        // ou n est un nombre en intertitres avec des etoiles type {{{* (avec n etoiles)\r
        // {1{ sera converti en {{{* ; {2{ sera converti en {{{** ; etc.\r
        // Ne faire la recherche que s'il y a au moins un titre ancienne mode a convertir\r
-       if (strpos($texte, '{2{')!==false\r
+       if (strpos($texte, '{1{')!==false\r\r
+               OR strpos($texte, '{2{')!==false\r
                OR strpos($texte, '{3{')!==false\r
                OR strpos($texte, '{4{')!==false\r
                OR strpos($texte, '{5{')!==false) {\r
@@ -158,6 +159,15 @@ function typoenluminee_post_propre($texte) {
        return $texte;\r
 }\r
 \r
+function typoenluminee_pre_liens($texte) {\r
+       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) OR $GLOBALS['barre_typo_pas_de_fork_typo'] === true)\r
+               return $texte;\r
+\r
+       $texte = str_replace('<-->','&harr;',$texte);\r
+       $texte = str_replace('-->','&rarr;',$texte);\r
+\r
+       return $texte;\r
+}\r
 \r
 function typoenluminee_pre_typo($texte) {\r
        if(!$texte) return $texte;\r
@@ -197,8 +207,6 @@ function typoenluminee_pre_typo($texte) {
                $texte =  preg_replace('/^-\s+/m','-* ',$texte);\r
        }\r
 \r
-       $texte = str_replace('<-->','&harr;',$texte);\r
-       $texte = str_replace('-->','&rarr;',$texte);\r
        $texte = str_replace('<--','&larr;',$texte);\r
        $texte = str_replace('<==>','&hArr;',$texte);\r
        $texte = str_replace('==>','&rArr;',$texte);\r
@@ -208,7 +216,6 @@ function typoenluminee_pre_typo($texte) {
        $texte = str_ireplace('(tm)','&trade;',$texte);\r
        $texte = str_replace('...','&hellip;',$texte);\r
        $texte = preg_replace($chercher_raccourcis, $remplacer_raccourcis, $texte);\r
-       \r
        /*\r
                Cas particulier pour le gras\r
                Il ne faut pas traiter la mise en gras ici si le texte contient un tableau\r
@@ -244,6 +251,7 @@ function typoenluminee_post_typo($texte) {
        // Raccourci typographique <sc></sc>\r
        $texte = str_replace('<sc>', '<span class="caps">', $texte);\r
        $texte = str_replace('</sc>', '</span>', $texte);\r
+       $texte = acronymes_traiter_raccourcis($texte);\r
        return $texte;\r
 }\r
 \r
@@ -255,4 +263,24 @@ function typoenluminee_nettoyer_raccourcis_typo($texte){
        return $texte;\r
 }\r
 \r
+// traite les raccourcis de la forme [SNCF|societe nationale...]\r
+// reprise du plugin acronymes\r
+if (!function_exists('acronymes_traiter_raccourcis')) {\r
+       function acronymes_traiter_raccourcis($letexte){\r
+               $pattern="{\[([^\|\]-]+)\|([^\|\]-]+)\]}";\r
+               preg_match_all ($pattern, $letexte, $tagMatches, PREG_SET_ORDER);\r
+               $textMatches = preg_split ($pattern, $letexte);\r
+\r
+               $tag_attr=array();\r
+               foreach ($tagMatches as $key => $value) {\r
+                       $tag_attr[]="<acronym title='".texte_backend($value[2])."'>".$value[1]."</acronym>";\r
+               }\r
+               for ($i = 0; $i < count ($textMatches); $i ++) {\r
+                       $textMatches [$i] = $textMatches [$i] . $tag_attr [$i];\r
+               }\r
+               return implode ("", $textMatches);\r
+       }\r
+}\r
+\r
+\r
 ?>
\ No newline at end of file