~ubuntu-branches/ubuntu/gutsy/smarty/gutsy-security

« back to all changes in this revision

Viewing changes to libs/plugins/modifier.capitalize.php

  • Committer: Bazaar Package Importer
  • Author(s): Dimitri Fontaine
  • Date: 2005-03-29 11:53:20 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050329115320-g3rvndgnn75ogm35
Tags: 2.6.8-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * @param string
18
18
 * @return string
19
19
 */
20
 
function smarty_modifier_capitalize($string)
21
 
{
22
 
    return ucwords($string);
23
 
}
 
20
function smarty_modifier_capitalize($string, $uc_digits = false)
 
21
{
 
22
    smarty_modifier_capitalize_ucfirst(null, $uc_digits);
 
23
    return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
 
24
}
 
25
 
 
26
function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
 
27
{
 
28
    static $_uc_digits = false;
 
29
    
 
30
    if(isset($uc_digits)) {
 
31
        $_uc_digits = $uc_digits;
 
32
        return;
 
33
    }
 
34
    
 
35
    if(!preg_match('!\d!',$string[0]) || $_uc_digits)
 
36
        return ucfirst($string[0]);
 
37
    else
 
38
        return $string[0];
 
39
}
 
40
 
24
41
 
25
42
?>