Use local context to get messages instead of relying on global variables
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index 82b5211..70edabc 100644 (file)
@@ -29,10 +29,6 @@ class InfoAction extends FormlessAction {
                return 'info';
        }
 
-       public function getRestriction() {
-               return 'read';
-       }
-
        protected function getDescription() {
                return '';
        }
@@ -45,57 +41,59 @@ class InfoAction extends FormlessAction {
                return false;
        }
 
+       protected function getPageTitle() {
+               return $this->msg( 'pageinfo-title', $this->getTitle()->getSubjectPage()->getPrefixedText() )->text();
+       }
+
        public function onView() {
                global $wgDisableCounters;
 
                $title = $this->getTitle()->getSubjectPage();
 
-               $this->getOutput()->setPagetitle( wfMsg( 'pageinfo-title', $title->getPrefixedText() ) );
-
                $pageInfo = self::pageCountInfo( $title );
                $talkInfo = self::pageCountInfo( $title->getTalkPage() );
 
                return Html::rawElement( 'table', array( 'class' => 'wikitable mw-page-info' ),
                        Html::rawElement( 'tr', array(),
                                Html::element( 'th', array(), '' ) .
-                               Html::element( 'th', array(), wfMsg( 'pageinfo-subjectpage' ) ) .
-                               Html::element( 'th', array(), wfMsg( 'pageinfo-talkpage' ) )
+                               Html::element( 'th', array(), $this->msg( 'pageinfo-subjectpage' )->text() ) .
+                               Html::element( 'th', array(), $this->msg( 'pageinfo-talkpage' )->text() )
                        ) .
                        Html::rawElement( 'tr', array(),
-                               Html::element( 'th', array( 'colspan' => 3 ), wfMsg( 'pageinfo-header-edits' ) )
+                               Html::element( 'th', array( 'colspan' => 3 ), $this->msg( 'pageinfo-header-edits' )->text() )
                        ) .
                        Html::rawElement( 'tr', array(),
-                               Html::element( 'td', array(), wfMsg( 'pageinfo-edits' ) ) .
-                               Html::element( 'td', array(), $this->getLang()->formatNum( $pageInfo['edits'] ) ) .
-                               Html::element( 'td', array(), $this->getLang()->formatNum( $talkInfo['edits'] ) )
+                               Html::element( 'td', array(), $this->msg( 'pageinfo-edits' )->text() ) .
+                               Html::element( 'td', array(), $this->getLanguage()->formatNum( $pageInfo['edits'] ) ) .
+                               Html::element( 'td', array(), $this->getLanguage()->formatNum( $talkInfo['edits'] ) )
                        ) .
                        Html::rawElement( 'tr', array(),
-                               Html::element( 'td', array(), wfMsg( 'pageinfo-authors' ) ) .
-                               Html::element( 'td', array(), $this->getLang()->formatNum( $pageInfo['authors'] ) ) .
-                               Html::element( 'td', array(), $this->getLang()->formatNum( $talkInfo['authors'] ) )
+                               Html::element( 'td', array(), $this->msg( 'pageinfo-authors' )->text() ) .
+                               Html::element( 'td', array(), $this->getLanguage()->formatNum( $pageInfo['authors'] ) ) .
+                               Html::element( 'td', array(), $this->getLanguage()->formatNum( $talkInfo['authors'] ) )
                        ) .
                        ( !$this->getUser()->isAllowed( 'unwatchedpages' ) ? '' :
                                Html::rawElement( 'tr', array(),
-                                       Html::element( 'th', array( 'colspan' => 3 ), wfMsg( 'pageinfo-header-watchlist' ) )
+                                       Html::element( 'th', array( 'colspan' => 3 ), $this->msg( 'pageinfo-header-watchlist' )->text() )
                                ) .
                                Html::rawElement( 'tr', array(),
-                                       Html::element( 'td', array(), wfMsg( 'pageinfo-watchers' ) ) .
-                                       Html::element( 'td', array( 'colspan' => 2 ), $this->getLang()->formatNum( $pageInfo['watchers'] ) )
+                                       Html::element( 'td', array(), $this->msg( 'pageinfo-watchers' )->text() ) .
+                                       Html::element( 'td', array( 'colspan' => 2 ), $this->getLanguage()->formatNum( $pageInfo['watchers'] ) )
                                )
                        ).
                        ( $wgDisableCounters ? '' :
                                Html::rawElement( 'tr', array(),
-                                       Html::element( 'th', array( 'colspan' => 3 ), wfMsg( 'pageinfo-header-views' ) )
+                                       Html::element( 'th', array( 'colspan' => 3 ), $this->msg( 'pageinfo-header-views' )->text() )
                                ) .
                                Html::rawElement( 'tr', array(),
-                                       Html::element( 'td', array(), wfMsg( 'pageinfo-views' ) ) .
-                                       Html::element( 'td', array(), $this->getLang()->formatNum( $pageInfo['views'] ) ) .
-                                       Html::element( 'td', array(), $this->getLang()->formatNum( $talkInfo['views'] ) )
+                                       Html::element( 'td', array(), $this->msg( 'pageinfo-views' )->text() ) .
+                                       Html::element( 'td', array(), $this->getLanguage()->formatNum( $pageInfo['views'] ) ) .
+                                       Html::element( 'td', array(), $this->getLanguage()->formatNum( $talkInfo['views'] ) )
                                ) .
                                Html::rawElement( 'tr', array(),
-                                       Html::element( 'td', array(), wfMsg( 'pageinfo-viewsperedit' ) ) .
-                                       Html::element( 'td', array(), $this->getLang()->formatNum( sprintf( '%.2f', $pageInfo['edits'] ? $pageInfo['views'] / $pageInfo['edits'] : 0 ) ) ) .
-                                       Html::element( 'td', array(), $this->getLang()->formatNum( sprintf( '%.2f', $talkInfo['edits'] ? $talkInfo['views'] / $talkInfo['edits'] : 0 ) ) )
+                                       Html::element( 'td', array(), $this->msg( 'pageinfo-viewsperedit' )->text() ) .
+                                       Html::element( 'td', array(), $this->getLanguage()->formatNum( sprintf( '%.2f', $pageInfo['edits'] ? $pageInfo['views'] / $pageInfo['edits'] : 0 ) ) ) .
+                                       Html::element( 'td', array(), $this->getLanguage()->formatNum( sprintf( '%.2f', $talkInfo['edits'] ? $talkInfo['views'] / $talkInfo['edits'] : 0 ) ) )
                                )
                        )
                );