[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / couteau_suisse / couteau_suisse / outils / titres_typo.php
diff --git a/www/plugins/auto/couteau_suisse/couteau_suisse/outils/titres_typo.php b/www/plugins/auto/couteau_suisse/couteau_suisse/outils/titres_typo.php
new file mode 100644 (file)
index 0000000..7f647a8
--- /dev/null
@@ -0,0 +1,29 @@
+<?php\r
+if(defined('_SPIP20100')) include_spip('images_fonctions');\r
+\r
+// Fonction de pipeline\r
+function titres_typo_pre_typo($texte) {\r
+       if (strpos($texte, '{{{')===false) return $texte;\r
+       // appeler titres_typo_rempl() une fois que certaines balises ont ete protegees\r
+       return cs_echappe_balises('', 'titres_typo_rempl', $texte);\r
+}\r
+\r
+ // Fonction de remplacement\r
+ // Transforme les intertitres d'un texte en image typo\r
+function titres_typo_rempl($texte){\r
+       static $arguments;\r
+       if(!isset($arguments)) {\r
+               $arguments = str_replace(array("'",","),array('','","'),_titres_typo_ARG);\r
+               include_spip('outils/couleurs');\r
+               list($couleurs, $html) = couleurs_constantes();\r
+               if(preg_match(',couleur=#?([\w\s]+),', $arguments, $regs)) {\r
+                       $c = trim($regs[1]);\r
+                       if(($i=array_search($c, $couleurs[0]))!==false || ($i=array_search($c, $couleurs[1]))!==false)\r
+                               $c = $html[$couleurs[1][$i]];\r
+                       $arguments .= '","couleur='.$c;\r
+               }\r
+       }\r
+       return preg_replace_callback(",(\{\{\{\**)(.*?)\}\}\},is", create_function('$match', 'return $match[1].image_typo($match[2],"'.$arguments.'")."}}}";'), $texte);\r
+}\r
+\r
+?>
\ No newline at end of file