function nodewords_replace_tokens in Nodewords: D6 Meta Tags 6.2
Same name and namespace in other branches
- 6.3 nodewords.module \nodewords_replace_tokens()
13 calls to nodewords_replace_tokens()
- nodewords_basic_abstract_prepare in nodewords_basic/
includes/ nodewords_basic.nodewords.tags.inc - Set the meta tag content.
- nodewords_basic_canonical_prepare in nodewords_basic/
includes/ nodewords_basic.nodewords.tags.inc - Set the meta tag content.
- nodewords_basic_copyright_prepare in nodewords_basic/
includes/ nodewords_basic.nodewords.tags.inc - Set the meta tag content.
- nodewords_basic_description_prepare in nodewords_basic/
includes/ nodewords_basic.nodewords.tags.inc - Set the meta tag content.
- nodewords_basic_keywords_prepare in nodewords_basic/
includes/ nodewords_basic.nodewords.tags.inc - Set the meta tag content.
File
- ./
nodewords.module, line 536 - Implement an API that other modules can use to add meta tags.
Code
function nodewords_replace_tokens($content, $options = array()) {
if (empty($content) || !variable_get('nodewords_enable_tokens', TRUE) || !module_exists('token')) {
return $content;
}
// Always include the global context.
$token_objects['global'] = NULL;
$options += _nodewords_get_default_metatags_type();
// Allow other modules to alter the context used for tokens below if the
// current context is not yet specific.
switch ($options['type']) {
case NODEWORDS_TYPE_DEFAULT:
case NODEWORDS_TYPE_FRONTPAGE:
case NODEWORDS_TYPE_PAGE:
case NODEWORDS_TYPE_PAGER:
$original_type = $options['type'];
$arg = arg() + array_fill(0, MENU_MAX_PARTS, NULL);
foreach (module_implements('nodewords_type_id') as $module) {
$function = $module . '_nodewords_type_id';
$function($options, $arg);
if ($options['type'] != $original_type) {
break;
}
}
break;
}
switch ($options['type']) {
case NODEWORDS_TYPE_NODE:
$token_objects['node'] = node_load($options['id']);
break;
case NODEWORDS_TYPE_TERM:
$token_objects['taxonomy'] = taxonomy_get_term($options['id']);
break;
case NODEWORDS_TYPE_VOCABULARY:
$token_objects['vocabulary'] = taxonomy_vocabulary_load($options['id']);
break;
case NODEWORDS_TYPE_USER:
$token_objects['user'] = user_load($options['id']);
break;
}
// Perform token replacement, making sure all tokens are replaced even if
// there is no replacement value for a token.
$content = token_replace_multiple($content, $token_objects, TOKEN_PREFIX, TOKEN_SUFFIX, array(
'clear' => TRUE,
));
return $content;
}