MediaWiki  1.23.8
InfoAction.php
Go to the documentation of this file.
1 <?php
30 class InfoAction extends FormlessAction {
31  const CACHE_VERSION = '2013-03-17';
32 
38  public function getName() {
39  return 'info';
40  }
41 
47  public function requiresUnblock() {
48  return false;
49  }
50 
56  public function requiresWrite() {
57  return false;
58  }
59 
66  public static function invalidateCache( Title $title ) {
68  // Clear page info.
69  $revision = WikiPage::factory( $title )->getRevision();
70  if ( $revision !== null ) {
71  $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revision->getId() );
72  $wgMemc->delete( $key );
73  }
74  }
75 
81  public function onView() {
82  $content = '';
83 
84  // Validate revision
85  $oldid = $this->page->getOldID();
86  if ( $oldid ) {
87  $revision = $this->page->getRevisionFetched();
88 
89  // Revision is missing
90  if ( $revision === null ) {
91  return $this->msg( 'missing-revision', $oldid )->parse();
92  }
93 
94  // Revision is not current
95  if ( !$revision->isCurrent() ) {
96  return $this->msg( 'pageinfo-not-current' )->plain();
97  }
98  }
99 
100  // Page header
101  if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
102  $content .= $this->msg( 'pageinfo-header' )->parse();
103  }
104 
105  // Hide "This page is a member of # hidden categories" explanation
106  $content .= Html::element( 'style', array(),
107  '.mw-hiddenCategoriesExplanation { display: none; }' ) . "\n";
108 
109  // Hide "Templates used on this page" explanation
110  $content .= Html::element( 'style', array(),
111  '.mw-templatesUsedExplanation { display: none; }' ) . "\n";
112 
113  // Get page information
114  $pageInfo = $this->pageInfo();
115 
116  // Allow extensions to add additional information
117  wfRunHooks( 'InfoAction', array( $this->getContext(), &$pageInfo ) );
118 
119  // Render page information
120  foreach ( $pageInfo as $header => $infoTable ) {
121  // Messages:
122  // pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions,
123  // pageinfo-header-properties, pageinfo-category-info
124  $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
125  $table = "\n";
126  foreach ( $infoTable as $infoRow ) {
127  $name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
128  $value = ( $infoRow[1] instanceof Message ) ? $infoRow[1]->escaped() : $infoRow[1];
129  $id = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->getKey() : null;
130  $table = $this->addRow( $table, $name, $value, $id ) . "\n";
131  }
132  $content = $this->addTable( $content, $table ) . "\n";
133  }
134 
135  // Page footer
136  if ( !$this->msg( 'pageinfo-footer' )->isDisabled() ) {
137  $content .= $this->msg( 'pageinfo-footer' )->parse();
138  }
139 
140  // Page credits
141  /*if ( $this->page->exists() ) {
142  $content .= Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $this->getContributors() );
143  }*/
144 
145  return $content;
146  }
147 
154  protected function makeHeader( $header ) {
155  $spanAttribs = array( 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) );
156 
157  return Html::rawElement( 'h2', array(), Html::element( 'span', $spanAttribs, $header ) );
158  }
159 
169  protected function addRow( $table, $name, $value, $id ) {
170  return $table . Html::rawElement( 'tr', $id === null ? array() : array( 'id' => 'mw-' . $id ),
171  Html::rawElement( 'td', array( 'style' => 'vertical-align: top;' ), $name ) .
172  Html::rawElement( 'td', array(), $value )
173  );
174  }
175 
183  protected function addTable( $content, $table ) {
184  return $content . Html::rawElement( 'table', array( 'class' => 'wikitable mw-page-info' ),
185  $table );
186  }
187 
195  protected function pageInfo() {
196  global $wgContLang, $wgRCMaxAge, $wgMemc, $wgMiserMode,
197  $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit;
198 
199  $user = $this->getUser();
200  $lang = $this->getLanguage();
201  $title = $this->getTitle();
202  $id = $title->getArticleID();
203 
204  $memcKey = wfMemcKey( 'infoaction',
205  sha1( $title->getPrefixedText() ), $this->page->getLatest() );
206  $pageCounts = $wgMemc->get( $memcKey );
207  $version = isset( $pageCounts['cacheversion'] ) ? $pageCounts['cacheversion'] : false;
208  if ( $pageCounts === false || $version !== self::CACHE_VERSION ) {
209  // Get page information that would be too "expensive" to retrieve by normal means
210  $pageCounts = self::pageCounts( $title );
211  $pageCounts['cacheversion'] = self::CACHE_VERSION;
212 
213  $wgMemc->set( $memcKey, $pageCounts );
214  }
215 
216  // Get page properties
217  $dbr = wfGetDB( DB_SLAVE );
218  $result = $dbr->select(
219  'page_props',
220  array( 'pp_propname', 'pp_value' ),
221  array( 'pp_page' => $id ),
222  __METHOD__
223  );
224 
225  $pageProperties = array();
226  foreach ( $result as $row ) {
227  $pageProperties[$row->pp_propname] = $row->pp_value;
228  }
229 
230  // Basic information
231  $pageInfo = array();
232  $pageInfo['header-basic'] = array();
233 
234  // Display title
235  $displayTitle = $title->getPrefixedText();
236  if ( !empty( $pageProperties['displaytitle'] ) ) {
237  $displayTitle = $pageProperties['displaytitle'];
238  }
239 
240  $pageInfo['header-basic'][] = array(
241  $this->msg( 'pageinfo-display-title' ), $displayTitle
242  );
243 
244  // Is it a redirect? If so, where to?
245  if ( $title->isRedirect() ) {
246  $pageInfo['header-basic'][] = array(
247  $this->msg( 'pageinfo-redirectsto' ),
248  Linker::link( $this->page->getRedirectTarget() ) .
249  $this->msg( 'word-separator' )->text() .
250  $this->msg( 'parentheses', Linker::link(
251  $this->page->getRedirectTarget(),
252  $this->msg( 'pageinfo-redirectsto-info' )->escaped(),
253  array(),
254  array( 'action' => 'info' )
255  ) )->text()
256  );
257  }
258 
259  // Default sort key
260  $sortKey = $title->getCategorySortkey();
261  if ( !empty( $pageProperties['defaultsort'] ) ) {
262  $sortKey = $pageProperties['defaultsort'];
263  }
264 
265  $sortKey = htmlspecialchars( $sortKey );
266  $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-default-sort' ), $sortKey );
267 
268  // Page length (in bytes)
269  $pageInfo['header-basic'][] = array(
270  $this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
271  );
272 
273  // Page ID (number not localised, as it's a database ID)
274  $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-article-id' ), $id );
275 
276  // Language in which the page content is (supposed to be) written
277  $pageLang = $title->getPageLanguage()->getCode();
278  $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-language' ),
279  Language::fetchLanguageName( $pageLang, $lang->getCode() )
280  . ' ' . $this->msg( 'parentheses', $pageLang ) );
281 
282  // Content model of the page
283  $pageInfo['header-basic'][] = array(
284  $this->msg( 'pageinfo-content-model' ),
285  ContentHandler::getLocalizedName( $title->getContentModel() )
286  );
287 
288  // Search engine status
289  $pOutput = new ParserOutput();
290  if ( isset( $pageProperties['noindex'] ) ) {
291  $pOutput->setIndexPolicy( 'noindex' );
292  }
293  if ( isset( $pageProperties['index'] ) ) {
294  $pOutput->setIndexPolicy( 'index' );
295  }
296 
297  // Use robot policy logic
298  $policy = $this->page->getRobotPolicy( 'view', $pOutput );
299  $pageInfo['header-basic'][] = array(
300  // Messages: pageinfo-robot-index, pageinfo-robot-noindex
301  $this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" )
302  );
303 
304  if ( isset( $pageCounts['views'] ) ) {
305  // Number of views
306  $pageInfo['header-basic'][] = array(
307  $this->msg( 'pageinfo-views' ), $lang->formatNum( $pageCounts['views'] )
308  );
309  }
310 
311  if (
312  $user->isAllowed( 'unwatchedpages' ) ||
313  ( $wgUnwatchedPageThreshold !== false &&
314  $pageCounts['watchers'] >= $wgUnwatchedPageThreshold )
315  ) {
316  // Number of page watchers
317  $pageInfo['header-basic'][] = array(
318  $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] )
319  );
320  } elseif ( $wgUnwatchedPageThreshold !== false ) {
321  $pageInfo['header-basic'][] = array(
322  $this->msg( 'pageinfo-watchers' ),
323  $this->msg( 'pageinfo-few-watchers' )->numParams( $wgUnwatchedPageThreshold )
324  );
325  }
326 
327  // Redirects to this page
328  $whatLinksHere = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
329  $pageInfo['header-basic'][] = array(
330  Linker::link(
331  $whatLinksHere,
332  $this->msg( 'pageinfo-redirects-name' )->escaped(),
333  array(),
334  array( 'hidelinks' => 1, 'hidetrans' => 1 )
335  ),
336  $this->msg( 'pageinfo-redirects-value' )
337  ->numParams( count( $title->getRedirectsHere() ) )
338  );
339 
340  // Is it counted as a content page?
341  if ( $this->page->isCountable() ) {
342  $pageInfo['header-basic'][] = array(
343  $this->msg( 'pageinfo-contentpage' ),
344  $this->msg( 'pageinfo-contentpage-yes' )
345  );
346  }
347 
348  // Subpages of this page, if subpages are enabled for the current NS
349  if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
350  $prefixIndex = SpecialPage::getTitleFor( 'Prefixindex', $title->getPrefixedText() . '/' );
351  $pageInfo['header-basic'][] = array(
352  Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
353  $this->msg( 'pageinfo-subpages-value' )
354  ->numParams(
355  $pageCounts['subpages']['total'],
356  $pageCounts['subpages']['redirects'],
357  $pageCounts['subpages']['nonredirects'] )
358  );
359  }
360 
361  if ( $title->inNamespace( NS_CATEGORY ) ) {
362  $category = Category::newFromTitle( $title );
363  $pageInfo['category-info'] = array(
364  array(
365  $this->msg( 'pageinfo-category-pages' ),
366  $lang->formatNum( $category->getPageCount() )
367  ),
368  array(
369  $this->msg( 'pageinfo-category-subcats' ),
370  $lang->formatNum( $category->getSubcatCount() )
371  ),
372  array(
373  $this->msg( 'pageinfo-category-files' ),
374  $lang->formatNum( $category->getFileCount() )
375  )
376  );
377  }
378 
379  // Page protection
380  $pageInfo['header-restrictions'] = array();
381 
382  // Is this page effected by the cascading protection of something which includes it?
383  if ( $title->isCascadeProtected() ) {
384  $cascadingFrom = '';
385  $sources = $title->getCascadeProtectionSources(); // Array deferencing is in PHP 5.4 :(
386 
387  foreach ( $sources[0] as $sourceTitle ) {
388  $cascadingFrom .= Html::rawElement( 'li', array(), Linker::linkKnown( $sourceTitle ) );
389  }
390 
391  $cascadingFrom = Html::rawElement( 'ul', array(), $cascadingFrom );
392  $pageInfo['header-restrictions'][] = array(
393  $this->msg( 'pageinfo-protect-cascading-from' ),
394  $cascadingFrom
395  );
396  }
397 
398  // Is out protection set to cascade to other pages?
399  if ( $title->areRestrictionsCascading() ) {
400  $pageInfo['header-restrictions'][] = array(
401  $this->msg( 'pageinfo-protect-cascading' ),
402  $this->msg( 'pageinfo-protect-cascading-yes' )
403  );
404  }
405 
406  // Page protection
407  foreach ( $title->getRestrictionTypes() as $restrictionType ) {
408  $protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
409 
410  if ( $protectionLevel == '' ) {
411  // Allow all users
412  $message = $this->msg( 'protect-default' )->escaped();
413  } else {
414  // Administrators only
415  // Messages: protect-level-autoconfirmed, protect-level-sysop
416  $message = $this->msg( "protect-level-$protectionLevel" );
417  if ( $message->isDisabled() ) {
418  // Require "$1" permission
419  $message = $this->msg( "protect-fallback", $protectionLevel )->parse();
420  } else {
421  $message = $message->escaped();
422  }
423  }
424 
425  // Messages: restriction-edit, restriction-move, restriction-create,
426  // restriction-upload
427  $pageInfo['header-restrictions'][] = array(
428  $this->msg( "restriction-$restrictionType" ), $message
429  );
430  }
431 
432  if ( !$this->page->exists() ) {
433  return $pageInfo;
434  }
435 
436  // Edit history
437  $pageInfo['header-edits'] = array();
438 
439  $firstRev = $this->page->getOldestRevision();
440  $lastRev = $this->page->getRevision();
441  $batch = new LinkBatch;
442 
443  if ( $firstRev ) {
444  $firstRevUser = $firstRev->getUserText( Revision::FOR_THIS_USER );
445  if ( $firstRevUser !== '' ) {
446  $batch->add( NS_USER, $firstRevUser );
447  $batch->add( NS_USER_TALK, $firstRevUser );
448  }
449  }
450 
451  if ( $lastRev ) {
452  $lastRevUser = $lastRev->getUserText( Revision::FOR_THIS_USER );
453  if ( $lastRevUser !== '' ) {
454  $batch->add( NS_USER, $lastRevUser );
455  $batch->add( NS_USER_TALK, $lastRevUser );
456  }
457  }
458 
459  $batch->execute();
460 
461  if ( $firstRev ) {
462  // Page creator
463  $pageInfo['header-edits'][] = array(
464  $this->msg( 'pageinfo-firstuser' ),
465  Linker::revUserTools( $firstRev )
466  );
467 
468  // Date of page creation
469  $pageInfo['header-edits'][] = array(
470  $this->msg( 'pageinfo-firsttime' ),
472  $title,
473  $lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
474  array(),
475  array( 'oldid' => $firstRev->getId() )
476  )
477  );
478  }
479 
480  if ( $lastRev ) {
481  // Latest editor
482  $pageInfo['header-edits'][] = array(
483  $this->msg( 'pageinfo-lastuser' ),
484  Linker::revUserTools( $lastRev )
485  );
486 
487  // Date of latest edit
488  $pageInfo['header-edits'][] = array(
489  $this->msg( 'pageinfo-lasttime' ),
491  $title,
492  $lang->userTimeAndDate( $this->page->getTimestamp(), $user ),
493  array(),
494  array( 'oldid' => $this->page->getLatest() )
495  )
496  );
497  }
498 
499  // Total number of edits
500  $pageInfo['header-edits'][] = array(
501  $this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
502  );
503 
504  // Total number of distinct authors
505  $pageInfo['header-edits'][] = array(
506  $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
507  );
508 
509  // Recent number of edits (within past 30 days)
510  $pageInfo['header-edits'][] = array(
511  $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $wgRCMaxAge ) ),
512  $lang->formatNum( $pageCounts['recent_edits'] )
513  );
514 
515  // Recent number of distinct authors
516  $pageInfo['header-edits'][] = array(
517  $this->msg( 'pageinfo-recent-authors' ), $lang->formatNum( $pageCounts['recent_authors'] )
518  );
519 
520  // Array of MagicWord objects
522 
523  // Array of magic word IDs
524  $wordIDs = $magicWords->names;
525 
526  // Array of IDs => localized magic words
527  $localizedWords = $wgContLang->getMagicWords();
528 
529  $listItems = array();
530  foreach ( $pageProperties as $property => $value ) {
531  if ( in_array( $property, $wordIDs ) ) {
532  $listItems[] = Html::element( 'li', array(), $localizedWords[$property][1] );
533  }
534  }
535 
536  $localizedList = Html::rawElement( 'ul', array(), implode( '', $listItems ) );
537  $hiddenCategories = $this->page->getHiddenCategories();
538 
539  if (
540  count( $listItems ) > 0 ||
541  count( $hiddenCategories ) > 0 ||
542  $pageCounts['transclusion']['from'] > 0 ||
543  $pageCounts['transclusion']['to'] > 0
544  ) {
545  $options = array( 'LIMIT' => $wgPageInfoTransclusionLimit );
546  $transcludedTemplates = $title->getTemplateLinksFrom( $options );
547  if ( $wgMiserMode ) {
548  $transcludedTargets = array();
549  } else {
550  $transcludedTargets = $title->getTemplateLinksTo( $options );
551  }
552 
553  // Page properties
554  $pageInfo['header-properties'] = array();
555 
556  // Magic words
557  if ( count( $listItems ) > 0 ) {
558  $pageInfo['header-properties'][] = array(
559  $this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
560  $localizedList
561  );
562  }
563 
564  // Hidden categories
565  if ( count( $hiddenCategories ) > 0 ) {
566  $pageInfo['header-properties'][] = array(
567  $this->msg( 'pageinfo-hidden-categories' )
568  ->numParams( count( $hiddenCategories ) ),
569  Linker::formatHiddenCategories( $hiddenCategories )
570  );
571  }
572 
573  // Transcluded templates
574  if ( $pageCounts['transclusion']['from'] > 0 ) {
575  if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
576  $more = $this->msg( 'morenotlisted' )->escaped();
577  } else {
578  $more = null;
579  }
580 
581  $pageInfo['header-properties'][] = array(
582  $this->msg( 'pageinfo-templates' )
583  ->numParams( $pageCounts['transclusion']['from'] ),
585  $transcludedTemplates,
586  false,
587  false,
588  $more )
589  );
590  }
591 
592  if ( !$wgMiserMode && $pageCounts['transclusion']['to'] > 0 ) {
593  if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
594  $more = Linker::link(
595  $whatLinksHere,
596  $this->msg( 'moredotdotdot' )->escaped(),
597  array(),
598  array( 'hidelinks' => 1, 'hideredirs' => 1 )
599  );
600  } else {
601  $more = null;
602  }
603 
604  $pageInfo['header-properties'][] = array(
605  $this->msg( 'pageinfo-transclusions' )
606  ->numParams( $pageCounts['transclusion']['to'] ),
608  $transcludedTargets,
609  false,
610  false,
611  $more )
612  );
613  }
614  }
615 
616  return $pageInfo;
617  }
618 
625  protected static function pageCounts( Title $title ) {
626  global $wgRCMaxAge, $wgDisableCounters, $wgMiserMode;
627 
628  wfProfileIn( __METHOD__ );
629  $id = $title->getArticleID();
630 
631  $dbr = wfGetDB( DB_SLAVE );
632  $result = array();
633 
634  if ( !$wgDisableCounters ) {
635  // Number of views
636  $views = (int)$dbr->selectField(
637  'page',
638  'page_counter',
639  array( 'page_id' => $id ),
640  __METHOD__
641  );
642  $result['views'] = $views;
643  }
644 
645  // Number of page watchers
646  $watchers = (int)$dbr->selectField(
647  'watchlist',
648  'COUNT(*)',
649  array(
650  'wl_namespace' => $title->getNamespace(),
651  'wl_title' => $title->getDBkey(),
652  ),
653  __METHOD__
654  );
655  $result['watchers'] = $watchers;
656 
657  // Total number of edits
658  $edits = (int)$dbr->selectField(
659  'revision',
660  'COUNT(rev_page)',
661  array( 'rev_page' => $id ),
662  __METHOD__
663  );
664  $result['edits'] = $edits;
665 
666  // Total number of distinct authors
667  $authors = (int)$dbr->selectField(
668  'revision',
669  'COUNT(DISTINCT rev_user_text)',
670  array( 'rev_page' => $id ),
671  __METHOD__
672  );
673  $result['authors'] = $authors;
674 
675  // "Recent" threshold defined by $wgRCMaxAge
676  $threshold = $dbr->timestamp( time() - $wgRCMaxAge );
677 
678  // Recent number of edits
679  $edits = (int)$dbr->selectField(
680  'revision',
681  'COUNT(rev_page)',
682  array(
683  'rev_page' => $id,
684  "rev_timestamp >= " . $dbr->addQuotes( $threshold )
685  ),
686  __METHOD__
687  );
688  $result['recent_edits'] = $edits;
689 
690  // Recent number of distinct authors
691  $authors = (int)$dbr->selectField(
692  'revision',
693  'COUNT(DISTINCT rev_user_text)',
694  array(
695  'rev_page' => $id,
696  "rev_timestamp >= " . $dbr->addQuotes( $threshold )
697  ),
698  __METHOD__
699  );
700  $result['recent_authors'] = $authors;
701 
702  // Subpages (if enabled)
703  if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
704  $conds = array( 'page_namespace' => $title->getNamespace() );
705  $conds[] = 'page_title ' . $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
706 
707  // Subpages of this page (redirects)
708  $conds['page_is_redirect'] = 1;
709  $result['subpages']['redirects'] = (int)$dbr->selectField(
710  'page',
711  'COUNT(page_id)',
712  $conds,
713  __METHOD__ );
714 
715  // Subpages of this page (non-redirects)
716  $conds['page_is_redirect'] = 0;
717  $result['subpages']['nonredirects'] = (int)$dbr->selectField(
718  'page',
719  'COUNT(page_id)',
720  $conds,
721  __METHOD__
722  );
723 
724  // Subpages of this page (total)
725  $result['subpages']['total'] = $result['subpages']['redirects']
726  + $result['subpages']['nonredirects'];
727  }
728 
729  // Counts for the number of transclusion links (to/from)
730  if ( $wgMiserMode ) {
731  $result['transclusion']['to'] = 0;
732  } else {
733  $result['transclusion']['to'] = (int)$dbr->selectField(
734  'templatelinks',
735  'COUNT(tl_from)',
736  array(
737  'tl_namespace' => $title->getNamespace(),
738  'tl_title' => $title->getDBkey()
739  ),
740  __METHOD__
741  );
742  }
743 
744  $result['transclusion']['from'] = (int)$dbr->selectField(
745  'templatelinks',
746  'COUNT(*)',
747  array( 'tl_from' => $title->getArticleID() ),
748  __METHOD__
749  );
750 
751  wfProfileOut( __METHOD__ );
752 
753  return $result;
754  }
755 
761  protected function getPageTitle() {
762  return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
763  }
764 
769  protected function getContributors() {
770  global $wgHiddenPrefs;
771 
772  $contributors = $this->page->getContributors();
773  $real_names = array();
774  $user_names = array();
775  $anon_ips = array();
776 
777  # Sift for real versus user names
778 
779  foreach ( $contributors as $user ) {
780  $page = $user->isAnon()
781  ? SpecialPage::getTitleFor( 'Contributions', $user->getName() )
782  : $user->getUserPage();
783 
784  if ( $user->getID() == 0 ) {
785  $anon_ips[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
786  } elseif ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
787  $real_names[] = Linker::link( $page, htmlspecialchars( $user->getRealName() ) );
788  } else {
789  $user_names[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
790  }
791  }
792 
793  $lang = $this->getLanguage();
794 
795  $real = $lang->listToText( $real_names );
796 
797  # "ThisSite user(s) A, B and C"
798  if ( count( $user_names ) ) {
799  $user = $this->msg( 'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
800  count( $user_names ) )->escaped();
801  } else {
802  $user = false;
803  }
804 
805  if ( count( $anon_ips ) ) {
806  $anon = $this->msg( 'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
807  count( $anon_ips ) )->escaped();
808  } else {
809  $anon = false;
810  }
811 
812  # This is the big list, all mooshed together. We sift for blank strings
813  $fulllist = array();
814  foreach ( array( $real, $user, $anon ) as $s ) {
815  if ( $s !== '' ) {
816  array_push( $fulllist, $s );
817  }
818  }
819 
820  $count = count( $fulllist );
821 
822  # "Based on work by ..."
823  return $count
824  ? $this->msg( 'othercontribs' )->rawParams(
825  $lang->listToText( $fulllist ) )->params( $count )->escaped()
826  : '';
827  }
828 
834  protected function getDescription() {
835  return '';
836  }
837 }
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
ParserOutput
Definition: ParserOutput.php:24
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:30
FormlessAction
An action which just does something, without showing a form first.
Definition: FormlessAction.php:29
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
InfoAction\getDescription
getDescription()
Returns the description that goes below the "<h1>" tag.
Definition: InfoAction.php:834
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
InfoAction\requiresWrite
requiresWrite()
Whether this action requires the wiki not to be locked.
Definition: InfoAction.php:56
InfoAction\CACHE_VERSION
const CACHE_VERSION
Definition: InfoAction.php:31
$s
$s
Definition: mergeMessageFileList.php:156
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
InfoAction\makeHeader
makeHeader( $header)
Creates a header that can be added to the output.
Definition: InfoAction.php:154
InfoAction\getName
getName()
Returns the name of the action this object responds to.
Definition: InfoAction.php:38
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
InfoAction\getContributors
getContributors()
Get a list of contributors of $article.
Definition: InfoAction.php:769
Linker\formatHiddenCategories
static formatHiddenCategories( $hiddencats)
Returns HTML for the "hidden categories on this page" list.
Definition: Linker.php:2029
$dbr
$dbr
Definition: testCompression.php:48
Linker\link
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
Definition: Linker.php:192
ContentHandler\getLocalizedName
static getLocalizedName( $name)
Returns the localized name for a given content model.
Definition: ContentHandler.php:360
Revision\FOR_THIS_USER
const FOR_THIS_USER
Definition: Revision.php:73
Action\getContext
getContext()
Get the IContextSource in use here.
Definition: Action.php:164
InfoAction
Displays information about a page.
Definition: InfoAction.php:30
wfMemcKey
wfMemcKey()
Get a cache key.
Definition: GlobalFunctions.php:3580
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:103
$property
$property
Definition: styleTest.css.php:44
InfoAction\getPageTitle
getPageTitle()
Returns the name that goes in the "<h1>" page title.
Definition: InfoAction.php:761
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:148
InfoAction\invalidateCache
static invalidateCache(Title $title)
Clear the info cache for a given Title.
Definition: InfoAction.php:66
Linker\revUserTools
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
Definition: Linker.php:1219
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4010
MWNamespace\hasSubpages
static hasSubpages( $index)
Does the namespace allow subpages?
Definition: Namespace.php:325
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:93
$magicWords
magicword txt Magic Words are some phrases used in the wikitext They are used for two that looks like templates but that don t accept any parameter *Parser functions(like {{fullurl:...}}, {{#special:...}}) $magicWords['en']
Definition: magicword.txt:33
InfoAction\addRow
addRow( $table, $name, $value, $id)
Adds a row to a table that will be added to the content.
Definition: InfoAction.php:169
Sanitizer\escapeId
static escapeId( $id, $options=array())
Given a value, escape it so that it can be used in an id attribute and return it.
Definition: Sanitizer.php:1099
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
Category\newFromTitle
static newFromTitle( $title)
Factory function.
Definition: Category.php:134
Action\getUser
getUser()
Shortcut to get the User being used for this instance.
Definition: Action.php:200
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:82
InfoAction\pageInfo
pageInfo()
Returns page information in an easily-manipulated format.
Definition: InfoAction.php:195
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
InfoAction\addTable
addTable( $content, $table)
Adds a table to the content that will be added to the output.
Definition: InfoAction.php:183
$value
$value
Definition: styleTest.css.php:45
$version
$version
Definition: parserTests.php:86
Action\getTitle
getTitle()
Shortcut to get the Title object from the page.
Definition: Action.php:237
Linker\formatTemplates
static formatTemplates( $templates, $preview=false, $section=false, $more=null)
Returns HTML for the "templates used on this page" list.
Definition: Linker.php:1936
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition: Language.php:941
InfoAction\requiresUnblock
requiresUnblock()
Whether this action can still be executed by a blocked user.
Definition: InfoAction.php:47
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
$count
$count
Definition: UtfNormalTest2.php:96
Action\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: Action.php:247
InfoAction\onView
onView()
Shows page information on GET request.
Definition: InfoAction.php:81
InfoAction\pageCounts
static pageCounts(Title $title)
Returns page counts that would be too "expensive" to retrieve by normal means.
Definition: InfoAction.php:625
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
Title
Represents a title within MediaWiki.
Definition: Title.php:35
Action\$page
WikiPage Article ImagePage CategoryPage Page $page
Page on which we're performing the action $page.
Definition: Action.php:42
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Action\getLanguage
getLanguage()
Shortcut to get the user Language being used for this instance.
Definition: Action.php:218
NS_USER
const NS_USER
Definition: Defines.php:81
MagicWord\getDoubleUnderscoreArray
static getDoubleUnderscoreArray()
Get a MagicWordArray of double-underscore entities.
Definition: MagicWord.php:288
$batch
$batch
Definition: linkcache.txt:23
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk page
Definition: hooks.txt:1956