Merge "Add custom collation for Northern Sami"
[lhc/web/wiklou.git] / includes / specials / SpecialComparePages.php
index c3bd3fe..35cc6b8 100644 (file)
@@ -43,63 +43,64 @@ class SpecialComparePages extends SpecialPage {
        /**
         * Show a form for filtering namespace and username
         *
-        * @param $par String
-        * @return String
+        * @param string $par
+        * @return string
         */
        public function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
+               $this->getOutput()->addModuleStyles( 'mediawiki.special.comparepages.styles' );
 
-               $form = new HTMLForm( array(
-                       'Page1' => array(
-                               'type' => 'text',
+               $form = HTMLForm::factory( 'ooui', [
+                       'Page1' => [
+                               'type' => 'title',
                                'name' => 'page1',
                                'label-message' => 'compare-page1',
                                'size' => '40',
                                'section' => 'page1',
-                               'validation-callback' => array( $this, 'checkExistingTitle' ),
-                       ),
-                       'Revision1' => array(
+                               'validation-callback' => [ $this, 'checkExistingTitle' ],
+                       ],
+                       'Revision1' => [
                                'type' => 'int',
                                'name' => 'rev1',
                                'label-message' => 'compare-rev1',
                                'size' => '8',
                                'section' => 'page1',
-                               'validation-callback' => array( $this, 'checkExistingRevision' ),
-                       ),
-                       'Page2' => array(
-                               'type' => 'text',
+                               'validation-callback' => [ $this, 'checkExistingRevision' ],
+                       ],
+                       'Page2' => [
+                               'type' => 'title',
                                'name' => 'page2',
                                'label-message' => 'compare-page2',
                                'size' => '40',
                                'section' => 'page2',
-                               'validation-callback' => array( $this, 'checkExistingTitle' ),
-                       ),
-                       'Revision2' => array(
+                               'validation-callback' => [ $this, 'checkExistingTitle' ],
+                       ],
+                       'Revision2' => [
                                'type' => 'int',
                                'name' => 'rev2',
                                'label-message' => 'compare-rev2',
                                'size' => '8',
                                'section' => 'page2',
-                               'validation-callback' => array( $this, 'checkExistingRevision' ),
-                       ),
-                       'Action' => array(
+                               'validation-callback' => [ $this, 'checkExistingRevision' ],
+                       ],
+                       'Action' => [
                                'type' => 'hidden',
                                'name' => 'action',
-                       ),
-                       'Diffonly' => array(
+                       ],
+                       'Diffonly' => [
                                'type' => 'hidden',
                                'name' => 'diffonly',
-                       ),
-                       'Unhide' => array(
+                       ],
+                       'Unhide' => [
                                'type' => 'hidden',
                                'name' => 'unhide',
-                       ),
-               ), $this->getContext(), 'compare' );
+                       ],
+               ], $this->getContext(), 'compare' );
                $form->setSubmitTextMsg( 'compare-submit' );
                $form->suppressReset();
                $form->setMethod( 'get' );
-               $form->setSubmitCallback( array( __CLASS__, 'showDiff' ) );
+               $form->setSubmitCallback( [ __CLASS__, 'showDiff' ] );
 
                $form->loadData();
                $form->displayForm( '' );
@@ -110,7 +111,7 @@ class SpecialComparePages extends SpecialPage {
                $rev1 = self::revOrTitle( $data['Revision1'], $data['Page1'] );
                $rev2 = self::revOrTitle( $data['Revision2'], $data['Page2'] );
 
-               if( $rev1 && $rev2 ) {
+               if ( $rev1 && $rev2 ) {
                        $revision = Revision::newFromId( $rev1 );
 
                        if ( $revision ) { // NOTE: $rev1 was already checked, should exist.
@@ -128,14 +129,15 @@ class SpecialComparePages extends SpecialPage {
        }
 
        public static function revOrTitle( $revision, $title ) {
-               if( $revision ) {
+               if ( $revision ) {
                        return $revision;
-               } elseif( $title ) {
+               } elseif ( $title ) {
                        $title = Title::newFromText( $title );
-                       if( $title instanceof Title ) {
+                       if ( $title instanceof Title ) {
                                return $title->getLatestRevID();
                        }
                }
+
                return null;
        }
 
@@ -150,6 +152,7 @@ class SpecialComparePages extends SpecialPage {
                if ( !$title->exists() ) {
                        return $this->msg( 'compare-title-not-exists' )->parseAsBlock();
                }
+
                return true;
        }
 
@@ -161,6 +164,7 @@ class SpecialComparePages extends SpecialPage {
                if ( $revision === null ) {
                        return $this->msg( 'compare-revision-not-exists' )->parseAsBlock();
                }
+
                return true;
        }