X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/098a79f0819ebb89b7d48df4a6b154af4560f68e..9a23a8c0a51b7ec38a96f525484134f3cb85dc7e:/WEB-INF/lib/smarty/plugins/modifier.capitalize.php diff --git a/WEB-INF/lib/smarty/plugins/modifier.capitalize.php b/WEB-INF/lib/smarty/plugins/modifier.capitalize.php new file mode 100644 index 00000000..cd24589d --- /dev/null +++ b/WEB-INF/lib/smarty/plugins/modifier.capitalize.php @@ -0,0 +1,37 @@ + + * Name: capitalize
+ * Purpose: capitalize words in the string + * + * @link + * @author Monte Ohrt + * @param string $ + * @return string + */ +function smarty_modifier_capitalize($string, $uc_digits = false) +{ + // 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; +} + +?> \ No newline at end of file