return $redirect;
} else {
- $class = static::class;
- throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
+ $this->showNoRedirectPage();
}
}
public function personallyIdentifiableTarget() {
return false;
}
+
+ protected function showNoRedirectPage() {
+ $class = static::class;
+ throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
+ }
}
/**
$this->mAddedRedirectParams['oldid'] = $parts[0];
$this->mAddedRedirectParams['diff'] = $parts[1];
} else {
- // Wrong number of parameters, bail out
- $this->addHelpLink( 'Help:Diff' );
- throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
+ return false;
}
return true;
}
+
+ protected function showNoRedirectPage() {
+ $this->addHelpLink( 'Help:Diff' );
+ $this->setHeaders();
+ $this->outputHeader();
+ $this->showForm();
+ }
+
+ private function showForm() {
+ $form = HTMLForm::factory( 'ooui', [
+ 'oldid' => [
+ 'name' => 'oldid',
+ 'type' => 'int',
+ 'label-message' => 'diff-form-oldid',
+ ],
+ 'diff' => [
+ 'name' => 'diff',
+ 'class' => 'HTMLTextField',
+ 'label-message' => 'diff-form-revid',
+ ],
+ ], $this->getContext(), 'diff-form' );
+ $form->setSubmitTextMsg( 'diff-form-submit' );
+ $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
+ $form->show();
+ }
+
+ public function onFormSubmit( $formData ) {
+ $params = [];
+ if ( $formData['oldid'] ) {
+ $params[] = $formData['oldid'];
+ }
+ if ( $formData['diff'] ) {
+ $params[] = $formData['diff'];
+ }
+ $title = $this->getPageTitle( $params ? implode( '/', $params ) : null );
+ $url = $title->getFullUrlForRedirect();
+ $this->getOutput()->redirect( $url );
+ }
+
+ public function getDescription() {
+ // 'diff' message is in lowercase, using own message
+ return $this->msg( 'diff-form' )->text();
+ }
+
+ public function getName() {
+ return 'diff-form';
+ }
+
+ public function isListed() {
+ return true;
+ }
+
+ protected function getGroupName() {
+ return 'redirects';
+ }
}
public function getRedirect( $subpage ) {
$subpage = intval( $subpage );
if ( $subpage === 0 ) {
- # throw an error page when no subpage was given
- throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
+ return false;
}
$this->mAddedRedirectParams['oldid'] = $subpage;
return true;
}
+
+ protected function showNoRedirectPage() {
+ $this->setHeaders();
+ $this->outputHeader();
+ $this->showForm();
+ }
+
+ private function showForm() {
+ $form = HTMLForm::factory( 'ooui', [
+ 'revid' => [
+ 'type' => 'int',
+ 'name' => 'revid',
+ 'label-message' => 'permanentlink-revid',
+ ],
+ ], $this->getContext(), 'permanentlink' );
+ $form->setSubmitTextMsg( 'permanentlink-submit' );
+ $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
+ $form->show();
+ }
+
+ public function onFormSubmit( $formData ) {
+ $revid = $formData['revid'];
+ $title = $this->getPageTitle( $revid ?: null );
+ $url = $title->getFullUrlForRedirect();
+ $this->getOutput()->redirect( $url );
+ }
+
+ public function isListed() {
+ return true;
+ }
+
+ protected function getGroupName() {
+ return 'redirects';
+ }
}
"compare-invalid-title": "The title you specified is invalid.",
"compare-title-not-exists": "The title you specified does not exist.",
"compare-revision-not-exists": "The revision you specified does not exist.",
+ "diff-form": "Differences",
+ "diff-form-oldid": "Old revision ID (optional)",
+ "diff-form-revid": "Revision ID of difference",
+ "diff-form-submit": "Show differences",
+ "diff-form-summary": "",
+ "permanentlink": "Permanent link",
+ "permanentlink-revid": "Revision ID",
+ "permanentlink-submit": "Go to revision",
+ "permanentlink-summary": "",
"dberr-problems": "Sorry! This site is experiencing technical difficulties.",
"dberr-again": "Try waiting a few minutes and reloading.",
"dberr-info": "(Cannot access the database: $1)",
"compare-invalid-title": "Used as error message in [[Special:ComparePages]].",
"compare-title-not-exists": "Used as error message in [[Special:ComparePages]].",
"compare-revision-not-exists": "Used as error message in [[Special:ComparePages]].",
+ "permanentlink": "The title of [[Special:PermanentLink]]",
+ "permanentlink-revid": "Label for the field for the revision ID in [[Special:PermanentLink]]",
+ "permanentlink-submit": "Submit button on [[Special:PermanentLink]]",
+ "permanentlink-summary": "{{doc-specialpagesummary|permanentlink}}",
+ "diff-form": "The title of [[Special:Diff]]",
+ "diff-form-summary": "{{doc-specialpagesummary|diff}}",
+ "diff-form-oldid": "Label for the field of the old revision in the comparison for [[Special:Diff]]",
+ "diff-form-revid": "Label for the field of the new revision in the comparison for [[Special:Diff]]",
+ "diff-form-submit": "Submit button on [[Special:Diff]]",
"dberr-problems": "This message does not allow any wiki nor html markup.",
"dberr-again": "This message does not allow any wiki nor html markup.",
"dberr-info": "This message does not allow any wiki nor html markup. Parameters:\n* $1 - database server name\nSee also:\n* {{msg-mw|Dberr-info-hidden}} - hides database server name",