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
;
26 use Wikimedia\Rdbms\Database
;
29 * Displays information about a page.
33 class InfoAction
extends FormlessAction
{
37 * Returns the name of the action this object responds to.
39 * @return string Lowercase name
41 public function getName() {
46 * Whether this action can still be executed by a blocked user.
50 public function requiresUnblock() {
55 * Whether this action requires the wiki not to be locked.
59 public function requiresWrite() {
64 * Clear the info cache for a given Title.
67 * @param Title $title Title to clear cache for
68 * @param int|null $revid Revision id to clear
70 public static function invalidateCache( Title
$title, $revid = null ) {
72 $revision = Revision
::newFromTitle( $title, 0, Revision
::READ_LATEST
);
73 $revid = $revision ?
$revision->getId() : null;
75 if ( $revid !== null ) {
76 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
77 $key = self
::getCacheKey( $cache, $title, $revid );
78 $cache->delete( $key );
83 * Shows page information on GET request.
85 * @return string Page information that will be added to the output
87 public function onView() {
91 $oldid = $this->page
->getOldID();
93 $revision = $this->page
->getRevisionFetched();
95 // Revision is missing
96 if ( $revision === null ) {
97 return $this->msg( 'missing-revision', $oldid )->parse();
100 // Revision is not current
101 if ( !$revision->isCurrent() ) {
102 return $this->msg( 'pageinfo-not-current' )->plain();
107 if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
108 $content .= $this->msg( 'pageinfo-header' )->parse();
111 // Hide "This page is a member of # hidden categories" explanation
112 $content .= Html
::element( 'style', [],
113 '.mw-hiddenCategoriesExplanation { display: none; }' ) . "\n";
115 // Hide "Templates used on this page" explanation
116 $content .= Html
::element( 'style', [],
117 '.mw-templatesUsedExplanation { display: none; }' ) . "\n";
119 // Get page information
120 $pageInfo = $this->pageInfo();
122 // Allow extensions to add additional information
123 Hooks
::run( 'InfoAction', [ $this->getContext(), &$pageInfo ] );
125 // Render page information
126 foreach ( $pageInfo as $header => $infoTable ) {
128 // pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions,
129 // pageinfo-header-properties, pageinfo-category-info
130 $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
132 foreach ( $infoTable as $infoRow ) {
133 $name = ( $infoRow[0] instanceof Message
) ?
$infoRow[0]->escaped() : $infoRow[0];
134 $value = ( $infoRow[1] instanceof Message
) ?
$infoRow[1]->escaped() : $infoRow[1];
135 $id = ( $infoRow[0] instanceof Message
) ?
$infoRow[0]->getKey() : null;
136 $table = $this->addRow( $table, $name, $value, $id ) . "\n";
138 $content = $this->addTable( $content, $table ) . "\n";
142 if ( !$this->msg( 'pageinfo-footer' )->isDisabled() ) {
143 $content .= $this->msg( 'pageinfo-footer' )->parse();
150 * Creates a header that can be added to the output.
152 * @param string $header The header text.
153 * @return string The HTML.
155 protected function makeHeader( $header ) {
156 $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer
::escapeId( $header ) ];
158 return Html
::rawElement( 'h2', [], Html
::element( 'span', $spanAttribs, $header ) );
162 * Adds a row to a table that will be added to the content.
164 * @param string $table The table that will be added to the content
165 * @param string $name The name of the row
166 * @param string $value The value of the row
167 * @param string $id The ID to use for the 'tr' element
168 * @return string The table with the row added
170 protected function addRow( $table, $name, $value, $id ) {
174 $id === null ?
[] : [ 'id' => 'mw-' . $id ],
175 Html
::rawElement( 'td', [ 'style' => 'vertical-align: top;' ], $name ) .
176 Html
::rawElement( 'td', [], $value )
181 * Adds a table to the content that will be added to the output.
183 * @param string $content The content that will be added to the output
184 * @param string $table The table
185 * @return string The content with the table added
187 protected function addTable( $content, $table ) {
188 return $content . Html
::rawElement( 'table', [ 'class' => 'wikitable mw-page-info' ],
193 * Returns page information in an easily-manipulated format. Array keys are used so extensions
194 * may add additional information in arbitrary positions. Array values are arrays with one
195 * element to be rendered as a header, arrays with two elements to be rendered as a table row.
199 protected function pageInfo() {
202 $user = $this->getUser();
203 $lang = $this->getLanguage();
204 $title = $this->getTitle();
205 $id = $title->getArticleID();
206 $config = $this->context
->getConfig();
207 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
209 $pageCounts = $this->pageCounts( $this->page
);
211 $pageProperties = [];
212 $props = PageProps
::getInstance()->getAllProperties( $title );
213 if ( isset( $props[$id] ) ) {
214 $pageProperties = $props[$id];
219 $pageInfo['header-basic'] = [];
222 $displayTitle = $title->getPrefixedText();
223 if ( isset( $pageProperties['displaytitle'] ) ) {
224 $displayTitle = $pageProperties['displaytitle'];
227 $pageInfo['header-basic'][] = [
228 $this->msg( 'pageinfo-display-title' ), $displayTitle
231 // Is it a redirect? If so, where to?
232 if ( $title->isRedirect() ) {
233 $pageInfo['header-basic'][] = [
234 $this->msg( 'pageinfo-redirectsto' ),
235 $linkRenderer->makeLink( $this->page
->getRedirectTarget() ) .
236 $this->msg( 'word-separator' )->escaped() .
237 $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
238 $this->page
->getRedirectTarget(),
239 $this->msg( 'pageinfo-redirectsto-info' )->text(),
241 [ 'action' => 'info' ]
247 $sortKey = $title->getCategorySortkey();
248 if ( isset( $pageProperties['defaultsort'] ) ) {
249 $sortKey = $pageProperties['defaultsort'];
252 $sortKey = htmlspecialchars( $sortKey );
253 $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-default-sort' ), $sortKey ];
255 // Page length (in bytes)
256 $pageInfo['header-basic'][] = [
257 $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
260 // Page ID (number not localised, as it's a database ID)
261 $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-article-id' ), $id ];
263 // Language in which the page content is (supposed to be) written
264 $pageLang = $title->getPageLanguage()->getCode();
266 $pageLangHtml = $pageLang . ' - ' .
267 Language
::fetchLanguageName( $pageLang, $lang->getCode() );
268 // Link to Special:PageLanguage with pre-filled page title if user has permissions
269 if ( $config->get( 'PageLanguageUseDB' )
270 && $title->userCan( 'pagelang', $user )
272 $pageLangHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
273 SpecialPage
::getTitleValueFor( 'PageLanguage', $title->getPrefixedText() ),
274 $this->msg( 'pageinfo-language-change' )->text()
278 $pageInfo['header-basic'][] = [
279 $this->msg( 'pageinfo-language' )->escaped(),
283 // Content model of the page
284 $modelHtml = htmlspecialchars( ContentHandler
::getLocalizedName( $title->getContentModel() ) );
285 // If the user can change it, add a link to Special:ChangeContentModel
286 if ( $config->get( 'ContentHandlerUseDB' )
287 && $title->userCan( 'editcontentmodel', $user )
289 $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
290 SpecialPage
::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
291 $this->msg( 'pageinfo-content-model-change' )->text()
295 $pageInfo['header-basic'][] = [
296 $this->msg( 'pageinfo-content-model' ),
300 if ( $title->inNamespace( NS_USER
) ) {
301 $pageUser = User
::newFromName( $title->getRootText() );
302 if ( $pageUser && $pageUser->getId() && !$pageUser->isHidden() ) {
303 $pageInfo['header-basic'][] = [
304 $this->msg( 'pageinfo-user-id' ),
310 // Search engine status
311 $pOutput = new ParserOutput();
312 if ( isset( $pageProperties['noindex'] ) ) {
313 $pOutput->setIndexPolicy( 'noindex' );
315 if ( isset( $pageProperties['index'] ) ) {
316 $pOutput->setIndexPolicy( 'index' );
319 // Use robot policy logic
320 $policy = $this->page
->getRobotPolicy( 'view', $pOutput );
321 $pageInfo['header-basic'][] = [
322 // Messages: pageinfo-robot-index, pageinfo-robot-noindex
323 $this->msg( 'pageinfo-robot-policy' ),
324 $this->msg( "pageinfo-robot-${policy['index']}" )
327 $unwatchedPageThreshold = $config->get( 'UnwatchedPageThreshold' );
329 $user->isAllowed( 'unwatchedpages' ) ||
330 ( $unwatchedPageThreshold !== false &&
331 $pageCounts['watchers'] >= $unwatchedPageThreshold )
333 // Number of page watchers
334 $pageInfo['header-basic'][] = [
335 $this->msg( 'pageinfo-watchers' ),
336 $lang->formatNum( $pageCounts['watchers'] )
339 $config->get( 'ShowUpdatedMarker' ) &&
340 isset( $pageCounts['visitingWatchers'] )
342 $minToDisclose = $config->get( 'UnwatchedPageSecret' );
343 if ( $pageCounts['visitingWatchers'] > $minToDisclose ||
344 $user->isAllowed( 'unwatchedpages' ) ) {
345 $pageInfo['header-basic'][] = [
346 $this->msg( 'pageinfo-visiting-watchers' ),
347 $lang->formatNum( $pageCounts['visitingWatchers'] )
350 $pageInfo['header-basic'][] = [
351 $this->msg( 'pageinfo-visiting-watchers' ),
352 $this->msg( 'pageinfo-few-visiting-watchers' )
356 } elseif ( $unwatchedPageThreshold !== false ) {
357 $pageInfo['header-basic'][] = [
358 $this->msg( 'pageinfo-watchers' ),
359 $this->msg( 'pageinfo-few-watchers' )->numParams( $unwatchedPageThreshold )
363 // Redirects to this page
364 $whatLinksHere = SpecialPage
::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
365 $pageInfo['header-basic'][] = [
366 $linkRenderer->makeLink(
368 $this->msg( 'pageinfo-redirects-name' )->text(),
373 'hideimages' => $title->getNamespace() == NS_FILE
376 $this->msg( 'pageinfo-redirects-value' )
377 ->numParams( count( $title->getRedirectsHere() ) )
380 // Is it counted as a content page?
381 if ( $this->page
->isCountable() ) {
382 $pageInfo['header-basic'][] = [
383 $this->msg( 'pageinfo-contentpage' ),
384 $this->msg( 'pageinfo-contentpage-yes' )
388 // Subpages of this page, if subpages are enabled for the current NS
389 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
390 $prefixIndex = SpecialPage
::getTitleFor(
391 'Prefixindex', $title->getPrefixedText() . '/' );
392 $pageInfo['header-basic'][] = [
393 $linkRenderer->makeLink(
395 $this->msg( 'pageinfo-subpages-name' )->text()
397 $this->msg( 'pageinfo-subpages-value' )
399 $pageCounts['subpages']['total'],
400 $pageCounts['subpages']['redirects'],
401 $pageCounts['subpages']['nonredirects'] )
405 if ( $title->inNamespace( NS_CATEGORY
) ) {
406 $category = Category
::newFromTitle( $title );
408 // $allCount is the total number of cat members,
409 // not the count of how many members are normal pages.
410 $allCount = (int)$category->getPageCount();
411 $subcatCount = (int)$category->getSubcatCount();
412 $fileCount = (int)$category->getFileCount();
413 $pagesCount = $allCount - $subcatCount - $fileCount;
415 $pageInfo['category-info'] = [
417 $this->msg( 'pageinfo-category-total' ),
418 $lang->formatNum( $allCount )
421 $this->msg( 'pageinfo-category-pages' ),
422 $lang->formatNum( $pagesCount )
425 $this->msg( 'pageinfo-category-subcats' ),
426 $lang->formatNum( $subcatCount )
429 $this->msg( 'pageinfo-category-files' ),
430 $lang->formatNum( $fileCount )
436 $pageInfo['header-restrictions'] = [];
438 // Is this page affected by the cascading protection of something which includes it?
439 if ( $title->isCascadeProtected() ) {
441 $sources = $title->getCascadeProtectionSources()[0];
443 foreach ( $sources as $sourceTitle ) {
444 $cascadingFrom .= Html
::rawElement(
445 'li', [], $linkRenderer->makeKnownLink( $sourceTitle ) );
448 $cascadingFrom = Html
::rawElement( 'ul', [], $cascadingFrom );
449 $pageInfo['header-restrictions'][] = [
450 $this->msg( 'pageinfo-protect-cascading-from' ),
455 // Is out protection set to cascade to other pages?
456 if ( $title->areRestrictionsCascading() ) {
457 $pageInfo['header-restrictions'][] = [
458 $this->msg( 'pageinfo-protect-cascading' ),
459 $this->msg( 'pageinfo-protect-cascading-yes' )
464 foreach ( $title->getRestrictionTypes() as $restrictionType ) {
465 $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
467 if ( $protectionLevel == '' ) {
469 $message = $this->msg( 'protect-default' )->escaped();
471 // Administrators only
472 // Messages: protect-level-autoconfirmed, protect-level-sysop
473 $message = $this->msg( "protect-level-$protectionLevel" );
474 if ( $message->isDisabled() ) {
475 // Require "$1" permission
476 $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
478 $message = $message->escaped();
481 $expiry = $title->getRestrictionExpiry( $restrictionType );
482 $formattedexpiry = $this->msg( 'parentheses',
483 $lang->formatExpiry( $expiry ) )->escaped();
484 $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
486 // Messages: restriction-edit, restriction-move, restriction-create,
487 // restriction-upload
488 $pageInfo['header-restrictions'][] = [
489 $this->msg( "restriction-$restrictionType" ), $message
493 if ( !$this->page
->exists() ) {
498 $pageInfo['header-edits'] = [];
500 $firstRev = $this->page
->getOldestRevision();
501 $lastRev = $this->page
->getRevision();
502 $batch = new LinkBatch
;
505 $firstRevUser = $firstRev->getUserText( Revision
::FOR_THIS_USER
);
506 if ( $firstRevUser !== '' ) {
507 $firstRevUserTitle = Title
::makeTitle( NS_USER
, $firstRevUser );
508 $batch->addObj( $firstRevUserTitle );
509 $batch->addObj( $firstRevUserTitle->getTalkPage() );
514 $lastRevUser = $lastRev->getUserText( Revision
::FOR_THIS_USER
);
515 if ( $lastRevUser !== '' ) {
516 $lastRevUserTitle = Title
::makeTitle( NS_USER
, $lastRevUser );
517 $batch->addObj( $lastRevUserTitle );
518 $batch->addObj( $lastRevUserTitle->getTalkPage() );
526 $pageInfo['header-edits'][] = [
527 $this->msg( 'pageinfo-firstuser' ),
528 Linker
::revUserTools( $firstRev )
531 // Date of page creation
532 $pageInfo['header-edits'][] = [
533 $this->msg( 'pageinfo-firsttime' ),
534 $linkRenderer->makeKnownLink(
536 $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
538 [ 'oldid' => $firstRev->getId() ]
545 $pageInfo['header-edits'][] = [
546 $this->msg( 'pageinfo-lastuser' ),
547 Linker
::revUserTools( $lastRev )
550 // Date of latest edit
551 $pageInfo['header-edits'][] = [
552 $this->msg( 'pageinfo-lasttime' ),
553 $linkRenderer->makeKnownLink(
555 $lang->userTimeAndDate( $this->page
->getTimestamp(), $user ),
557 [ 'oldid' => $this->page
->getLatest() ]
562 // Total number of edits
563 $pageInfo['header-edits'][] = [
564 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
567 // Total number of distinct authors
568 if ( $pageCounts['authors'] > 0 ) {
569 $pageInfo['header-edits'][] = [
570 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
574 // Recent number of edits (within past 30 days)
575 $pageInfo['header-edits'][] = [
576 $this->msg( 'pageinfo-recent-edits',
577 $lang->formatDuration( $config->get( 'RCMaxAge' ) ) ),
578 $lang->formatNum( $pageCounts['recent_edits'] )
581 // Recent number of distinct authors
582 $pageInfo['header-edits'][] = [
583 $this->msg( 'pageinfo-recent-authors' ),
584 $lang->formatNum( $pageCounts['recent_authors'] )
587 // Array of MagicWord objects
588 $magicWords = MagicWord
::getDoubleUnderscoreArray();
590 // Array of magic word IDs
591 $wordIDs = $magicWords->names
;
593 // Array of IDs => localized magic words
594 $localizedWords = $wgContLang->getMagicWords();
597 foreach ( $pageProperties as $property => $value ) {
598 if ( in_array( $property, $wordIDs ) ) {
599 $listItems[] = Html
::element( 'li', [], $localizedWords[$property][1] );
603 $localizedList = Html
::rawElement( 'ul', [], implode( '', $listItems ) );
604 $hiddenCategories = $this->page
->getHiddenCategories();
607 count( $listItems ) > 0 ||
608 count( $hiddenCategories ) > 0 ||
609 $pageCounts['transclusion']['from'] > 0 ||
610 $pageCounts['transclusion']['to'] > 0
612 $options = [ 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) ];
613 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
614 if ( $config->get( 'MiserMode' ) ) {
615 $transcludedTargets = [];
617 $transcludedTargets = $title->getTemplateLinksTo( $options );
621 $pageInfo['header-properties'] = [];
624 if ( count( $listItems ) > 0 ) {
625 $pageInfo['header-properties'][] = [
626 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
632 if ( count( $hiddenCategories ) > 0 ) {
633 $pageInfo['header-properties'][] = [
634 $this->msg( 'pageinfo-hidden-categories' )
635 ->numParams( count( $hiddenCategories ) ),
636 Linker
::formatHiddenCategories( $hiddenCategories )
640 // Transcluded templates
641 if ( $pageCounts['transclusion']['from'] > 0 ) {
642 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
643 $more = $this->msg( 'morenotlisted' )->escaped();
648 $templateListFormatter = new TemplatesOnThisPageFormatter(
653 $pageInfo['header-properties'][] = [
654 $this->msg( 'pageinfo-templates' )
655 ->numParams( $pageCounts['transclusion']['from'] ),
656 $templateListFormatter->format( $transcludedTemplates, false, $more )
660 if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
661 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
662 $more = $linkRenderer->makeLink(
664 $this->msg( 'moredotdotdot' )->text(),
666 [ 'hidelinks' => 1, 'hideredirs' => 1 ]
672 $templateListFormatter = new TemplatesOnThisPageFormatter(
677 $pageInfo['header-properties'][] = [
678 $this->msg( 'pageinfo-transclusions' )
679 ->numParams( $pageCounts['transclusion']['to'] ),
680 $templateListFormatter->format( $transcludedTargets, false, $more )
689 * Returns page counts that would be too "expensive" to retrieve by normal means.
691 * @param WikiPage|Article|Page $page
694 protected function pageCounts( Page
$page ) {
696 $config = $this->context
->getConfig();
697 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
699 return $cache->getWithSetCallback(
700 self
::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
701 WANObjectCache
::TTL_WEEK
,
702 function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
703 $title = $page->getTitle();
704 $id = $title->getArticleID();
706 $dbr = wfGetDB( DB_REPLICA
);
707 $dbrWatchlist = wfGetDB( DB_REPLICA
, 'watchlist' );
708 $setOpts +
= Database
::getCacheSetOptions( $dbr, $dbrWatchlist );
710 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
713 $result['watchers'] = $watchedItemStore->countWatchers( $title );
715 if ( $config->get( 'ShowUpdatedMarker' ) ) {
716 $updated = wfTimestamp( TS_UNIX
, $page->getTimestamp() );
717 $result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
719 $updated - $config->get( 'WatchersMaxAge' )
723 // Total number of edits
724 $edits = (int)$dbr->selectField(
727 [ 'rev_page' => $id ],
730 $result['edits'] = $edits;
732 // Total number of distinct authors
733 if ( $config->get( 'MiserMode' ) ) {
734 $result['authors'] = 0;
736 $result['authors'] = (int)$dbr->selectField(
738 'COUNT(DISTINCT rev_user_text)',
739 [ 'rev_page' => $id ],
744 // "Recent" threshold defined by RCMaxAge setting
745 $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
747 // Recent number of edits
748 $edits = (int)$dbr->selectField(
753 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
757 $result['recent_edits'] = $edits;
759 // Recent number of distinct authors
760 $result['recent_authors'] = (int)$dbr->selectField(
762 'COUNT(DISTINCT rev_user_text)',
765 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
770 // Subpages (if enabled)
771 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
772 $conds = [ 'page_namespace' => $title->getNamespace() ];
773 $conds[] = 'page_title ' .
774 $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
776 // Subpages of this page (redirects)
777 $conds['page_is_redirect'] = 1;
778 $result['subpages']['redirects'] = (int)$dbr->selectField(
785 // Subpages of this page (non-redirects)
786 $conds['page_is_redirect'] = 0;
787 $result['subpages']['nonredirects'] = (int)$dbr->selectField(
794 // Subpages of this page (total)
795 $result['subpages']['total'] = $result['subpages']['redirects']
796 +
$result['subpages']['nonredirects'];
799 // Counts for the number of transclusion links (to/from)
800 if ( $config->get( 'MiserMode' ) ) {
801 $result['transclusion']['to'] = 0;
803 $result['transclusion']['to'] = (int)$dbr->selectField(
807 'tl_namespace' => $title->getNamespace(),
808 'tl_title' => $title->getDBkey()
814 $result['transclusion']['from'] = (int)$dbr->selectField(
817 [ 'tl_from' => $title->getArticleID() ],
827 * Returns the name that goes in the "<h1>" page title.
831 protected function getPageTitle() {
832 return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
836 * Get a list of contributors of $article
837 * @return string Html
839 protected function getContributors() {
840 $contributors = $this->page
->getContributors();
844 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
846 # Sift for real versus user names
847 /** @var $user User */
848 foreach ( $contributors as $user ) {
849 $page = $user->isAnon()
850 ? SpecialPage
::getTitleFor( 'Contributions', $user->getName() )
851 : $user->getUserPage();
853 $hiddenPrefs = $this->context
->getConfig()->get( 'HiddenPrefs' );
854 if ( $user->getId() == 0 ) {
855 $anon_ips[] = $linkRenderer->makeLink( $page, $user->getName() );
856 } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
857 $real_names[] = $linkRenderer->makeLink( $page, $user->getRealName() );
859 $user_names[] = $linkRenderer->makeLink( $page, $user->getName() );
863 $lang = $this->getLanguage();
865 $real = $lang->listToText( $real_names );
867 # "ThisSite user(s) A, B and C"
868 if ( count( $user_names ) ) {
869 $user = $this->msg( 'siteusers' )
870 ->rawParams( $lang->listToText( $user_names ) )
871 ->params( count( $user_names ) )->escaped();
876 if ( count( $anon_ips ) ) {
877 $anon = $this->msg( 'anonusers' )
878 ->rawParams( $lang->listToText( $anon_ips ) )
879 ->params( count( $anon_ips ) )->escaped();
884 # This is the big list, all mooshed together. We sift for blank strings
886 foreach ( [ $real, $user, $anon ] as $s ) {
888 array_push( $fulllist, $s );
892 $count = count( $fulllist );
894 # "Based on work by ..."
896 ?
$this->msg( 'othercontribs' )->rawParams(
897 $lang->listToText( $fulllist ) )->params( $count )->escaped()
902 * Returns the description that goes below the "<h1>" tag.
906 protected function getDescription() {
911 * @param WANObjectCache $cache
912 * @param Title $title
916 protected static function getCacheKey( WANObjectCache
$cache, Title
$title, $revId ) {
917 return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self
::VERSION
);