diff --git a/change_log.txt b/change_log.txt
index d45bb645..84f89678 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -1,3 +1,7 @@
+05/08/2010
+- added plugin type modifiercompiler to produce compiled modifier code
+- changed standard modifier plugins to the compiling versions whenever possible
+
02/08/2010
- bugfix strip did not work correctly in conjunction with comment lines
diff --git a/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php
index acff0bc9..cd24589d 100644
--- a/libs/plugins/modifier.capitalize.php
+++ b/libs/plugins/modifier.capitalize.php
@@ -1,41 +1,37 @@
* Name: capitalize
* Purpose: capitalize words in the string
- * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE
- * capitalize (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @return string
+ *
+ * @link
+ * @author Monte Ohrt
+ * @param string $
+ * @return string
*/
function smarty_modifier_capitalize($string, $uc_digits = false)
-{
- smarty_modifier_capitalize_ucfirst(null, $uc_digits);
- return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string);
-}
+{
+ // uppercase with php function ucwords
+ $upper_string = ucwords($string);
+ // check for any missed hyphenated words
+ $upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!ue", "'\\1'.ucfirst('\\2')", $upper_string);
+ // check uc_digits case
+ if (!$uc_digits) {
+ if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) {
+ foreach($matches[1] as $match)
+ $upper_string = substr_replace($upper_string, $match[0], $match[1], strlen($match[0]));
+ }
+ }
+ return $upper_string;
+}
-function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
-{
- static $_uc_digits = false;
-
- if(isset($uc_digits)) {
- $_uc_digits = $uc_digits;
- return;
- }
-
- if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits)
- return ucfirst($string[0]);
- else
- return $string[0];
-}
-?>
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifier.count_characters.php b/libs/plugins/modifier.count_characters.php
deleted file mode 100644
index 6d524655..00000000
--- a/libs/plugins/modifier.count_characters.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- * Name: count_characteres
- * Purpose: count the number of characters in a text
- * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
- * count_characters (Smarty online manual)
- * @author Monte Ohrt
- * @param string $string input string
- * @param boolean $include_spaces include whitespace in the character count
- * @return integer number of characters
- */
-function smarty_modifier_count_characters($string, $include_spaces = false)
-{
- if ($include_spaces)
- return(strlen($string));
-
- return preg_match_all("/[^\s]/",$string, $match);
-}
-?>
diff --git a/libs/plugins/modifier.count_words.php b/libs/plugins/modifier.count_words.php
deleted file mode 100644
index 1079d8f2..00000000
--- a/libs/plugins/modifier.count_words.php
+++ /dev/null
@@ -1,25 +0,0 @@
-
- * Name: count_words
- * Purpose: count the number of words in a text
- * @link http://smarty.php.net/manual/en/language.modifier.count.words.php
- * count_words (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @return integer
- */
-function smarty_modifier_count_words($string)
-{
- return str_word_count($string);
-}
-?>
diff --git a/libs/plugins/modifier.default.php b/libs/plugins/modifier.default.php
deleted file mode 100644
index 2622d072..00000000
--- a/libs/plugins/modifier.default.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- * Name: default
- * Purpose: designate default value for empty variables
- * @link http://smarty.php.net/manual/en/language.modifier.default.php
- * default (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @param string
- * @return string
- */
-function smarty_modifier_default($string, $default = '')
-{
- if (!isset($string) || $string === '')
- return $default;
- else
- return $string;
-}
-?>
diff --git a/libs/plugins/modifier.indent.php b/libs/plugins/modifier.indent.php
deleted file mode 100644
index 4f2f9d85..00000000
--- a/libs/plugins/modifier.indent.php
+++ /dev/null
@@ -1,28 +0,0 @@
-
- * Name: indent
- * Purpose: indent lines of text
- * @link http://smarty.php.net/manual/en/language.modifier.indent.php
- * indent (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @param integer
- * @param string
- * @return string
- */
-function smarty_modifier_indent($string,$chars=4,$char=" ")
-{
- return preg_replace('!^!m',str_repeat($char,$chars),$string);
-}
-
-?>
diff --git a/libs/plugins/modifier.lower.php b/libs/plugins/modifier.lower.php
deleted file mode 100644
index 34a609e6..00000000
--- a/libs/plugins/modifier.lower.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
-* Name: lower
-* Purpose: convert string to lowercase
-*
-* @link http://smarty.php.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
-* @author Monte Ohrt
-* @param string $
-* @return string
-*/
-function smarty_modifier_lower($string)
-{
- if (function_exists('mb_strtolower')) {
- return mb_strtolower($string);
- } else {
- return strtolower($string);
- }
-}
-
-?>
diff --git a/libs/plugins/modifier.noprint.php b/libs/plugins/modifier.noprint.php
deleted file mode 100644
index 3e9df069..00000000
--- a/libs/plugins/modifier.noprint.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
- * Name: noprint
- * Purpose: return an empty string
- * @author Uwe Tews
- * @param string
- * @return string
- */
-function smarty_modifier_noprint($string)
-{
- return '';
-}
-
-?>
diff --git a/libs/plugins/modifier.spacify.php b/libs/plugins/modifier.spacify.php
index d2593ec3..790e373b 100644
--- a/libs/plugins/modifier.spacify.php
+++ b/libs/plugins/modifier.spacify.php
@@ -1,27 +1,38 @@
-* Name: spacify
-* Purpose: add spaces between characters in a string
-*
-* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
-* @author Monte Ohrt
-* @param string $
-* @param string $
-* @return string
-*/
+ * Smarty spacify modifier plugin
+ *
+ * Type: modifier
+ * Name: spacify
+ * Purpose: add spaces between characters in a string
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
+ * @author Monte Ohrt
+ * @param string $
+ * @param string $
+ * @return string
+ */
function smarty_modifier_spacify($string, $spacify_char = ' ')
-{
- return implode($spacify_char, preg_split('//', $string, -1));
+{
+ // mb_ functions available?
+ if (function_exists('mb_strlen') && mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
+ $strlen = mb_strlen($string);
+ while ($strlen) {
+ $array[] = mb_substr($string, 0, 1, "UTF-8");
+ $string = mb_substr($string, 1, $strlen, "UTF-8");
+ $strlen = mb_strlen($string);
+ }
+ return implode($spacify_char, $array);
+ } else {
+ return implode($spacify_char, preg_split('//', $string, -1));
+ }
}
-?>
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifier.strip.php b/libs/plugins/modifier.strip.php
deleted file mode 100644
index 39f0f9f7..00000000
--- a/libs/plugins/modifier.strip.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
-* Name: strip
-* Purpose: Replace all repeated spaces, newlines, tabs
-* with a single space or supplied replacement string.
-* Example: {$var|strip} {$var|strip:" "}
-* Date: September 25th, 2002
-*
-* @link http://smarty.php.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
-* @author Monte Ohrt
-* @version 1.0
-* @param string $
-* @param string $
-* @return string
-*/
-function smarty_modifier_strip($text, $replace = ' ')
-{
- return preg_replace('!\s+!', $replace, $text);
-}
-
-?>
diff --git a/libs/plugins/modifier.strip_tags.php b/libs/plugins/modifier.strip_tags.php
deleted file mode 100644
index 6af08b2f..00000000
--- a/libs/plugins/modifier.strip_tags.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
-* Name: strip_tags
-* Purpose: strip html tags from text
-*
-* @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
-* @author Monte Ohrt
-* @param string $
-* @param boolean $
-* @return string
-*/
-function smarty_modifier_strip_tags($string, $replace_with_space = true)
-{
- if ($replace_with_space) {
- return preg_replace('!<[^>]*?>!', ' ', $string);
- } else {
- return strip_tags($string);
- }
-}
-
-?>
diff --git a/libs/plugins/modifier.upper.php b/libs/plugins/modifier.upper.php
deleted file mode 100644
index fefa854f..00000000
--- a/libs/plugins/modifier.upper.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
-* Name: upper
-* Purpose: convert string to uppercase
-*
-* @link http://smarty.php.net/manual/en/language.modifier.upper.php upper (Smarty online manual)
-* @author Monte Ohrt
-* @param string $
-* @return string
-*/
-function smarty_modifier_upper($string)
-{
- if (function_exists('mb_strtoupper')) {
- return mb_strtoupper($string);
- } else {
- return strtoupper($string);
- }
-}
-
-?>
diff --git a/libs/plugins/modifier.wordwrap.php b/libs/plugins/modifier.wordwrap.php
deleted file mode 100644
index 92a79de7..00000000
--- a/libs/plugins/modifier.wordwrap.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- * Name: wordwrap
- * Purpose: wrap a string of text at a given length
- * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php
- * wordwrap (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @param integer
- * @param string
- * @param boolean
- * @return string
- */
-function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false)
-{
- return wordwrap($string,$length,$break,$cut);
-}
-
-?>
diff --git a/libs/plugins/modifier.cat.php b/libs/plugins/modifiercompiler.cat.php
similarity index 59%
rename from libs/plugins/modifier.cat.php
rename to libs/plugins/modifiercompiler.cat.php
index 1b932d02..a388c6f8 100644
--- a/libs/plugins/modifier.cat.php
+++ b/libs/plugins/modifiercompiler.cat.php
@@ -1,31 +1,29 @@
-
- * Name: cat
- * Date: Feb 24, 2003
- * Purpose: catenate a value to a variable
- * Input: string to catenate
- * Example: {$var|cat:"foo"}
- * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
- * (Smarty online manual)
- * @author Monte Ohrt
- * @version 1.0
- * @param string
- * @param string
- * @return string
- */
-function smarty_modifier_cat($string, $cat)
-{
- return $string . $cat;
-}
-
-?>
+
+ * Name: cat
+ * Date: Feb 24, 2003
+ * Purpose: catenate a value to a variable
+ * Input: string to catenate
+ * Example: {$var|cat:"foo"}
+ * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
+ * (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_cat($params, $compiler)
+{
+ return '('.implode(').(', $params).')';
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.count_characters.php b/libs/plugins/modifiercompiler.count_characters.php
new file mode 100644
index 00000000..9a620c49
--- /dev/null
+++ b/libs/plugins/modifiercompiler.count_characters.php
@@ -0,0 +1,38 @@
+
+ * Name: count_characteres
+ * Purpose: count the number of characters in a text
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_count_characters($params, $compiler)
+{
+ // mb_ functions available?
+ if (function_exists('mb_strlen')) {
+ // count also spaces?
+ if (isset($params[1]) && $params[1] == 'true') {
+ return '(mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? mb_strlen(' . $params[0] . ', SMARTY_RESOURCE_CHAR_SET) : strlen(' . $params[0] . ')';
+ }
+ return '(mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? preg_match_all(\'#[^\s\pZ]#u\', ' . $params[0] . ', $tmp) : preg_match_all(\'/[^\s]/\',' . $params[0] . ', $tmp)';
+ } else {
+ // count also spaces?
+ if (isset($params[1]) && $params[1] == 'true') {
+ return 'strlen(' . $params[0] . ')';
+ }
+ return 'preg_match_all(\'/[^\s]/\',' . $params[0] . ', $tmp)';
+ }
+}
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifier.count_paragraphs.php b/libs/plugins/modifiercompiler.count_paragraphs.php
similarity index 56%
rename from libs/plugins/modifier.count_paragraphs.php
rename to libs/plugins/modifiercompiler.count_paragraphs.php
index 441da09b..412bbd7d 100644
--- a/libs/plugins/modifier.count_paragraphs.php
+++ b/libs/plugins/modifiercompiler.count_paragraphs.php
@@ -1,26 +1,26 @@
-
- * Name: count_paragraphs
- * Purpose: count the number of paragraphs in a text
- * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
- * count_paragraphs (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @return integer
- */
-function smarty_modifier_count_paragraphs($string)
-{
- // count \r or \n characters
- return count(preg_split('/[\r\n]+/', $string));
-}
-?>
+
+ * Name: count_paragraphs
+ * Purpose: count the number of paragraphs in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
+ * count_paragraphs (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_count_paragraphs($params, $compiler)
+{
+ // count \r or \n characters
+ return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
+}
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifier.count_sentences.php b/libs/plugins/modifiercompiler.count_sentences.php
similarity index 56%
rename from libs/plugins/modifier.count_sentences.php
rename to libs/plugins/modifiercompiler.count_sentences.php
index 7783c927..c410868d 100644
--- a/libs/plugins/modifier.count_sentences.php
+++ b/libs/plugins/modifiercompiler.count_sentences.php
@@ -1,27 +1,27 @@
-
- * Name: count_sentences
- * Purpose: count the number of sentences in a text
- * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
- * count_sentences (Smarty online manual)
- * @author Monte Ohrt
- * @param string
- * @return integer
- */
-function smarty_modifier_count_sentences($string)
-{
- // find periods with a word before but not after.
- return preg_match_all('/[^\s]\.(?!\w)/', $string, $match);
-}
-
-?>
+
+ * Name: count_sentences
+ * Purpose: count the number of sentences in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
+ * count_sentences (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_count_sentences($params, $compiler)
+{
+ // find periods with a word before but not after.
+ return 'preg_match_all(\'/[^\s]\.(?!\w)/\', ' . $params[0] . ', $tmp)';
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.count_words.php b/libs/plugins/modifiercompiler.count_words.php
new file mode 100644
index 00000000..cf40e9d3
--- /dev/null
+++ b/libs/plugins/modifiercompiler.count_words.php
@@ -0,0 +1,31 @@
+
+ * Name: count_words
+ * Purpose: count the number of words in a text
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_count_words($params, $compiler)
+{
+ // mb_ functions available?
+ if (function_exists('mb_strlen')) {
+ return '(mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? preg_match_all(\'#[\w\pL]+#u\', ' . $params[0] . ', $tmp) : preg_match_all(\'#\w+#\',' . $params[0] . ', $tmp)';
+ } else {
+ return 'str_word_count(' . $params[0] . ')';
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.default.php b/libs/plugins/modifiercompiler.default.php
new file mode 100644
index 00000000..444b285b
--- /dev/null
+++ b/libs/plugins/modifiercompiler.default.php
@@ -0,0 +1,33 @@
+
+ * Name: default
+ * Purpose: designate default value for empty variables
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.default.php default (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_default ($params, $compiler)
+{
+ $output = $params[0];
+ if (!isset($params[1])) {
+ $params[1] = "''";
+ }
+ for ($i = 1, $cnt = count($params); $i < $cnt; $i++) {
+ $output = '(($tmp = ' . $output . ')===null||$tmp===\'\' ? ' . $params[$i] . ' : $tmp)';
+ }
+ return $output;
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.indent.php b/libs/plugins/modifiercompiler.indent.php
new file mode 100644
index 00000000..cc690725
--- /dev/null
+++ b/libs/plugins/modifiercompiler.indent.php
@@ -0,0 +1,32 @@
+
+ * Name: indent
+ * Purpose: indent lines of text
+ * @link http://smarty.php.net/manual/en/language.modifier.indent.php
+ * indent (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_indent($params, $compiler)
+{
+ if (!isset($params[1])) {
+ $params[1] = 4;
+ }
+ if (!isset($params[2])) {
+ $params[2] = "' '";
+ }
+ return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.lower.php b/libs/plugins/modifiercompiler.lower.php
new file mode 100644
index 00000000..835c8a40
--- /dev/null
+++ b/libs/plugins/modifiercompiler.lower.php
@@ -0,0 +1,31 @@
+
+* Name: lower
+* Purpose: convert string to lowercase
+*
+* @link http://smarty.php.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
+* @author Monte Ohrt
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+*/
+function smarty_modifiercompiler_lower($params, $compiler)
+{
+ if (function_exists('mb_strtolower')) {
+ return '(mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? mb_strtolower(' . $params[0] . ',SMARTY_RESOURCE_CHAR_SET) : strtolower(' . $params[0] . ')' ;
+ } else {
+ return 'strtolower(' . $params[0] . ')';
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.noprint.php b/libs/plugins/modifiercompiler.noprint.php
new file mode 100644
index 00000000..15c9999f
--- /dev/null
+++ b/libs/plugins/modifiercompiler.noprint.php
@@ -0,0 +1,24 @@
+
+ * Name: noprint
+ * Purpose: return an empty string
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_noprint($params, $compiler)
+{
+ return "''";
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifier.string_format.php b/libs/plugins/modifiercompiler.string_format.php
similarity index 52%
rename from libs/plugins/modifier.string_format.php
rename to libs/plugins/modifiercompiler.string_format.php
index fd96c8b4..dd414ba1 100644
--- a/libs/plugins/modifier.string_format.php
+++ b/libs/plugins/modifiercompiler.string_format.php
@@ -1,27 +1,26 @@
-
-* Name: string_format
-* Purpose: format strings via sprintf
-*
-* @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
-* @author Monte Ohrt
-* @param string $string input string
-* @param string $format format string
-* @return string formatted string
-*/
- function smarty_modifier_string_format($string, $format)
- {
- return sprintf($format, $string);
- }
-
-?>
+
+* Name: string_format
+* Purpose: format strings via sprintf
+*
+* @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+*/
+ function smarty_modifiercompiler_string_format($params, $compiler)
+ {
+ return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
+ }
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.strip.php b/libs/plugins/modifiercompiler.strip.php
new file mode 100644
index 00000000..bef97583
--- /dev/null
+++ b/libs/plugins/modifiercompiler.strip.php
@@ -0,0 +1,32 @@
+
+ * Name: strip
+ * Purpose: Replace all repeated spaces, newlines, tabs
+ * with a single space or supplied replacement string.
+ * Example: {$var|strip} {$var|strip:" "}
+ * Date: September 25th, 2002
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_strip($params, $compiler)
+{
+ if (!isset($params[1])) {
+ $params[1] = "' '";
+ }
+ return 'preg_replace(\'!\s+!\',' . $params[1] . ',' . $params[0] . ')';
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.strip_tags.php b/libs/plugins/modifiercompiler.strip_tags.php
new file mode 100644
index 00000000..96fe9613
--- /dev/null
+++ b/libs/plugins/modifiercompiler.strip_tags.php
@@ -0,0 +1,33 @@
+
+ * Name: strip_tags
+ * Purpose: strip html tags from text
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_strip_tags($params, $compiler)
+{
+ if (!isset($params[1])) {
+ $params[1] = true;
+ }
+ if ($params[1] === true) {
+ return 'preg_replace(\'!<[^>]*?>!\', \' \', ' . $params[0] . ')';
+ } else {
+ return 'strip_tags(' . $params[0] . ')';
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.upper.php b/libs/plugins/modifiercompiler.upper.php
new file mode 100644
index 00000000..6e1f54ab
--- /dev/null
+++ b/libs/plugins/modifiercompiler.upper.php
@@ -0,0 +1,30 @@
+
+ * Name: lower
+ * Purpose: convert string to uppercase
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_upper($params, $compiler)
+{
+ if (function_exists('mb_strtoupper')) {
+ return '(mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? mb_strtoupper(' . $params[0] . ',SMARTY_RESOURCE_CHAR_SET) : strtoupper(' . $params[0] . ')' ;
+ } else {
+ return 'strtoupper(' . $params[0] . ')';
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/libs/plugins/modifiercompiler.wordwrap.php b/libs/plugins/modifiercompiler.wordwrap.php
new file mode 100644
index 00000000..37ca2709
--- /dev/null
+++ b/libs/plugins/modifiercompiler.wordwrap.php
@@ -0,0 +1,35 @@
+
+ * Name: wordwrap
+ * Purpose: wrap a string of text at a given length
+ *
+ * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
+ * @author Uwe Tews
+ * @param array $params parameters
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_wordwrap($params, $compiler)
+{
+ if (!isset($params[1])) {
+ $params[1] = 80;
+ }
+ if (!isset($params[2])) {
+ $params[2] = '"\n"';
+ }
+ if (!isset($params[3])) {
+ $params[3] = 'false';
+ }
+ return 'wordwrap(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
+}
+
+?>
\ No newline at end of file
diff --git a/libs/sysplugins/smarty_internal_compile_private_modifier.php b/libs/sysplugins/smarty_internal_compile_private_modifier.php
index add824dc..0e879503 100644
--- a/libs/sysplugins/smarty_internal_compile_private_modifier.php
+++ b/libs/sysplugins/smarty_internal_compile_private_modifier.php
@@ -29,9 +29,12 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$output = $_attr['value'];
// loop over list of modifiers
foreach ($_attr['modifierlist'] as $single_modifier) {
- preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_modifier, $mod_array);
+ preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|::?|[^:]+)/', $single_modifier, $mod_array);
$modifier = $mod_array[0][0];
for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
+ if ($mod_array[0][$i] == '::') {
+ continue;
+ }
if ($mod_array[0][$i] == ':') {
$mod_array[0][$i] = ',';
}
@@ -50,6 +53,11 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
}
}
+ // check for plugin modifiercompiler
+ } else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
+ $plugin = 'smarty_modifiercompiler_' . $modifier;
+ $args = explode(',', $params);
+ $output = $plugin($args, $compiler);
// check for plugin modifier
} else if ($function = $this->compiler->getPlugin($modifier, 'modifier')) {
$output = "{$function}({$params})";