) );
}
+ /**
+ * Handle Special:Redirect/page/xxx (by redirecting to index.php?curid=xxx)
+ *
+ * @return string|null url to redirect to, or null if $mValue is invalid.
+ */
+ function dispatchPage() {
+ $curid = $this->mValue;
+ if ( !ctype_digit( $curid ) ) {
+ return null;
+ }
+ $curid = (int)$curid;
+ if ( $curid === 0 ) {
+ return null;
+ }
+ return wfAppendQuery( wfScript( 'index' ), array(
+ 'curid' => $curid
+ ) );
+ }
+
/**
* Use appropriate dispatch* method to obtain a redirection URL,
* and either: redirect, set a 404 error code and error message,
*/
function dispatch() {
// the various namespaces supported by Special:Redirect
- switch( $this->mType ) {
+ switch ( $this->mType ) {
case 'user':
$url = $this->dispatchUser();
break;
case 'revision':
$url = $this->dispatchRevision();
break;
+ case 'page':
+ $url = $this->dispatchPage();
+ break;
default:
$this->getOutput()->setStatusCode( 404 );
$url = null;
}
if ( !is_null( $this->mValue ) ) {
$this->getOutput()->setStatusCode( 404 );
+ // Message: redirect-not-exists
$msg = $this->getMessagePrefix() . '-not-exists';
return Status::newFatal( $msg );
}
$mp = $this->getMessagePrefix();
$ns = array(
// subpage => message
+ // Messages: redirect-user, redirect-page, redirect-revision,
+ // redirect-file
'user' => $mp . '-user',
+ 'page' => $mp . '-page',
'revision' => $mp . '-revision',
'file' => $mp . '-file',
);
$a = array();
$a['type'] = array(
'type' => 'select',
- 'label-message' => $mp . '-lookup',
+ 'label-message' => $mp . '-lookup', // Message: redirect-lookup
'options' => array(),
'default' => current( array_keys( $ns ) ),
);
- foreach( $ns as $n => $m ) {
+ foreach ( $ns as $n => $m ) {
$m = $this->msg( $m )->text();
$a['type']['options'][$m] = $n;
}
$a['value'] = array(
'type' => 'text',
- 'label-message' => $mp . '-value'
+ 'label-message' => $mp . '-value' // Message: redirect-value
);
// set the defaults according to the parsed subpage path
if ( !empty( $this->mType ) ) {
protected function alterForm( HTMLForm $form ) {
/* display summary at top of page */
$this->outputHeader();
- /* tweak label on submit button */
+ // tweak label on submit button
+ // Message: redirect-submit
$form->setSubmitTextMsg( $this->getMessagePrefix() . '-submit' );
/* submit form every time */
$form->setMethod( 'get' );