ebedde3003bbf546529adb3b4bdd19eb32473c07
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
1 <?php
2 /**
3 * Displays information about a page.
4 *
5 * Copyright © 2011 Alexandre Emsenhuber
6 *
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.
11 *
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.
16 *
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
20 *
21 * @file
22 * @ingroup Actions
23 */
24
25 class InfoAction extends FormlessAction {
26 /**
27 * Returns the name of the action this object responds to.
28 *
29 * @return string lowercase
30 */
31 public function getName() {
32 return 'info';
33 }
34
35 /**
36 * Whether this action can still be executed by a blocked user.
37 *
38 * @return bool
39 */
40 public function requiresUnblock() {
41 return false;
42 }
43
44 /**
45 * Whether this action requires the wiki not to be locked.
46 *
47 * @return bool
48 */
49 public function requiresWrite() {
50 return false;
51 }
52
53 /**
54 * Shows page information on GET request.
55 *
56 * @return string Page information that will be added to the output
57 */
58 public function onView() {
59 $content = '';
60
61 // Validate revision
62 $oldid = $this->page->getOldID();
63 if ( $oldid ) {
64 $revision = $this->page->getRevisionFetched();
65
66 // Revision is missing
67 if ( $revision === null ) {
68 return $this->msg( 'missing-revision', $oldid )->parse();
69 }
70
71 // Revision is not current
72 if ( !$revision->isCurrent() ) {
73 return $this->msg( 'pageinfo-not-current' )->plain();
74 }
75 }
76
77 // Page header
78 if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
79 $content .= $this->msg( 'pageinfo-header' )->parse();
80 }
81
82 // Hide "This page is a member of # hidden categories" explanation
83 $content .= Html::element( 'style', array(),
84 '.mw-hiddenCategoriesExplanation { display: none; }' );
85
86 // Hide "Templates used on this page" explanation
87 $content .= Html::element( 'style', array(),
88 '.mw-templatesUsedExplanation { display: none; }' );
89
90 // Get page information
91 $pageInfo = $this->pageInfo();
92
93 // Allow extensions to add additional information
94 wfRunHooks( 'InfoAction', array( $this->getContext(), &$pageInfo ) );
95
96 // Render page information
97 foreach ( $pageInfo as $header => $infoTable ) {
98 $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() );
99 $table = '';
100 foreach ( $infoTable as $infoRow ) {
101 $name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
102 $value = ( $infoRow[1] instanceof Message ) ? $infoRow[1]->escaped() : $infoRow[1];
103 $table = $this->addRow( $table, $name, $value );
104 }
105 $content = $this->addTable( $content, $table );
106 }
107
108 // Page footer
109 if ( !$this->msg( 'pageinfo-footer' )->isDisabled() ) {
110 $content .= $this->msg( 'pageinfo-footer' )->parse();
111 }
112
113 // Page credits
114 /*if ( $this->page->exists() ) {
115 $content .= Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $this->getContributors() );
116 }*/
117
118 return $content;
119 }
120
121 /**
122 * Creates a header that can be added to the output.
123 *
124 * @param $header The header text.
125 * @return string The HTML.
126 */
127 protected function makeHeader( $header ) {
128 $spanAttribs = array( 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) );
129 return Html::rawElement( 'h2', array(), Html::element( 'span', $spanAttribs, $header ) );
130 }
131
132 /**
133 * Adds a row to a table that will be added to the content.
134 *
135 * @param $table string The table that will be added to the content
136 * @param $name string The name of the row
137 * @param $value string The value of the row
138 * @return string The table with the row added
139 */
140 protected function addRow( $table, $name, $value ) {
141 return $table . Html::rawElement( 'tr', array(),
142 Html::rawElement( 'td', array( 'style' => 'vertical-align: top;' ), $name ) .
143 Html::rawElement( 'td', array(), $value )
144 );
145 }
146
147 /**
148 * Adds a table to the content that will be added to the output.
149 *
150 * @param $content string The content that will be added to the output
151 * @param $table string The table
152 * @return string The content with the table added
153 */
154 protected function addTable( $content, $table ) {
155 return $content . Html::rawElement( 'table', array( 'class' => 'wikitable mw-page-info' ),
156 $table );
157 }
158
159 /**
160 * Returns page information in an easily-manipulated format. Array keys are used so extensions
161 * may add additional information in arbitrary positions. Array values are arrays with one
162 * element to be rendered as a header, arrays with two elements to be rendered as a table row.
163 *
164 * @return array
165 */
166 protected function pageInfo() {
167 global $wgContLang, $wgRCMaxAge, $wgMemc, $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit;
168
169 $user = $this->getUser();
170 $lang = $this->getLanguage();
171 $title = $this->getTitle();
172 $id = $title->getArticleID();
173
174 $memcKey = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $this->page->getLatest() );
175 $pageCounts = $wgMemc->get( $memcKey );
176 if ( $pageCounts === false ) {
177 // Get page information that would be too "expensive" to retrieve by normal means
178 $pageCounts = self::pageCounts( $title );
179
180 $wgMemc->set( $memcKey, $pageCounts );
181 }
182
183 // Get page properties
184 $dbr = wfGetDB( DB_SLAVE );
185 $result = $dbr->select(
186 'page_props',
187 array( 'pp_propname', 'pp_value' ),
188 array( 'pp_page' => $id ),
189 __METHOD__
190 );
191
192 $pageProperties = array();
193 foreach ( $result as $row ) {
194 $pageProperties[$row->pp_propname] = $row->pp_value;
195 }
196
197 // Basic information
198 $pageInfo = array();
199 $pageInfo['header-basic'] = array();
200
201 // Display title
202 $displayTitle = $title->getPrefixedText();
203 if ( !empty( $pageProperties['displaytitle'] ) ) {
204 $displayTitle = $pageProperties['displaytitle'];
205 }
206
207 $pageInfo['header-basic'][] = array(
208 $this->msg( 'pageinfo-display-title' ), $displayTitle
209 );
210
211 // Is it a redirect? If so, where to?
212 if ( $title->isRedirect() ) {
213 $pageInfo['header-basic'][] = array(
214 $this->msg( 'pageinfo-redirectsto' ),
215 Linker::link( $this->page->getRedirectTarget() ) .
216 $this->msg( 'word-separator' )->text() .
217 $this->msg( 'parentheses', Linker::link(
218 $this->page->getRedirectTarget(),
219 $this->msg( 'pageinfo-redirectsto-info' )->escaped(),
220 array(),
221 array( 'action' => 'info' )
222 ) )->text()
223 );
224 }
225
226 // Default sort key
227 $sortKey = $title->getCategorySortKey();
228 if ( !empty( $pageProperties['defaultsort'] ) ) {
229 $sortKey = $pageProperties['defaultsort'];
230 }
231
232 $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-default-sort' ), $sortKey );
233
234 // Page length (in bytes)
235 $pageInfo['header-basic'][] = array(
236 $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
237 );
238
239 // Page ID (number not localised, as it's a database ID)
240 $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-article-id' ), $id );
241
242 // Language in which the page content is (supposed to be) written
243 $pageLang = $title->getPageLanguage()->getCode();
244 $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-language' ),
245 Language::fetchLanguageName( $pageLang, $lang->getCode() )
246 . ' ' . $this->msg( 'parentheses', $pageLang ) );
247
248 // Search engine status
249 $pOutput = new ParserOutput();
250 if ( isset( $pageProperties['noindex'] ) ) {
251 $pOutput->setIndexPolicy( 'noindex' );
252 }
253
254 // Use robot policy logic
255 $policy = $this->page->getRobotPolicy( 'view', $pOutput );
256 $pageInfo['header-basic'][] = array(
257 $this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" )
258 );
259
260 if ( isset( $pageCounts['views'] ) ) {
261 // Number of views
262 $pageInfo['header-basic'][] = array(
263 $this->msg( 'pageinfo-views' ), $lang->formatNum( $pageCounts['views'] )
264 );
265 }
266
267 if (
268 $user->isAllowed( 'unwatchedpages' ) ||
269 ( $wgUnwatchedPageThreshold !== false &&
270 $pageCounts['watchers'] >= $wgUnwatchedPageThreshold )
271 ) {
272 // Number of page watchers
273 $pageInfo['header-basic'][] = array(
274 $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] )
275 );
276 } elseif ( $wgUnwatchedPageThreshold !== false ) {
277 $pageInfo['header-basic'][] = array(
278 $this->msg( 'pageinfo-watchers' ),
279 $this->msg( 'pageinfo-few-watchers' )->numParams( $wgUnwatchedPageThreshold )
280 );
281 }
282
283 // Redirects to this page
284 $whatLinksHere = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
285 $pageInfo['header-basic'][] = array(
286 Linker::link(
287 $whatLinksHere,
288 $this->msg( 'pageinfo-redirects-name' )->escaped(),
289 array(),
290 array( 'hidelinks' => 1, 'hidetrans' => 1 )
291 ),
292 $this->msg( 'pageinfo-redirects-value' )
293 ->numParams( count( $title->getRedirectsHere() ) )
294 );
295
296 // Is it counted as a content page?
297 if ( $this->page->isCountable() ) {
298 $pageInfo['header-basic'][] = array(
299 $this->msg( 'pageinfo-contentpage' ),
300 $this->msg( 'pageinfo-contentpage-yes' )
301 );
302 }
303
304 // Subpages of this page, if subpages are enabled for the current NS
305 if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
306 $prefixIndex = SpecialPage::getTitleFor( 'Prefixindex', $title->getPrefixedText() . '/' );
307 $pageInfo['header-basic'][] = array(
308 Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
309 $this->msg( 'pageinfo-subpages-value' )
310 ->numParams(
311 $pageCounts['subpages']['total'],
312 $pageCounts['subpages']['redirects'],
313 $pageCounts['subpages']['nonredirects'] )
314 );
315 }
316
317 if ( $title->inNamespace( NS_CATEGORY ) ) {
318 $category = Category::newFromTitle( $title );
319 $pageInfo['category-info'] = array(
320 array(
321 $this->msg( 'pageinfo-category-pages' ),
322 $lang->formatNum( $category->getPageCount() )
323 ),
324 array(
325 $this->msg( 'pageinfo-category-subcats' ),
326 $lang->formatNum( $category->getSubcatCount() )
327 ),
328 array(
329 $this->msg( 'pageinfo-category-files' ),
330 $lang->formatNum( $category->getFileCount() )
331 )
332 );
333 }
334
335 // Page protection
336 $pageInfo['header-restrictions'] = array();
337
338 // Is this page effected by the cascading protection of something which includes it?
339 if ( $title->isCascadeProtected() ) {
340 $cascadingFrom = '';
341 $sources = $title->getCascadeProtectionSources(); // Array deferencing is in PHP 5.4 :(
342
343 foreach ( $sources[0] as $sourceTitle ) {
344 $cascadingFrom .= Html::rawElement( 'li', array(), Linker::linkKnown( $sourceTitle ) );
345 }
346
347 $cascadingFrom = Html::rawElement( 'ul', array(), $cascadingFrom );
348 $pageInfo['header-restrictions'][] = array(
349 $this->msg( 'pageinfo-protect-cascading-from' ),
350 $cascadingFrom
351 );
352 }
353
354 // Is out protection set to cascade to other pages?
355 if ( $title->areRestrictionsCascading() ) {
356 $pageInfo['header-restrictions'][] = array(
357 $this->msg( 'pageinfo-protect-cascading' ),
358 $this->msg( 'pageinfo-protect-cascading-yes' )
359 );
360 }
361
362 // Page protection
363 foreach ( $title->getRestrictionTypes() as $restrictionType ) {
364 $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
365
366 if ( $protectionLevel == '' ) {
367 // Allow all users
368 $message = $this->msg( 'protect-default' )->escaped();
369 } else {
370 // Administrators only
371 $message = $this->msg( "protect-level-$protectionLevel" );
372 if ( $message->isDisabled() ) {
373 // Require "$1" permission
374 $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
375 } else {
376 $message = $message->escaped();
377 }
378 }
379
380 $pageInfo['header-restrictions'][] = array(
381 $this->msg( "restriction-$restrictionType" ), $message
382 );
383 }
384
385 if ( !$this->page->exists() ) {
386 return $pageInfo;
387 }
388
389 // Edit history
390 $pageInfo['header-edits'] = array();
391
392 $firstRev = $this->page->getOldestRevision();
393 $lastRev = $this->page->getRevision();
394 $batch = new LinkBatch;
395
396 $firstRevUser = $firstRev->getUserText( Revision::FOR_THIS_USER );
397 if ( $firstRevUser !== '' ) {
398 $batch->add( NS_USER, $firstRevUser );
399 $batch->add( NS_USER_TALK, $firstRevUser );
400 }
401
402 $lastRevUser = $lastRev->getUserText( Revision::FOR_THIS_USER );
403 if ( $lastRevUser !== '' ) {
404 $batch->add( NS_USER, $lastRevUser );
405 $batch->add( NS_USER_TALK, $lastRevUser );
406 }
407
408 $batch->execute();
409
410 // Page creator
411 $pageInfo['header-edits'][] = array(
412 $this->msg( 'pageinfo-firstuser' ),
413 Linker::revUserTools( $firstRev )
414 );
415
416 // Date of page creation
417 $pageInfo['header-edits'][] = array(
418 $this->msg( 'pageinfo-firsttime' ),
419 Linker::linkKnown(
420 $title,
421 $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
422 array(),
423 array( 'oldid' => $firstRev->getId() )
424 )
425 );
426
427 // Latest editor
428 $pageInfo['header-edits'][] = array(
429 $this->msg( 'pageinfo-lastuser' ),
430 Linker::revUserTools( $lastRev )
431 );
432
433 // Date of latest edit
434 $pageInfo['header-edits'][] = array(
435 $this->msg( 'pageinfo-lasttime' ),
436 Linker::linkKnown(
437 $title,
438 $lang->userTimeAndDate( $this->page->getTimestamp(), $user ),
439 array(),
440 array( 'oldid' => $this->page->getLatest() )
441 )
442 );
443
444 // Total number of edits
445 $pageInfo['header-edits'][] = array(
446 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
447 );
448
449 // Total number of distinct authors
450 $pageInfo['header-edits'][] = array(
451 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
452 );
453
454 // Recent number of edits (within past 30 days)
455 $pageInfo['header-edits'][] = array(
456 $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $wgRCMaxAge ) ),
457 $lang->formatNum( $pageCounts['recent_edits'] )
458 );
459
460 // Recent number of distinct authors
461 $pageInfo['header-edits'][] = array(
462 $this->msg( 'pageinfo-recent-authors' ), $lang->formatNum( $pageCounts['recent_authors'] )
463 );
464
465 // Array of MagicWord objects
466 $magicWords = MagicWord::getDoubleUnderscoreArray();
467
468 // Array of magic word IDs
469 $wordIDs = $magicWords->names;
470
471 // Array of IDs => localized magic words
472 $localizedWords = $wgContLang->getMagicWords();
473
474 $listItems = array();
475 foreach ( $pageProperties as $property => $value ) {
476 if ( in_array( $property, $wordIDs ) ) {
477 $listItems[] = Html::element( 'li', array(), $localizedWords[$property][1] );
478 }
479 }
480
481 $localizedList = Html::rawElement( 'ul', array(), implode( '', $listItems ) );
482 $hiddenCategories = $this->page->getHiddenCategories();
483
484 if (
485 count( $listItems ) > 0 ||
486 count( $hiddenCategories ) > 0 ||
487 $pageCounts['transclusion']['from'] > 0 ||
488 $pageCounts['transclusion']['to'] > 0
489 ) {
490 $options = array( 'LIMIT' => $wgPageInfoTransclusionLimit );
491 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
492 $transcludedTargets = $title->getTemplateLinksTo( $options );
493
494 // Page properties
495 $pageInfo['header-properties'] = array();
496
497 // Magic words
498 if ( count( $listItems ) > 0 ) {
499 $pageInfo['header-properties'][] = array(
500 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
501 $localizedList
502 );
503 }
504
505 // Hidden categories
506 if ( count( $hiddenCategories ) > 0 ) {
507 $pageInfo['header-properties'][] = array(
508 $this->msg( 'pageinfo-hidden-categories' )
509 ->numParams( count( $hiddenCategories ) ),
510 Linker::formatHiddenCategories( $hiddenCategories )
511 );
512 }
513
514 // Transcluded templates
515 if ( $pageCounts['transclusion']['from'] > 0 ) {
516 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
517 $more = $this->msg( 'morenotlisted' )->escaped();
518 } else {
519 $more = null;
520 }
521
522 $pageInfo['header-properties'][] = array(
523 $this->msg( 'pageinfo-templates' )
524 ->numParams( $pageCounts['transclusion']['from'] ),
525 Linker::formatTemplates(
526 $transcludedTemplates,
527 false,
528 false,
529 $more )
530 );
531 }
532
533 if ( $pageCounts['transclusion']['to'] > 0 ) {
534 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
535 $more = Linker::link(
536 $whatLinksHere,
537 $this->msg( 'moredotdotdot' )->escaped(),
538 array(),
539 array( 'hidelinks' => 1, 'hideredirs' => 1 )
540 );
541 } else {
542 $more = null;
543 }
544
545 $pageInfo['header-properties'][] = array(
546 $this->msg( 'pageinfo-transclusions' )
547 ->numParams( $pageCounts['transclusion']['to'] ),
548 Linker::formatTemplates(
549 $transcludedTargets,
550 false,
551 false,
552 $more )
553 );
554 }
555 }
556
557 return $pageInfo;
558 }
559
560 /**
561 * Returns page counts that would be too "expensive" to retrieve by normal means.
562 *
563 * @param Title $title Title to get counts for
564 * @return array
565 */
566 protected static function pageCounts( Title $title ) {
567 global $wgRCMaxAge, $wgDisableCounters;
568
569 wfProfileIn( __METHOD__ );
570 $id = $title->getArticleID();
571
572 $dbr = wfGetDB( DB_SLAVE );
573 $result = array();
574
575 if ( !$wgDisableCounters ) {
576 // Number of views
577 $views = (int) $dbr->selectField(
578 'page',
579 'page_counter',
580 array( 'page_id' => $id ),
581 __METHOD__
582 );
583 $result['views'] = $views;
584 }
585
586 // Number of page watchers
587 $watchers = (int) $dbr->selectField(
588 'watchlist',
589 'COUNT(*)',
590 array(
591 'wl_namespace' => $title->getNamespace(),
592 'wl_title' => $title->getDBkey(),
593 ),
594 __METHOD__
595 );
596 $result['watchers'] = $watchers;
597
598 // Total number of edits
599 $edits = (int) $dbr->selectField(
600 'revision',
601 'COUNT(rev_page)',
602 array( 'rev_page' => $id ),
603 __METHOD__
604 );
605 $result['edits'] = $edits;
606
607 // Total number of distinct authors
608 $authors = (int) $dbr->selectField(
609 'revision',
610 'COUNT(DISTINCT rev_user_text)',
611 array( 'rev_page' => $id ),
612 __METHOD__
613 );
614 $result['authors'] = $authors;
615
616 // "Recent" threshold defined by $wgRCMaxAge
617 $threshold = $dbr->timestamp( time() - $wgRCMaxAge );
618
619 // Recent number of edits
620 $edits = (int) $dbr->selectField(
621 'revision',
622 'COUNT(rev_page)',
623 array(
624 'rev_page' => $id,
625 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
626 ),
627 __METHOD__
628 );
629 $result['recent_edits'] = $edits;
630
631 // Recent number of distinct authors
632 $authors = (int) $dbr->selectField(
633 'revision',
634 'COUNT(DISTINCT rev_user_text)',
635 array(
636 'rev_page' => $id,
637 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
638 ),
639 __METHOD__
640 );
641 $result['recent_authors'] = $authors;
642
643 // Subpages (if enabled)
644 if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
645 $conds = array( 'page_namespace' => $title->getNamespace() );
646 $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
647
648 // Subpages of this page (redirects)
649 $conds['page_is_redirect'] = 1;
650 $result['subpages']['redirects'] = (int) $dbr->selectField(
651 'page',
652 'COUNT(page_id)',
653 $conds,
654 __METHOD__ );
655
656 // Subpages of this page (non-redirects)
657 $conds['page_is_redirect'] = 0;
658 $result['subpages']['nonredirects'] = (int) $dbr->selectField(
659 'page',
660 'COUNT(page_id)',
661 $conds,
662 __METHOD__
663 );
664
665 // Subpages of this page (total)
666 $result['subpages']['total'] = $result['subpages']['redirects']
667 + $result['subpages']['nonredirects'];
668 }
669
670 // Counts for the number of transclusion links (to/from)
671 $result['transclusion']['to'] = (int) $dbr->selectField(
672 'templatelinks',
673 'COUNT(tl_from)',
674 array(
675 'tl_namespace' => $title->getNamespace(),
676 'tl_title' => $title->getDBkey()
677 ),
678 __METHOD__
679 );
680
681 $result['transclusion']['from'] = (int) $dbr->selectField(
682 'templatelinks',
683 'COUNT(*)',
684 array( 'tl_from' => $title->getArticleID() ),
685 __METHOD__
686 );
687
688 wfProfileOut( __METHOD__ );
689 return $result;
690 }
691
692 /**
693 * Returns the name that goes in the "<h1>" page title.
694 *
695 * @return string
696 */
697 protected function getPageTitle() {
698 return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
699 }
700
701 /**
702 * Get a list of contributors of $article
703 * @return string: html
704 */
705 protected function getContributors() {
706 global $wgHiddenPrefs;
707
708 $contributors = $this->page->getContributors();
709 $real_names = array();
710 $user_names = array();
711 $anon_ips = array();
712
713 # Sift for real versus user names
714 foreach ( $contributors as $user ) {
715 $page = $user->isAnon()
716 ? SpecialPage::getTitleFor( 'Contributions', $user->getName() )
717 : $user->getUserPage();
718
719 if ( $user->getID() == 0 ) {
720 $anon_ips[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
721 } elseif ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
722 $real_names[] = Linker::link( $page, htmlspecialchars( $user->getRealName() ) );
723 } else {
724 $user_names[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
725 }
726 }
727
728 $lang = $this->getLanguage();
729
730 $real = $lang->listToText( $real_names );
731
732 # "ThisSite user(s) A, B and C"
733 if ( count( $user_names ) ) {
734 $user = $this->msg( 'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
735 count( $user_names ) )->escaped();
736 } else {
737 $user = false;
738 }
739
740 if ( count( $anon_ips ) ) {
741 $anon = $this->msg( 'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
742 count( $anon_ips ) )->escaped();
743 } else {
744 $anon = false;
745 }
746
747 # This is the big list, all mooshed together. We sift for blank strings
748 $fulllist = array();
749 foreach ( array( $real, $user, $anon ) as $s ) {
750 if ( $s !== '' ) {
751 array_push( $fulllist, $s );
752 }
753 }
754
755 $count = count( $fulllist );
756 # "Based on work by ..."
757 return $count
758 ? $this->msg( 'othercontribs' )->rawParams(
759 $lang->listToText( $fulllist ) )->params( $count )->escaped()
760 : '';
761 }
762
763 /**
764 * Returns the description that goes below the "<h1>" tag.
765 *
766 * @return string
767 */
768 protected function getDescription() {
769 return '';
770 }
771 }