Merge "Fix more UnitTests for databases that do not use integer timestamps"
[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; }' ) . "\n";
85
86 // Hide "Templates used on this page" explanation
87 $content .= Html::element( 'style', array(),
88 '.mw-templatesUsedExplanation { display: none; }' ) . "\n";
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() ) . "\n";
99 $table = "\n";
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 ) . "\n";
104 }
105 $content = $this->addTable( $content, $table ) . "\n";
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 if ( $firstRev ) {
397 $firstRevUser = $firstRev->getUserText( Revision::FOR_THIS_USER );
398 if ( $firstRevUser !== '' ) {
399 $batch->add( NS_USER, $firstRevUser );
400 $batch->add( NS_USER_TALK, $firstRevUser );
401 }
402 }
403
404 if ( $lastRev ) {
405 $lastRevUser = $lastRev->getUserText( Revision::FOR_THIS_USER );
406 if ( $lastRevUser !== '' ) {
407 $batch->add( NS_USER, $lastRevUser );
408 $batch->add( NS_USER_TALK, $lastRevUser );
409 }
410 }
411
412 $batch->execute();
413
414 if ( $firstRev ) {
415 // Page creator
416 $pageInfo['header-edits'][] = array(
417 $this->msg( 'pageinfo-firstuser' ),
418 Linker::revUserTools( $firstRev )
419 );
420
421 // Date of page creation
422 $pageInfo['header-edits'][] = array(
423 $this->msg( 'pageinfo-firsttime' ),
424 Linker::linkKnown(
425 $title,
426 $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
427 array(),
428 array( 'oldid' => $firstRev->getId() )
429 )
430 );
431 }
432
433 if ( $lastRev ) {
434 // Latest editor
435 $pageInfo['header-edits'][] = array(
436 $this->msg( 'pageinfo-lastuser' ),
437 Linker::revUserTools( $lastRev )
438 );
439
440 // Date of latest edit
441 $pageInfo['header-edits'][] = array(
442 $this->msg( 'pageinfo-lasttime' ),
443 Linker::linkKnown(
444 $title,
445 $lang->userTimeAndDate( $this->page->getTimestamp(), $user ),
446 array(),
447 array( 'oldid' => $this->page->getLatest() )
448 )
449 );
450 }
451
452 // Total number of edits
453 $pageInfo['header-edits'][] = array(
454 $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
455 );
456
457 // Total number of distinct authors
458 $pageInfo['header-edits'][] = array(
459 $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
460 );
461
462 // Recent number of edits (within past 30 days)
463 $pageInfo['header-edits'][] = array(
464 $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $wgRCMaxAge ) ),
465 $lang->formatNum( $pageCounts['recent_edits'] )
466 );
467
468 // Recent number of distinct authors
469 $pageInfo['header-edits'][] = array(
470 $this->msg( 'pageinfo-recent-authors' ), $lang->formatNum( $pageCounts['recent_authors'] )
471 );
472
473 // Array of MagicWord objects
474 $magicWords = MagicWord::getDoubleUnderscoreArray();
475
476 // Array of magic word IDs
477 $wordIDs = $magicWords->names;
478
479 // Array of IDs => localized magic words
480 $localizedWords = $wgContLang->getMagicWords();
481
482 $listItems = array();
483 foreach ( $pageProperties as $property => $value ) {
484 if ( in_array( $property, $wordIDs ) ) {
485 $listItems[] = Html::element( 'li', array(), $localizedWords[$property][1] );
486 }
487 }
488
489 $localizedList = Html::rawElement( 'ul', array(), implode( '', $listItems ) );
490 $hiddenCategories = $this->page->getHiddenCategories();
491
492 if (
493 count( $listItems ) > 0 ||
494 count( $hiddenCategories ) > 0 ||
495 $pageCounts['transclusion']['from'] > 0 ||
496 $pageCounts['transclusion']['to'] > 0
497 ) {
498 $options = array( 'LIMIT' => $wgPageInfoTransclusionLimit );
499 $transcludedTemplates = $title->getTemplateLinksFrom( $options );
500 $transcludedTargets = $title->getTemplateLinksTo( $options );
501
502 // Page properties
503 $pageInfo['header-properties'] = array();
504
505 // Magic words
506 if ( count( $listItems ) > 0 ) {
507 $pageInfo['header-properties'][] = array(
508 $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
509 $localizedList
510 );
511 }
512
513 // Hidden categories
514 if ( count( $hiddenCategories ) > 0 ) {
515 $pageInfo['header-properties'][] = array(
516 $this->msg( 'pageinfo-hidden-categories' )
517 ->numParams( count( $hiddenCategories ) ),
518 Linker::formatHiddenCategories( $hiddenCategories )
519 );
520 }
521
522 // Transcluded templates
523 if ( $pageCounts['transclusion']['from'] > 0 ) {
524 if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
525 $more = $this->msg( 'morenotlisted' )->escaped();
526 } else {
527 $more = null;
528 }
529
530 $pageInfo['header-properties'][] = array(
531 $this->msg( 'pageinfo-templates' )
532 ->numParams( $pageCounts['transclusion']['from'] ),
533 Linker::formatTemplates(
534 $transcludedTemplates,
535 false,
536 false,
537 $more )
538 );
539 }
540
541 if ( $pageCounts['transclusion']['to'] > 0 ) {
542 if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
543 $more = Linker::link(
544 $whatLinksHere,
545 $this->msg( 'moredotdotdot' )->escaped(),
546 array(),
547 array( 'hidelinks' => 1, 'hideredirs' => 1 )
548 );
549 } else {
550 $more = null;
551 }
552
553 $pageInfo['header-properties'][] = array(
554 $this->msg( 'pageinfo-transclusions' )
555 ->numParams( $pageCounts['transclusion']['to'] ),
556 Linker::formatTemplates(
557 $transcludedTargets,
558 false,
559 false,
560 $more )
561 );
562 }
563 }
564
565 return $pageInfo;
566 }
567
568 /**
569 * Returns page counts that would be too "expensive" to retrieve by normal means.
570 *
571 * @param Title $title Title to get counts for
572 * @return array
573 */
574 protected static function pageCounts( Title $title ) {
575 global $wgRCMaxAge, $wgDisableCounters;
576
577 wfProfileIn( __METHOD__ );
578 $id = $title->getArticleID();
579
580 $dbr = wfGetDB( DB_SLAVE );
581 $result = array();
582
583 if ( !$wgDisableCounters ) {
584 // Number of views
585 $views = (int) $dbr->selectField(
586 'page',
587 'page_counter',
588 array( 'page_id' => $id ),
589 __METHOD__
590 );
591 $result['views'] = $views;
592 }
593
594 // Number of page watchers
595 $watchers = (int) $dbr->selectField(
596 'watchlist',
597 'COUNT(*)',
598 array(
599 'wl_namespace' => $title->getNamespace(),
600 'wl_title' => $title->getDBkey(),
601 ),
602 __METHOD__
603 );
604 $result['watchers'] = $watchers;
605
606 // Total number of edits
607 $edits = (int) $dbr->selectField(
608 'revision',
609 'COUNT(rev_page)',
610 array( 'rev_page' => $id ),
611 __METHOD__
612 );
613 $result['edits'] = $edits;
614
615 // Total number of distinct authors
616 $authors = (int) $dbr->selectField(
617 'revision',
618 'COUNT(DISTINCT rev_user_text)',
619 array( 'rev_page' => $id ),
620 __METHOD__
621 );
622 $result['authors'] = $authors;
623
624 // "Recent" threshold defined by $wgRCMaxAge
625 $threshold = $dbr->timestamp( time() - $wgRCMaxAge );
626
627 // Recent number of edits
628 $edits = (int) $dbr->selectField(
629 'revision',
630 'COUNT(rev_page)',
631 array(
632 'rev_page' => $id,
633 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
634 ),
635 __METHOD__
636 );
637 $result['recent_edits'] = $edits;
638
639 // Recent number of distinct authors
640 $authors = (int) $dbr->selectField(
641 'revision',
642 'COUNT(DISTINCT rev_user_text)',
643 array(
644 'rev_page' => $id,
645 "rev_timestamp >= " . $dbr->addQuotes( $threshold )
646 ),
647 __METHOD__
648 );
649 $result['recent_authors'] = $authors;
650
651 // Subpages (if enabled)
652 if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
653 $conds = array( 'page_namespace' => $title->getNamespace() );
654 $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
655
656 // Subpages of this page (redirects)
657 $conds['page_is_redirect'] = 1;
658 $result['subpages']['redirects'] = (int) $dbr->selectField(
659 'page',
660 'COUNT(page_id)',
661 $conds,
662 __METHOD__ );
663
664 // Subpages of this page (non-redirects)
665 $conds['page_is_redirect'] = 0;
666 $result['subpages']['nonredirects'] = (int) $dbr->selectField(
667 'page',
668 'COUNT(page_id)',
669 $conds,
670 __METHOD__
671 );
672
673 // Subpages of this page (total)
674 $result['subpages']['total'] = $result['subpages']['redirects']
675 + $result['subpages']['nonredirects'];
676 }
677
678 // Counts for the number of transclusion links (to/from)
679 $result['transclusion']['to'] = (int) $dbr->selectField(
680 'templatelinks',
681 'COUNT(tl_from)',
682 array(
683 'tl_namespace' => $title->getNamespace(),
684 'tl_title' => $title->getDBkey()
685 ),
686 __METHOD__
687 );
688
689 $result['transclusion']['from'] = (int) $dbr->selectField(
690 'templatelinks',
691 'COUNT(*)',
692 array( 'tl_from' => $title->getArticleID() ),
693 __METHOD__
694 );
695
696 wfProfileOut( __METHOD__ );
697 return $result;
698 }
699
700 /**
701 * Returns the name that goes in the "<h1>" page title.
702 *
703 * @return string
704 */
705 protected function getPageTitle() {
706 return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
707 }
708
709 /**
710 * Get a list of contributors of $article
711 * @return string: html
712 */
713 protected function getContributors() {
714 global $wgHiddenPrefs;
715
716 $contributors = $this->page->getContributors();
717 $real_names = array();
718 $user_names = array();
719 $anon_ips = array();
720
721 # Sift for real versus user names
722 foreach ( $contributors as $user ) {
723 $page = $user->isAnon()
724 ? SpecialPage::getTitleFor( 'Contributions', $user->getName() )
725 : $user->getUserPage();
726
727 if ( $user->getID() == 0 ) {
728 $anon_ips[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
729 } elseif ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
730 $real_names[] = Linker::link( $page, htmlspecialchars( $user->getRealName() ) );
731 } else {
732 $user_names[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
733 }
734 }
735
736 $lang = $this->getLanguage();
737
738 $real = $lang->listToText( $real_names );
739
740 # "ThisSite user(s) A, B and C"
741 if ( count( $user_names ) ) {
742 $user = $this->msg( 'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
743 count( $user_names ) )->escaped();
744 } else {
745 $user = false;
746 }
747
748 if ( count( $anon_ips ) ) {
749 $anon = $this->msg( 'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
750 count( $anon_ips ) )->escaped();
751 } else {
752 $anon = false;
753 }
754
755 # This is the big list, all mooshed together. We sift for blank strings
756 $fulllist = array();
757 foreach ( array( $real, $user, $anon ) as $s ) {
758 if ( $s !== '' ) {
759 array_push( $fulllist, $s );
760 }
761 }
762
763 $count = count( $fulllist );
764 # "Based on work by ..."
765 return $count
766 ? $this->msg( 'othercontribs' )->rawParams(
767 $lang->listToText( $fulllist ) )->params( $count )->escaped()
768 : '';
769 }
770
771 /**
772 * Returns the description that goes below the "<h1>" tag.
773 *
774 * @return string
775 */
776 protected function getDescription() {
777 return '';
778 }
779 }