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(
131 $this->msg( "pageinfo-${header}" )->escaped(),
132 "mw-pageinfo-${header}"
135 foreach ( $infoTable as $infoRow ) {
136 $name = ( $infoRow[0] instanceof Message
) ?
$infoRow[0]->escaped() : $infoRow[0];
137 $value = ( $infoRow[1] instanceof Message
) ?
$infoRow[1]->escaped() : $infoRow[1];
138 $id = ( $infoRow[0] instanceof Message
) ?
$infoRow[0]->getKey() : null;
139 $table = $this->addRow( $table, $name, $value, $id ) . "\n";
141 $content = $this->addTable( $content, $table ) . "\n";
145 if ( !$this->msg( 'pageinfo-footer' )->isDisabled() ) {
146 $content .= $this->msg( 'pageinfo-footer' )->parse();
153 * Creates a header that can be added to the output.
155 * @param string $header The header text.
156 * @return string The HTML.
158 protected function makeHeader( $header, $canonicalId ) {
159 $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer
::escapeIdForAttribute( $header ) ];
160 $h2Attribs = [ 'id' => Sanitizer
::escapeIdForAttribute( $canonicalId ) ];
162 return Html
::rawElement( 'h2', $h2Attribs, Html
::element( 'span', $spanAttribs, $header ) );
166 * Adds a row to a table that will be added to the content.
168 * @param string $table The table that will be added to the content
169 * @param string $name The name of the row
170 * @param string $value The value of the row
171 * @param string $id The ID to use for the 'tr' element
172 * @return string The table with the row added
174 protected function addRow( $table, $name, $value, $id ) {
178 $id === null ?
[] : [ 'id' => 'mw-' . $id ],
179 Html
::rawElement( 'td', [ 'style' => 'vertical-align: top;' ], $name ) .
180 Html
::rawElement( 'td', [], $value )
185 * Adds a table to the content that will be added to the output.
187 * @param string $content The content that will be added to the output
188 * @param string $table The table
189 * @return string The content with the table added
191 protected function addTable( $content, $table ) {
192 return $content . Html
::rawElement( 'table', [ 'class' => 'wikitable mw-page-info' ],
197 * Returns page information in an easily-manipulated format. Array keys are used so extensions
198 * may add additional information in arbitrary positions. Array values are arrays with one
199 * element to be rendered as a header, arrays with two elements to be rendered as a table row.
203 protected function pageInfo() {
206 $user = $this->getUser();
207 $lang = $this->getLanguage();
208 $title = $this->getTitle();
209 $id = $title->getArticleID();
210 $config = $this->context
->getConfig();
211 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
213 $pageCounts = $this->pageCounts( $this->page
);
215 $pageProperties = [];
216 $props = PageProps
::getInstance()->getAllProperties( $title );
217 if ( isset( $props[$id] ) ) {
218 $pageProperties = $props[$id];
223 $pageInfo['header-basic'] = [];
226 $displayTitle = $title->getPrefixedText();
227 if ( isset( $pageProperties['displaytitle'] ) ) {
228 $displayTitle = $pageProperties['displaytitle'];
231 $pageInfo['header-basic'][] = [
232 $this->msg( 'pageinfo-display-title' ), $displayTitle
235 // Is it a redirect? If so, where to?
236 if ( $title->isRedirect() ) {
237 $pageInfo['header-basic'][] = [
238 $this->msg( 'pageinfo-redirectsto' ),
239 $linkRenderer->makeLink( $this->page
->getRedirectTarget() ) .
240 $this->msg( 'word-separator' )->escaped() .
241 $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
242 $this->page
->getRedirectTarget(),
243 $this->msg( 'pageinfo-redirectsto-info' )->text(),
245 [ 'action' => 'info' ]
251 $sortKey = $title->getCategorySortkey();
252 if ( isset( $pageProperties['defaultsort'] ) ) {
253 $sortKey = $pageProperties['defaultsort'];
256 $sortKey = htmlspecialchars( $sortKey );
257 $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-default-sort' ), $sortKey ];
259 // Page length (in bytes)
260 $pageInfo['header-basic'][] = [
261 $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
264 // Page ID (number not localised, as it's a database ID)
265 $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-article-id' ), $id ];
267 // Language in which the page content is (supposed to be) written
268 $pageLang = $title->getPageLanguage()->getCode();
270 $pageLangHtml = $pageLang . ' - ' .
271 Language
::fetchLanguageName( $pageLang, $lang->getCode() );
272 // Link to Special:PageLanguage with pre-filled page title if user has permissions
273 if ( $config->get( 'PageLanguageUseDB' )
274 && $title->userCan( 'pagelang', $user )
276 $pageLangHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
277 SpecialPage
::getTitleValueFor( 'PageLanguage', $title->getPrefixedText() ),
278 $this->msg( 'pageinfo-language-change' )->text()
282 $pageInfo['header-basic'][] = [
283 $this->msg( 'pageinfo-language' )->escaped(),
287 // Content model of the page
288 $modelHtml = htmlspecialchars( ContentHandler
::getLocalizedName( $title->getContentModel() ) );
289 // If the user can change it, add a link to Special:ChangeContentModel
290 if ( $config->get( 'ContentHandlerUseDB' )
291 && $title->userCan( 'editcontentmodel', $user )
293 $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
294 SpecialPage
::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
295 $this->msg( 'pageinfo-content-model-change' )->text()
299 $pageInfo['header-basic'][] = [
300 $this->msg( 'pageinfo-content-model' ),
304 if ( $title->inNamespace( NS_USER
) ) {
305 $pageUser = User
::newFromName( $title->getRootText() );
306 if ( $pageUser && $pageUser->getId() && !$pageUser->isHidden() ) {
307 $pageInfo['header-basic'][] = [
308 $this->msg( 'pageinfo-user-id' ),
314 // Search engine status
315 $pOutput = new ParserOutput();
316 if ( isset( $pageProperties['noindex'] ) ) {
317 $pOutput->setIndexPolicy( 'noindex' );
319 if ( isset( $pageProperties['index'] ) ) {
320 $pOutput->setIndexPolicy( 'index' );
323 // Use robot policy logic
324 $policy = $this->page
->getRobotPolicy( 'view', $pOutput );
325 $pageInfo['header-basic'][] = [
326 // Messages: pageinfo-robot-index, pageinfo-robot-noindex
327 $this->msg( 'pageinfo-robot-policy' ),
328 $this->msg( "pageinfo-robot-${policy['index']}" )
331 $unwatchedPageThreshold = $config->get( 'UnwatchedPageThreshold' );
333 $user->isAllowed( 'unwatchedpages' ) ||
334 ( $unwatchedPageThreshold !== false &&
335 $pageCounts['watchers'] >= $unwatchedPageThreshold )
337 // Number of page watchers
338 $pageInfo['header-basic'][] = [
339 $this->msg( 'pageinfo-watchers' ),
340 $lang->formatNum( $pageCounts['watchers'] )
343 $config->get( 'ShowUpdatedMarker' ) &&
344 isset( $pageCounts['visitingWatchers'] )
346 $minToDisclose = $config->get( 'UnwatchedPageSecret' );
347 if ( $pageCounts['visitingWatchers'] > $minToDisclose ||
348 $user->isAllowed( 'unwatchedpages' ) ) {
349 $pageInfo['header-basic'][] = [
350 $this->msg( 'pageinfo-visiting-watchers' ),
351 $lang->formatNum( $pageCounts['visitingWatchers'] )
354 $pageInfo['header-basic'][] = [
355 $this->msg( 'pageinfo-visiting-watchers' ),
356 $this->msg( 'pageinfo-few-visiting-watchers' )
360 } elseif ( $unwatchedPageThreshold !== false ) {
361 $pageInfo['header-basic'][] = [
362 $this->msg( 'pageinfo-watchers' ),
363 $this->msg( 'pageinfo-few-watchers' )->numParams( $unwatchedPageThreshold )
367 // Redirects to this page
368 $whatLinksHere = SpecialPage
::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
369 $pageInfo['header-basic'][] = [
370 $linkRenderer->makeLink(
372 $this->msg( 'pageinfo-redirects-name' )->text(),
377 'hideimages' => $title->getNamespace() == NS_FILE
380 $this->msg( 'pageinfo-redirects-value' )
381 ->numParams( count( $title->getRedirectsHere() ) )
384 // Is it counted as a content page?
385 if ( $this->page
->isCountable() ) {
386 $pageInfo['header-basic'][] = [
387 $this->msg( 'pageinfo-contentpage' ),
388 $this->msg( 'pageinfo-contentpage-yes' )
392 // Subpages of this page, if subpages are enabled for the current NS
393 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
394 $prefixIndex = SpecialPage
::getTitleFor(
395 'Prefixindex', $title->getPrefixedText() . '/' );
396 $pageInfo['header-basic'][] = [
397 $linkRenderer->makeLink(
399 $this->msg( 'pageinfo-subpages-name' )->text()
401 $this->msg( 'pageinfo-subpages-value' )
403 $pageCounts['subpages']['total'],
404 $pageCounts['subpages']['redirects'],
405 $pageCounts['subpages']['nonredirects'] )
409 if ( $title->inNamespace( NS_CATEGORY
) ) {
410 $category = Category
::newFromTitle( $title );
412 // $allCount is the total number of cat members,
413 // not the count of how many members are normal pages.
414 $allCount = (int)$category->getPageCount();
415 $subcatCount = (int)$category->getSubcatCount();
416 $fileCount = (int)$category->getFileCount();
417 $pagesCount = $allCount - $subcatCount - $fileCount;
419 $pageInfo['category-info'] = [
421 $this->msg( 'pageinfo-category-total' ),
422 $lang->formatNum( $allCount )
425 $this->msg( 'pageinfo-category-pages' ),
426 $lang->formatNum( $pagesCount )
429 $this->msg( 'pageinfo-category-subcats' ),
430 $lang->formatNum( $subcatCount )
433 $this->msg( 'pageinfo-category-files' ),
434 $lang->formatNum( $fileCount )
440 $pageInfo['header-restrictions'] = [];
442 // Is this page affected by the cascading protection of something which includes it?
443 if ( $title->isCascadeProtected() ) {
445 $sources = $title->getCascadeProtectionSources()[0];
447 foreach ( $sources as $sourceTitle ) {
448 $cascadingFrom .= Html
::rawElement(
449 'li', [], $linkRenderer->makeKnownLink( $sourceTitle ) );
452 $cascadingFrom = Html
::rawElement( 'ul', [], $cascadingFrom );
453 $pageInfo['header-restrictions'][] = [
454 $this->msg( 'pageinfo-protect-cascading-from' ),
459 // Is out protection set to cascade to other pages?
460 if ( $title->areRestrictionsCascading() ) {
461 $pageInfo['header-restrictions'][] = [
462 $this->msg( 'pageinfo-protect-cascading' ),
463 $this->msg( 'pageinfo-protect-cascading-yes' )
468 foreach ( $title->getRestrictionTypes() as $restrictionType ) {
469 $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
471 if ( $protectionLevel == '' ) {
473 $message = $this->msg( 'protect-default' )->escaped();
475 // Administrators only
476 // Messages: protect-level-autoconfirmed, protect-level-sysop
477 $message = $this->msg( "protect-level-$protectionLevel" );
478 if ( $message->isDisabled() ) {
479 // Require "$1" permission
480 $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
482 $message = $message->escaped();
485 $expiry = $title->getRestrictionExpiry( $restrictionType );
486 $formattedexpiry = $this->msg( 'parentheses',
487 $lang->formatExpiry( $expiry ) )->escaped();
488 $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
490 // Messages: restriction-edit, restriction-move, restriction-create,
491 // restriction-upload
492 $pageInfo['header-restrictions'][] = [
493 $this->msg( "restriction-$restrictionType" ), $message
497 if ( !$this->page
->exists() ) {
502 $pageInfo['header-edits'] = [];
504 $firstRev = $this->page
->getOldestRevision();
505 $lastRev = $this->page
->getRevision();
506 $batch = new LinkBatch
;
509 $firstRevUser = $firstRev->getUserText( Revision
::FOR_THIS_USER
);
510 if ( $firstRevUser !== '' ) {
511 $firstRevUserTitle = Title
::makeTitle( NS_USER
, $firstRevUser );
512 $batch->addObj( $firstRevUserTitle );
513 $batch->addObj( $firstRevUserTitle->getTalkPage() );
518 $lastRevUser = $lastRev->getUserText( Revision
::FOR_THIS_USER
);
519 if ( $lastRevUser !== '' ) {
520 $lastRevUserTitle = Title
::makeTitle( NS_USER
, $lastRevUser );
521 $batch->addObj( $lastRevUserTitle );
522 $batch->addObj( $lastRevUserTitle->getTalkPage() );
530 $pageInfo['header-edits'][] = [
531 $this->msg( 'pageinfo-firstuser' ),
532 Linker
::revUserTools( $firstRev )
535 // Date of page creation
536 $pageInfo['header-edits'][] = [
537 $this->msg( 'pageinfo-firsttime' ),
538 $linkRenderer->makeKnownLink(
540 $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
542 [ 'oldid' => $firstRev->getId() ]
549 $pageInfo['header-edits'][] = [
550 $this->msg( 'pageinfo-lastuser' ),
551 Linker
::revUserTools( $lastRev )
554 // Date of latest edit
555 $pageInfo['header-edits'][] = [
556 $this->msg( 'pageinfo-lasttime' ),
557 $linkRenderer->makeKnownLink(
559 $lang->userTimeAndDate( $this->page
->getTimestamp(), $user ),
561 [ 'oldid' => $this->page
->getLatest() ]
566 // Total number of edits
567 $pageInfo['header-edits'][] = [
568 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
571 // Total number of distinct authors
572 if ( $pageCounts['authors'] > 0 ) {
573 $pageInfo['header-edits'][] = [
574 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
578 // Recent number of edits (within past 30 days)
579 $pageInfo['header-edits'][] = [
580 $this->msg( 'pageinfo-recent-edits',
581 $lang->formatDuration( $config->get( 'RCMaxAge' ) ) ),
582 $lang->formatNum( $pageCounts['recent_edits'] )
585 // Recent number of distinct authors
586 $pageInfo['header-edits'][] = [
587 $this->msg( 'pageinfo-recent-authors' ),
588 $lang->formatNum( $pageCounts['recent_authors'] )
591 // Array of MagicWord objects
592 $magicWords = MagicWord
::getDoubleUnderscoreArray();
594 // Array of magic word IDs
595 $wordIDs = $magicWords->names
;
597 // Array of IDs => localized magic words
598 $localizedWords = $wgContLang->getMagicWords();
601 foreach ( $pageProperties as $property => $value ) {
602 if ( in_array( $property, $wordIDs ) ) {
603 $listItems[] = Html
::element( 'li', [], $localizedWords[$property][1] );
607 $localizedList = Html
::rawElement( 'ul', [], implode( '', $listItems ) );
608 $hiddenCategories = $this->page
->getHiddenCategories();
611 count( $listItems ) > 0 ||
612 count( $hiddenCategories ) > 0 ||
613 $pageCounts['transclusion']['from'] > 0 ||
614 $pageCounts['transclusion']['to'] > 0
616 $options = [ 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) ];
617 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
618 if ( $config->get( 'MiserMode' ) ) {
619 $transcludedTargets = [];
621 $transcludedTargets = $title->getTemplateLinksTo( $options );
625 $pageInfo['header-properties'] = [];
628 if ( count( $listItems ) > 0 ) {
629 $pageInfo['header-properties'][] = [
630 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
636 if ( count( $hiddenCategories ) > 0 ) {
637 $pageInfo['header-properties'][] = [
638 $this->msg( 'pageinfo-hidden-categories' )
639 ->numParams( count( $hiddenCategories ) ),
640 Linker
::formatHiddenCategories( $hiddenCategories )
644 // Transcluded templates
645 if ( $pageCounts['transclusion']['from'] > 0 ) {
646 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
647 $more = $this->msg( 'morenotlisted' )->escaped();
652 $templateListFormatter = new TemplatesOnThisPageFormatter(
657 $pageInfo['header-properties'][] = [
658 $this->msg( 'pageinfo-templates' )
659 ->numParams( $pageCounts['transclusion']['from'] ),
660 $templateListFormatter->format( $transcludedTemplates, false, $more )
664 if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
665 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
666 $more = $linkRenderer->makeLink(
668 $this->msg( 'moredotdotdot' )->text(),
670 [ 'hidelinks' => 1, 'hideredirs' => 1 ]
676 $templateListFormatter = new TemplatesOnThisPageFormatter(
681 $pageInfo['header-properties'][] = [
682 $this->msg( 'pageinfo-transclusions' )
683 ->numParams( $pageCounts['transclusion']['to'] ),
684 $templateListFormatter->format( $transcludedTargets, false, $more )
693 * Returns page counts that would be too "expensive" to retrieve by normal means.
695 * @param WikiPage|Article|Page $page
698 protected function pageCounts( Page
$page ) {
700 $config = $this->context
->getConfig();
701 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
703 return $cache->getWithSetCallback(
704 self
::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
705 WANObjectCache
::TTL_WEEK
,
706 function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
707 $title = $page->getTitle();
708 $id = $title->getArticleID();
710 $dbr = wfGetDB( DB_REPLICA
);
711 $dbrWatchlist = wfGetDB( DB_REPLICA
, 'watchlist' );
712 $setOpts +
= Database
::getCacheSetOptions( $dbr, $dbrWatchlist );
714 $watchedItemStore = MediaWikiServices
::getInstance()->getWatchedItemStore();
717 $result['watchers'] = $watchedItemStore->countWatchers( $title );
719 if ( $config->get( 'ShowUpdatedMarker' ) ) {
720 $updated = wfTimestamp( TS_UNIX
, $page->getTimestamp() );
721 $result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
723 $updated - $config->get( 'WatchersMaxAge' )
727 // Total number of edits
728 $edits = (int)$dbr->selectField(
731 [ 'rev_page' => $id ],
734 $result['edits'] = $edits;
736 // Total number of distinct authors
737 if ( $config->get( 'MiserMode' ) ) {
738 $result['authors'] = 0;
740 $result['authors'] = (int)$dbr->selectField(
742 'COUNT(DISTINCT rev_user_text)',
743 [ 'rev_page' => $id ],
748 // "Recent" threshold defined by RCMaxAge setting
749 $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
751 // Recent number of edits
752 $edits = (int)$dbr->selectField(
757 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
761 $result['recent_edits'] = $edits;
763 // Recent number of distinct authors
764 $result['recent_authors'] = (int)$dbr->selectField(
766 'COUNT(DISTINCT rev_user_text)',
769 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
774 // Subpages (if enabled)
775 if ( MWNamespace
::hasSubpages( $title->getNamespace() ) ) {
776 $conds = [ 'page_namespace' => $title->getNamespace() ];
777 $conds[] = 'page_title ' .
778 $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
780 // Subpages of this page (redirects)
781 $conds['page_is_redirect'] = 1;
782 $result['subpages']['redirects'] = (int)$dbr->selectField(
789 // Subpages of this page (non-redirects)
790 $conds['page_is_redirect'] = 0;
791 $result['subpages']['nonredirects'] = (int)$dbr->selectField(
798 // Subpages of this page (total)
799 $result['subpages']['total'] = $result['subpages']['redirects']
800 +
$result['subpages']['nonredirects'];
803 // Counts for the number of transclusion links (to/from)
804 if ( $config->get( 'MiserMode' ) ) {
805 $result['transclusion']['to'] = 0;
807 $result['transclusion']['to'] = (int)$dbr->selectField(
811 'tl_namespace' => $title->getNamespace(),
812 'tl_title' => $title->getDBkey()
818 $result['transclusion']['from'] = (int)$dbr->selectField(
821 [ 'tl_from' => $title->getArticleID() ],
831 * Returns the name that goes in the "<h1>" page title.
835 protected function getPageTitle() {
836 return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
840 * Get a list of contributors of $article
841 * @return string Html
843 protected function getContributors() {
844 $contributors = $this->page
->getContributors();
848 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
850 # Sift for real versus user names
851 /** @var $user User */
852 foreach ( $contributors as $user ) {
853 $page = $user->isAnon()
854 ? SpecialPage
::getTitleFor( 'Contributions', $user->getName() )
855 : $user->getUserPage();
857 $hiddenPrefs = $this->context
->getConfig()->get( 'HiddenPrefs' );
858 if ( $user->getId() == 0 ) {
859 $anon_ips[] = $linkRenderer->makeLink( $page, $user->getName() );
860 } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
861 $real_names[] = $linkRenderer->makeLink( $page, $user->getRealName() );
863 $user_names[] = $linkRenderer->makeLink( $page, $user->getName() );
867 $lang = $this->getLanguage();
869 $real = $lang->listToText( $real_names );
871 # "ThisSite user(s) A, B and C"
872 if ( count( $user_names ) ) {
873 $user = $this->msg( 'siteusers' )
874 ->rawParams( $lang->listToText( $user_names ) )
875 ->params( count( $user_names ) )->escaped();
880 if ( count( $anon_ips ) ) {
881 $anon = $this->msg( 'anonusers' )
882 ->rawParams( $lang->listToText( $anon_ips ) )
883 ->params( count( $anon_ips ) )->escaped();
888 # This is the big list, all mooshed together. We sift for blank strings
890 foreach ( [ $real, $user, $anon ] as $s ) {
892 array_push( $fulllist, $s );
896 $count = count( $fulllist );
898 # "Based on work by ..."
900 ?
$this->msg( 'othercontribs' )->rawParams(
901 $lang->listToText( $fulllist ) )->params( $count )->escaped()
906 * Returns the description that goes below the "<h1>" tag.
910 protected function getDescription() {
915 * @param WANObjectCache $cache
916 * @param Title $title
920 protected static function getCacheKey( WANObjectCache
$cache, Title
$title, $revId ) {
921 return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self
::VERSION
);