Followup r67094, factor out code duplication in HistoryPage::getStartBody()
authorSam Reed <reedy@users.mediawiki.org>
Wed, 2 Feb 2011 22:31:48 +0000 (22:31 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 2 Feb 2011 22:31:48 +0000 (22:31 +0000)
includes/HistoryPage.php

index fed09ae..4c15d7f 100644 (file)
@@ -401,44 +401,35 @@ class HistoryPager extends ReverseChronologicalPager {
                ) . "\n";
 
                if ( $wgUser->isAllowed( 'deleterevision' ) ) {
-                       $this->preventClickjacking();
-                       $float = $wgContLang->alignEnd();
-                       # Note bug #20966, <button> is non-standard in IE<8
-                       $element = Html::element( 'button',
-                               array(
-                                       'type' => 'submit',
-                                       'name' => 'revisiondelete',
-                                       'value' => '1',
-                                       'style' => "float: $float;",
-                                       'class' => 'mw-history-revisiondelete-button',
-                               ),
-                               wfMsg( 'showhideselectedversions' )
-                       ) . "\n";
-                       $s .= $element;
-                       $this->buttons .= $element;
+                       $s .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
                }
                if ( $wgUser->isAllowed( 'revisionmove' ) ) {
-                       $this->preventClickjacking();
-                       $float = $wgContLang->alignEnd();
-                       # Note bug #20966, <button> is non-standard in IE<8
-                       $element = Html::element( 'button',
-                               array(
-                                       'type' => 'submit',
-                                       'name' => 'revisionmove',
-                                       'value' => '1',
-                                       'style' => "float: $float;",
-                                       'class' => 'mw-history-revisionmove-button',
-                               ),
-                               wfMsg( 'revisionmoveselectedversions' )
-                       ) . "\n";
-                       $s .= $element;
-                       $this->buttons .= $element;
+                       $s .= $this->getRevisionButton( 'revisionmove', 'revisionmoveselectedversions' );
                }
                $this->buttons .= '</div>';
                $s .= '</div><ul id="pagehistory">' . "\n";
                return $s;
        }
 
+       private function getRevisionButton( $name, $msg ) {
+               global $wgContLang;
+               $this->preventClickjacking();
+               $float = $wgContLang->alignEnd();
+               # Note bug #20966, <button> is non-standard in IE<8
+               $element = Html::element( 'button',
+                       array(
+                               'type' => 'submit',
+                               'name' => $name,
+                               'value' => '1',
+                               'style' => "float: $float;",
+                               'class' => "mw-history-$name-button",
+                       ),
+                       wfMsg( 'revisionmoveselectedversions' )
+               ) . "\n";
+               $this->buttons .= $element;
+               return $element;
+       }
+
        function getEndBody() {
                if ( $this->lastRow ) {
                        $latest = $this->counter == 1 && $this->mIsFirst;