Page MenuHomePhabricator

sitemap.patch

Authored By
bzimport
Nov 21 2014, 10:02 PM
Size
1 KB
Referenced Files
None
Subscribers
None

sitemap.patch

Index: maintenance/generateSitemap.php
===================================================================
--- maintenance/generateSitemap.php (revision 30843)
+++ maintenance/generateSitemap.php (working copy)
@@ -162,6 +162,16 @@
* Generate a one-dimensional array of existing namespaces
*/
function generateNamespaces() {
+ /*
+ Use a subset of namespaces if it's defined
+ */
+ global $wgSiteMapNamespaces, $wgSiteMapExcludeNamespaces;
+ if (is_array($wgSiteMapNamespaces))
+ {
+ $this->namespaces = $wgSiteMapNamespaces;
+ return;
+ }
+
$fname = 'GenerateSitemap::generateNamespaces';
$res = $this->dbr->select( 'page',
@@ -175,7 +185,14 @@
);
while ( $row = $this->dbr->fetchObject( $res ) )
+ {
+ if (is_array($wgSiteMapExcludeNamespaces)
+ && array_key_exists($row->page_namespace, $wgSiteMapExcludeNamespaces))
+ {
+ continue;
+ }
$this->namespaces[] = $row->page_namespace;
+ }
}
/**
@@ -367,9 +384,10 @@
* @return string
*/
function indexEntry( $filename ) {
+ global $wgServer;
return
"\t<sitemap>\n" .
- "\t\t<loc>$filename</loc>\n" .
+ "\t\t<loc>" . $wgServer . "/$filename</loc>\n" .
"\t\t<lastmod>{$this->timestamp}</lastmod>\n" .
"\t</sitemap>\n";
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4201
Default Alt Text
sitemap.patch (1 KB)

Event Timeline