function xmlsitemap_url in XML sitemap 5.2
Same name and namespace in other branches
- 5 xmlsitemap.module \xmlsitemap_url()
Modified version of url(). We don't want to do a separate database query for each url, so we pass the alias as an extra parameter.
Parameters
$alias: The URL alias. Default is NULL.:
Return value
The fully formatted URL
10 calls to xmlsitemap_url()
- theme_xmlsitemap_node_view_news in xmlsitemap_node/
xmlsitemap_node.module - Display the nodes of a view as a Google News sitemap.
- theme_xmlsitemap_node_view_sitemap in xmlsitemap_node/
xmlsitemap_node.module - Display the nodes of a view as an XML sitemap.
- xmlsitemap_file_create_url in xmlsitemap/
xmlsitemap.module - Modified version of file_create_url(). Allows us to remove language prefixes.
- xmlsitemap_node_xmlsitemap_links in xmlsitemap_node/
xmlsitemap_node.module - Implementation of hook_xmlsitemap_links().
- xmlsitemap_robotstxt in xmlsitemap/
xmlsitemap.module - Implementation of hook_robotstxt().
File
- xmlsitemap/
xmlsitemap.module, line 482 - Creates a sitemap compatible with the sitemaps.org schema.
Code
function xmlsitemap_url($path = NULL, $alias = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
if (isset($fragment)) {
$fragment = "#{$fragment}";
}
$colonpos = strpos($path, ':');
if ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path)) {
if (strpos($path, '#') !== FALSE) {
list($path, $old_fragment) = explode('#', $path, 2);
if (isset($old_fragment) && !isset($fragment)) {
$fragment = "#{$old_fragment}";
}
}
if (isset($query)) {
$path .= (strpos($path, '?') !== FALSE ? '&' : '?') . $query;
}
return $path . $fragment;
}
static $script;
$script = isset($script) ? $script : strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === FALSE ? 'index.php' : '';
$base = $absolute ? "{$GLOBALS['base_url']}/" : base_path();
if (!empty($path) && $path != '<front>') {
$path = _xmlsitemap_get_path_alias($path, $alias);
$path = drupal_urlencode($path);
if (!variable_get('clean_url', FALSE)) {
if (isset($query)) {
return $base . $script . '?q=' . $path . '&' . $query . $fragment;
}
else {
return $base . $script . '?q=' . $path . $fragment;
}
}
else {
if (isset($query)) {
return $base . $path . '?' . $query . $fragment;
}
else {
return $base . $path . $fragment;
}
}
}
else {
if (isset($query)) {
return $base . $script . '?' . $query . $fragment;
}
else {
return $base . $fragment;
}
}
}