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 Linker
::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
394 $this->msg( 'pageinfo-subpages-value' )
396 $pageCounts['subpages']['total'],
397 $pageCounts['subpages']['redirects'],
398 $pageCounts['subpages']['nonredirects'] )
402 if ( $title->inNamespace( NS_CATEGORY
) ) {
403 $category = Category
::newFromTitle( $title );
405 // $allCount is the total number of cat members,
406 // not the count of how many members are normal pages.
407 $allCount = (int)$category->getPageCount();
408 $subcatCount = (int)$category->getSubcatCount();
409 $fileCount = (int)$category->getFileCount();
410 $pagesCount = $allCount - $subcatCount - $fileCount;
412 $pageInfo['category-info'] = [
414 $this->msg( 'pageinfo-category-total' ),
415 $lang->formatNum( $allCount )
418 $this->msg( 'pageinfo-category-pages' ),
419 $lang->formatNum( $pagesCount )
422 $this->msg( 'pageinfo-category-subcats' ),
423 $lang->formatNum( $subcatCount )
426 $this->msg( 'pageinfo-category-files' ),
427 $lang->formatNum( $fileCount )
433 $pageInfo['header-restrictions'] = [];
435 // Is this page affected by the cascading protection of something which includes it?
436 if ( $title->isCascadeProtected() ) {
438 $sources = $title->getCascadeProtectionSources()[0];
440 foreach ( $sources as $sourceTitle ) {
441 $cascadingFrom .= Html
::rawElement(
442 'li', [], $linkRenderer->makeKnownLink( $sourceTitle ) );
445 $cascadingFrom = Html
::rawElement( 'ul', [], $cascadingFrom );
446 $pageInfo['header-restrictions'][] = [
447 $this->msg( 'pageinfo-protect-cascading-from' ),
452 // Is out protection set to cascade to other pages?
453 if ( $title->areRestrictionsCascading() ) {
454 $pageInfo['header-restrictions'][] = [
455 $this->msg( 'pageinfo-protect-cascading' ),
456 $this->msg( 'pageinfo-protect-cascading-yes' )
461 foreach ( $title->getRestrictionTypes() as $restrictionType ) {
462 $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
464 if ( $protectionLevel == '' ) {
466 $message = $this->msg( 'protect-default' )->escaped();
468 // Administrators only
469 // Messages: protect-level-autoconfirmed, protect-level-sysop
470 $message = $this->msg( "protect-level-$protectionLevel" );
471 if ( $message->isDisabled() ) {
472 // Require "$1" permission
473 $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
475 $message = $message->escaped();
478 $expiry = $title->getRestrictionExpiry( $restrictionType );
479 $formattedexpiry = $this->msg( 'parentheses',
480 $lang->formatExpiry( $expiry ) )->escaped();
481 $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
483 // Messages: restriction-edit, restriction-move, restriction-create,
484 // restriction-upload
485 $pageInfo['header-restrictions'][] = [
486 $this->msg( "restriction-$restrictionType" ), $message
490 if ( !$this->page
->exists() ) {
495 $pageInfo['header-edits'] = [];
497 $firstRev = $this->page
->getOldestRevision();
498 $lastRev = $this->page
->getRevision();
499 $batch = new LinkBatch
;
502 $firstRevUser = $firstRev->getUserText( Revision
::FOR_THIS_USER
);
503 if ( $firstRevUser !== '' ) {
504 $firstRevUserTitle = Title
::makeTitle( NS_USER
, $firstRevUser );
505 $batch->addObj( $firstRevUserTitle );
506 $batch->addObj( $firstRevUserTitle->getTalkPage() );
511 $lastRevUser = $lastRev->getUserText( Revision
::FOR_THIS_USER
);
512 if ( $lastRevUser !== '' ) {
513 $lastRevUserTitle = Title
::makeTitle( NS_USER
, $lastRevUser );
514 $batch->addObj( $lastRevUserTitle );
515 $batch->addObj( $lastRevUserTitle->getTalkPage() );
523 $pageInfo['header-edits'][] = [
524 $this->msg( 'pageinfo-firstuser' ),
525 Linker
::revUserTools( $firstRev )
528 // Date of page creation
529 $pageInfo['header-edits'][] = [
530 $this->msg( 'pageinfo-firsttime' ),
531 $linkRenderer->makeKnownLink(
533 $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
535 [ 'oldid' => $firstRev->getId() ]
542 $pageInfo['header-edits'][] = [
543 $this->msg( 'pageinfo-lastuser' ),
544 Linker
::revUserTools( $lastRev )
547 // Date of latest edit
548 $pageInfo['header-edits'][] = [
549 $this->msg( 'pageinfo-lasttime' ),
550 $linkRenderer->makeKnownLink(
552 $lang->userTimeAndDate( $this->page
->getTimestamp(), $user ),
554 [ 'oldid' => $this->page
->getLatest() ]
559 // Total number of edits
560 $pageInfo['header-edits'][] = [
561 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
564 // Total number of distinct authors
565 if ( $pageCounts['authors'] > 0 ) {
566 $pageInfo['header-edits'][] = [
567 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
571 // Recent number of edits (within past 30 days)
572 $pageInfo['header-edits'][] = [
573 $this->msg( 'pageinfo-recent-edits',
574 $lang->formatDuration( $config->get( 'RCMaxAge' ) ) ),
575 $lang->formatNum( $pageCounts['recent_edits'] )
578 // Recent number of distinct authors
579 $pageInfo['header-edits'][] = [
580 $this->msg( 'pageinfo-recent-authors' ),
581 $lang->formatNum( $pageCounts['recent_authors'] )
584 // Array of MagicWord objects
585 $magicWords = MagicWord
::getDoubleUnderscoreArray();
587 // Array of magic word IDs
588 $wordIDs = $magicWords->names
;
590 // Array of IDs => localized magic words
591 $localizedWords = $wgContLang->getMagicWords();
594 foreach ( $pageProperties as $property => $value ) {
595 if ( in_array( $property, $wordIDs ) ) {
596 $listItems[] = Html
::element( 'li', [], $localizedWords[$property][1] );
600 $localizedList = Html
::rawElement( 'ul', [], implode( '', $listItems ) );
601 $hiddenCategories = $this->page
->getHiddenCategories();
604 count( $listItems ) > 0 ||
605 count( $hiddenCategories ) > 0 ||
606 $pageCounts['transclusion']['from'] > 0 ||
607 $pageCounts['transclusion']['to'] > 0
609 $options = [ 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) ];
610 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
611 if ( $config->get( 'MiserMode' ) ) {
612 $transcludedTargets = [];
614 $transcludedTargets = $title->getTemplateLinksTo( $options );
618 $pageInfo['header-properties'] = [];
621 if ( count( $listItems ) > 0 ) {
622 $pageInfo['header-properties'][] = [
623 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
629 if ( count( $hiddenCategories ) > 0 ) {
630 $pageInfo['header-properties'][] = [
631 $this->msg( 'pageinfo-hidden-categories' )
632 ->numParams( count( $hiddenCategories ) ),
633 Linker
::formatHiddenCategories( $hiddenCategories )
637 // Transcluded templates
638 if ( $pageCounts['transclusion']['from'] > 0 ) {
639 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
640 $more = $this->msg( 'morenotlisted' )->escaped();
645 $templateListFormatter = new TemplatesOnThisPageFormatter(
650 $pageInfo['header-properties'][] = [
651 $this->msg( 'pageinfo-templates' )
652 ->numParams( $pageCounts['transclusion']['from'] ),
653 $templateListFormatter->format( $transcludedTemplates, false, $more )
657 if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
658 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
659 $more = $linkRenderer->makeLink(
661 $this->msg( 'moredotdotdot' )->text(),
663 [ 'hidelinks' => 1, 'hideredirs' => 1 ]
669 $templateListFormatter = new TemplatesOnThisPageFormatter(
674 $pageInfo['header-properties'][] = [
675 $this->msg( 'pageinfo-transclusions' )
676 ->numParams( $pageCounts['transclusion']['to'] ),
677 $templateListFormatter->format( $transcludedTargets, false, $more )
686 * Returns page counts that would be too "expensive" to retrieve by normal means.
688 * @param WikiPage|Article|Page $page
691 protected function pageCounts( Page
$page ) {
693 $config = $this->context
->getConfig();
694 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
696 return $cache->getWithSetCallback(
697 self
::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
698 WANObjectCache
::TTL_WEEK
,
699 function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
700 $title = $page->getTitle();
701 $id = $title->getArticleID();
703 $dbr = wfGetDB( DB_REPLICA
);
704 $dbrWatchlist = wfGetDB( DB_REPLICA
, 'watchlist' );
705 $setOpts +
= Database
::getCacheSetOptions( $dbr, $dbrWatchlist );
707 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
710 $result['watchers'] = $watchedItemStore->countWatchers( $title );
712 if ( $config->get( 'ShowUpdatedMarker' ) ) {
713 $updated = wfTimestamp( TS_UNIX
, $page->getTimestamp() );
714 $result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
716 $updated - $config->get( 'WatchersMaxAge' )
720 // Total number of edits
721 $edits = (int)$dbr->selectField(
724 [ 'rev_page' => $id ],
727 $result['edits'] = $edits;
729 // Total number of distinct authors
730 if ( $config->get( 'MiserMode' ) ) {
731 $result['authors'] = 0;
733 $result['authors'] = (int)$dbr->selectField(
735 'COUNT(DISTINCT rev_user_text)',
736 [ 'rev_page' => $id ],
741 // "Recent" threshold defined by RCMaxAge setting
742 $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
744 // Recent number of edits
745 $edits = (int)$dbr->selectField(
750 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
754 $result['recent_edits'] = $edits;
756 // Recent number of distinct authors
757 $result['recent_authors'] = (int)$dbr->selectField(
759 'COUNT(DISTINCT rev_user_text)',
762 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
767 // Subpages (if enabled)
768 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
769 $conds = [ 'page_namespace' => $title->getNamespace() ];
770 $conds[] = 'page_title ' .
771 $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
773 // Subpages of this page (redirects)
774 $conds['page_is_redirect'] = 1;
775 $result['subpages']['redirects'] = (int)$dbr->selectField(
782 // Subpages of this page (non-redirects)
783 $conds['page_is_redirect'] = 0;
784 $result['subpages']['nonredirects'] = (int)$dbr->selectField(
791 // Subpages of this page (total)
792 $result['subpages']['total'] = $result['subpages']['redirects']
793 +
$result['subpages']['nonredirects'];
796 // Counts for the number of transclusion links (to/from)
797 if ( $config->get( 'MiserMode' ) ) {
798 $result['transclusion']['to'] = 0;
800 $result['transclusion']['to'] = (int)$dbr->selectField(
804 'tl_namespace' => $title->getNamespace(),
805 'tl_title' => $title->getDBkey()
811 $result['transclusion']['from'] = (int)$dbr->selectField(
814 [ 'tl_from' => $title->getArticleID() ],
824 * Returns the name that goes in the "<h1>" page title.
828 protected function getPageTitle() {
829 return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
833 * Get a list of contributors of $article
834 * @return string Html
836 protected function getContributors() {
837 $contributors = $this->page
->getContributors();
841 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
843 # Sift for real versus user names
844 /** @var $user User */
845 foreach ( $contributors as $user ) {
846 $page = $user->isAnon()
847 ? SpecialPage
::getTitleFor( 'Contributions', $user->getName() )
848 : $user->getUserPage();
850 $hiddenPrefs = $this->context
->getConfig()->get( 'HiddenPrefs' );
851 if ( $user->getId() == 0 ) {
852 $anon_ips[] = $linkRenderer->makeLink( $page, $user->getName() );
853 } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
854 $real_names[] = $linkRenderer->makeLink( $page, $user->getRealName() );
856 $user_names[] = $linkRenderer->makeLink( $page, $user->getName() );
860 $lang = $this->getLanguage();
862 $real = $lang->listToText( $real_names );
864 # "ThisSite user(s) A, B and C"
865 if ( count( $user_names ) ) {
866 $user = $this->msg( 'siteusers' )
867 ->rawParams( $lang->listToText( $user_names ) )
868 ->params( count( $user_names ) )->escaped();
873 if ( count( $anon_ips ) ) {
874 $anon = $this->msg( 'anonusers' )
875 ->rawParams( $lang->listToText( $anon_ips ) )
876 ->params( count( $anon_ips ) )->escaped();
881 # This is the big list, all mooshed together. We sift for blank strings
883 foreach ( [ $real, $user, $anon ] as $s ) {
885 array_push( $fulllist, $s );
889 $count = count( $fulllist );
891 # "Based on work by ..."
893 ?
$this->msg( 'othercontribs' )->rawParams(
894 $lang->listToText( $fulllist ) )->params( $count )->escaped()
899 * Returns the description that goes below the "<h1>" tag.
903 protected function getDescription() {
908 * @param WANObjectCache $cache
909 * @param Title $title
913 protected static function getCacheKey( WANObjectCache
$cache, Title
$title, $revId ) {
914 return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self
::VERSION
);