function pathauto_i18n_cleanstring in Pathauto i18n 8
Same name and namespace in other branches
- 7 pathauto_i18n.module \pathauto_i18n_cleanstring()
Clean up a string segment for certain language.
1 call to pathauto_i18n_cleanstring()
- pathauto_i18n_tokens_alter in ./
pathauto_i18n.module - Implements hook_tokens_alter().
File
- ./
pathauto_i18n.module, line 209 - Provides common functions and callbacks for pathauto_i18n submodules.
Code
function pathauto_i18n_cleanstring($language, $string) {
$ignore_words = variable_get('pathauto_ignore_words_' . $language . '_language', '');
$ignore_words_regex = preg_replace(array(
'/^[,\\s]+|[,\\s]+$/',
'/[,\\s]+/',
), array(
'',
'\\b|\\b',
), $ignore_words);
if ($ignore_words_regex) {
$ignore_words_regex = '\\b' . $ignore_words_regex . '\\b';
if (function_exists('mb_eregi_replace')) {
$ignore_words_callback = 'mb_eregi_replace';
}
else {
$ignore_words_callback = 'preg_replace';
$ignore_words_regex = '/' . $ignore_words_regex . '/i';
}
if (!empty($ignore_words_regex) && !empty($ignore_words_callback)) {
$words_removed = $ignore_words_callback($ignore_words_regex, '', $string);
if (drupal_strlen(trim($words_removed)) > 0) {
$string = $words_removed;
}
}
}
return $string;
}