Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index 4d80a1c..6cafaa5 100644 (file)
@@ -230,11 +230,11 @@ class InfoAction extends FormlessAction {
                if ( $title->isRedirect() ) {
                        $pageInfo['header-basic'][] = [
                                $this->msg( 'pageinfo-redirectsto' ),
-                               Linker::link( $this->page->getRedirectTarget() ) .
+                               $linkRenderer->makeLink( $this->page->getRedirectTarget() ) .
                                $this->msg( 'word-separator' )->escaped() .
-                               $this->msg( 'parentheses' )->rawParams( Linker::link(
+                               $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
                                        $this->page->getRedirectTarget(),
-                                       $this->msg( 'pageinfo-redirectsto-info' )->escaped(),
+                                       $this->msg( 'pageinfo-redirectsto-info' )->text(),
                                        [],
                                        [ 'action' => 'info' ]
                                ) )->escaped()
@@ -262,13 +262,13 @@ class InfoAction extends FormlessAction {
                $pageLang = $title->getPageLanguage()->getCode();
 
                if ( $config->get( 'PageLanguageUseDB' )
-                       && $this->getTitle()->userCan( 'pagelang', $this->getUser() )
+                       && $title->userCan( 'pagelang', $user )
                ) {
                        // Link to Special:PageLanguage with pre-filled page title if user has permissions
                        $titleObj = SpecialPage::getTitleFor( 'PageLanguage', $title->getPrefixedText() );
-                       $langDisp = Linker::link(
+                       $langDisp = $linkRenderer->makeLink(
                                $titleObj,
-                               $this->msg( 'pageinfo-language' )->escaped()
+                               $this->msg( 'pageinfo-language' )->text()
                        );
                } else {
                        // Display just the message
@@ -282,7 +282,9 @@ class InfoAction extends FormlessAction {
                // Content model of the page
                $modelHtml = htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) );
                // If the user can change it, add a link to Special:ChangeContentModel
-               if ( $title->quickUserCan( 'editcontentmodel' ) ) {
+               if ( $config->get( 'ContentHandlerUseDB' )
+                       && $title->userCan( 'editcontentmodel', $user )
+               ) {
                        $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
                                SpecialPage::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
                                $this->msg( 'pageinfo-content-model-change' )->text()
@@ -294,6 +296,16 @@ class InfoAction extends FormlessAction {
                        $modelHtml
                ];
 
+               if ( $title->inNamespace( NS_USER ) ) {
+                       $pageUser = User::newFromName( $title->getRootText() );
+                       if ( $pageUser && $pageUser->getId() && !$pageUser->isHidden() ) {
+                               $pageInfo['header-basic'][] = [
+                                       $this->msg( 'pageinfo-user-id' ),
+                                       $pageUser->getId()
+                               ];
+                       }
+               }
+
                // Search engine status
                $pOutput = new ParserOutput();
                if ( isset( $pageProperties['noindex'] ) ) {
@@ -350,9 +362,9 @@ class InfoAction extends FormlessAction {
                // Redirects to this page
                $whatLinksHere = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
                $pageInfo['header-basic'][] = [
-                       Linker::link(
+                       $linkRenderer->makeLink(
                                $whatLinksHere,
-                               $this->msg( 'pageinfo-redirects-name' )->escaped(),
+                               $this->msg( 'pageinfo-redirects-name' )->text(),
                                [],
                                [
                                        'hidelinks' => 1,
@@ -426,7 +438,7 @@ class InfoAction extends FormlessAction {
 
                        foreach ( $sources as $sourceTitle ) {
                                $cascadingFrom .= Html::rawElement(
-                                       'li', [], Linker::linkKnown( $sourceTitle ) );
+                                       'li', [], $linkRenderer->makeKnownLink( $sourceTitle ) );
                        }
 
                        $cascadingFrom = Html::rawElement( 'ul', [], $cascadingFrom );
@@ -464,7 +476,7 @@ class InfoAction extends FormlessAction {
                        }
                        $expiry = $title->getRestrictionExpiry( $restrictionType );
                        $formattedexpiry = $this->msg( 'parentheses',
-                               $this->getLanguage()->formatExpiry( $expiry ) )->escaped();
+                               $lang->formatExpiry( $expiry ) )->escaped();
                        $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
 
                        // Messages: restriction-edit, restriction-move, restriction-create,
@@ -515,9 +527,9 @@ class InfoAction extends FormlessAction {
                        // Date of page creation
                        $pageInfo['header-edits'][] = [
                                $this->msg( 'pageinfo-firsttime' ),
-                               Linker::linkKnown(
+                               $linkRenderer->makeKnownLink(
                                        $title,
-                                       htmlspecialchars( $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ) ),
+                                       $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
                                        [],
                                        [ 'oldid' => $firstRev->getId() ]
                                )
@@ -534,11 +546,9 @@ class InfoAction extends FormlessAction {
                        // Date of latest edit
                        $pageInfo['header-edits'][] = [
                                $this->msg( 'pageinfo-lasttime' ),
-                               Linker::linkKnown(
+                               $linkRenderer->makeKnownLink(
                                        $title,
-                                       htmlspecialchars(
-                                               $lang->userTimeAndDate( $this->page->getTimestamp(), $user )
-                                       ),
+                                       $lang->userTimeAndDate( $this->page->getTimestamp(), $user ),
                                        [],
                                        [ 'oldid' => $this->page->getLatest() ]
                                )
@@ -645,9 +655,9 @@ class InfoAction extends FormlessAction {
 
                        if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
                                if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
-                                       $more = Linker::link(
+                                       $more = $linkRenderer->makeLink(
                                                $whatLinksHere,
-                                               $this->msg( 'moredotdotdot' )->escaped(),
+                                               $this->msg( 'moredotdotdot' )->text(),
                                                [],
                                                [ 'hidelinks' => 1, 'hideredirs' => 1 ]
                                        );
@@ -690,7 +700,6 @@ class InfoAction extends FormlessAction {
 
                                $dbr = wfGetDB( DB_REPLICA );
                                $dbrWatchlist = wfGetDB( DB_REPLICA, 'watchlist' );
-
                                $setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
 
                                $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
@@ -827,6 +836,7 @@ class InfoAction extends FormlessAction {
                $real_names = [];
                $user_names = [];
                $anon_ips = [];
+               $linkRenderer = MediaWikiServices::getLinkRenderer();
 
                # Sift for real versus user names
                /** @var $user User */
@@ -837,11 +847,11 @@ class InfoAction extends FormlessAction {
 
                        $hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' );
                        if ( $user->getId() == 0 ) {
-                               $anon_ips[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
+                               $anon_ips[] = $linkRenderer->makeLink( $page, $user->getName() );
                        } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
-                               $real_names[] = Linker::link( $page, htmlspecialchars( $user->getRealName() ) );
+                               $real_names[] = $linkRenderer->makeLink( $page, $user->getRealName() );
                        } else {
-                               $user_names[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
+                               $user_names[] = $linkRenderer->makeLink( $page, $user->getName() );
                        }
                }