[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Smarty plugin 4 * 5 * @package Smarty 6 * @subpackage PluginsModifier 7 */ 8 9 /** 10 * Smarty capitalize modifier plugin 11 * 12 * Type: modifier<br> 13 * Name: capitalize<br> 14 * Purpose: capitalize words in the string 15 * 16 * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }} 17 * 18 * @param string $string string to capitalize 19 * @param boolean $uc_digits also capitalize "x123" to "X123" 20 * @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa" 21 * @return string capitalized string 22 * @author Monte Ohrt <monte at ohrt dot com> 23 * @author Rodney Rehm 24 */ 25 function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false) 26 { 27 if (Smarty::$_MBSTRING) { 28 if ($lc_rest) { 29 // uppercase (including hyphenated words) 30 $upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET ); 31 } else { 32 // uppercase word breaks 33 $upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string); 34 } 35 // check uc_digits case 36 if (!$uc_digits) { 37 if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { 38 foreach($matches[1] as $match) { 39 $upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0])); 40 } 41 } 42 } 43 $upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string); 44 return $upper_string; 45 } 46 47 // lowercase first 48 if ($lc_rest) { 49 $string = strtolower($string); 50 } 51 // uppercase (including hyphenated words) 52 $upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string); 53 // check uc_digits case 54 if (!$uc_digits) { 55 if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { 56 foreach($matches[1] as $match) { 57 $upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0])); 58 } 59 } 60 } 61 $upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string); 62 return $upper_string; 63 } 64 65 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |