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