Code

Readded smarty
[gosa.git] / gosa-core / include / smarty / plugins / modifiercompiler.count_paragraphs.php
diff --git a/gosa-core/include/smarty/plugins/modifiercompiler.count_paragraphs.php b/gosa-core/include/smarty/plugins/modifiercompiler.count_paragraphs.php
new file mode 100644 (file)
index 0000000..0e1b0af
--- /dev/null
@@ -0,0 +1,28 @@
+<?php\r
+/**\r
+ * Smarty plugin\r
+ *\r
+ * @package Smarty\r
+ * @subpackage PluginsModifierCompiler\r
+ */\r
+\r
+/**\r
+ * Smarty count_paragraphs modifier plugin\r
+ *\r
+ * Type:     modifier<br>\r
+ * Name:     count_paragraphs<br>\r
+ * Purpose:  count the number of paragraphs in a text\r
+ *\r
+ * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php\r
+ *          count_paragraphs (Smarty online manual)\r
+ * @author Uwe Tews\r
+ * @param array $params parameters\r
+ * @return string with compiled code\r
+ */\r
+function smarty_modifiercompiler_count_paragraphs($params, $compiler)\r
+{\r
+    // count \r or \n characters\r
+    return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';\r
+}\r
+\r
+?>
\ No newline at end of file