3 * Displays information about a page.
5 * Copyright © 2011 Alexandre Emsenhuber
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 use MediaWiki\MediaWikiServices
;
28 * Displays information about a page.
32 class InfoAction
extends FormlessAction
{
36 * Returns the name of the action this object responds to.
38 * @return string Lowercase name
40 public function getName() {
45 * Whether this action can still be executed by a blocked user.
49 public function requiresUnblock() {
54 * Whether this action requires the wiki not to be locked.
58 public function requiresWrite() {
63 * Clear the info cache for a given Title.
66 * @param Title $title Title to clear cache for
67 * @param int|null $revid Revision id to clear
69 public static function invalidateCache( Title
$title, $revid = null ) {
71 $revision = Revision
::newFromTitle( $title, 0, Revision
::READ_LATEST
);
72 $revid = $revision ?
$revision->getId() : null;
74 if ( $revid !== null ) {
75 $key = self
::getCacheKey( $title, $revid );
76 ObjectCache
::getMainWANInstance()->delete( $key );
81 * Shows page information on GET request.
83 * @return string Page information that will be added to the output
85 public function onView() {
89 $oldid = $this->page
->getOldID();
91 $revision = $this->page
->getRevisionFetched();
93 // Revision is missing
94 if ( $revision === null ) {
95 return $this->msg( 'missing-revision', $oldid )->parse();
98 // Revision is not current
99 if ( !$revision->isCurrent() ) {
100 return $this->msg( 'pageinfo-not-current' )->plain();
105 if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
106 $content .= $this->msg( 'pageinfo-header' )->parse();
109 // Hide "This page is a member of # hidden categories" explanation
110 $content .= Html
::element( 'style', [],
111 '.mw-hiddenCategoriesExplanation { display: none; }' ) . "\n";
113 // Hide "Templates used on this page" explanation
114 $content .= Html
::element( 'style', [],
115 '.mw-templatesUsedExplanation { display: none; }' ) . "\n";
117 // Get page information
118 $pageInfo = $this->pageInfo();
120 // Allow extensions to add additional information
121 Hooks
::run( 'InfoAction', [ $this->getContext(), &$pageInfo ] );
123 // Render page information
124 foreach ( $pageInfo as $header => $infoTable ) {
126 // pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions,
127 // pageinfo-header-properties, pageinfo-category-info
128 $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
130 foreach ( $infoTable as $infoRow ) {
131 $name = ( $infoRow[0] instanceof Message
) ?
$infoRow[0]->escaped() : $infoRow[0];
132 $value = ( $infoRow[1] instanceof Message
) ?
$infoRow[1]->escaped() : $infoRow[1];
133 $id = ( $infoRow[0] instanceof Message
) ?
$infoRow[0]->getKey() : null;
134 $table = $this->addRow( $table, $name, $value, $id ) . "\n";
136 $content = $this->addTable( $content, $table ) . "\n";
140 if ( !$this->msg( 'pageinfo-footer' )->isDisabled() ) {
141 $content .= $this->msg( 'pageinfo-footer' )->parse();
148 * Creates a header that can be added to the output.
150 * @param string $header The header text.
151 * @return string The HTML.
153 protected function makeHeader( $header ) {
154 $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer
::escapeId( $header ) ];
156 return Html
::rawElement( 'h2', [], Html
::element( 'span', $spanAttribs, $header ) );
160 * Adds a row to a table that will be added to the content.
162 * @param string $table The table that will be added to the content
163 * @param string $name The name of the row
164 * @param string $value The value of the row
165 * @param string $id The ID to use for the 'tr' element
166 * @return string The table with the row added
168 protected function addRow( $table, $name, $value, $id ) {
172 $id === null ?
[] : [ 'id' => 'mw-' . $id ],
173 Html
::rawElement( 'td', [ 'style' => 'vertical-align: top;' ], $name ) .
174 Html
::rawElement( 'td', [], $value )
179 * Adds a table to the content that will be added to the output.
181 * @param string $content The content that will be added to the output
182 * @param string $table The table
183 * @return string The content with the table added
185 protected function addTable( $content, $table ) {
186 return $content . Html
::rawElement( 'table', [ 'class' => 'wikitable mw-page-info' ],
191 * Returns page information in an easily-manipulated format. Array keys are used so extensions
192 * may add additional information in arbitrary positions. Array values are arrays with one
193 * element to be rendered as a header, arrays with two elements to be rendered as a table row.
197 protected function pageInfo() {
200 $user = $this->getUser();
201 $lang = $this->getLanguage();
202 $title = $this->getTitle();
203 $id = $title->getArticleID();
204 $config = $this->context
->getConfig();
205 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
207 $pageCounts = $this->pageCounts( $this->page
);
209 $pageProperties = [];
210 $props = PageProps
::getInstance()->getAllProperties( $title );
211 if ( isset( $props[$id] ) ) {
212 $pageProperties = $props[$id];
217 $pageInfo['header-basic'] = [];
220 $displayTitle = $title->getPrefixedText();
221 if ( isset( $pageProperties['displaytitle'] ) ) {
222 $displayTitle = $pageProperties['displaytitle'];
225 $pageInfo['header-basic'][] = [
226 $this->msg( 'pageinfo-display-title' ), $displayTitle
229 // Is it a redirect? If so, where to?
230 if ( $title->isRedirect() ) {
231 $pageInfo['header-basic'][] = [
232 $this->msg( 'pageinfo-redirectsto' ),
233 $linkRenderer->makeLink( $this->page
->getRedirectTarget() ) .
234 $this->msg( 'word-separator' )->escaped() .
235 $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
236 $this->page
->getRedirectTarget(),
237 $this->msg( 'pageinfo-redirectsto-info' )->text(),
239 [ 'action' => 'info' ]
245 $sortKey = $title->getCategorySortkey();
246 if ( isset( $pageProperties['defaultsort'] ) ) {
247 $sortKey = $pageProperties['defaultsort'];
250 $sortKey = htmlspecialchars( $sortKey );
251 $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-default-sort' ), $sortKey ];
253 // Page length (in bytes)
254 $pageInfo['header-basic'][] = [
255 $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
258 // Page ID (number not localised, as it's a database ID)
259 $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-article-id' ), $id ];
261 // Language in which the page content is (supposed to be) written
262 $pageLang = $title->getPageLanguage()->getCode();
264 if ( $config->get( 'PageLanguageUseDB' )
265 && $this->getTitle()->userCan( 'pagelang', $this->getUser() )
267 // Link to Special:PageLanguage with pre-filled page title if user has permissions
268 $titleObj = SpecialPage
::getTitleFor( 'PageLanguage', $title->getPrefixedText() );
269 $langDisp = $linkRenderer->makeLink(
271 $this->msg( 'pageinfo-language' )->text()
274 // Display just the message
275 $langDisp = $this->msg( 'pageinfo-language' )->escaped();
278 $pageInfo['header-basic'][] = [ $langDisp,
279 Language
::fetchLanguageName( $pageLang, $lang->getCode() )
280 . ' ' . $this->msg( 'parentheses', $pageLang )->escaped() ];
282 // Content model of the page
283 $modelHtml = htmlspecialchars( ContentHandler
::getLocalizedName( $title->getContentModel() ) );
284 // If the user can change it, add a link to Special:ChangeContentModel
285 if ( $title->quickUserCan( 'editcontentmodel' ) ) {
286 $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
287 SpecialPage
::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
288 $this->msg( 'pageinfo-content-model-change' )->text()
292 $pageInfo['header-basic'][] = [
293 $this->msg( 'pageinfo-content-model' ),
297 if ( $title->inNamespace( NS_USER
) ) {
298 $pageUser = User
::newFromName( $title->getRootText() );
299 if ( $pageUser && $pageUser->getId() && !$pageUser->isHidden() ) {
300 $pageInfo['header-basic'][] = [
301 $this->msg( 'pageinfo-user-id' ),
307 // Search engine status
308 $pOutput = new ParserOutput();
309 if ( isset( $pageProperties['noindex'] ) ) {
310 $pOutput->setIndexPolicy( 'noindex' );
312 if ( isset( $pageProperties['index'] ) ) {
313 $pOutput->setIndexPolicy( 'index' );
316 // Use robot policy logic
317 $policy = $this->page
->getRobotPolicy( 'view', $pOutput );
318 $pageInfo['header-basic'][] = [
319 // Messages: pageinfo-robot-index, pageinfo-robot-noindex
320 $this->msg( 'pageinfo-robot-policy' ),
321 $this->msg( "pageinfo-robot-${policy['index']}" )
324 $unwatchedPageThreshold = $config->get( 'UnwatchedPageThreshold' );
326 $user->isAllowed( 'unwatchedpages' ) ||
327 ( $unwatchedPageThreshold !== false &&
328 $pageCounts['watchers'] >= $unwatchedPageThreshold )
330 // Number of page watchers
331 $pageInfo['header-basic'][] = [
332 $this->msg( 'pageinfo-watchers' ),
333 $lang->formatNum( $pageCounts['watchers'] )
336 $config->get( 'ShowUpdatedMarker' ) &&
337 isset( $pageCounts['visitingWatchers'] )
339 $minToDisclose = $config->get( 'UnwatchedPageSecret' );
340 if ( $pageCounts['visitingWatchers'] > $minToDisclose ||
341 $user->isAllowed( 'unwatchedpages' ) ) {
342 $pageInfo['header-basic'][] = [
343 $this->msg( 'pageinfo-visiting-watchers' ),
344 $lang->formatNum( $pageCounts['visitingWatchers'] )
347 $pageInfo['header-basic'][] = [
348 $this->msg( 'pageinfo-visiting-watchers' ),
349 $this->msg( 'pageinfo-few-visiting-watchers' )
353 } elseif ( $unwatchedPageThreshold !== false ) {
354 $pageInfo['header-basic'][] = [
355 $this->msg( 'pageinfo-watchers' ),
356 $this->msg( 'pageinfo-few-watchers' )->numParams( $unwatchedPageThreshold )
360 // Redirects to this page
361 $whatLinksHere = SpecialPage
::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
362 $pageInfo['header-basic'][] = [
363 $linkRenderer->makeLink(
365 $this->msg( 'pageinfo-redirects-name' )->text(),
370 'hideimages' => $title->getNamespace() == NS_FILE
373 $this->msg( 'pageinfo-redirects-value' )
374 ->numParams( count( $title->getRedirectsHere() ) )
377 // Is it counted as a content page?
378 if ( $this->page
->isCountable() ) {
379 $pageInfo['header-basic'][] = [
380 $this->msg( 'pageinfo-contentpage' ),
381 $this->msg( 'pageinfo-contentpage-yes' )
385 // Subpages of this page, if subpages are enabled for the current NS
386 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
387 $prefixIndex = SpecialPage
::getTitleFor(
388 'Prefixindex', $title->getPrefixedText() . '/' );
389 $pageInfo['header-basic'][] = [
390 Linker
::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
391 $this->msg( 'pageinfo-subpages-value' )
393 $pageCounts['subpages']['total'],
394 $pageCounts['subpages']['redirects'],
395 $pageCounts['subpages']['nonredirects'] )
399 if ( $title->inNamespace( NS_CATEGORY
) ) {
400 $category = Category
::newFromTitle( $title );
402 // $allCount is the total number of cat members,
403 // not the count of how many members are normal pages.
404 $allCount = (int)$category->getPageCount();
405 $subcatCount = (int)$category->getSubcatCount();
406 $fileCount = (int)$category->getFileCount();
407 $pagesCount = $allCount - $subcatCount - $fileCount;
409 $pageInfo['category-info'] = [
411 $this->msg( 'pageinfo-category-total' ),
412 $lang->formatNum( $allCount )
415 $this->msg( 'pageinfo-category-pages' ),
416 $lang->formatNum( $pagesCount )
419 $this->msg( 'pageinfo-category-subcats' ),
420 $lang->formatNum( $subcatCount )
423 $this->msg( 'pageinfo-category-files' ),
424 $lang->formatNum( $fileCount )
430 $pageInfo['header-restrictions'] = [];
432 // Is this page affected by the cascading protection of something which includes it?
433 if ( $title->isCascadeProtected() ) {
435 $sources = $title->getCascadeProtectionSources()[0];
437 foreach ( $sources as $sourceTitle ) {
438 $cascadingFrom .= Html
::rawElement(
439 'li', [], $linkRenderer->makeKnownLink( $sourceTitle ) );
442 $cascadingFrom = Html
::rawElement( 'ul', [], $cascadingFrom );
443 $pageInfo['header-restrictions'][] = [
444 $this->msg( 'pageinfo-protect-cascading-from' ),
449 // Is out protection set to cascade to other pages?
450 if ( $title->areRestrictionsCascading() ) {
451 $pageInfo['header-restrictions'][] = [
452 $this->msg( 'pageinfo-protect-cascading' ),
453 $this->msg( 'pageinfo-protect-cascading-yes' )
458 foreach ( $title->getRestrictionTypes() as $restrictionType ) {
459 $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
461 if ( $protectionLevel == '' ) {
463 $message = $this->msg( 'protect-default' )->escaped();
465 // Administrators only
466 // Messages: protect-level-autoconfirmed, protect-level-sysop
467 $message = $this->msg( "protect-level-$protectionLevel" );
468 if ( $message->isDisabled() ) {
469 // Require "$1" permission
470 $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
472 $message = $message->escaped();
475 $expiry = $title->getRestrictionExpiry( $restrictionType );
476 $formattedexpiry = $this->msg( 'parentheses',
477 $this->getLanguage()->formatExpiry( $expiry ) )->escaped();
478 $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
480 // Messages: restriction-edit, restriction-move, restriction-create,
481 // restriction-upload
482 $pageInfo['header-restrictions'][] = [
483 $this->msg( "restriction-$restrictionType" ), $message
487 if ( !$this->page
->exists() ) {
492 $pageInfo['header-edits'] = [];
494 $firstRev = $this->page
->getOldestRevision();
495 $lastRev = $this->page
->getRevision();
496 $batch = new LinkBatch
;
499 $firstRevUser = $firstRev->getUserText( Revision
::FOR_THIS_USER
);
500 if ( $firstRevUser !== '' ) {
501 $firstRevUserTitle = Title
::makeTitle( NS_USER
, $firstRevUser );
502 $batch->addObj( $firstRevUserTitle );
503 $batch->addObj( $firstRevUserTitle->getTalkPage() );
508 $lastRevUser = $lastRev->getUserText( Revision
::FOR_THIS_USER
);
509 if ( $lastRevUser !== '' ) {
510 $lastRevUserTitle = Title
::makeTitle( NS_USER
, $lastRevUser );
511 $batch->addObj( $lastRevUserTitle );
512 $batch->addObj( $lastRevUserTitle->getTalkPage() );
520 $pageInfo['header-edits'][] = [
521 $this->msg( 'pageinfo-firstuser' ),
522 Linker
::revUserTools( $firstRev )
525 // Date of page creation
526 $pageInfo['header-edits'][] = [
527 $this->msg( 'pageinfo-firsttime' ),
528 $linkRenderer->makeKnownLink(
530 $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
532 [ 'oldid' => $firstRev->getId() ]
539 $pageInfo['header-edits'][] = [
540 $this->msg( 'pageinfo-lastuser' ),
541 Linker
::revUserTools( $lastRev )
544 // Date of latest edit
545 $pageInfo['header-edits'][] = [
546 $this->msg( 'pageinfo-lasttime' ),
547 $linkRenderer->makeKnownLink(
549 $lang->userTimeAndDate( $this->page
->getTimestamp(), $user ),
551 [ 'oldid' => $this->page
->getLatest() ]
556 // Total number of edits
557 $pageInfo['header-edits'][] = [
558 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
561 // Total number of distinct authors
562 if ( $pageCounts['authors'] > 0 ) {
563 $pageInfo['header-edits'][] = [
564 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
568 // Recent number of edits (within past 30 days)
569 $pageInfo['header-edits'][] = [
570 $this->msg( 'pageinfo-recent-edits',
571 $lang->formatDuration( $config->get( 'RCMaxAge' ) ) ),
572 $lang->formatNum( $pageCounts['recent_edits'] )
575 // Recent number of distinct authors
576 $pageInfo['header-edits'][] = [
577 $this->msg( 'pageinfo-recent-authors' ),
578 $lang->formatNum( $pageCounts['recent_authors'] )
581 // Array of MagicWord objects
582 $magicWords = MagicWord
::getDoubleUnderscoreArray();
584 // Array of magic word IDs
585 $wordIDs = $magicWords->names
;
587 // Array of IDs => localized magic words
588 $localizedWords = $wgContLang->getMagicWords();
591 foreach ( $pageProperties as $property => $value ) {
592 if ( in_array( $property, $wordIDs ) ) {
593 $listItems[] = Html
::element( 'li', [], $localizedWords[$property][1] );
597 $localizedList = Html
::rawElement( 'ul', [], implode( '', $listItems ) );
598 $hiddenCategories = $this->page
->getHiddenCategories();
601 count( $listItems ) > 0 ||
602 count( $hiddenCategories ) > 0 ||
603 $pageCounts['transclusion']['from'] > 0 ||
604 $pageCounts['transclusion']['to'] > 0
606 $options = [ 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) ];
607 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
608 if ( $config->get( 'MiserMode' ) ) {
609 $transcludedTargets = [];
611 $transcludedTargets = $title->getTemplateLinksTo( $options );
615 $pageInfo['header-properties'] = [];
618 if ( count( $listItems ) > 0 ) {
619 $pageInfo['header-properties'][] = [
620 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
626 if ( count( $hiddenCategories ) > 0 ) {
627 $pageInfo['header-properties'][] = [
628 $this->msg( 'pageinfo-hidden-categories' )
629 ->numParams( count( $hiddenCategories ) ),
630 Linker
::formatHiddenCategories( $hiddenCategories )
634 // Transcluded templates
635 if ( $pageCounts['transclusion']['from'] > 0 ) {
636 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
637 $more = $this->msg( 'morenotlisted' )->escaped();
642 $templateListFormatter = new TemplatesOnThisPageFormatter(
647 $pageInfo['header-properties'][] = [
648 $this->msg( 'pageinfo-templates' )
649 ->numParams( $pageCounts['transclusion']['from'] ),
650 $templateListFormatter->format( $transcludedTemplates, false, $more )
654 if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
655 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
656 $more = $linkRenderer->makeLink(
658 $this->msg( 'moredotdotdot' )->text(),
660 [ 'hidelinks' => 1, 'hideredirs' => 1 ]
666 $templateListFormatter = new TemplatesOnThisPageFormatter(
671 $pageInfo['header-properties'][] = [
672 $this->msg( 'pageinfo-transclusions' )
673 ->numParams( $pageCounts['transclusion']['to'] ),
674 $templateListFormatter->format( $transcludedTargets, false, $more )
683 * Returns page counts that would be too "expensive" to retrieve by normal means.
685 * @param WikiPage|Article|Page $page
688 protected function pageCounts( Page
$page ) {
690 $config = $this->context
->getConfig();
692 return ObjectCache
::getMainWANInstance()->getWithSetCallback(
693 self
::getCacheKey( $page->getTitle(), $page->getLatest() ),
694 WANObjectCache
::TTL_WEEK
,
695 function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
696 $title = $page->getTitle();
697 $id = $title->getArticleID();
699 $dbr = wfGetDB( DB_REPLICA
);
700 $dbrWatchlist = wfGetDB( DB_REPLICA
, 'watchlist' );
701 $setOpts +
= Database
::getCacheSetOptions( $dbr, $dbrWatchlist );
703 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
706 $result['watchers'] = $watchedItemStore->countWatchers( $title );
708 if ( $config->get( 'ShowUpdatedMarker' ) ) {
709 $updated = wfTimestamp( TS_UNIX
, $page->getTimestamp() );
710 $result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
712 $updated - $config->get( 'WatchersMaxAge' )
716 // Total number of edits
717 $edits = (int)$dbr->selectField(
720 [ 'rev_page' => $id ],
723 $result['edits'] = $edits;
725 // Total number of distinct authors
726 if ( $config->get( 'MiserMode' ) ) {
727 $result['authors'] = 0;
729 $result['authors'] = (int)$dbr->selectField(
731 'COUNT(DISTINCT rev_user_text)',
732 [ 'rev_page' => $id ],
737 // "Recent" threshold defined by RCMaxAge setting
738 $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
740 // Recent number of edits
741 $edits = (int)$dbr->selectField(
746 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
750 $result['recent_edits'] = $edits;
752 // Recent number of distinct authors
753 $result['recent_authors'] = (int)$dbr->selectField(
755 'COUNT(DISTINCT rev_user_text)',
758 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
763 // Subpages (if enabled)
764 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
765 $conds = [ 'page_namespace' => $title->getNamespace() ];
766 $conds[] = 'page_title ' .
767 $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
769 // Subpages of this page (redirects)
770 $conds['page_is_redirect'] = 1;
771 $result['subpages']['redirects'] = (int)$dbr->selectField(
778 // Subpages of this page (non-redirects)
779 $conds['page_is_redirect'] = 0;
780 $result['subpages']['nonredirects'] = (int)$dbr->selectField(
787 // Subpages of this page (total)
788 $result['subpages']['total'] = $result['subpages']['redirects']
789 +
$result['subpages']['nonredirects'];
792 // Counts for the number of transclusion links (to/from)
793 if ( $config->get( 'MiserMode' ) ) {
794 $result['transclusion']['to'] = 0;
796 $result['transclusion']['to'] = (int)$dbr->selectField(
800 'tl_namespace' => $title->getNamespace(),
801 'tl_title' => $title->getDBkey()
807 $result['transclusion']['from'] = (int)$dbr->selectField(
810 [ 'tl_from' => $title->getArticleID() ],
820 * Returns the name that goes in the "<h1>" page title.
824 protected function getPageTitle() {
825 return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
829 * Get a list of contributors of $article
830 * @return string Html
832 protected function getContributors() {
833 $contributors = $this->page
->getContributors();
837 $linkRenderer = MediaWikiServices
::getLinkRenderer();
839 # Sift for real versus user names
840 /** @var $user User */
841 foreach ( $contributors as $user ) {
842 $page = $user->isAnon()
843 ? SpecialPage
::getTitleFor( 'Contributions', $user->getName() )
844 : $user->getUserPage();
846 $hiddenPrefs = $this->context
->getConfig()->get( 'HiddenPrefs' );
847 if ( $user->getId() == 0 ) {
848 $anon_ips[] = $linkRenderer->makeLink( $page, $user->getName() );
849 } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
850 $real_names[] = $linkRenderer->makeLink( $page, $user->getRealName() );
852 $user_names[] = $linkRenderer->makeLink( $page, $user->getName() );
856 $lang = $this->getLanguage();
858 $real = $lang->listToText( $real_names );
860 # "ThisSite user(s) A, B and C"
861 if ( count( $user_names ) ) {
862 $user = $this->msg( 'siteusers' )
863 ->rawParams( $lang->listToText( $user_names ) )
864 ->params( count( $user_names ) )->escaped();
869 if ( count( $anon_ips ) ) {
870 $anon = $this->msg( 'anonusers' )
871 ->rawParams( $lang->listToText( $anon_ips ) )
872 ->params( count( $anon_ips ) )->escaped();
877 # This is the big list, all mooshed together. We sift for blank strings
879 foreach ( [ $real, $user, $anon ] as $s ) {
881 array_push( $fulllist, $s );
885 $count = count( $fulllist );
887 # "Based on work by ..."
889 ?
$this->msg( 'othercontribs' )->rawParams(
890 $lang->listToText( $fulllist ) )->params( $count )->escaped()
895 * Returns the description that goes below the "<h1>" tag.
899 protected function getDescription() {
904 * @param Title $title
908 protected static function getCacheKey( Title
$title, $revId ) {
909 return wfMemcKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self
::VERSION
);