function nodewords_replace_tokens in Nodewords: D6 Meta Tags 6.3
Same name and namespace in other branches
- 6.2 nodewords.module \nodewords_replace_tokens()
Create the content of a meta tag from a node teaser.
Parameters
$text: The string to use.
$format: The format set for the node.
$options: An array of options; currently, the only used is the maximum allowed length.
Return value
The string to use to populate the meta tag.
5 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 603 - Implement an version that other modules can use to add meta tags.
Code
function nodewords_replace_tokens($content, array $options = array()) {
global $user;
$token_objects = array();
$options += _nodewords_get_default_metatags_type();
if (empty($content) || !module_exists('token')) {
return $content;
}
switch ($options['type']) {
case NODEWORDS_TYPE_ERRORPAGE:
case NODEWORDS_TYPE_PAGE:
$token_objects['global'] = NULL;
$token_objects['global meta tags'] = NULL;
break;
case NODEWORDS_TYPE_NODE:
$token_objects['global'] = NULL;
$token_objects['global meta tags'] = NULL;
$token_objects['node'] = _nodewords_node_load($options);
$token_objects['node meta tags'] = $token_objects['node'];
break;
case NODEWORDS_TYPE_TERM:
case NODEWORDS_TYPE_VOCABULARY:
$token_objects['global'] = NULL;
$token_objects['global meta tags'] = NULL;
$token_objects['taxonomy'] = _nodewords_taxonomy_load($options);
break;
case NODEWORDS_TYPE_USER:
$token_objects['global'] = NULL;
$token_objects['global meta tags'] = NULL;
$token_objects['user'] = user_load($options['id']);
break;
default:
return $content;
}
// Remove the not replaced tokens.
$content = token_replace_multiple($content, $token_objects);
$replacements = array();
token_include();
foreach (module_implements('token_list') as $module) {
$function = $module . '_token_list';
$result = $function('all');
if (is_array($result)) {
foreach ($result as $category => $tokens) {
foreach ($tokens as $token => $title) {
$replacements['[' . $token . ']'] = '';
}
}
}
}
if (!empty($replacements)) {
$content = strtr($content, $replacements);
}
return $content;
}