function profanity_list_get_replacements in Profanity 7
Grab a list of replacements from cache or set the cache and return.
1 call to profanity_list_get_replacements()
- profanity_list_execute in ./
profanity.module - Helper function for use in replacing or validating.
File
- ./
profanity.module, line 399 - Main {profanity} file.
Code
function profanity_list_get_replacements($list) {
$replacements =& drupal_static(__FUNCTION__);
if (!isset($replacements[$list->name])) {
if ($cache = cache_get('profanity_list:' . $list->name)) {
$replacements[$list->name] = $cache->data;
}
else {
$replacements[$list->name] = array();
$words = trim($list->words, ',');
$words = explode(',', $words);
if (empty($words)) {
return array();
}
// Match partials.
if ($list->match_partial && $list->replacement_mode == 0) {
foreach ($words as $word) {
$replacements[$list->name][] = str_repeat($list->replacement_character, strlen(utf8_decode($word)));
}
}
cache_set('profanity_list:' . $list->name, $replacements[$list->name], 'cache');
}
}
return $replacements[$list->name];
}