MediaWiki  1.29.2
Cite.php
Go to the documentation of this file.
1 <?php
2 
29 class Cite {
30 
34  const DEFAULT_GROUP = '';
35 
40  const MAX_STORAGE_LENGTH = 65535; // Size of MySQL 'blob' field
41 
45  const EXT_DATA_KEY = 'Cite:References';
46 
50  const DATA_VERSION_NUMBER = 1;
51 
55  const CACHE_DURATION_ONPARSE = 3600; // 1 hour
56 
60  const CACHE_DURATION_ONFETCH = 18000; // 5 hours
61 
93  private $mRefs = [];
94 
100  private $mOutCnt = 0;
101 
105  private $mGroupCnt = [];
106 
113  private $mCallCnt = 0;
114 
122  private $mBacklinkLabels;
123 
129  private $mLinkLabels = [];
130 
134  private $mParser;
135 
142  private $mHaveAfterParse = false;
143 
150  public $mInCite = false;
151 
158  public $mInReferences = false;
159 
165  private $mReferencesErrors = [];
166 
172  private $mReferencesGroup = '';
173 
181  private $mRefCallStack = [];
182 
186  private $mBumpRefData = false;
187 
192  private static $hooksInstalled = false;
193 
204  public function ref( $str, array $argv, Parser $parser, PPFrame $frame ) {
205  if ( $this->mInCite ) {
206  return htmlspecialchars( "<ref>$str</ref>" );
207  }
208 
209  $this->mCallCnt++;
210  $this->mInCite = true;
211 
212  $ret = $this->guardedRef( $str, $argv, $parser );
213 
214  $this->mInCite = false;
215 
216  $parserOutput = $parser->getOutput();
217  $parserOutput->addModules( 'ext.cite.a11y' );
218  $parserOutput->addModuleStyles( 'ext.cite.styles' );
219 
220  if ( is_callable( [ $frame, 'setVolatile' ] ) ) {
221  $frame->setVolatile();
222  }
223 
224  // new <ref> tag, we may need to bump the ref data counter
225  // to avoid overwriting a previous group
226  $this->mBumpRefData = true;
227 
228  return $ret;
229  }
230 
240  private function guardedRef(
241  $str,
242  array $argv,
243  Parser $parser,
244  $default_group = self::DEFAULT_GROUP
245  ) {
246  $this->mParser = $parser;
247 
248  # The key here is the "name" attribute.
249  list( $key, $group, $follow ) = $this->refArg( $argv );
250 
251  # Split these into groups.
252  if ( $group === null ) {
253  if ( $this->mInReferences ) {
254  $group = $this->mReferencesGroup;
255  } else {
256  $group = $default_group;
257  }
258  }
259 
260  /*
261  * This section deals with constructions of the form
262  *
263  * <references>
264  * <ref name="foo"> BAR </ref>
265  * </references>
266  */
267  if ( $this->mInReferences ) {
268  $isSectionPreview = $parser->getOptions()->getIsSectionPreview();
269  if ( $group != $this->mReferencesGroup ) {
270  # <ref> and <references> have conflicting group attributes.
271  $this->mReferencesErrors[] =
272  $this->error( 'cite_error_references_group_mismatch', htmlspecialchars( $group ) );
273  } elseif ( $str !== '' ) {
274  if ( !$isSectionPreview && !isset( $this->mRefs[$group] ) ) {
275  # Called with group attribute not defined in text.
276  $this->mReferencesErrors[] =
277  $this->error( 'cite_error_references_missing_group', htmlspecialchars( $group ) );
278  } elseif ( $key === null || $key === '' ) {
279  # <ref> calls inside <references> must be named
280  $this->mReferencesErrors[] =
281  $this->error( 'cite_error_references_no_key' );
282  } elseif ( !$isSectionPreview && !isset( $this->mRefs[$group][$key] ) ) {
283  # Called with name attribute not defined in text.
284  $this->mReferencesErrors[] =
285  $this->error( 'cite_error_references_missing_key', $key );
286  } else {
287  if (
288  isset( $this->mRefs[$group][$key]['text'] ) &&
289  $str !== $this->mRefs[$group][$key]['text']
290  ) {
291  // two refs with same key and different content
292  // add error message to the original ref
293  $this->mRefs[$group][$key]['text'] .= ' ' . $this->error(
294  'cite_error_references_duplicate_key', $key, 'noparse'
295  );
296  } else {
297  # Assign the text to corresponding ref
298  $this->mRefs[$group][$key]['text'] = $str;
299  }
300  }
301  } else {
302  # <ref> called in <references> has no content.
303  $this->mReferencesErrors[] =
304  $this->error( 'cite_error_empty_references_define', $key );
305  }
306  return '';
307  }
308 
309  if ( $str === '' ) {
310  # <ref ...></ref>. This construct is invalid if
311  # it's a contentful ref, but OK if it's a named duplicate and should
312  # be equivalent <ref ... />, for compatability with #tag.
313  if ( is_string( $key ) && $key !== '' ) {
314  $str = null;
315  } else {
316  $this->mRefCallStack[] = false;
317 
318  return $this->error( 'cite_error_ref_no_input' );
319  }
320  }
321 
322  if ( $key === false ) {
323  # TODO: Comment this case; what does this condition mean?
324  $this->mRefCallStack[] = false;
325  return $this->error( 'cite_error_ref_too_many_keys' );
326  }
327 
328  if ( $str === null && $key === null ) {
329  # Something like <ref />; this makes no sense.
330  $this->mRefCallStack[] = false;
331  return $this->error( 'cite_error_ref_no_key' );
332  }
333 
334  if ( preg_match( '/^[0-9]+$/', $key ) || preg_match( '/^[0-9]+$/', $follow ) ) {
335  # Numeric names mess up the resulting id's, potentially produ-
336  # cing duplicate id's in the XHTML. The Right Thing To Do
337  # would be to mangle them, but it's not really high-priority
338  # (and would produce weird id's anyway).
339 
340  $this->mRefCallStack[] = false;
341  return $this->error( 'cite_error_ref_numeric_key' );
342  }
343 
344  if ( preg_match(
345  '/<ref\b[^<]*?>/',
346  preg_replace( '#<([^ ]+?).*?>.*?</\\1 *>|<!--.*?-->#', '', $str )
347  ) ) {
348  # (bug T8199) This most likely implies that someone left off the
349  # closing </ref> tag, which will cause the entire article to be
350  # eaten up until the next <ref>. So we bail out early instead.
351  # The fancy regex above first tries chopping out anything that
352  # looks like a comment or SGML tag, which is a crude way to avoid
353  # false alarms for <nowiki>, <pre>, etc.
354 
355  # Possible improvement: print the warning, followed by the contents
356  # of the <ref> tag. This way no part of the article will be eaten
357  # even temporarily.
358 
359  $this->mRefCallStack[] = false;
360  return $this->error( 'cite_error_included_ref' );
361  }
362 
363  if ( is_string( $key ) || is_string( $str ) ) {
364  # We don't care about the content: if the key exists, the ref
365  # is presumptively valid. Either it stores a new ref, or re-
366  # fers to an existing one. If it refers to a nonexistent ref,
367  # we'll figure that out later. Likewise it's definitely valid
368  # if there's any content, regardless of key.
369 
370  return $this->stack( $str, $key, $group, $follow, $argv );
371  }
372 
373  # Not clear how we could get here, but something is probably
374  # wrong with the types. Let's fail fast.
375  throw new Exception( 'Invalid $str and/or $key: ' . serialize( [ $str, $key ] ) );
376  }
377 
390  private function refArg( array $argv ) {
391  $cnt = count( $argv );
392  $group = null;
393  $key = null;
394  $follow = null;
395 
396  if ( $cnt > 2 ) {
397  // There should only be one key or follow parameter, and one group parameter
398  // FIXME : this looks inconsistent, it should probably return a tuple
399  return false;
400  } elseif ( $cnt >= 1 ) {
401  if ( isset( $argv['name'] ) && isset( $argv['follow'] ) ) {
402  return [ false, false, false ];
403  }
404  if ( isset( $argv['name'] ) ) {
405  // Key given.
406  $key = Sanitizer::escapeId( $argv['name'], 'noninitial' );
407  unset( $argv['name'] );
408  --$cnt;
409  }
410  if ( isset( $argv['follow'] ) ) {
411  // Follow given.
412  $follow = Sanitizer::escapeId( $argv['follow'], 'noninitial' );
413  unset( $argv['follow'] );
414  --$cnt;
415  }
416  if ( isset( $argv['group'] ) ) {
417  // Group given.
418  $group = $argv['group'];
419  unset( $argv['group'] );
420  --$cnt;
421  }
422 
423  if ( $cnt === 0 ) {
424  return [ $key, $group, $follow ];
425  } else {
426  // Invalid key
427  return [ false, false, false ];
428  }
429  } else {
430  // No key
431  return [ null, $group, false ];
432  }
433  }
434 
447  private function stack( $str, $key = null, $group, $follow, array $call ) {
448  if ( !isset( $this->mRefs[$group] ) ) {
449  $this->mRefs[$group] = [];
450  }
451  if ( !isset( $this->mGroupCnt[$group] ) ) {
452  $this->mGroupCnt[$group] = 0;
453  }
454  if ( $follow != null ) {
455  if ( isset( $this->mRefs[$group][$follow] ) && is_array( $this->mRefs[$group][$follow] ) ) {
456  // add text to the note that is being followed
457  $this->mRefs[$group][$follow]['text'] .= ' ' . $str;
458  } else {
459  // insert part of note at the beginning of the group
460  $groupsCount = count( $this->mRefs[$group] );
461  for ( $k = 0; $k < $groupsCount; $k++ ) {
462  if ( !isset( $this->mRefs[$group][$k]['follow'] ) ) {
463  break;
464  }
465  }
466  array_splice( $this->mRefs[$group], $k, 0, [ [
467  'count' => -1,
468  'text' => $str,
469  'key' => ++$this->mOutCnt,
470  'follow' => $follow
471  ] ] );
472  array_splice( $this->mRefCallStack, $k, 0,
473  [ [ 'new', $call, $str, $key, $group, $this->mOutCnt ] ] );
474  }
475  // return an empty string : this is not a reference
476  return '';
477  }
478 
479  if ( $key === null ) {
480  // No key
481  // $this->mRefs[$group][] = $str;
482  $this->mRefs[$group][] = [
483  'count' => -1,
484  'text' => $str,
485  'key' => ++$this->mOutCnt
486  ];
487  $this->mRefCallStack[] = [ 'new', $call, $str, $key, $group, $this->mOutCnt ];
488 
489  return $this->linkRef( $group, $this->mOutCnt );
490  }
491  if ( !is_string( $key ) ) {
492  throw new Exception( 'Invalid stack key: ' . serialize( $key ) );
493  }
494 
495  // Valid key
496  if ( !isset( $this->mRefs[$group][$key] ) || !is_array( $this->mRefs[$group][$key] ) ) {
497  // First occurrence
498  $this->mRefs[$group][$key] = [
499  'text' => $str,
500  'count' => 0,
501  'key' => ++$this->mOutCnt,
502  'number' => ++$this->mGroupCnt[$group]
503  ];
504  $this->mRefCallStack[] = [ 'new', $call, $str, $key, $group, $this->mOutCnt ];
505 
506  return $this->linkRef(
507  $group,
508  $key,
509  $this->mRefs[$group][$key]['key'] . "-" . $this->mRefs[$group][$key]['count'],
510  $this->mRefs[$group][$key]['number'],
511  "-" . $this->mRefs[$group][$key]['key']
512  );
513  }
514 
515  // We've been here before
516  if ( $this->mRefs[$group][$key]['text'] === null && $str !== '' ) {
517  // If no text found before, use this text
518  $this->mRefs[$group][$key]['text'] = $str;
519  $this->mRefCallStack[] = [ 'assign', $call, $str, $key, $group,
520  $this->mRefs[$group][$key]['key'] ];
521  } else {
522  if ( $str != null && $str !== '' && $str !== $this->mRefs[$group][$key]['text'] ) {
523  // two refs with same key and different content
524  // add error message to the original ref
525  $this->mRefs[$group][$key]['text'] .= ' ' . $this->error(
526  'cite_error_references_duplicate_key', $key, 'noparse'
527  );
528  }
529  $this->mRefCallStack[] = [ 'increment', $call, $str, $key, $group,
530  $this->mRefs[$group][$key]['key'] ];
531  }
532  return $this->linkRef(
533  $group,
534  $key,
535  $this->mRefs[$group][$key]['key'] . "-" . ++$this->mRefs[$group][$key]['count'],
536  $this->mRefs[$group][$key]['number'],
537  "-" . $this->mRefs[$group][$key]['key']
538  );
539  }
540 
562  private function rollbackRef( $type, $key, $group, $index ) {
563  if ( !isset( $this->mRefs[$group] ) ) {
564  return;
565  }
566 
567  if ( $key === null ) {
568  foreach ( $this->mRefs[$group] as $k => $v ) {
569  if ( $this->mRefs[$group][$k]['key'] === $index ) {
570  $key = $k;
571  break;
572  }
573  }
574  }
575 
576  // Sanity checks that specified element exists.
577  if ( $key === null ) {
578  return;
579  }
580  if ( !isset( $this->mRefs[$group][$key] ) ) {
581  return;
582  }
583  if ( $this->mRefs[$group][$key]['key'] != $index ) {
584  return;
585  }
586 
587  switch ( $type ) {
588  case 'new':
589  # Rollback the addition of new elements to the stack.
590  unset( $this->mRefs[$group][$key] );
591  if ( $this->mRefs[$group] === [] ) {
592  unset( $this->mRefs[$group] );
593  unset( $this->mGroupCnt[$group] );
594  }
595  break;
596  case 'assign':
597  # Rollback assignment of text to pre-existing elements.
598  $this->mRefs[$group][$key]['text'] = null;
599  # continue without break
600  case 'increment':
601  # Rollback increase in named ref occurrences.
602  $this->mRefs[$group][$key]['count']--;
603  break;
604  }
605  }
606 
617  public function references( $str, array $argv, Parser $parser, PPFrame $frame ) {
618  if ( $this->mInCite || $this->mInReferences ) {
619  if ( is_null( $str ) ) {
620  return htmlspecialchars( "<references/>" );
621  }
622  return htmlspecialchars( "<references>$str</references>" );
623  }
624  $this->mCallCnt++;
625  $this->mInReferences = true;
626  $ret = $this->guardedReferences( $str, $argv, $parser );
627  $this->mInReferences = false;
628  if ( is_callable( [ $frame, 'setVolatile' ] ) ) {
629  $frame->setVolatile();
630  }
631  return $ret;
632  }
633 
642  private function guardedReferences(
643  $str,
644  array $argv,
645  Parser $parser,
646  $group = self::DEFAULT_GROUP
647  ) {
648  global $wgCiteResponsiveReferences;
649 
650  $this->mParser = $parser;
651 
652  if ( isset( $argv['group'] ) ) {
653  $group = $argv['group'];
654  unset( $argv['group'] );
655  }
656 
657  if ( strval( $str ) !== '' ) {
658  $this->mReferencesGroup = $group;
659 
660  # Detect whether we were sent already rendered <ref>s.
661  # Mostly a side effect of using #tag to call references.
662  # The following assumes that the parsed <ref>s sent within
663  # the <references> block were the most recent calls to
664  # <ref>. This assumption is true for all known use cases,
665  # but not strictly enforced by the parser. It is possible
666  # that some unusual combination of #tag, <references> and
667  # conditional parser functions could be created that would
668  # lead to malformed references here.
669  $count = substr_count( $str, Parser::MARKER_PREFIX . "-ref-" );
670  $redoStack = [];
671 
672  # Undo effects of calling <ref> while unaware of containing <references>
673  for ( $i = 1; $i <= $count; $i++ ) {
674  if ( !$this->mRefCallStack ) {
675  break;
676  }
677 
678  $call = array_pop( $this->mRefCallStack );
679  $redoStack[] = $call;
680  if ( $call !== false ) {
681  list( $type, $ref_argv, $ref_str,
682  $ref_key, $ref_group, $ref_index ) = $call;
683  $this->rollbackRef( $type, $ref_key, $ref_group, $ref_index );
684  }
685  }
686 
687  # Rerun <ref> call now that mInReferences is set.
688  for ( $i = count( $redoStack ) - 1; $i >= 0; $i-- ) {
689  $call = $redoStack[$i];
690  if ( $call !== false ) {
691  list( $type, $ref_argv, $ref_str,
692  $ref_key, $ref_group, $ref_index ) = $call;
693  $this->guardedRef( $ref_str, $ref_argv, $parser );
694  }
695  }
696 
697  # Parse $str to process any unparsed <ref> tags.
698  $parser->recursiveTagParse( $str );
699 
700  # Reset call stack
701  $this->mRefCallStack = [];
702  }
703 
704  if ( isset( $argv['responsive'] ) ) {
705  $responsive = $argv['responsive'] !== '0';
706  unset( $argv['responsive'] );
707  } else {
708  $responsive = $wgCiteResponsiveReferences;
709  }
710 
711  // There are remaining parameters we don't recognise
712  if ( $argv ) {
713  return $this->error( 'cite_error_references_invalid_parameters' );
714  }
715 
716  $s = $this->referencesFormat( $group, $responsive );
717 
718  # Append errors generated while processing <references>
719  if ( $this->mReferencesErrors ) {
720  $s .= "\n" . implode( "<br />\n", $this->mReferencesErrors );
721  $this->mReferencesErrors = [];
722  }
723  return $s;
724  }
725 
733  private function referencesFormat( $group, $responsive ) {
734  if ( !$this->mRefs || !isset( $this->mRefs[$group] ) ) {
735  return '';
736  }
737 
738  $ent = [];
739  foreach ( $this->mRefs[$group] as $k => $v ) {
740  $ent[] = $this->referencesFormatEntry( $k, $v );
741  }
742 
743  // Add new lines between the list items (ref entires) to avoid confusing tidy (bug 13073).
744  // Note: This builds a string of wikitext, not html.
745  $parserInput = Html::rawElement( 'ol', [ 'class' => [ 'references' ] ],
746  "\n" . implode( "\n", $ent ) . "\n"
747  );
748 
749  // Let's try to cache it.
750  global $wgCiteCacheReferences, $wgMemc;
751  $data = false;
752  if ( $wgCiteCacheReferences ) {
753  $cacheKey = wfMemcKey(
754  'citeref',
755  md5( $parserInput ),
756  $this->mParser->Title()->getArticleID()
757  );
758  $data = $wgMemc->get( $cacheKey );
759  }
760 
761  if ( !$data || !$this->mParser->isValidHalfParsedText( $data ) ) {
762 
763  // Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
764  $ret = rtrim( $this->mParser->recursiveTagParse( $parserInput ), "\n" );
765 
766  if ( $wgCiteCacheReferences ) {
767  $serData = $this->mParser->serializeHalfParsedText( $ret );
768  $wgMemc->set( $cacheKey, $serData, 86400 );
769  }
770 
771  } else {
772  $ret = $this->mParser->unserializeHalfParsedText( $data );
773  }
774 
775  if ( $responsive ) {
776  // Use a DIV wrap because column-count on a list directly is broken in Chrome.
777  // See https://bugs.chromium.org/p/chromium/issues/detail?id=498730.
778  $wrapClasses = [ 'mw-references-wrap' ];
779  if ( count( $this->mRefs[$group] ) > 10 ) {
780  $wrapClasses[] = 'mw-references-columns';
781  }
782  $ret = Html::rawElement( 'div', [ 'class' => $wrapClasses ], $ret );
783  }
784 
785  if ( !$this->mParser->getOptions()->getIsPreview() ) {
786  // save references data for later use by LinksUpdate hooks
787  $this->saveReferencesData( $group );
788  }
789 
790  // done, clean up so we can reuse the group
791  unset( $this->mRefs[$group] );
792  unset( $this->mGroupCnt[$group] );
793 
794  return $ret;
795  }
796 
805  private function referencesFormatEntry( $key, $val ) {
806  // Anonymous reference
807  if ( !is_array( $val ) ) {
808  return wfMessage(
809  'cite_references_link_one',
810  self::getReferencesKey( $key ),
811  $this->refKey( $key ),
812  $this->referenceText( $key, $val )
813  )->inContentLanguage()->plain();
814  }
815  $text = $this->referenceText( $key, $val['text'] );
816  if ( isset( $val['follow'] ) ) {
817  return wfMessage(
818  'cite_references_no_link',
819  self::getReferencesKey( $val['follow'] ),
820  $text
821  )->inContentLanguage()->plain();
822  }
823  if ( !isset( $val['count'] ) ) {
824  // this handles the case of section preview for list-defined references
825  return wfMessage( 'cite_references_link_many',
826  self::getReferencesKey( $key . "-" . ( isset( $val['key'] ) ? $val['key'] : '' ) ),
827  '',
828  $text
829  )->inContentLanguage()->plain();
830  }
831  if ( $val['count'] < 0 ) {
832  return wfMessage(
833  'cite_references_link_one',
834  self::getReferencesKey( $val['key'] ),
835  # $this->refKey( $val['key'], $val['count'] ),
836  $this->refKey( $val['key'] ),
837  $text
838  )->inContentLanguage()->plain();
839  // Standalone named reference, I want to format this like an
840  // anonymous reference because displaying "1. 1.1 Ref text" is
841  // overkill and users frequently use named references when they
842  // don't need them for convenience
843  }
844  if ( $val['count'] === 0 ) {
845  return wfMessage(
846  'cite_references_link_one',
847  self::getReferencesKey( $key . "-" . $val['key'] ),
848  # $this->refKey( $key, $val['count'] ),
849  $this->refKey( $key, $val['key'] . "-" . $val['count'] ),
850  $text
851  )->inContentLanguage()->plain();
852  // Named references with >1 occurrences
853  }
854  $links = [];
855  // for group handling, we have an extra key here.
856  for ( $i = 0; $i <= $val['count']; ++$i ) {
857  $links[] = wfMessage(
858  'cite_references_link_many_format',
859  $this->refKey( $key, $val['key'] . "-$i" ),
860  $this->referencesFormatEntryNumericBacklinkLabel( $val['number'], $i, $val['count'] ),
861  $this->referencesFormatEntryAlternateBacklinkLabel( $i )
862  )->inContentLanguage()->plain();
863  }
864 
865  $list = $this->listToText( $links );
866 
867  return wfMessage( 'cite_references_link_many',
868  self::getReferencesKey( $key . "-" . $val['key'] ),
869  $list,
870  $text
871  )->inContentLanguage()->plain();
872  }
873 
880  private function referenceText( $key, $text ) {
881  if ( !isset( $text ) || $text === '' ) {
882  if ( $this->mParser->getOptions()->getIsSectionPreview() ) {
883  return $this->warning( 'cite_warning_sectionpreview_no_text', $key, 'noparse' );
884  }
885  return $this->error( 'cite_error_references_no_text', $key, 'noparse' );
886  }
887  return '<span class="reference-text">' . rtrim( $text, "\n" ) . "</span>\n";
888  }
889 
902  private function referencesFormatEntryNumericBacklinkLabel( $base, $offset, $max ) {
904  $scope = strlen( $max );
905  $ret = $wgContLang->formatNum(
906  sprintf( "%s.%0{$scope}s", $base, $offset )
907  );
908  return $ret;
909  }
910 
921  private function referencesFormatEntryAlternateBacklinkLabel( $offset ) {
922  if ( !isset( $this->mBacklinkLabels ) ) {
923  $this->genBacklinkLabels();
924  }
925  if ( isset( $this->mBacklinkLabels[$offset] ) ) {
926  return $this->mBacklinkLabels[$offset];
927  } else {
928  // Feed me!
929  return $this->error( 'cite_error_references_no_backlink_label', null, 'noparse' );
930  }
931  }
932 
945  private function getLinkLabel( $offset, $group, $label ) {
946  $message = "cite_link_label_group-$group";
947  if ( !isset( $this->mLinkLabels[$group] ) ) {
948  $this->genLinkLabels( $group, $message );
949  }
950  if ( $this->mLinkLabels[$group] === false ) {
951  // Use normal representation, ie. "$group 1", "$group 2"...
952  return $label;
953  }
954 
955  if ( isset( $this->mLinkLabels[$group][$offset - 1] ) ) {
956  return $this->mLinkLabels[$group][$offset - 1];
957  } else {
958  // Feed me!
959  return $this->error( 'cite_error_no_link_label_group', [ $group, $message ], 'noparse' );
960  }
961  }
962 
974  private function refKey( $key, $num = null ) {
975  $prefix = wfMessage( 'cite_reference_link_prefix' )->inContentLanguage()->text();
976  $suffix = wfMessage( 'cite_reference_link_suffix' )->inContentLanguage()->text();
977  if ( isset( $num ) ) {
978  $key = wfMessage( 'cite_reference_link_key_with_num', $key, $num )
979  ->inContentLanguage()->plain();
980  }
981 
982  return "$prefix$key$suffix";
983  }
984 
995  public static function getReferencesKey( $key ) {
996  $prefix = wfMessage( 'cite_references_link_prefix' )->inContentLanguage()->text();
997  $suffix = wfMessage( 'cite_references_link_suffix' )->inContentLanguage()->text();
998 
999  return "$prefix$key$suffix";
1000  }
1001 
1017  private function linkRef( $group, $key, $count = null, $label = null, $subkey = '' ) {
1019  $label = is_null( $label ) ? ++$this->mGroupCnt[$group] : $label;
1020 
1021  return
1022  $this->mParser->recursiveTagParse(
1023  wfMessage(
1024  'cite_reference_link',
1025  $this->refKey( $key, $count ),
1026  self::getReferencesKey( $key . $subkey ),
1027  $this->getLinkLabel( $label, $group,
1028  ( ( $group === self::DEFAULT_GROUP ) ? '' : "$group " ) . $wgContLang->formatNum( $label ) )
1029  )->inContentLanguage()->plain()
1030  );
1031  }
1032 
1045  private function listToText( $arr ) {
1046  $cnt = count( $arr );
1047 
1048  $sep = wfMessage( 'cite_references_link_many_sep' )->inContentLanguage()->plain();
1049  $and = wfMessage( 'cite_references_link_many_and' )->inContentLanguage()->plain();
1050 
1051  if ( $cnt === 1 ) {
1052  // Enforce always returning a string
1053  return (string)$arr[0];
1054  } else {
1055  $t = array_slice( $arr, 0, $cnt - 1 );
1056  return implode( $sep, $t ) . $and . $arr[$cnt - 1];
1057  }
1058  }
1059 
1065  private function genBacklinkLabels() {
1066  $text = wfMessage( 'cite_references_link_many_format_backlink_labels' )
1067  ->inContentLanguage()->plain();
1068  $this->mBacklinkLabels = preg_split( '#[\n\t ]#', $text );
1069  }
1070 
1079  private function genLinkLabels( $group, $message ) {
1080  $text = false;
1081  $msg = wfMessage( $message )->inContentLanguage();
1082  if ( $msg->exists() ) {
1083  $text = $msg->plain();
1084  }
1085  $this->mLinkLabels[$group] = ( !$text ) ? false : preg_split( '#[\n\t ]#', $text );
1086  }
1087 
1096  public function clearState( Parser &$parser ) {
1097  if ( $parser->extCite !== $this ) {
1098  return $parser->extCite->clearState( $parser );
1099  }
1100 
1101  # Don't clear state when we're in the middle of parsing
1102  # a <ref> tag
1103  if ( $this->mInCite || $this->mInReferences ) {
1104  return true;
1105  }
1106 
1107  $this->mGroupCnt = [];
1108  $this->mOutCnt = 0;
1109  $this->mCallCnt = 0;
1110  $this->mRefs = [];
1111  $this->mReferencesErrors = [];
1112  $this->mRefCallStack = [];
1113 
1114  return true;
1115  }
1116 
1124  public function cloneState( Parser $parser ) {
1125  if ( $parser->extCite !== $this ) {
1126  return $parser->extCite->cloneState( $parser );
1127  }
1128 
1129  $parser->extCite = clone $this;
1130  $parser->setHook( 'ref', [ $parser->extCite, 'ref' ] );
1131  $parser->setHook( 'references', [ $parser->extCite, 'references' ] );
1132 
1133  // Clear the state, making sure it will actually work.
1134  $parser->extCite->mInCite = false;
1135  $parser->extCite->mInReferences = false;
1136  $parser->extCite->clearState( $parser );
1137 
1138  return true;
1139  }
1140 
1155  public function checkRefsNoReferences( $afterParse, &$parser, &$text ) {
1156  global $wgCiteResponsiveReferences;
1157  if ( is_null( $parser->extCite ) ) {
1158  return true;
1159  }
1160  if ( $parser->extCite !== $this ) {
1161  return $parser->extCite->checkRefsNoReferences( $afterParse, $parser, $text );
1162  }
1163 
1164  if ( $afterParse ) {
1165  $this->mHaveAfterParse = true;
1166  } elseif ( $this->mHaveAfterParse ) {
1167  return true;
1168  }
1169 
1170  if ( !$parser->getOptions()->getIsPreview() ) {
1171  // save references data for later use by LinksUpdate hooks
1172  if ( $this->mRefs && isset( $this->mRefs[self::DEFAULT_GROUP] ) ) {
1173  $this->saveReferencesData();
1174  }
1175  $isSectionPreview = false;
1176  } else {
1177  $isSectionPreview = $parser->getOptions()->getIsSectionPreview();
1178  }
1179 
1180  $s = '';
1181  foreach ( $this->mRefs as $group => $refs ) {
1182  if ( !$refs ) {
1183  continue;
1184  }
1185  if ( $group === self::DEFAULT_GROUP || $isSectionPreview ) {
1186  $s .= $this->referencesFormat( $group, $wgCiteResponsiveReferences );
1187  } else {
1188  $s .= "\n<br />" .
1189  $this->error( 'cite_error_group_refs_without_references', htmlspecialchars( $group ) );
1190  }
1191  }
1192  if ( $isSectionPreview && $s !== '' ) {
1193  // provide a preview of references in its own section
1194  $text .= "\n" . '<div class="mw-ext-cite-cite_section_preview_references" >';
1195  $headerMsg = wfMessage( 'cite_section_preview_references' );
1196  if ( !$headerMsg->isDisabled() ) {
1197  $text .= '<h2 id="mw-ext-cite-cite_section_preview_references_header" >'
1198  . $headerMsg->escaped()
1199  . '</h2>';
1200  }
1201  $text .= $s . '</div>';
1202  } else {
1203  $text .= $s;
1204  }
1205  return true;
1206  }
1207 
1215  private function saveReferencesData( $group = self::DEFAULT_GROUP ) {
1216  global $wgCiteStoreReferencesData;
1217  if ( !$wgCiteStoreReferencesData ) {
1218  return;
1219  }
1220  $savedRefs = $this->mParser->getOutput()->getExtensionData( self::EXT_DATA_KEY );
1221  if ( $savedRefs === null ) {
1222  // Initialize array structure
1223  $savedRefs = [
1224  'refs' => [],
1225  'version' => self::DATA_VERSION_NUMBER,
1226  ];
1227  }
1228  if ( $this->mBumpRefData ) {
1229  // This handles pages with multiple <references/> tags with <ref> tags in between.
1230  // On those, a group can appear several times, so we need to avoid overwriting
1231  // a previous appearance.
1232  $savedRefs['refs'][] = [];
1233  $this->mBumpRefData = false;
1234  }
1235  $n = count( $savedRefs['refs'] ) - 1;
1236  // save group
1237  $savedRefs['refs'][$n][$group] = $this->mRefs[$group];
1238 
1239  $this->mParser->getOutput()->setExtensionData( self::EXT_DATA_KEY, $savedRefs );
1240  }
1241 
1251  public function checkAnyCalls( &$output ) {
1252  global $wgParser;
1253  /* InlineEditor always uses $wgParser */
1254  return ( $wgParser->extCite->mCallCnt <= 0 );
1255  }
1256 
1264  public static function setHooks( Parser $parser ) {
1265  global $wgHooks;
1266 
1267  $parser->extCite = new self();
1268 
1269  if ( !Cite::$hooksInstalled ) {
1270  $wgHooks['ParserClearState'][] = [ $parser->extCite, 'clearState' ];
1271  $wgHooks['ParserCloned'][] = [ $parser->extCite, 'cloneState' ];
1272  $wgHooks['ParserAfterParse'][] = [ $parser->extCite, 'checkRefsNoReferences', true ];
1273  $wgHooks['ParserBeforeTidy'][] = [ $parser->extCite, 'checkRefsNoReferences', false ];
1274  $wgHooks['InlineEditorPartialAfterParse'][] = [ $parser->extCite, 'checkAnyCalls' ];
1275  Cite::$hooksInstalled = true;
1276  }
1277  $parser->setHook( 'ref', [ $parser->extCite, 'ref' ] );
1278  $parser->setHook( 'references', [ $parser->extCite, 'references' ] );
1279 
1280  return true;
1281  }
1282 
1291  private function error( $key, $param = null, $parse = 'parse' ) {
1292  # For ease of debugging and because errors are rare, we
1293  # use the user language and split the parser cache.
1294  $lang = $this->mParser->getOptions()->getUserLangObj();
1295  $dir = $lang->getDir();
1296 
1297  # We rely on the fact that PHP is okay with passing unused argu-
1298  # ments to functions. If $1 is not used in the message, wfMessage will
1299  # just ignore the extra parameter.
1300  $msg = wfMessage(
1301  'cite_error',
1302  wfMessage( $key, $param )->inLanguage( $lang )->plain()
1303  )
1304  ->inLanguage( $lang )
1305  ->plain();
1306 
1307  $this->mParser->addTrackingCategory( 'cite-tracking-category-cite-error' );
1308 
1310  'span',
1311  [
1312  'class' => 'error mw-ext-cite-error',
1313  'lang' => $lang->getHtmlCode(),
1314  'dir' => $dir,
1315  ],
1316  $msg
1317  );
1318 
1319  if ( $parse === 'parse' ) {
1320  $ret = $this->mParser->recursiveTagParse( $ret );
1321  }
1322 
1323  return $ret;
1324  }
1325 
1334  private function warning( $key, $param = null, $parse = 'parse' ) {
1335  # For ease of debugging and because errors are rare, we
1336  # use the user language and split the parser cache.
1337  $lang = $this->mParser->getOptions()->getUserLangObj();
1338  $dir = $lang->getDir();
1339 
1340  # We rely on the fact that PHP is okay with passing unused argu-
1341  # ments to functions. If $1 is not used in the message, wfMessage will
1342  # just ignore the extra parameter.
1343  $msg = wfMessage(
1344  'cite_warning',
1345  wfMessage( $key, $param )->inLanguage( $lang )->plain()
1346  )
1347  ->inLanguage( $lang )
1348  ->plain();
1349 
1350  $key = preg_replace( '/^cite_warning_/', '', $key ) . '';
1352  'span',
1353  [
1354  'class' => 'warning mw-ext-cite-warning mw-ext-cite-warning-' .
1355  Sanitizer::escapeClass( $key ),
1356  'lang' => $lang->getHtmlCode(),
1357  'dir' => $dir,
1358  ],
1359  $msg
1360  );
1361 
1362  if ( $parse === 'parse' ) {
1363  $ret = $this->mParser->recursiveTagParse( $ret );
1364  }
1365 
1366  return $ret;
1367  }
1368 
1376  public static function getStoredReferences( Title $title ) {
1377  global $wgCiteStoreReferencesData;
1378  if ( !$wgCiteStoreReferencesData ) {
1379  return false;
1380  }
1382  $key = $cache->makeKey( self::EXT_DATA_KEY, $title->getArticleID() );
1383  return $cache->getWithSetCallback(
1384  $key,
1385  self::CACHE_DURATION_ONFETCH,
1386  function ( $oldValue, &$ttl, array &$setOpts ) use ( $title ) {
1387  $dbr = wfGetDB( DB_SLAVE );
1388  $setOpts += Database::getCacheSetOptions( $dbr );
1389  return self::recursiveFetchRefsFromDB( $title, $dbr );
1390  },
1391  [
1392  'checkKeys' => [ $key ],
1393  'lockTSE' => 30,
1394  ]
1395  );
1396  }
1397 
1409  private static function recursiveFetchRefsFromDB( Title $title, DatabaseBase $dbr,
1410  $string = '', $i = 1 ) {
1411  $id = $title->getArticleID();
1412  $result = $dbr->selectField(
1413  'page_props',
1414  'pp_value',
1415  [
1416  'pp_page' => $id,
1417  'pp_propname' => 'references-' . $i
1418  ],
1419  __METHOD__
1420  );
1421  if ( $result !== false ) {
1422  $string .= $result;
1423  $decodedString = gzdecode( $string );
1424  if ( $decodedString !== false ) {
1425  $json = json_decode( $decodedString, true );
1426  if ( json_last_error() === JSON_ERROR_NONE ) {
1427  return $json;
1428  }
1429  // corrupted json ?
1430  // shouldn't happen since when string is truncated, gzdecode should fail
1431  wfDebug( "Corrupted json detected when retrieving stored references for title id $id" );
1432  }
1433  // if gzdecode fails, try to fetch next references- property value
1434  return self::recursiveFetchRefsFromDB( $title, $dbr, $string, ++$i );
1435 
1436  } else {
1437  // no refs stored in page_props at this index
1438  if ( $i > 1 ) {
1439  // shouldn't happen
1440  wfDebug( "Failed to retrieve stored references for title id $id" );
1441  }
1442  return false;
1443  }
1444  }
1445 
1446 }
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
$wgParser
$wgParser
Definition: Setup.php:796
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:225
$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
$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. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. '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 '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 '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 '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. '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 IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() '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 Sanitizer::validateEmail(), 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. '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) '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 '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:Array with elements of the form "language:title" in the order that they will be output. & $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. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. 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:1954
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
serialize
serialize()
Definition: ApiMessage.php:177
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:34
$s
$s
Definition: mergeMessageFileList.php:188
$type
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 before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
$base
$base
Definition: generateLocalAutoload.php:10
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
wfMemcKey
wfMemcKey()
Make a cache key for the local wiki.
Definition: GlobalFunctions.php:2961
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
PPFrame\setVolatile
setVolatile( $flag=true)
Set the "volatile" flag.
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2536
$output
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition: hooks.txt:1049
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:999
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
$dir
$dir
Definition: Autoload.php:8
PPFrame
Definition: Preprocessor.php:165
$ret
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 noclasses & $ret
Definition: hooks.txt:1956
error
&</p >< p >< sup id="cite_ref-blank_1-1" class="reference">< a href="#cite_note-blank-1"> &</p >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-blank-1">< span class="mw-cite-backlink"> ↑< sup >< a href="#cite_ref-blank_1-0"></a ></sup >< sup >< a href="#cite_ref-blank_1-1"></a ></sup ></span >< span class="reference-text">< span class="error mw-ext-cite-error" lang="en" dir="ltr"> Cite error
Definition: citeParserTests.txt:219
plain
either a plain
Definition: hooks.txt:2007
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
$cache
$cache
Definition: mcc.php:33
ObjectCache\getMainWANInstance
static getMainWANInstance()
Get the main WAN cache object.
Definition: ObjectCache.php:370
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
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
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
true
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 noclasses just before the function returns a value If you return true
Definition: hooks.txt:1956
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
$argv
global $argv
Definition: autoload.ide.php:24
$t
$t
Definition: testCompression.php:67
$parserOutput
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
Definition: hooks.txt:1049
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$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