function _nodewords_detect_type_and_ids in Nodewords: D6 Meta Tags 5
Try to guess the $type and $ids by looking at $_GET['q'].
1 call to _nodewords_detect_type_and_ids()
- nodewords_get in ./
nodewords.module - Get the defined meta tags for $type / $id.
File
- ./
nodewords.module, line 911 - Assign META tags to nodes, vocabularies, terms and pages.
Code
function _nodewords_detect_type_and_ids() {
if (!variable_get('nodewords-repeat', 1) && isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0) {
return array(
'type' => 'none',
'ids' => array(),
);
}
if (drupal_is_front_page()) {
if (variable_get('nodewords-use_front', 1)) {
return array(
'type' => 'page',
'ids' => array(
'',
),
);
}
}
if (module_exists('panels')) {
if (function_exists('panels_api_version') && module_exists('panels_page')) {
$version = panels_api_version();
if ($version[0] == 2 && $version[1] == 0) {
$panel = db_fetch_array(db_query("SELECT * FROM {panels_page} WHERE path = '%s'", $_GET['q']));
}
}
else {
if (db_table_exists('panels_info')) {
$panel = db_fetch_array(db_query("SELECT * FROM {panels_info} WHERE path = '%s'", $_GET['q']));
}
}
if ($panel) {
return array(
'type' => 'panels',
'ids' => array(
$panel['did'],
),
);
}
}
if (module_exists('views') && drupal_strlen($_GET['q']) > 0) {
static $views_urls;
// Get all urls from views cache.
if (!is_array($views_urls)) {
$views_urls = array_flip(array_filter(views_get_all_urls()));
}
// Check for exact match first.
if (isset($views_urls[$_GET['q']])) {
$view = views_get_view($views_urls[$_GET['q']]);
return array(
'type' => 'views',
'ids' => array(
$view->vid,
),
);
}
// Check for views that begin with current url.
foreach ($views_urls as $view_url => $view_name) {
if (0 === strpos($view_url, $_GET['q'])) {
$view = views_get_view($view_name);
return array(
'type' => 'views',
'ids' => array(
$view->vid,
),
);
}
}
}
switch (arg(0)) {
case 'node':
// Node paths: node/$nid
if (is_numeric(arg(1)) && !arg(2)) {
return array(
'type' => 'node',
'ids' => arg(1),
);
}
break;
case 'user':
// User paths translated into nodes: user/$uid -> node/$bio_nid
if (is_numeric(arg(1)) && module_exists('bio') && variable_get('bio_profile_takeover', 0)) {
if ($bio_nid = bio_for_user(arg(1))) {
return array(
'type' => 'node',
'ids' => $bio_nid,
);
}
}
break;
case 'taxonomy':
// Taxonomy paths: term/$tid , term/$tid1+$tid2 , vocabulary/$vid
if (arg(1) == 'term' || arg(1) == 'vocabulary') {
$ids = preg_split('![+, ]!', arg(2));
if (count($ids)) {
return array(
'type' => arg(1),
'ids' => $ids,
);
}
}
break;
case 'forum':
// Forum paths: forum/$tid , forum/
if (is_numeric(arg(1))) {
return array(
'type' => 'term',
'ids' => arg(1),
);
}
elseif (is_null(arg(1))) {
return array(
'type' => 'vocabulary',
'ids' => variable_get('forum_nav_vocabulary', 0),
);
}
break;
case 'image':
// Image gallery paths: image/ , image/???/$tid
if (is_null(arg(1))) {
return array(
'type' => 'vocabulary',
'ids' => variable_get('image_gallery_nav_vocabulary', 0),
);
}
else {
if (is_numeric(arg(2))) {
return array(
'type' => 'term',
'ids' => arg(2),
);
}
}
break;
case 'taxonomy_menu':
// Taxonomy menu paths: taxonomy_menu/$vid, taxonomy_menu/$vid/$tid
if (!is_null(arg(2)) && is_numeric(arg(2))) {
return array(
'type' => 'term',
'ids' => arg(2),
);
}
else {
if (is_numeric(arg(1))) {
return array(
'type' => 'vocabulary',
'ids' => arg(1),
);
}
}
break;
}
return array(
'type' => 'none',
'ids' => array(),
);
}