* @see http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
*/
+use MediaWiki\MediaWikiServices;
+
require_once __DIR__ . '/Maintenance.php';
/**
* Main loop
*/
public function main() {
- global $wgContLang;
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
fwrite( $this->findex, $this->openIndex() );
$length = $this->limit[0];
$i = $smcount = 0;
- $fns = $wgContLang->getFormattedNsText( $namespace );
+ $fns = $contLang->getFormattedNsText( $namespace );
$this->output( "$namespace ($fns)\n" );
$skippedRedirects = 0; // Number of redirects skipped for that namespace
foreach ( $res as $row ) {
$length += strlen( $entry );
$this->write( $this->file, $entry );
// generate pages for language variants
- if ( $wgContLang->hasVariants() ) {
- $variants = $wgContLang->getVariants();
+ if ( $contLang->hasVariants() ) {
+ $variants = $contLang->getVariants();
foreach ( $variants as $vCode ) {
- if ( $vCode == $wgContLang->getCode() ) {
+ if ( $vCode == $contLang->getCode() ) {
continue; // we don't want default variant
}
$entry = $this->fileEntry(
*/
function indexEntry( $filename ) {
return "\t<sitemap>\n" .
- "\t\t<loc>{$this->urlpath}$filename</loc>\n" .
+ "\t\t<loc>" . wfGetServerUrl( PROTO_CANONICAL ) .
+ ( substr( $this->urlpath, 0, 1 ) === "/" ? "" : "/" ) .
+ "{$this->urlpath}$filename</loc>\n" .
"\t\t<lastmod>{$this->timestamp}</lastmod>\n" .
"\t</sitemap>\n";
}