function _termcase_convert_string_to_case in Termcase 7
Same name and namespace in other branches
- 8 termcase.module \_termcase_convert_string_to_case()
- 6 termcase.module \_termcase_convert_string_to_case()
Helper function to convert the current string to the specified case.
3 calls to _termcase_convert_string_to_case()
- termcase_taxonomy_term_insert in ./
termcase.module - Implements hook_taxonomy_term_insert().
- termcase_taxonomy_term_update in ./
termcase.module - Implements hook_taxonomy_term_update().
- _termcase_update_all_terms in ./
termcase.module - Apply case formatting to all terms in a vocabulary.
File
- ./
termcase.module, line 268 - The Termcase module gives you the option to specify specific case-formatting on terms.
Code
function _termcase_convert_string_to_case($original_string, $case = TERMCASE_NONE) {
switch ($case) {
case TERMCASE_UCFIRST:
$converted_string = drupal_ucfirst($original_string);
break;
case TERMCASE_LOWERCASE:
$converted_string = drupal_strtolower($original_string);
break;
case TERMCASE_UPPERCASE:
$converted_string = drupal_strtoupper($original_string);
break;
case TERMCASE_PROPERCASE:
$words = explode(' ', $original_string);
foreach ($words as $key => $word) {
$words[$key] = drupal_ucfirst($word);
}
$converted_string = implode(' ', $words);
break;
default:
$converted_string = $original_string;
break;
}
// Allow modules to change the string before saving it.
drupal_alter('termcase_convert_string', $converted_string, $original_string, $case);
return $converted_string;
}