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
26 * Displays information about a page.
30 class InfoAction
extends FormlessAction
{
31 const CACHE_VERSION
= '2013-03-17';
34 * Returns the name of the action this object responds to.
36 * @return string Lowercase name
38 public function getName() {
43 * Whether this action can still be executed by a blocked user.
47 public function requiresUnblock() {
52 * Whether this action requires the wiki not to be locked.
56 public function requiresWrite() {
61 * Clear the info cache for a given Title.
64 * @param Title $title Title to clear cache for
65 * @param int|null $revid Revision id to clear
67 public static function invalidateCache( Title
$title, $revid = null ) {
68 $cache = ObjectCache
::getMainWANInstance();
71 $revision = Revision
::newFromTitle( $title, 0, Revision
::READ_LATEST
);
72 $revid = $revision ?
$revision->getId() : null;
74 if ( $revid !== null ) {
75 $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revid );
76 $cache->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', array(),
111 '.mw-hiddenCategoriesExplanation { display: none; }' ) . "\n";
113 // Hide "Templates used on this page" explanation
114 $content .= Html
::element( 'style', array(),
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', array( $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();
145 /*if ( $this->page->exists() ) {
146 $content .= Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $this->getContributors() );
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 ) {
159 $spanAttribs = array( 'class' => 'mw-headline', 'id' => Sanitizer
::escapeId( $header ) );
161 return Html
::rawElement( 'h2', array(), Html
::element( 'span', $spanAttribs, $header ) );
165 * Adds a row to a table that will be added to the content.
167 * @param string $table The table that will be added to the content
168 * @param string $name The name of the row
169 * @param string $value The value of the row
170 * @param string $id The ID to use for the 'tr' element
171 * @return string The table with the row added
173 protected function addRow( $table, $name, $value, $id ) {
174 return $table . Html
::rawElement( 'tr', $id === null ?
array() : array( 'id' => 'mw-' . $id ),
175 Html
::rawElement( 'td', array( 'style' => 'vertical-align: top;' ), $name ) .
176 Html
::rawElement( 'td', array(), $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', array( '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();
208 $cache = ObjectCache
::getMainWANInstance();
209 $memcKey = wfMemcKey( 'infoaction',
210 sha1( $title->getPrefixedText() ), $this->page
->getLatest() );
211 $pageCounts = $cache->get( $memcKey );
212 $version = isset( $pageCounts['cacheversion'] ) ?
$pageCounts['cacheversion'] : false;
213 if ( $pageCounts === false ||
$version !== self
::CACHE_VERSION
) {
214 // Get page information that would be too "expensive" to retrieve by normal means
215 $pageCounts = $this->pageCounts( $title );
216 $pageCounts['cacheversion'] = self
::CACHE_VERSION
;
218 $cache->set( $memcKey, $pageCounts );
221 // Get page properties
222 $dbr = wfGetDB( DB_SLAVE
);
223 $result = $dbr->select(
225 array( 'pp_propname', 'pp_value' ),
226 array( 'pp_page' => $id ),
230 $pageProperties = array();
231 foreach ( $result as $row ) {
232 $pageProperties[$row->pp_propname
] = $row->pp_value
;
237 $pageInfo['header-basic'] = array();
240 $displayTitle = $title->getPrefixedText();
241 if ( isset( $pageProperties['displaytitle'] ) ) {
242 $displayTitle = $pageProperties['displaytitle'];
245 $pageInfo['header-basic'][] = array(
246 $this->msg( 'pageinfo-display-title' ), $displayTitle
249 // Is it a redirect? If so, where to?
250 if ( $title->isRedirect() ) {
251 $pageInfo['header-basic'][] = array(
252 $this->msg( 'pageinfo-redirectsto' ),
253 Linker
::link( $this->page
->getRedirectTarget() ) .
254 $this->msg( 'word-separator' )->escaped() .
255 $this->msg( 'parentheses' )->rawParams( Linker
::link(
256 $this->page
->getRedirectTarget(),
257 $this->msg( 'pageinfo-redirectsto-info' )->escaped(),
259 array( 'action' => 'info' )
265 $sortKey = $title->getCategorySortkey();
266 if ( isset( $pageProperties['defaultsort'] ) ) {
267 $sortKey = $pageProperties['defaultsort'];
270 $sortKey = htmlspecialchars( $sortKey );
271 $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-default-sort' ), $sortKey );
273 // Page length (in bytes)
274 $pageInfo['header-basic'][] = array(
275 $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
278 // Page ID (number not localised, as it's a database ID)
279 $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-article-id' ), $id );
281 // Language in which the page content is (supposed to be) written
282 $pageLang = $title->getPageLanguage()->getCode();
284 if ( $config->get( 'PageLanguageUseDB' )
285 && $this->getTitle()->userCan( 'pagelang', $this->getUser() )
287 // Link to Special:PageLanguage with pre-filled page title if user has permissions
288 $titleObj = SpecialPage
::getTitleFor( 'PageLanguage', $title->getPrefixedText() );
289 $langDisp = Linker
::link(
291 $this->msg( 'pageinfo-language' )->escaped()
294 // Display just the message
295 $langDisp = $this->msg( 'pageinfo-language' )->escaped();
298 $pageInfo['header-basic'][] = array( $langDisp,
299 Language
::fetchLanguageName( $pageLang, $lang->getCode() )
300 . ' ' . $this->msg( 'parentheses', $pageLang )->escaped() );
302 // Content model of the page
303 $pageInfo['header-basic'][] = array(
304 $this->msg( 'pageinfo-content-model' ),
305 htmlspecialchars( ContentHandler
::getLocalizedName( $title->getContentModel() ) )
308 // Search engine status
309 $pOutput = new ParserOutput();
310 if ( isset( $pageProperties['noindex'] ) ) {
311 $pOutput->setIndexPolicy( 'noindex' );
313 if ( isset( $pageProperties['index'] ) ) {
314 $pOutput->setIndexPolicy( 'index' );
317 // Use robot policy logic
318 $policy = $this->page
->getRobotPolicy( 'view', $pOutput );
319 $pageInfo['header-basic'][] = array(
320 // Messages: pageinfo-robot-index, pageinfo-robot-noindex
321 $this->msg( 'pageinfo-robot-policy' ), $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'][] = array(
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'][] = array(
343 $this->msg( 'pageinfo-visiting-watchers' ),
344 $lang->formatNum( $pageCounts['visitingWatchers'] )
347 $pageInfo['header-basic'][] = array(
348 $this->msg( 'pageinfo-visiting-watchers' ),
349 $this->msg( 'pageinfo-few-visiting-watchers' )
353 } elseif ( $unwatchedPageThreshold !== false ) {
354 $pageInfo['header-basic'][] = array(
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'][] = array(
365 $this->msg( 'pageinfo-redirects-name' )->escaped(),
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'][] = array(
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( 'Prefixindex', $title->getPrefixedText() . '/' );
388 $pageInfo['header-basic'][] = array(
389 Linker
::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
390 $this->msg( 'pageinfo-subpages-value' )
392 $pageCounts['subpages']['total'],
393 $pageCounts['subpages']['redirects'],
394 $pageCounts['subpages']['nonredirects'] )
398 if ( $title->inNamespace( NS_CATEGORY
) ) {
399 $category = Category
::newFromTitle( $title );
401 // $allCount is the total number of cat members,
402 // not the count of how many members are normal pages.
403 $allCount = (int)$category->getPageCount();
404 $subcatCount = (int)$category->getSubcatCount();
405 $fileCount = (int)$category->getFileCount();
406 $pagesCount = $allCount - $subcatCount - $fileCount;
408 $pageInfo['category-info'] = array(
410 $this->msg( 'pageinfo-category-total' ),
411 $lang->formatNum( $allCount )
414 $this->msg( 'pageinfo-category-pages' ),
415 $lang->formatNum( $pagesCount )
418 $this->msg( 'pageinfo-category-subcats' ),
419 $lang->formatNum( $subcatCount )
422 $this->msg( 'pageinfo-category-files' ),
423 $lang->formatNum( $fileCount )
429 $pageInfo['header-restrictions'] = array();
431 // Is this page affected by the cascading protection of something which includes it?
432 if ( $title->isCascadeProtected() ) {
434 $sources = $title->getCascadeProtectionSources(); // Array deferencing is in PHP 5.4 :(
436 foreach ( $sources[0] as $sourceTitle ) {
437 $cascadingFrom .= Html
::rawElement( 'li', array(), Linker
::linkKnown( $sourceTitle ) );
440 $cascadingFrom = Html
::rawElement( 'ul', array(), $cascadingFrom );
441 $pageInfo['header-restrictions'][] = array(
442 $this->msg( 'pageinfo-protect-cascading-from' ),
447 // Is out protection set to cascade to other pages?
448 if ( $title->areRestrictionsCascading() ) {
449 $pageInfo['header-restrictions'][] = array(
450 $this->msg( 'pageinfo-protect-cascading' ),
451 $this->msg( 'pageinfo-protect-cascading-yes' )
456 foreach ( $title->getRestrictionTypes() as $restrictionType ) {
457 $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
459 if ( $protectionLevel == '' ) {
461 $message = $this->msg( 'protect-default' )->escaped();
463 // Administrators only
464 // Messages: protect-level-autoconfirmed, protect-level-sysop
465 $message = $this->msg( "protect-level-$protectionLevel" );
466 if ( $message->isDisabled() ) {
467 // Require "$1" permission
468 $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
470 $message = $message->escaped();
473 $expiry = $title->getRestrictionExpiry( $restrictionType );
474 $formattedexpiry = $this->msg( 'parentheses',
475 $this->getLanguage()->formatExpiry( $expiry ) )->escaped();
476 $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
478 // Messages: restriction-edit, restriction-move, restriction-create,
479 // restriction-upload
480 $pageInfo['header-restrictions'][] = array(
481 $this->msg( "restriction-$restrictionType" ), $message
485 if ( !$this->page
->exists() ) {
490 $pageInfo['header-edits'] = array();
492 $firstRev = $this->page
->getOldestRevision();
493 $lastRev = $this->page
->getRevision();
494 $batch = new LinkBatch
;
497 $firstRevUser = $firstRev->getUserText( Revision
::FOR_THIS_USER
);
498 if ( $firstRevUser !== '' ) {
499 $batch->add( NS_USER
, $firstRevUser );
500 $batch->add( NS_USER_TALK
, $firstRevUser );
505 $lastRevUser = $lastRev->getUserText( Revision
::FOR_THIS_USER
);
506 if ( $lastRevUser !== '' ) {
507 $batch->add( NS_USER
, $lastRevUser );
508 $batch->add( NS_USER_TALK
, $lastRevUser );
516 $pageInfo['header-edits'][] = array(
517 $this->msg( 'pageinfo-firstuser' ),
518 Linker
::revUserTools( $firstRev )
521 // Date of page creation
522 $pageInfo['header-edits'][] = array(
523 $this->msg( 'pageinfo-firsttime' ),
526 htmlspecialchars( $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ) ),
528 array( 'oldid' => $firstRev->getId() )
535 $pageInfo['header-edits'][] = array(
536 $this->msg( 'pageinfo-lastuser' ),
537 Linker
::revUserTools( $lastRev )
540 // Date of latest edit
541 $pageInfo['header-edits'][] = array(
542 $this->msg( 'pageinfo-lasttime' ),
545 htmlspecialchars( $lang->userTimeAndDate( $this->page
->getTimestamp(), $user ) ),
547 array( 'oldid' => $this->page
->getLatest() )
552 // Total number of edits
553 $pageInfo['header-edits'][] = array(
554 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
557 // Total number of distinct authors
558 if ( $pageCounts['authors'] > 0 ) {
559 $pageInfo['header-edits'][] = array(
560 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
564 // Recent number of edits (within past 30 days)
565 $pageInfo['header-edits'][] = array(
566 $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $config->get( 'RCMaxAge' ) ) ),
567 $lang->formatNum( $pageCounts['recent_edits'] )
570 // Recent number of distinct authors
571 $pageInfo['header-edits'][] = array(
572 $this->msg( 'pageinfo-recent-authors' ), $lang->formatNum( $pageCounts['recent_authors'] )
575 // Array of MagicWord objects
576 $magicWords = MagicWord
::getDoubleUnderscoreArray();
578 // Array of magic word IDs
579 $wordIDs = $magicWords->names
;
581 // Array of IDs => localized magic words
582 $localizedWords = $wgContLang->getMagicWords();
584 $listItems = array();
585 foreach ( $pageProperties as $property => $value ) {
586 if ( in_array( $property, $wordIDs ) ) {
587 $listItems[] = Html
::element( 'li', array(), $localizedWords[$property][1] );
591 $localizedList = Html
::rawElement( 'ul', array(), implode( '', $listItems ) );
592 $hiddenCategories = $this->page
->getHiddenCategories();
595 count( $listItems ) > 0 ||
596 count( $hiddenCategories ) > 0 ||
597 $pageCounts['transclusion']['from'] > 0 ||
598 $pageCounts['transclusion']['to'] > 0
600 $options = array( 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) );
601 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
602 if ( $config->get( 'MiserMode' ) ) {
603 $transcludedTargets = array();
605 $transcludedTargets = $title->getTemplateLinksTo( $options );
609 $pageInfo['header-properties'] = array();
612 if ( count( $listItems ) > 0 ) {
613 $pageInfo['header-properties'][] = array(
614 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
620 if ( count( $hiddenCategories ) > 0 ) {
621 $pageInfo['header-properties'][] = array(
622 $this->msg( 'pageinfo-hidden-categories' )
623 ->numParams( count( $hiddenCategories ) ),
624 Linker
::formatHiddenCategories( $hiddenCategories )
628 // Transcluded templates
629 if ( $pageCounts['transclusion']['from'] > 0 ) {
630 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
631 $more = $this->msg( 'morenotlisted' )->escaped();
636 $pageInfo['header-properties'][] = array(
637 $this->msg( 'pageinfo-templates' )
638 ->numParams( $pageCounts['transclusion']['from'] ),
639 Linker
::formatTemplates(
640 $transcludedTemplates,
647 if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
648 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
649 $more = Linker
::link(
651 $this->msg( 'moredotdotdot' )->escaped(),
653 array( 'hidelinks' => 1, 'hideredirs' => 1 )
659 $pageInfo['header-properties'][] = array(
660 $this->msg( 'pageinfo-transclusions' )
661 ->numParams( $pageCounts['transclusion']['to'] ),
662 Linker
::formatTemplates(
675 * Returns page counts that would be too "expensive" to retrieve by normal means.
677 * @param Title $title Title to get counts for
680 protected function pageCounts( Title
$title ) {
681 $id = $title->getArticleID();
682 $config = $this->context
->getConfig();
684 $dbrWatchlist = wfGetDB( DB_SLAVE
, 'watchlist' );
687 // Number of page watchers
688 $watchers = (int)$dbrWatchlist->selectField(
692 'wl_namespace' => $title->getNamespace(),
693 'wl_title' => $title->getDBkey(),
697 $result['watchers'] = $watchers;
699 if ( $config->get( 'ShowUpdatedMarker' ) ) {
700 // Threshold: last visited about 26 weeks before latest edit
701 $updated = wfTimestamp( TS_UNIX
, $this->page
->getTimestamp() );
702 $age = $config->get( 'WatchersMaxAge' );
703 $threshold = $dbrWatchlist->timestamp( $updated - $age );
704 // Number of page watchers who also visited a "recent" edit
705 $visitingWatchers = (int)$dbrWatchlist->selectField(
709 'wl_namespace' => $title->getNamespace(),
710 'wl_title' => $title->getDBkey(),
711 'wl_notificationtimestamp >= ' . $dbrWatchlist->addQuotes( $threshold ) .
712 ' OR wl_notificationtimestamp IS NULL'
716 $result['visitingWatchers'] = $visitingWatchers;
719 $dbr = wfGetDB( DB_SLAVE
);
720 // Total number of edits
721 $edits = (int)$dbr->selectField(
724 array( '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 array( '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 = array( 'page_namespace' => $title->getNamespace() );
770 $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
772 // Subpages of this page (redirects)
773 $conds['page_is_redirect'] = 1;
774 $result['subpages']['redirects'] = (int)$dbr->selectField(
780 // Subpages of this page (non-redirects)
781 $conds['page_is_redirect'] = 0;
782 $result['subpages']['nonredirects'] = (int)$dbr->selectField(
789 // Subpages of this page (total)
790 $result['subpages']['total'] = $result['subpages']['redirects']
791 +
$result['subpages']['nonredirects'];
794 // Counts for the number of transclusion links (to/from)
795 if ( $config->get( 'MiserMode' ) ) {
796 $result['transclusion']['to'] = 0;
798 $result['transclusion']['to'] = (int)$dbr->selectField(
802 'tl_namespace' => $title->getNamespace(),
803 'tl_title' => $title->getDBkey()
809 $result['transclusion']['from'] = (int)$dbr->selectField(
812 array( '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();
834 $real_names = array();
835 $user_names = array();
838 # Sift for real versus user names
839 /** @var $user User */
840 foreach ( $contributors as $user ) {
841 $page = $user->isAnon()
842 ? SpecialPage
::getTitleFor( 'Contributions', $user->getName() )
843 : $user->getUserPage();
845 $hiddenPrefs = $this->context
->getConfig()->get( 'HiddenPrefs' );
846 if ( $user->getID() == 0 ) {
847 $anon_ips[] = Linker
::link( $page, htmlspecialchars( $user->getName() ) );
848 } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
849 $real_names[] = Linker
::link( $page, htmlspecialchars( $user->getRealName() ) );
851 $user_names[] = Linker
::link( $page, htmlspecialchars( $user->getName() ) );
855 $lang = $this->getLanguage();
857 $real = $lang->listToText( $real_names );
859 # "ThisSite user(s) A, B and C"
860 if ( count( $user_names ) ) {
861 $user = $this->msg( 'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
862 count( $user_names ) )->escaped();
867 if ( count( $anon_ips ) ) {
868 $anon = $this->msg( 'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
869 count( $anon_ips ) )->escaped();
874 # This is the big list, all mooshed together. We sift for blank strings
876 foreach ( array( $real, $user, $anon ) as $s ) {
878 array_push( $fulllist, $s );
882 $count = count( $fulllist );
884 # "Based on work by ..."
886 ?
$this->msg( 'othercontribs' )->rawParams(
887 $lang->listToText( $fulllist ) )->params( $count )->escaped()
892 * Returns the description that goes below the "<h1>" tag.
896 protected function getDescription() {