function _name_format_apply_modifiers in Name Field 7
Same name and namespace in other branches
- 6 includes/name.parser.inc \_name_format_apply_modifiers()
1 call to _name_format_apply_modifiers()
- _name_format_add_component in includes/
name.parser.inc
File
- includes/
name.parser.inc, line 287 - Provides the functionality and information about the Name module name parsing engine.
Code
function _name_format_apply_modifiers($string, $modifiers) {
if (!is_null($string) || strlen($string)) {
if ($modifiers) {
$original_string = $string;
$prefix = '';
$suffix = '';
if (preg_match('/^(<span[^>]*>)(.*)(<\\/span>)$/i', $string, $matches)) {
$prefix = $matches[1];
$string = $matches[2];
$suffix = $matches[3];
}
for ($j = 0; $j < strlen($modifiers); $j++) {
switch ($modifiers[$j]) {
case 'L':
$string = drupal_strtolower($string);
break;
case 'U':
$string = drupal_strtoupper($string);
break;
case 'F':
$string = drupal_ucfirst($string);
break;
case 'G':
if (!empty($string)) {
$parts = explode(' ', $string);
$string = array();
foreach ($parts as $part) {
$string[] = drupal_ucfirst($part);
}
$string = implode(' ', $string);
}
break;
case 'T':
$string = trim($string);
break;
case 'S':
$string = check_plain($string);
break;
}
}
$string = $prefix . $string . $suffix;
}
}
return $string;
}