function paging_xmlsitemap_xmlsitemap_links in Paging 5
Implementation of hook_xmlsitemap_links().
File
- contrib/
paging_xmlsitemap/ paging_xmlsitemap.module, line 11 - Adds node paging links to the site map.
Code
function paging_xmlsitemap_xmlsitemap_links($type = NULL, $excludes = array()) {
if ($type == 'node') {
$excludes = array_merge($excludes, _paging_xmlsitemap_excludes());
if (module_exists('comment')) {
$query = "\n SELECT n.nid, px.pages, n.type, n.promote, s.comment_count, n.changed, xn.previously_changed, s.last_comment_timestamp, xn.previous_comment, xn.priority_override, COALESCE(ua.dst) AS alias\n FROM {node} n\n INNER JOIN {paging_xmlsitemap} px ON n.nid = px.nid\n LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid";
}
else {
$query = "\n SELECT n.nid, px.pages, n.type, n.promote, n.changed, xn.previously_changed, xn.priority_override, COALESCE(ua.dst) AS alias\n FROM {node} n";
}
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$query .= "\n LEFT JOIN {url_alias} ua ON ua.src = CONCAT('node/', CAST(n.nid AS CHAR))";
break;
case 'pgsql':
$query .= "\n LEFT JOIN {url_alias} ua ON ua.src = CONCAT('node/', CAST(n.nid AS VARCHAR))";
break;
}
$query .= "\n LEFT JOIN {xmlsitemap_node} xn ON n.nid = xn.nid\n WHERE n.status > 0\n AND (n.type NOT IN ('" . implode("', '", $excludes) . "') AND xn.priority_override IS NULL OR xn.priority_override >= 0)\n GROUP BY n.nid";
$result = db_query(db_rewrite_sql($query));
while ($node = db_fetch_object($result)) {
for ($count = 1; $count < $node->pages; ++$count) {
if (function_exists('_xmlsitemap_links')) {
$links[] = array(
'nid' => $node->nid,
'#loc' => xmlsitemap_url('node/' . $node->nid, $node->alias, "page=0,{$count}", NULL, TRUE),
'#lastmod' => variable_get('xmlsitemap_node_count_comments', TRUE) ? max($node->changed, $node->last_comment_timestamp) : $node->changed,
'#changefreq' => xmlsitemap_node_frequency($node),
'#priority' => xmlsitemap_node_priority($node),
);
}
else {
$link = array(
'loc' => xmlsitemap_url('node/' . $node->nid, $node->alias, "page=0,{$count}", NULL, TRUE),
'lastmod' => variable_get('xmlsitemap_node_count_comments', TRUE) ? max($node->changed, $node->last_comment_timestamp) : $node->changed,
'changefreq' => xmlsitemap_node_frequency($node),
'priority' => xmlsitemap_node_priority($node),
);
db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)", $link);
}
}
}
if (function_exists('_xmlsitemap_links')) {
return $links;
}
}
}