forked from wikipathways/mediawiki-extensions-WikiPathways
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LegacySpecialPage.php
32 lines (24 loc) · 918 Bytes
/
LegacySpecialPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
class LegacySpecialPage extends SpecialPage {
protected $legacyDestination = null;
function __construct( $oldName, $newName ) {
parent::__construct( $oldName );
$this->legacyDestination = Title::newFromText( $newName, NS_SPECIAL );
$this->mListed = false;
}
function execute( $par ) {
global $wgRequest;
if ( !( $this->legacyDestination instanceof Title ) ) {
throw new MWException( "legacy-no-destination" );
}
if ( isset( $wgRequest->data['title'] ) ) { unset( $wgRequest->data['title'] );
}
$query = [];
foreach ( $wgRequest->data as $k => $v ) {
$query[] = urlencode( $k ) . '=' . urlencode( $v );
}
$wgRequest->response()->header( "HTTP/1.1 301 Moved Permanently" );
$wgRequest->response()->header( "Content-Type: text/html; charset=utf-8" );
$wgRequest->response()->header( "Location: ". $this->legacyDestination->getLocalURL( implode( "&", $query ) ) );
}
}