[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / couteau_suisse / couteau_suisse / outils / toutmulti.php
diff --git a/www/plugins/auto/couteau_suisse/couteau_suisse/outils/toutmulti.php b/www/plugins/auto/couteau_suisse/couteau_suisse/outils/toutmulti.php
new file mode 100644 (file)
index 0000000..90a1f91
--- /dev/null
@@ -0,0 +1,35 @@
+<?php\r
+/*\r
+ - ToutMulti -\r
+ Introduit le raccourci <:texte:> pour utiliser librement des\r
+ blocs multi dans un flux de texte (via typo ou propre)\r
+ Accepte egalement les arguments. Exemple :\r
+  <:chaine{argument1=un texte, argument2=un autre texte}:>\r
+*/\r
+\r
+// expression tiree du code de SPIP 2.0 : ecrire/public/phraser_html.php\r
+define('CS_BALISE_IDIOMES',',<:([a-z0-9_]+)({([^=>]*=[^>]*)})?:>,iS');\r
+\r
+function ToutMulti_rempl($texte) {\r
+       if (preg_match_all(CS_BALISE_IDIOMES, $texte, $matches, PREG_SET_ORDER)) {\r
+               foreach ($matches as $m) {\r
+                       // Stocker les arguments de la balise de traduction\r
+                       $args = array();\r
+                       foreach(explode(',',$m[3]) as $val) {\r
+                               $arg = explode('=', $val);\r
+                               if (strlen($key = trim($arg[0]))) $args[$key] = trim($arg[1]);  \r
+                       }\r
+                       $texte = str_replace($m[0], _T('spip/ecrire/public:'.$m[1], $args), $texte);\r
+               }\r
+       }\r
+       return $texte;\r
+}\r
+\r
+// fonction principale (pipeline pre_typo)\r
+function ToutMulti_pre_typo($texte) {\r
+       if (strpos($texte, '<:')===false) return $texte;\r
+       // appeler ToutMulti_rempl() une fois que certaines balises ont ete protegees\r
+       return cs_echappe_balises('', 'ToutMulti_rempl', $texte);\r
+}\r
+\r
+?>
\ No newline at end of file