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