Merge "Replace deprecated wfMsg* calls with Message class calls."
authorIAlex <ialex.wiki@gmail.com>
Sun, 19 Aug 2012 22:06:43 +0000 (22:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 19 Aug 2012 22:06:43 +0000 (22:06 +0000)
14 files changed:
includes/FeedUtils.php
includes/actions/HistoryAction.php
includes/actions/InfoAction.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialEmailuser.php
includes/specials/SpecialPreferences.php
includes/upload/UploadFromUrl.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/importSiteScripts.php
maintenance/language/messages.inc
tests/jasmine/spec_makers/makeJqueryMsgSpec.php
tests/phpunit/includes/ArticleTablesTest.php
thumb.php

index 1c5e777..16eba66 100644 (file)
@@ -85,7 +85,7 @@ class FeedUtils {
                        $row->rc_last_oldid, $row->rc_this_oldid,
                        $timestamp,
                        ($row->rc_deleted & Revision::DELETED_COMMENT)
-                               ? wfMsgHtml('rev-deleted-comment') 
+                               ? wfMessage('rev-deleted-comment')->escaped()
                                : $row->rc_comment,
                        $actiontext 
                );
index c22c04b..1c57f25 100644 (file)
@@ -248,8 +248,8 @@ class HistoryAction extends FormlessAction {
 
                $feed = new $wgFeedClasses[$type](
                        $this->getTitle()->getPrefixedText() . ' - ' .
-                       wfMessage( 'history-feed-title' )->inContentLanguage()->text(),
-                       wfMessage( 'history-feed-description' )->inContentLanguage()->text(),
+                       $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
+                       $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
                        $this->getTitle()->getFullUrl( 'action=history' )
                );
 
@@ -275,8 +275,8 @@ class HistoryAction extends FormlessAction {
 
        function feedEmpty() {
                return new FeedItem(
-                       wfMessage( 'nohistory' )->inContentLanguage()->text(),
-                       $this->getOutput()->parse( wfMessage( 'history-feed-empty' )->inContentLanguage()->text() ),
+                       $this->msg( 'nohistory' )->inContentLanguage()->text(),
+                       $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
                        $this->getTitle()->getFullUrl(),
                        wfTimestamp( TS_MW ),
                        '',
@@ -304,14 +304,14 @@ class HistoryAction extends FormlessAction {
                );
                if ( $rev->getComment() == '' ) {
                        global $wgContLang;
-                       $title = wfMessage( 'history-feed-item-nocomment',
+                       $title = $this->msg( 'history-feed-item-nocomment',
                                $rev->getUserText(),
                                $wgContLang->timeanddate( $rev->getTimestamp() ),
                                $wgContLang->date( $rev->getTimestamp() ),
                                $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
                } else {
                        $title = $rev->getUserText() .
-                       wfMessage( 'colon-separator' )->inContentLanguage()->text() .
+                       $this->msg( 'colon-separator' )->inContentLanguage()->text() .
                        FeedItem::stripComment( $rev->getComment() );
                }
                return new FeedItem(
index f4813a4..db7b61d 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 /**
- * Display informations about a page.
- * Very inefficient for the moment.
+ * Displays information about a page.
  *
  * Copyright © 2011 Alexandre Emsenhuber
  *
  */
 
 class InfoAction extends FormlessAction {
-
+       /**
+        * Returns the name of the action this object responds to.
+        *
+        * @return string lowercase
+        */
        public function getName() {
                return 'info';
        }
 
-       protected function getDescription() {
-               return '';
-       }
-
-       public function requiresWrite() {
-               return false;
-       }
-
+       /**
+        * Whether this action can still be executed by a blocked user.
+        *
+        * @return bool
+        */
        public function requiresUnblock() {
                return false;
        }
 
-       protected function getPageTitle() {
-               return $this->msg( 'pageinfo-title', $this->getTitle()->getSubjectPage()->getPrefixedText() )->text();
+       /**
+        * Whether this action requires the wiki not to be locked.
+        *
+        * @return bool
+        */
+       public function requiresWrite() {
+               return false;
        }
 
+       /**
+        * Shows page information on GET request.
+        *
+        * @return string Page information that will be added to the output
+        */
        public function onView() {
-               global $wgDisableCounters;
+               global $wgDisableCounters, $wgRCMaxAge, $wgRestrictionTypes;
 
-               $title = $this->getTitle()->getSubjectPage();
+               $lang = $this->getLanguage();
+               $title = $this->getTitle();
 
-               $userCanViewUnwatchedPages = $this->getUser()->isAllowed( 'unwatchedpages' );
+               $article = new Article( $title );
+               $id = $title->getArticleID();
 
+               // Get page information that would be too "expensive" to retrieve by normal means
+               $userCanViewUnwatchedPages = $this->getUser()->isAllowed( 'unwatchedpages' );
                $pageInfo = self::pageCountInfo( $title, $userCanViewUnwatchedPages, $wgDisableCounters );
-               $talkInfo = self::pageCountInfo( $title->getTalkPage(), $userCanViewUnwatchedPages, $wgDisableCounters );
 
-               $lang = $this->getLanguage();
+               // Get page properties
+               $dbr = wfGetDB( DB_SLAVE );
+               $result = $dbr->select(
+                       'page_props',
+                       array( 'pp_propname', 'pp_value' ),
+                       array( 'pp_page' => $id ),
+                       __METHOD__
+               );
+
+               $pageProperties = array();
+               foreach ( $result as $row ) {
+                       $pageProperties[$row->pp_propname] = $row->pp_value;
+               }
+
+               $content = '';
+               $table = '';
+
+               // Basic information
+               $content = $this->addHeader( $content, $this->msg( 'pageinfo-header-basic' ) );
+
+               // Display title
+               $displayTitle = $title->getPrefixedText();
+               if ( !empty( $pageProperties['displaytitle'] ) ) {
+                       $displayTitle = $pageProperties['displaytitle'];
+               }
+
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-display-title' ), $displayTitle );
+
+               // Default sort key
+               $sortKey = $title->getCategorySortKey();
+               if ( !empty( $pageProperties['defaultsort'] ) ) {
+                       $sortKey = $pageProperties['defaultsort'];
+               }
+
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-default-sort' ), $sortKey );
 
-               $content =
-                       Html::rawElement( 'tr', array(),
-                               Html::element( 'th', array(), '' ) .
-                                       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 ), $this->msg( 'pageinfo-header-edits' )->text() )
-                       ) .
-                       Html::rawElement( 'tr', array(),
-                               Html::element( 'td', array(), $this->msg( 'pageinfo-edits' )->text() ) .
-                                       Html::element( 'td', array(), $lang->formatNum( $pageInfo['edits'] ) ) .
-                                       Html::element( 'td', array(), $lang->formatNum( $talkInfo['edits'] ) )
-                       ) .
-                       Html::rawElement( 'tr', array(),
-                               Html::element( 'td', array(), $this->msg( 'pageinfo-authors' )->text() ) .
-                                       Html::element( 'td', array(), $lang->formatNum( $pageInfo['authors'] ) ) .
-                                       Html::element( 'td', array(), $lang->formatNum( $talkInfo['authors'] ) )
+               // Page length (in bytes)
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() ) );
+
+               // Page ID
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-article-id' ), $lang->formatNum( $id ) );
+
+               // Search engine status
+               $pOutput = new ParserOutput();
+               if ( isset( $pageProperties['noindex'] ) ) {
+                       $pOutput->setIndexPolicy( 'noindex' );
+               }
+
+               // Use robot policy logic
+               $policy = $article->getRobotPolicy( 'view', $pOutput );
+               $table = $this->addRow( $table,
+                       'Search engine status', "Marked as '" . $policy['index'] . "'"
+               );
+
+               if ( !$wgDisableCounters ) {
+                       // Number of views
+                       $table = $this->addRow( $table,
+                               $this->msg( 'pageinfo-views' ), $lang->formatNum( $pageInfo['views'] )
                        );
+               }
 
                if ( $userCanViewUnwatchedPages ) {
-                       $content .= Html::rawElement( 'tr', array(),
-                               Html::element( 'th', array( 'colspan' => 3 ), $this->msg( 'pageinfo-header-watchlist' )->text() )
-                       ) .
-                               Html::rawElement( 'tr', array(),
-                                       Html::element( 'td', array(), $this->msg( 'pageinfo-watchers' )->text() ) .
-                                               Html::element( 'td', array( 'colspan' => 2 ), $lang->formatNum( $pageInfo['watchers'] ) )
-                               );
+                       // Number of page watchers
+                       $table = $this->addRow( $table,
+                               $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageInfo['watchers'] ) );
                }
 
-               if ( !$wgDisableCounters ) {
-                       $content .= Html::rawElement( 'tr', array(),
-                               Html::element( 'th', array( 'colspan' => 3 ), $this->msg( 'pageinfo-header-views' )->text() )
-                       ) .
-                               Html::rawElement( 'tr', array(),
-                                       Html::element( 'td', array(), $this->msg( 'pageinfo-views' )->text() ) .
-                                               Html::element( 'td', array(), $lang->formatNum( $pageInfo['views'] ) ) .
-                                               Html::element( 'td', array(), $lang->formatNum( $talkInfo['views'] ) )
-                               ) .
-                               Html::rawElement( 'tr', array(),
-                                       Html::element( 'td', array(), $this->msg( 'pageinfo-viewsperedit' )->text() ) .
-                                               Html::element( 'td', array(), $lang->formatNum( sprintf( '%.2f', $pageInfo['edits'] ? $pageInfo['views'] / $pageInfo['edits'] : 0 ) ) ) .
-                                               Html::element( 'td', array(), $lang->formatNum( sprintf( '%.2f', $talkInfo['edits'] ? $talkInfo['views'] / $talkInfo['edits'] : 0 ) ) )
+               // Redirects to this page
+               $whatLinksHere = SpecialPage::getTitleFor( 'WhatLinksHere', $title->getPrefixedText() );
+               $table = $this->addRow( $table,
+                       Linker::link(
+                               $whatLinksHere,
+                               $this->msg( 'pageinfo-redirects-name' ),
+                               array(),
+                               array( 'hidelinks' => 1, 'hidetrans' => 1 )
+                       ),
+                       $this->msg( 'pageinfo-redirects-value',
+                               $lang->formatNum( count( $title->getRedirectsHere() ) )
+                       )
+               );
+
+               // Subpages of this page
+               $prefixIndex = SpecialPage::getTitleFor( 'PrefixIndex', $title->getPrefixedText() . '/' );
+               $table = $this->addRow( $table,
+                       Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' ) ),
+                       $this->msg( 'pageinfo-subpages-value',
+                               $lang->formatNum( $pageInfo['subpages']['total'] ),
+                               $pageInfo['subpages']['redirects'],
+                               $pageInfo['subpages']['nonredirects']
+                       )
+               );
+
+               // Page protection
+               $content = $this->addTable( $content, $table );
+               $content = $this->addHeader( $content, $this->msg( 'pageinfo-header-restrictions' ) );
+               $table = '';
+
+               // Page protection
+               foreach ( $wgRestrictionTypes as $restrictionType ) {
+                       $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
+                       if ( $protectionLevel == '' ) {
+                               // Allow all users
+                               $message = $this->msg( "protect-default" );
+                       } else {
+                               // Administrators only
+                               $message = $this->msg( "protect-level-$protectionLevel" );
+                               if ( !$message->exists() ) {
+                                       // Require "$1" permission
+                                       $message = $this->msg( "protect-fallback", $protectionLevel );
+                               }
+                       }
+
+                       $table = $this->addRow( $table,
+                               $this->msg( 'pageinfo-restriction', $restrictionType ), $message
+                       );
+               }
+
+               // Edit history
+               $content = $this->addTable( $content, $table );
+               $content = $this->addHeader( $content, $this->msg( 'pageinfo-header-edits' ) );
+               $table = '';
+
+               // Page creator
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-firstuser' ), $pageInfo['firstuser']
+               );
+
+               // Date of page creation
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-firsttime' ), $lang->timeanddate( $pageInfo['firsttime'] )
+               );
+
+               // Latest editor
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-lastuser' ), $pageInfo['lastuser']
+               );
+
+               // Date of latest edit
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-lasttime' ), $lang->timeanddate( $pageInfo['lasttime'] )
+               );
+
+               // Total number of edits
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageInfo['edits'] )
+               );
+
+               // Total number of distinct authors
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageInfo['authors'] )
+               );
+
+               // Recent number of edits (within past 30 days)
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $wgRCMaxAge ) ),
+                       $lang->formatNum( $pageInfo['recent_edits'] )
+               );
+
+               // Recent number of distinct authors
+               $table = $this->addRow( $table,
+                       $this->msg( 'pageinfo-recent-authors' ), $lang->formatNum( $pageInfo['recent_authors'] )
+               );
+
+               $content = $this->addTable( $content, $table );
+
+               // Array of MagicWord objects
+               $magicWords = MagicWord::getDoubleUnderscoreArray();
+
+               // Array of magic word IDs
+               $wordIDs = $magicWords->names;
+
+               // Array of IDs => localized magic words
+               $localizedWords = $lang->getMagicWords();
+
+               $listItems = array();
+               foreach ( $pageProperties as $property => $value ) {
+                       if ( in_array( $property, $wordIDs ) ) {
+                               $listItems[] = Html::element( 'li', array(), $localizedWords[$property][1] );
+                       }
+               }
+
+               $localizedList = Html::rawElement( 'ul', array(), implode( '', $listItems ) );
+               $hiddenCategories = $article->getHiddenCategories();
+               $transcludedTemplates = $title->getTemplateLinksFrom();
+
+               if ( count( $listItems ) > 0
+                       || count( $hiddenCategories ) > 0
+                       || count( $transcludedTemplates ) > 0 ) {
+                       // Page properties
+                       $content = $this->addHeader( $content, $this->msg( 'pageinfo-header-properties' ) );
+                       $table = '';
+
+                       // Magic words
+                       if ( count( $listItems ) > 0 ) {
+                               $table = $this->addRow( $table,
+                                       $this->msg( 'pageinfo-magic-words', count( $listItems ) ), $localizedList
+                               );
+                       }
+
+                       // Hide "This page is a member of # hidden categories explanation
+                       $content .= Html::element( 'style', array(),
+                               '.mw-hiddenCategoriesExplanation { display: none; }' );
+
+                       // Hidden categories
+                       if ( count( $hiddenCategories ) > 0 ) {
+                               $table = $this->addRow( $table,
+                                       $this->msg( 'pageinfo-hidden-categories', count( $hiddenCategories ) ),
+                                       Linker::formatHiddenCategories( $hiddenCategories )
                                );
+                       }
+
+                       // Hide "Templates used on this page:" explanation
+                       $content .= Html::element( 'style', array(),
+                               '.mw-templatesUsedExplanation { display: none; }' );
+
+                       // Transcluded templates
+                       if ( count( $transcludedTemplates ) > 0 ) {
+                               $table = $this->addRow( $table,
+                                       $this->msg( 'pageinfo-templates', count( $transcludedTemplates ) ),
+                                       Linker::formatTemplates( $transcludedTemplates )
+                               );
+                       }
+
+                       $content = $this->addTable( $content, $table );
                }
-               return Html::rawElement( 'table', array( 'class' => 'wikitable mw-page-info' ), $content );
+
+               return $content;
        }
 
        /**
-        * Return the total number of edits and number of unique editors
-        * on a given page. If page does not exist, returns false.
+        * Returns page information that would be too "expensive" to retrieve by normal means.
         *
         * @param $title Title object
         * @param $canViewUnwatched bool
@@ -115,13 +310,28 @@ class InfoAction extends FormlessAction {
         * @return array
         */
        public static function pageCountInfo( $title, $canViewUnwatched, $disableCounter ) {
+               global $wgRCMaxAge;
+
                wfProfileIn( __METHOD__ );
                $id = $title->getArticleID();
-               $dbr = wfGetDB( DB_SLAVE );
 
+               $dbr = wfGetDB( DB_SLAVE );
                $result = array();
+
+               if ( !$disableCounter ) {
+                       // Number of views
+                       $views = (int) $dbr->selectField(
+                               'page',
+                               'page_counter',
+                               array( 'page_id' => $id ),
+                               __METHOD__
+                       );
+                       $result['views'] = $views;
+               }
+
                if ( $canViewUnwatched ) {
-                       $watchers = (int)$dbr->selectField(
+                       // Number of page watchers
+                       $watchers = (int) $dbr->selectField(
                                'watchlist',
                                'COUNT(*)',
                                array(
@@ -133,7 +343,8 @@ class InfoAction extends FormlessAction {
                        $result['watchers'] = $watchers;
                }
 
-               $edits = (int)$dbr->selectField(
+               // Total number of edits
+               $edits = (int) $dbr->selectField(
                        'revision',
                        'COUNT(rev_page)',
                        array( 'rev_page' => $id ),
@@ -141,7 +352,8 @@ class InfoAction extends FormlessAction {
                );
                $result['edits'] = $edits;
 
-               $authors = (int)$dbr->selectField(
+               // Total number of distinct authors
+               $authors = (int) $dbr->selectField(
                        'revision',
                        'COUNT(DISTINCT rev_user_text)',
                        array( 'rev_page' => $id ),
@@ -149,17 +361,139 @@ class InfoAction extends FormlessAction {
                );
                $result['authors'] = $authors;
 
-               if ( !$disableCounter ) {
-                       $views = (int)$dbr->selectField(
-                               'page',
-                               'page_counter',
-                               array( 'page_id' => $id ),
-                               __METHOD__
-                       );
-                       $result['views'] = $views;
-               }
+               // "Recent" threshold defined by $wgRCMaxAge
+               $threshold = $dbr->timestamp( time() - $wgRCMaxAge );
+
+               // Recent number of edits
+               $edits = (int) $dbr->selectField(
+                       'revision',
+                       'COUNT(rev_page)',
+                       array(
+                               'rev_page' => $id ,
+                               "rev_timestamp >= $threshold"
+                       ),
+                       __METHOD__
+               );
+               $result['recent_edits'] = $edits;
+
+               // Recent number of distinct authors
+               $authors = (int) $dbr->selectField(
+                       'revision',
+                       'COUNT(DISTINCT rev_user_text)',
+                       array(
+                               'rev_page' => $id,
+                               "rev_timestamp >= $threshold"
+                       ),
+                       __METHOD__
+               );
+               $result['recent_authors'] = $authors;
+
+               $conds = array( 'page_namespace' => $title->getNamespace(), 'page_is_redirect' => 1 );
+               $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
+
+               // Subpages of this page (redirects)
+               $result['subpages']['redirects'] = (int) $dbr->selectField(
+                       'page',
+                       'COUNT(page_id)',
+                       $conds,
+                       __METHOD__ );
+
+               // Subpages of this page (non-redirects)
+               $conds['page_is_redirect'] = 0;
+               $result['subpages']['nonredirects'] = (int) $dbr->selectField(
+                       'page',
+                       'COUNT(page_id)',
+                       $conds,
+                       __METHOD__
+               );
+
+               // Subpages of this page (total)
+               $result['subpages']['total'] = $result['subpages']['redirects']
+                       + $result['subpages']['nonredirects'];
+
+               // Latest editor + date of latest edit
+               $options = array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 );
+               $row = $dbr->fetchRow( $dbr->select(
+                       'revision',
+                       array( 'rev_user_text', 'rev_timestamp' ),
+                       array( 'rev_page' => $id ),
+                       __METHOD__,
+                       $options
+               ) );
+
+               $result['firstuser'] = $row['rev_user_text'];
+               $result['firsttime'] = $row['rev_timestamp'];
+
+               // Latest editor + date of latest edit
+               $options['ORDER BY'] = 'rev_timestamp DESC';
+               $row = $dbr->fetchRow( $dbr->select(
+                       'revision',
+                       array( 'rev_user_text', 'rev_timestamp' ),
+                       array( 'rev_page' => $id ),
+                       __METHOD__,
+                       $options
+               ) );
+
+               $result['lastuser'] = $row['rev_user_text'];
+               $result['lasttime'] = $row['rev_timestamp'];
 
                wfProfileOut( __METHOD__ );
                return $result;
        }
+
+       /**
+        * Adds a header to the content that will be added to the output.
+        *
+        * @param $content string The content that will be added to the output
+        * @param $header string The value of the header
+        * @return string The content with the header added
+        */
+       protected function addHeader( $content, $header ) {
+               return $content . Html::element( 'h2', array(), $header );
+       }
+
+       /**
+        * Adds a row to a table that will be added to the content.
+        *
+        * @param $table string The table that will be added to the content
+        * @param $name string The name of the row
+        * @param $value string The value of the row
+        * @return string The table with the row added
+        */
+       protected function addRow( $table, $name, $value ) {
+               return $table . Html::rawElement( 'tr', array(),
+                       Html::rawElement( 'td', array(), $name ) .
+                       Html::rawElement( 'td', array(), $value )
+               );
+       }
+
+       /**
+        * Adds a table to the content that will be added to the output.
+        *
+        * @param $content string The content that will be added to the output
+        * @param $table string The table
+        * @return string The content with the table added
+        */
+       protected function addTable( $content, $table ) {
+               return $content . Html::rawElement( 'table', array( 'class' => 'wikitable mw-page-info' ),
+                       $table );
+       }
+
+       /**
+        * Returns the description that goes below the <h1> tag.
+        *
+        * @return string
+        */
+       protected function getDescription() {
+               return '';
+       }
+
+       /**
+        * Returns the name that goes in the <h1> page title.
+        *
+        * @return string
+        */
+       protected function getPageTitle() {
+               return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
+       }
 }
index 25a3e27..23cd9aa 100644 (file)
@@ -103,7 +103,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                                $form = $this->getRawForm();
                                if( $form->show() ){
                                        $out->addHTML( $this->successMessage );
-                                       $out->returnToMain();
+                                       $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
                                }
                                break;
 
@@ -113,7 +113,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                                $form = $this->getNormalForm();
                                if( $form->show() ){
                                        $out->addHTML( $this->successMessage );
-                                       $out->returnToMain();
+                                       $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
                                } elseif ( $this->toc !== false ) {
                                        $out->prependHTML( $this->toc );
                                }
index 3d6033e..4d875e6 100644 (file)
@@ -33,6 +33,15 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                parent::__construct( 'Emailuser' );
        }
 
+       public function getDescription() {
+               $target = self::getTarget( $this->mTarget );
+               if( !$target instanceof User ) {
+                       return $this->msg( 'emailuser-title-notarget' )->text();
+               }
+
+               return $this->msg( 'emailuser-title-target', $target->getName() )->text();
+       }
+
        protected function getFormFields() {
                return array(
                        'From' => array(
@@ -84,13 +93,18 @@ class SpecialEmailUser extends UnlistedSpecialPage {
        }
 
        public function execute( $par ) {
-               $this->setHeaders();
-               $this->outputHeader();
                $out = $this->getOutput();
                $out->addModuleStyles( 'mediawiki.special' );
+
                $this->mTarget = is_null( $par )
                        ? $this->getRequest()->getVal( 'wpTarget', $this->getRequest()->getVal( 'target', '' ) )
                        : $par;
+
+               // This needs to be below assignment of $this->mTarget because
+               // getDescription() needs it to determine the correct page title.
+               $this->setHeaders();
+               $this->outputHeader();
+
                // error out if sending user cannot do this
                $error = self::getPermissionsError( $this->getUser(), $this->getRequest()->getVal( 'wpEditToken' ) );
                switch ( $error ) {
@@ -136,7 +150,6 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        return false;
                }
 
-               $out->setPageTitle( $this->msg( 'emailpage' ) );
                $result = $form->show();
 
                if( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
index b69354c..c6b2bb6 100644 (file)
@@ -39,8 +39,7 @@ class SpecialPreferences extends SpecialPage {
 
                $user = $this->getUser();
                if ( $user->isAnon() ) {
-                       $out->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
-                       return;
+                       throw new ErrorPageError( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
                }
                $this->checkReadOnly();
 
index c11d719..fdd2b1a 100644 (file)
@@ -70,13 +70,14 @@ class UploadFromUrl extends UploadBase {
                if ( !count( $wgCopyUploadsDomains ) ) {
                        return true;
                }
-               $parsedUrl = wfParseUrl( $url );
-               if ( !$parsedUrl ) {
+               $uri = new Uri( $url );
+               $parsedDomain = $uri->getHost();
+               if ( $parsedDomain === null ) {
                        return false;
                }
                $valid = false;
                foreach( $wgCopyUploadsDomains as $domain ) {
-                       if ( $parsedUrl['host'] === $domain ) {
+                       if ( $parsedDomain === $domain ) {
                                $valid = true;
                                break;
                        }
index 41312c5..0b57602 100644 (file)
@@ -2794,6 +2794,8 @@ There may be [[{{MediaWiki:Listgrouprights-helppage}}|additional information]] a
 'mailnologin'          => 'No send address',
 'mailnologintext'      => 'You must be [[Special:UserLogin|logged in]] and have a valid e-mail address in your [[Special:Preferences|preferences]] to send e-mail to other users.',
 'emailuser'            => 'E-mail this user',
+'emailuser-title-target' => 'E-mail this {{GENDER:$1|user}}',
+'emailuser-title-notarget' => 'E-mail user',
 'emailuser-summary'    => '', # do not translate or duplicate this message to other languages
 'emailpage'            => 'E-mail user',
 'emailpagetext'        => 'You can use the form below to send an e-mail message to this user.
@@ -3730,17 +3732,34 @@ This is probably caused by a link to a blacklisted external site.',
 'spam_deleting'       => 'All revisions contained links to $1, deleting',
 
 # Info page
-'pageinfo-title'            => 'Information for "$1"',
-'pageinfo-header-edits'     => 'Edits',
-'pageinfo-header-watchlist' => 'Watchlist',
-'pageinfo-header-views'     => 'Views',
-'pageinfo-subjectpage'      => 'Page',
-'pageinfo-talkpage'         => 'Talk page',
-'pageinfo-watchers'         => 'Number of watchers',
-'pageinfo-edits'            => 'Number of edits',
-'pageinfo-authors'          => 'Number of distinct authors',
-'pageinfo-views'            => 'Number of views',
-'pageinfo-viewsperedit'     => 'Views per edit',
+'pageinfo-title'               => 'Information for "$1"',
+'pageinfo-header-basic'        => 'Basic information',
+'pageinfo-header-edits'        => 'Edit history',
+'pageinfo-header-restrictions' => 'Page protection',
+'pageinfo-header-properties'   => 'Page properties',
+'pageinfo-display-title'       => 'Display title',
+'pageinfo-default-sort'        => 'Default sort key',
+'pageinfo-length'              => 'Page length (in bytes)',
+'pageinfo-article-id'          => 'Page ID',
+'pageinfo-robot-policy'        => 'Search engine status',
+'pageinfo-views'               => 'Number of views',
+'pageinfo-watchers'            => 'Number of page watchers',
+'pageinfo-redirects-name'      => 'Redirects to this page',
+'pageinfo-redirects-value'     => '$1',
+'pageinfo-subpages-name'       => 'Subpages of this page',
+'pageinfo-subpages-value'      => '$1 ($2 {{PLURAL:$2|redirect|redirects}}; $3 {{PLURAL:$3|non-redirect|non-redirects}})',
+'pageinfo-firstuser'           => 'Page creator',
+'pageinfo-firsttime'           => 'Date of page creation',
+'pageinfo-lastuser'            => 'Latest editor',
+'pageinfo-lasttime'            => 'Date of latest edit',
+'pageinfo-edits'               => 'Total number of edits',
+'pageinfo-authors'             => 'Total number of distinct authors',
+'pageinfo-recent-edits'        => 'Recent number of edits (within past $1)',
+'pageinfo-recent-authors'      => 'Recent number of distinct authors',
+'pageinfo-restriction'         => 'Page protection ($1)',
+'pageinfo-magic-words'         => 'Magic words ($1)',
+'pageinfo-hidden-categories'   => 'Hidden categories ($1)',
+'pageinfo-templates'           => 'Transcluded {{PLURAL:$1|template|templates}} ($1)',
 
 # Skin names
 'skinname-standard'    => 'Classic', # only translate this message to other languages if you have to change it
index 3a03e53..1e15897 100644 (file)
@@ -2593,12 +2593,16 @@ See also {{msg-mw|listgrouprights-addgroup-all}}.',
 * $2 is the number of group names in $1.',
 
 # E-mail user
-'emailuser' => 'Link in the sidebar and title of [[Special:EmailUser|special page]]',
+'emailuser' => 'Link in the sidebar to send an e-mail to a user.',
+'emailuser-title-target' => 'Title of [[Special:EmailUser|special page]] when a user was given to e-mail. Parameters:
+* $1 is a plain text username, used for GENDER.',
+'emailuser-title-notarget' => 'Title of [[Special:EmailUser|special page]] when no user given to e-mail yet',
 'emailpage' => "Title of special page [[Special:EmailUser]], when it is the destination of the sidebar link {{msg-mw|Emailuser}} on a user's page.",
 'emailpagetext' => 'This is the text that is displayed above the e-mail form on [[Special:EmailUser]].
 
 Special:EmailUser appears when you click on the link "E-mail this user" in the sidebar, but only if there is an e-mail address in the recipient\'s user preferences. If there isn\'t then the message [[Mediawiki:Noemailtext]] will appear instead of Special:EmailUser.',
-'defemailsubject' => 'The default subject of EmailUser emails.  The first parameter is the username of the user sending the email.',
+'defemailsubject' => 'The default subject of EmailUser emails. Parameters:
+* $1 is the username of the user sending the email and can be used for GENDER.',
 'usermaildisabled' => 'Caption for an error message ({{msg-mw|Usermaildisabledtext}}) shown when the user-to-user e-mail feature is disabled on the wiki (see [[mw:Manual:$wgEnableEmail]], [[mw:Manual:$wgEnableUserEmail]]).',
 'noemailtitle' => 'The title of the message that appears instead of Special:EmailUser after clicking the "E-mail this user" link in the sidebar, if no e-mail can be sent to the user.',
 'noemailtext' => 'The text of the message that appears in [[Special:EmailUser]] after clicking the "E-mail this user" link in the sidebar, if no e-mail can be sent to the user because he has not specified or not confirmed an e-mail address.',
@@ -3447,17 +3451,43 @@ See also {{msg-mw|Anonuser}} and {{msg-mw|Siteusers}}.',
 * $1 is a spammed domain name.',
 
 # Info page
-'pageinfo-title' => 'Page title for action=info.
-
+'pageinfo-title' => 'Page title for action=info. Parameters:
 * $1 is the page name',
-'pageinfo-header-edits' => 'Table section header in action=info.
-{{Identical|Edit}}',
-'pageinfo-header-watchlist' => 'Table section header in action=info.',
-'pageinfo-header-views' => 'Table section header in action=info.
-{{Identical|View}}',
-'pageinfo-subjectpage' => 'Table header in action=info.
-{{Identical|Page}}',
-'pageinfo-talkpage' => 'Table header in action=info.',
+'pageinfo-header-basic' => 'Table section header in action=info.',
+'pageinfo-header-edits' => 'Table section header in action=info.',
+'pageinfo-header-restrictions' => 'Table section header in action=info.',
+'pageinfo-header-properties' => 'Table section header in action=info.',
+'pageinfo-display-title' => 'The title that is displayed when the page is viewed.',
+'pageinfo-default-sort' => 'The key by which the page is sorted in categories by default.',
+'pageinfo-length' => 'The length of the page, in bytes.',
+'pageinfo-article-id' => 'The numeric identifier of the page.',
+'pageinfo-robot-policy' => 'The search engine status of the page.',
+'pageinfo-views' => 'The number of times the page has been viewed.',
+'pageinfo-watchers' => 'The number of users watching the page.',
+'pageinfo-redirects-name' => 'The number of redirects to the page.',
+'pageinfo-redirects-value' => 'Parameters:
+* $1 is the number of redirects to the page.',
+'pageinfo-subpages-name' => 'The number of subpages of the page.',
+'pageinfo-subpages-value' => 'Parameters:
+* $1 is the number of subpages of the page.
+* $2 is the number of subpages of the page that are redirects.
+* $3 is the number of subpages of the page that are not redirects.',
+'pageinfo-firstuser' => 'The user who created the page.',
+'pageinfo-firsttime' => 'The date and time the page was created.',
+'pageinfo-lastuser' => 'The last user who edited the page.',
+'pageinfo-lasttime' => 'The date and time the page was last edited.',
+'pageinfo-edits' => 'The total number of times the page has been edited.',
+'pageinfo-authors' => 'The total number of users who have edited the page.',
+'pageinfo-recent-edits' => 'The number of times the page has been edited recently.',
+'pageinfo-recent-authors' => 'The number of users who have edited the page recently.',
+'pageinfo-restriction' => 'Parameters:
+* $1 is the type of page protection.',
+'pageinfo-magic-words' => 'The list of magic words on the page. Parameters:
+* $1 is the number of magic words on the page.',
+'pageinfo-hidden-categories' => 'The list of hidden categories on the page. Parameters:
+* $1 is the number of hidden categories on the page.',
+'pageinfo-templates' => 'The list of templates transcluded within the page. Parameters:
+* $1 is the number of templates transcluded within the page.',
 
 # Skin names
 'skinname-standard' => '{{optional}}
index 65ac65a..b4a1bac 100644 (file)
@@ -56,9 +56,12 @@ class ImportSiteScripts extends Maintenance {
                        }
 
                        $this->output( "Importing $page\n" );
-                       $url = wfAppendQuery( $baseUrl, array(
+                       $uri = new Uri( $baseUrl );
+                       $uri->extendQuery( array(
                                'action' => 'raw',
                                'title' => "MediaWiki:{$page}" ) );
+                       $url = $uri->toString();
+
                        $text = Http::get( $url );
 
                        $wikiPage = WikiPage::factory( $title );
@@ -79,7 +82,9 @@ class ImportSiteScripts extends Maintenance {
                $pages = array();
 
                do {
-                       $url = wfAppendQuery( $baseUrl, $data );
+                       $uri = new Uri( $baseUrl );
+                       $uri->extendQuery( $data );
+                       $url = $uri->toString();
                        $strResult = Http::get( $url );
                        //$result = FormatJson::decode( $strResult ); // Still broken
                        $result = unserialize( $strResult );
index bed7e5a..79c6ec7 100644 (file)
@@ -1861,6 +1861,8 @@ $wgMessageStructure = array(
                'mailnologin',
                'mailnologintext',
                'emailuser',
+               'emailuser-title-target',
+               'emailuser-title-notarget',
                'emailuser-summary',
                'emailpage',
                'emailpagetext',
@@ -2661,16 +2663,33 @@ $wgMessageStructure = array(
        ),
        'info' => array(
                'pageinfo-title',
+               'pageinfo-header-basic',
                'pageinfo-header-edits',
-               'pageinfo-header-watchlist',
-               'pageinfo-header-views',
-               'pageinfo-subjectpage',
-               'pageinfo-talkpage',
+               'pageinfo-header-restrictions',
+               'pageinfo-header-properties',
+               'pageinfo-display-title',
+               'pageinfo-default-sort',
+               'pageinfo-length',
+               'pageinfo-article-id',
+               'pageinfo-robot-policy',
+               'pageinfo-views',
                'pageinfo-watchers',
+               'pageinfo-redirects-name',
+               'pageinfo-redirects-value',
+               'pageinfo-subpages-name',
+               'pageinfo-subpages-value',
+               'pageinfo-firstuser',
+               'pageinfo-firsttime',
+               'pageinfo-lastuser',
+               'pageinfo-lasttime',
                'pageinfo-edits',
                'pageinfo-authors',
-               'pageinfo-views',
-               'pageinfo-viewsperedit',
+               'pageinfo-recent-edits',
+               'pageinfo-recent-authors',
+               'pageinfo-restriction',
+               'pageinfo-magic-words',
+               'pageinfo-hidden-categories',
+               'pageinfo-templates',
        ),
        'skin' => array(
                'skinname-standard',
index 1ac8dcb..9d75be4 100644 (file)
@@ -57,10 +57,11 @@ class MakeLanguageSpec extends Maintenance {
                        foreach ( self::$keyToTestArgs as $key => $testArgs ) {
                                foreach ($testArgs as $args) {
                                        // get the raw template, without any transformations
-                                       $template = wfMsgGetKey( $key, /* useDb */ true, $languageCode, /* transform */ false );
+                                       $template = wfMessage( $key )->inLanguage( $languageCode )->plain();
 
                                        // get the magic-parsed version with args
                                        $wfMsgExtArgs = array_merge( array( $key, $wfMsgExtOptions ), $args );
+                                       // @todo FIXME: Use Message class.
                                        $result = call_user_func_array( 'wfMsgExt', $wfMsgExtArgs ); 
 
                                        // record the template, args, language, and expected result
index 02571b5..17cee6e 100644 (file)
@@ -17,14 +17,14 @@ class ArticleTablesTest extends MediaWikiLangTestCase {
 
                $wgLang = Language::factory( 'fr' );
                $status = $page->doEdit( '{{:{{int:history}}}}', 'Test code for bug 14404', 0, false, $user );
-               $templates1 = $page->getUsedTemplates();
+               $templates1 = $title->getTemplateLinksFrom();
 
                $wgLang = Language::factory( 'de' );
                $page->mPreparedEdit = false; // In order to force the rerendering of the same wikitext
 
                // We need an edit, a purge is not enough to regenerate the tables
                $status = $page->doEdit( '{{:{{int:history}}}}', 'Test code for bug 14404', EDIT_UPDATE, false, $user );
-               $templates2 = $page->getUsedTemplates();
+               $templates2 = $title->getTemplateLinksFrom();
 
                $this->assertEquals( $templates1, $templates2 );
                $this->assertEquals( $templates1[0]->getFullText(), 'Historial' );
index 58a8194..5fc4446 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -71,10 +71,9 @@ function wfThumbHandle404() {
        }
        # Just get the URI path (REDIRECT_URL/REQUEST_URI is either a full URL or a path)
        if ( substr( $uriPath, 0, 1 ) !== '/' ) {
-               $bits = wfParseUrl( $uriPath );
-               if ( $bits && isset( $bits['path'] ) ) {
-                       $uriPath = $bits['path'];
-               } else {
+               $uri = new Uri( $uriPath );
+               $uriPath = $uri->getPath();
+               if ( $uriPath === null ) {
                        wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' );
                        return;
                }