xmlsitemap_file_xmlsitemap_links($type = NULL, $excludes = array())
contributions/modules/xmlsitemap/xmlsitemap_file/xmlsitemap_file.module, line 16
Implementation of hook_xmlsitemap_links().
| Name | Description |
|---|---|
| XML Sitemap | Notify search engines of site updates. |
function xmlsitemap_file_xmlsitemap_links($type = NULL, $excludes = array()) {
if ($type == 'node') {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$coalesce = 'COALESCE';
break;
case 'pgsql':
$coalesce = 'FIRST';
break;
}
$result = db_query(db_rewrite_sql("
SELECT n.nid, n.type, n.promote, f.fid, f.filepath, s.comment_count, xn.priority_override, xf.changed, xf.previously_changed, $coalesce(ua.dst) AS alias
FROM {node} n
INNER JOIN {files} f ON n.nid = f.nid
INNER JOIN {file_revisions} r ON f.fid = r.fid AND n.vid = r.vid
LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid
LEFT JOIN {xmlsitemap_node} xn ON n.nid = xn.nid
LEFT JOIN {xmlsitemap_file} xf ON f.fid = xf.fid
LEFT JOIN {url_alias} ua ON ua.src = CONCAT('system/files/', SUBSTRING(f.filepath FROM %d))
WHERE n.status > 0
AND (n.type NOT IN ('". implode("', '", $excludes) ."') AND xn.priority_override IS NULL OR xn.priority_override >= 0)
AND f.filepath <> '%s'
AND r.list = 1
GROUP BY n.nid, n.type, n.promote, f.fid, f.filepath, s.comment_count, xn.priority_override, xf.changed, xf.previously_changed
"), strlen(file_directory_path()) + 2, _xmlsitemap_file_frontpage());
while ($file = db_fetch_object($result)) {
$access = array();
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
$access = module_invoke_all('file_download', $file->filepath);
}
if (!in_array(-1, $access)) {
$link = array(
'loc' => xmlsitemap_file_create_url($file->filepath, $file->alias),
'lastmod' => filemtime($file->filepath),
'changefreq' => xmlsitemap_file_frequency($file),
'priority' => xmlsitemap_node_priority($file),
);
db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)", $link);
}
}
}
}