function nodewords_detect_type_id in Nodewords: D6 Meta Tags 6.3
Same name and namespace in other branches
- 6.2 nodewords.module \nodewords_detect_type_id()
Try to guess the type and the ID associated with the viewed page.
Parameters
$options: An array of parameters that describe the page to check. If the array is is not passed, the function will return the type of the currently viewed page.
Return value
An array containing information about the type of the page.
1 call to nodewords_detect_type_id()
- nodewords_preprocess_page in ./
nodewords.module - Implements hook_preprocess_page().
File
- ./
nodewords.module, line 368 - Implement an version that other modules can use to add meta tags.
Code
function nodewords_detect_type_id(array $options = array()) {
$arg = empty($options['q']) ? arg() : array_filter(explode('/', $options['q']));
$page = empty($options['page']) ? isset($_REQUEST['page']) ? $_REQUEST['page'] : -1 : $options['page'];
$headers = empty($options['headers']) ? drupal_get_headers() : $options['headers'];
$bool = variable_get('site_offline', 0) && !user_access('administer site configuration');
if ($bool) {
return array(
'type' => NODEWORDS_TYPE_OFFLINE,
'id' => 0,
);
}
if (preg_match('@HTTP/1\\.[01]\\x20+403[^a-zA-Z0-9]@', $headers)) {
return array(
'type' => NODEWORDS_TYPE_ERRORPAGE,
'id' => 403,
);
}
if (preg_match('@HTTP/1\\.[01]\\x20+404[^a-zA-Z0-9]@', $headers)) {
return array(
'type' => NODEWORDS_TYPE_ERRORPAGE,
'id' => 404,
);
}
$bool = !variable_get('nodewords_list_repeat', FALSE) && intval($page) > 0;
if ($bool) {
return array(
'type' => NODEWORDS_TYPE_PAGER,
'id' => 0,
);
}
if (!isset($arg[0])) {
return array(
'type' => NODEWORDS_TYPE_NONE,
'id' => 0,
);
}
_nodewords_load_hook_files();
$result = array(
'type' => NODEWORDS_TYPE_NONE,
'id' => 0,
);
foreach (module_implements('nodewords_type_id') as $module) {
$function = $module . '_nodewords_type_id';
$function($result, $arg);
if ($result['type'] != NODEWORDS_TYPE_NONE) {
return $result;
}
}
return array(
'type' => NODEWORDS_TYPE_NONE,
'id' => 0,
);
}