'label-message' => 'compare-page1',
'size' => '40',
'section' => 'page1',
+ 'validation-callback' => array( $this, 'checkExistingTitle' ),
),
'Revision1' => array(
'type' => 'int',
'label-message' => 'compare-rev1',
'size' => '8',
'section' => 'page1',
+ 'validation-callback' => array( $this, 'checkExistingRevision' ),
),
'Page2' => array(
'type' => 'text',
'label-message' => 'compare-page2',
'size' => '40',
'section' => 'page2',
+ 'validation-callback' => array( $this, 'checkExistingTitle' ),
),
'Revision2' => array(
'type' => 'int',
'label-message' => 'compare-rev2',
'size' => '8',
'section' => 'page2',
+ 'validation-callback' => array( $this, 'checkExistingRevision' ),
),
'Action' => array(
'type' => 'hidden',
'type' => 'hidden',
'name' => 'diffonly',
),
- ), 'compare' );
+ ), $this->getContext(), 'compare' );
$form->setSubmitText( wfMsg( 'compare-submit' ) );
$form->suppressReset();
$form->setMethod( 'get' );
- $form->setTitle( $this->getTitle() );
+ $form->setSubmitCallback( array( __CLASS__, 'showDiff' ) );
$form->loadData();
$form->displayForm( '' );
-
- self::showDiff( $form->mFieldData );
+ $form->trySubmit();
}
public static function showDiff( $data ){
}
return null;
}
+
+ public function checkExistingTitle( $value, $alldata ) {
+ if ( $value === '' ) {
+ return true;
+ }
+ $title = Title::newFromText( $value );
+ if ( !$title instanceof Title ) {
+ return wfMsgExt( 'compare-invalid-title', 'parse' );
+ }
+ if ( !$title->exists() ) {
+ return wfMsgExt( 'compare-title-not-exists', 'parse' );
+ }
+ return true;
+ }
+
+ public function checkExistingRevision( $value, $alldata ) {
+ if ( $value === '' ) {
+ return true;
+ }
+ $revision = Revision::newFromId( $value );
+ if ( $revision === null ) {
+ return wfMsgExt( 'compare-revision-not-exists', 'parse' );
+ }
+ return true;
+ }
}
'tags-hitcount' => '$1 {{PLURAL:$1|change|changes}}',
# Special:ComparePages
-'comparepages' => 'Compare pages',
-'compare-selector' => 'Compare page revisions',
-'compare-page1' => 'Page 1',
-'compare-page2' => 'Page 2',
-'compare-rev1' => 'Revision 1',
-'compare-rev2' => 'Revision 2',
-'compare-submit' => 'Compare',
+'comparepages' => 'Compare pages',
+'compare-selector' => 'Compare page revisions',
+'compare-page1' => 'Page 1',
+'compare-page2' => 'Page 2',
+'compare-rev1' => 'Revision 1',
+'compare-rev2' => 'Revision 2',
+'compare-submit' => 'Compare',
+'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.',
# Database error messages
'dberr-header' => 'This wiki has a problem',