PEEL Shopping
Open source ecommerce : PEEL Shopping
modifier.capitalize.php
Go to the documentation of this file.
1 <?php
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_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[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_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[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_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[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_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[3]));'), $upper_string);
62  return $upper_string;
63 }
64 
65 ?>
static $_UTF8_MODIFIER
Flag denoting if PCRE should run in UTF-8 mode.
static $_MBSTRING
Flag denoting if Multibyte String functions are available.
static $_CHARSET
The character set to adhere to (e.g.
$match
Definition: search.php:86
smarty_modifier_capitalize($string, $uc_digits=false, $lc_rest=false)
Smarty capitalize modifier plugin.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:16 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.