Updated to Smarty 2.6.26 (June 18th, 2009), we should update to Smarty 3.x (current...
[mirrors/Kyberia-bloodline.git] / wwwroot / smarty / libs / plugins / modifier.capitalize.php
CommitLineData
51ff3226 1<?php
2/**
3 * Smarty plugin
4 * @package Smarty
5 * @subpackage plugins
6 */
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 * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE
16 * capitalize (Smarty online manual)
9b7c11be 17 * @author Monte Ohrt <monte at ohrt dot com>
51ff3226 18 * @param string
19 * @return string
20 */
21function smarty_modifier_capitalize($string, $uc_digits = false)
22{
23 smarty_modifier_capitalize_ucfirst(null, $uc_digits);
9b7c11be 24 return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string);
51ff3226 25}
26
27function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
28{
29 static $_uc_digits = false;
9b7c11be 30
51ff3226 31 if(isset($uc_digits)) {
32 $_uc_digits = $uc_digits;
33 return;
34 }
9b7c11be
H
35
36 if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits)
51ff3226 37 return ucfirst($string[0]);
38 else
39 return $string[0];
40}
41
42
43?>
This page took 0.202084 seconds and 4 git commands to generate.