function nodewords_preprocess_page in Nodewords: D6 Meta Tags 6.3
Same name and namespace in other branches
- 6 nodewords.module \nodewords_preprocess_page()
- 6.2 nodewords.module \nodewords_preprocess_page()
Implements hook_preprocess_page().
File
- ./
nodewords.module, line 94 - Implement an version that other modules can use to add meta tags.
Code
function nodewords_preprocess_page(&$variables) {
$output_tags = array();
$head_tags = variable_get('nodewords_head', array());
$options = nodewords_detect_type_id();
$bool = $options['type'] != NODEWORDS_TYPE_NONE && $options['type'] != NODEWORDS_TYPE_OFFLINE;
if ($bool) {
$options['output'] = 'head';
if ($options['type'] == NODEWORDS_TYPE_PAGER) {
nodewords_load_all_includes('nodewords.tags.inc');
foreach (nodewords_get_possible_tags() as $name => $info) {
if (empty($head_tags[$name])) {
continue;
}
$bool = !empty($info['context']['allowed']) && in_array(NODEWORDS_TYPE_PAGER, $info['context']['allowed']) && function_exists($function = $info['callback'] . '_prepare');
if ($bool) {
$options['parameters'] = !empty($info['callback arguments']) ? $info['callback arguments'] : array();
$function($output_tags, array(), $options);
}
}
}
elseif ($options['type'] == NODEWORDS_TYPE_NODE) {
$node = node_load(array(
'nid' => $options['id'],
'vid' => $options['sid'],
));
if ($node && node_access('view', $node)) {
$tags = nodewords_load_tags($options + array(
'language' => $node->language,
));
}
else {
$tags = array();
}
}
else {
$tags = nodewords_load_tags($options);
nodewords_load_all_includes('nodewords.tags.inc');
// Prepare the tags.
foreach (nodewords_get_possible_tags() as $name => $info) {
if (empty($head_tags[$name])) {
continue;
}
if (function_exists($function = $info['callback'] . '_prepare')) {
$options['parameters'] = !empty($info['callback arguments']) ? $info['callback arguments'] : array();
$function($output_tags, _nodewords_tag_value($name, isset($tags[$name]) ? $tags[$name] : array(), $options + array(
'admin' => FALSE,
)), $options);
}
}
}
nodewords_load_all_includes('nodewords.hooks.inc');
drupal_alter('metatags', $output_tags, $options);
$output = _nodewords_output_tags($output_tags);
drupal_alter('metatags_output', $output, $options);
$variables['head'] = $output . "\n" . $variables['head'];
}
}