209 if ( $this->mInCite ) {
210 return htmlspecialchars(
"<ref>$str</ref>" );
214 $this->mInCite =
true;
218 $this->mInCite =
false;
220 $parserOutput =
$parser->getOutput();
221 $parserOutput->addModules(
'ext.cite.a11y' );
222 $parserOutput->addModuleStyles(
'ext.cite.styles' );
224 if ( is_callable( [ $frame,
'setVolatile' ] ) ) {
230 $this->mBumpRefData =
true;
248 $default_group = self::DEFAULT_GROUP
252 # The key here is the "name" attribute.
253 list( $key, $group, $follow ) = $this->
refArg( $argv );
255 # Split these into groups.
256 if ( $group ===
null ) {
257 if ( $this->mInReferences ) {
260 $group = $default_group;
271 if ( $this->mInReferences ) {
272 $isSectionPreview =
$parser->getOptions()->getIsSectionPreview();
273 if ( $group != $this->mReferencesGroup ) {
274 # <ref> and <references> have conflicting group attributes.
275 $this->mReferencesErrors[] =
277 'cite_error_references_group_mismatch',
278 Sanitizer::safeEncodeAttribute( $group )
280 } elseif ( $str !==
'' ) {
281 if ( !$isSectionPreview && !isset( $this->mRefs[$group] ) ) {
282 # Called with group attribute not defined in text.
283 $this->mReferencesErrors[] =
285 'cite_error_references_missing_group',
286 Sanitizer::safeEncodeAttribute( $group )
288 } elseif ( $key ===
null || $key ===
'' ) {
289 # <ref> calls inside <references> must be named
290 $this->mReferencesErrors[] =
291 $this->
error(
'cite_error_references_no_key' );
292 } elseif ( !$isSectionPreview && !isset( $this->mRefs[$group][$key] ) ) {
293 # Called with name attribute not defined in text.
294 $this->mReferencesErrors[] =
295 $this->
error(
'cite_error_references_missing_key', Sanitizer::safeEncodeAttribute( $key ) );
298 isset( $this->mRefs[$group][$key][
'text'] ) &&
299 $str !== $this->mRefs[$group][$key][
'text']
303 $this->mRefs[$group][$key][
'text'] .=
' ' . $this->
error(
304 'cite_error_references_duplicate_key', $key,
'noparse'
307 # Assign the text to corresponding ref
308 $this->mRefs[$group][$key][
'text'] = $str;
312 # <ref> called in <references> has no content.
313 $this->mReferencesErrors[] =
314 $this->
error(
'cite_error_empty_references_define', Sanitizer::safeEncodeAttribute( $key ) );
320 # <ref ...></ref>. This construct is invalid if
321 # it's a contentful ref, but OK if it's a named duplicate and should
322 # be equivalent <ref ... />, for compatability with #tag.
323 if ( is_string( $key ) && $key !==
'' ) {
326 $this->mRefCallStack[] =
false;
328 return $this->
error(
'cite_error_ref_no_input' );
332 if ( $key ===
false ) {
333 # TODO: Comment this case; what does this condition mean?
334 $this->mRefCallStack[] =
false;
335 return $this->
error(
'cite_error_ref_too_many_keys' );
338 if ( $str ===
null && $key ===
null ) {
339 # Something like <ref />; this makes no sense.
340 $this->mRefCallStack[] =
false;
341 return $this->
error(
'cite_error_ref_no_key' );
344 if ( is_string( $key ) && preg_match(
'/^[0-9]+$/', $key ) ||
345 is_string( $follow ) && preg_match(
'/^[0-9]+$/', $follow )
347 # Numeric names mess up the resulting id's, potentially produ-
348 # cing duplicate id's in the XHTML. The Right Thing To Do
349 # would be to mangle them, but it's not really high-priority
350 # (and would produce weird id's anyway).
352 $this->mRefCallStack[] =
false;
353 return $this->
error(
'cite_error_ref_numeric_key' );
358 preg_replace(
'#<([^ ]+?).*?>.*?</\\1 *>|<!--.*?-->#',
'', $str )
360 # (bug T8199) This most likely implies that someone left off the
361 # closing </ref> tag, which will cause the entire article to be
362 # eaten up until the next <ref>. So we bail out early instead.
363 # The fancy regex above first tries chopping out anything that
364 # looks like a comment or SGML tag, which is a crude way to avoid
365 # false alarms for <nowiki>, <pre>, etc.
367 # Possible improvement: print the warning, followed by the contents
368 # of the <ref> tag. This way no part of the article will be eaten
371 $this->mRefCallStack[] =
false;
372 return $this->
error(
'cite_error_included_ref' );
375 if ( is_string( $key ) || is_string( $str ) ) {
376 # We don't care about the content: if the key exists, the ref
377 # is presumptively valid. Either it stores a new ref, or re-
378 # fers to an existing one. If it refers to a nonexistent ref,
379 # we'll figure that out later. Likewise it's definitely valid
380 # if there's any content, regardless of key.
382 return $this->
stack( $str, $key, $group, $follow,
$argv );
385 # Not clear how we could get here, but something is probably
386 # wrong with the types. Let's fail fast.
387 throw new Exception(
'Invalid $str and/or $key: ' .
serialize( [ $str, $key ] ) );
402 $cnt = count(
$argv );
411 } elseif ( $cnt >= 1 ) {
412 if ( isset(
$argv[
'name'] ) && isset(
$argv[
'follow'] ) ) {
413 return [
false,
false,
false ];
415 if ( isset(
$argv[
'name'] ) ) {
417 $key = trim(
$argv[
'name'] );
418 unset(
$argv[
'name'] );
421 if ( isset(
$argv[
'follow'] ) ) {
423 $follow = trim(
$argv[
'follow'] );
424 unset(
$argv[
'follow'] );
427 if ( isset(
$argv[
'group'] ) ) {
429 $group =
$argv[
'group'];
430 unset(
$argv[
'group'] );
435 return [ $key, $group, $follow ];
438 return [
false,
false,
false ];
442 return [
null, $group,
false ];
458 private function stack( $str, $key, $group, $follow, array $call ) {
459 if ( !isset( $this->mRefs[$group] ) ) {
460 $this->mRefs[$group] = [];
462 if ( !isset( $this->mGroupCnt[$group] ) ) {
463 $this->mGroupCnt[$group] = 0;
465 if ( $follow !=
null ) {
466 if ( isset( $this->mRefs[$group][$follow] ) && is_array( $this->mRefs[$group][$follow] ) ) {
468 $this->mRefs[$group][$follow][
'text'] .=
' ' . $str;
471 $groupsCount = count( $this->mRefs[$group] );
472 for ( $k = 0; $k < $groupsCount; $k++ ) {
473 if ( !isset( $this->mRefs[$group][$k][
'follow'] ) ) {
477 array_splice( $this->mRefs[$group], $k, 0, [ [
480 'key' => ++$this->mOutCnt,
483 array_splice( $this->mRefCallStack, $k, 0,
484 [ [
'new', $call, $str, $key, $group, $this->mOutCnt ] ] );
490 if ( $key ===
null ) {
493 $this->mRefs[$group][] = [
498 $this->mRefCallStack[] = [
'new', $call, $str, $key, $group,
$this->mOutCnt ];
500 return $this->
linkRef( $group, $this->mOutCnt );
502 if ( !is_string( $key ) ) {
503 throw new Exception(
'Invalid stack key: ' .
serialize( $key ) );
507 if ( !isset( $this->mRefs[$group][$key] ) || !is_array( $this->mRefs[$group][$key] ) ) {
509 $this->mRefs[$group][$key] = [
513 'number' => ++$this->mGroupCnt[$group]
515 $this->mRefCallStack[] = [
'new', $call, $str, $key, $group,
$this->mOutCnt ];
520 $this->mRefs[$group][$key][
'key'] .
"-" . $this->mRefs[$group][$key][
'count'],
521 $this->mRefs[$group][$key][
'number'],
522 "-" . $this->mRefs[$group][$key][
'key']
527 if ( $this->mRefs[$group][$key][
'text'] ===
null && $str !==
'' ) {
529 $this->mRefs[$group][$key][
'text'] = $str;
530 $this->mRefCallStack[] = [
'assign', $call, $str, $key, $group,
531 $this->mRefs[$group][$key][
'key'] ];
533 if ( $str !=
null && $str !==
'' && $str !== $this->mRefs[$group][$key][
'text'] ) {
536 $this->mRefs[$group][$key][
'text'] .=
' ' . $this->
error(
537 'cite_error_references_duplicate_key', $key,
'noparse'
540 $this->mRefCallStack[] = [
'increment', $call, $str, $key, $group,
541 $this->mRefs[$group][$key][
'key'] ];
546 $this->mRefs[$group][$key][
'key'] .
"-" . ++$this->mRefs[$group][$key][
'count'],
547 $this->mRefs[$group][$key][
'number'],
548 "-" . $this->mRefs[$group][$key][
'key']
574 if ( !isset( $this->mRefs[$group] ) ) {
578 if ( $key ===
null ) {
579 foreach ( $this->mRefs[$group] as $k => $v ) {
580 if ( $this->mRefs[$group][$k][
'key'] === $index ) {
588 if ( $key ===
null ) {
591 if ( !isset( $this->mRefs[$group][$key] ) ) {
594 if ( $this->mRefs[$group][$key][
'key'] != $index ) {
600 # Rollback the addition of new elements to the stack.
601 unset( $this->mRefs[$group][$key] );
602 if ( $this->mRefs[$group] === [] ) {
603 unset( $this->mRefs[$group] );
604 unset( $this->mGroupCnt[$group] );
608 # Rollback assignment of text to pre-existing elements.
609 $this->mRefs[$group][$key][
'text'] =
null;
610 # continue without break
612 # Rollback increase in named ref occurrences.
613 $this->mRefs[$group][$key][
'count']--;
629 if ( $this->mInCite || $this->mInReferences ) {
630 if ( is_null( $str ) ) {
631 return htmlspecialchars(
"<references/>" );
633 return htmlspecialchars(
"<references>$str</references>" );
636 $this->mInReferences =
true;
638 $this->mInReferences =
false;
639 if ( is_callable( [ $frame,
'setVolatile' ] ) ) {
657 $group = self::DEFAULT_GROUP
659 global $wgCiteResponsiveReferences;
663 if ( isset(
$argv[
'group'] ) ) {
664 $group =
$argv[
'group'];
665 unset(
$argv[
'group'] );
668 if ( strval( $str ) !==
'' ) {
669 $this->mReferencesGroup = $group;
671 # Detect whether we were sent already rendered <ref>s.
672 # Mostly a side effect of using #tag to call references.
673 # The following assumes that the parsed <ref>s sent within
674 # the <references> block were the most recent calls to
675 # <ref>. This assumption is true for all known use cases,
676 # but not strictly enforced by the parser. It is possible
677 # that some unusual combination of #tag, <references> and
678 # conditional parser functions could be created that would
679 # lead to malformed references here.
680 $count = substr_count( $str, Parser::MARKER_PREFIX .
"-ref-" );
683 # Undo effects of calling <ref> while unaware of containing <references>
684 for ( $i = 1; $i <= $count; $i++ ) {
685 if ( !$this->mRefCallStack ) {
689 $call = array_pop( $this->mRefCallStack );
690 $redoStack[] = $call;
691 if ( $call !==
false ) {
693 $ref_key, $ref_group, $ref_index ) = $call;
698 # Rerun <ref> call now that mInReferences is set.
699 for ( $i = count( $redoStack ) - 1; $i >= 0; $i-- ) {
700 $call = $redoStack[$i];
701 if ( $call !==
false ) {
703 $ref_key, $ref_group, $ref_index ) = $call;
708 # Parse $str to process any unparsed <ref> tags.
709 $parser->recursiveTagParse( $str );
712 $this->mRefCallStack = [];
715 if ( isset(
$argv[
'responsive'] ) ) {
716 $responsive =
$argv[
'responsive'] !==
'0';
717 unset(
$argv[
'responsive'] );
719 $responsive = $wgCiteResponsiveReferences;
724 return $this->
error(
'cite_error_references_invalid_parameters' );
729 # Append errors generated while processing <references>
730 if ( $this->mReferencesErrors ) {
731 $s .=
"\n" . implode(
"<br />\n", $this->mReferencesErrors );
732 $this->mReferencesErrors = [];
745 if ( !$this->mRefs || !isset( $this->mRefs[$group] ) ) {
750 foreach ( $this->mRefs[$group] as $k => $v ) {
756 $parserInput = Html::rawElement(
'ol', [
'class' => [
'references' ] ],
757 "\n" . implode(
"\n", $ent ) .
"\n"
761 $ret = rtrim( $this->mParser->recursiveTagParse( $parserInput ),
"\n" );
766 $wrapClasses = [
'mw-references-wrap' ];
767 if ( count( $this->mRefs[$group] ) > 10 ) {
768 $wrapClasses[] =
'mw-references-columns';
770 $ret = Html::rawElement(
'div', [
'class' => $wrapClasses ],
$ret );
773 if ( !$this->mParser->getOptions()->getIsPreview() ) {
779 unset( $this->mRefs[$group] );
780 unset( $this->mGroupCnt[$group] );
795 if ( !is_array( $val ) ) {
797 'cite_references_link_one',
799 self::getReferencesKey( $key )
805 )->inContentLanguage()->plain();
808 if ( isset( $val[
'follow'] ) ) {
810 'cite_references_no_link',
812 self::getReferencesKey( $val[
'follow'] )
815 )->inContentLanguage()->plain();
817 if ( !isset( $val[
'count'] ) ) {
819 return wfMessage(
'cite_references_link_many',
821 self::getReferencesKey( $key .
"-" . ( isset( $val[
'key'] ) ? $val[
'key'] :
'' ) )
825 )->inContentLanguage()->plain();
827 if ( $val[
'count'] < 0 ) {
829 'cite_references_link_one',
831 self::getReferencesKey( $val[
'key'] )
834 # $this->
refKey( $val[
'key'], $val[
'count'] )
835 $this->
refKey( $val[
'key'] )
838 )->inContentLanguage()->plain();
844 if ( $val[
'count'] === 0 ) {
846 'cite_references_link_one',
848 self::getReferencesKey( $key .
"-" . $val[
'key'] )
851 # $this->
refKey( $key, $val[
'count'] ),
852 $this->
refKey( $key, $val[
'key'] .
"-" . $val[
'count'] )
855 )->inContentLanguage()->plain();
860 for ( $i = 0; $i <= $val[
'count']; ++$i ) {
862 'cite_references_link_many_format',
864 $this->
refKey( $key, $val[
'key'] .
"-$i" )
868 )->inContentLanguage()->plain();
873 return wfMessage(
'cite_references_link_many',
875 self::getReferencesKey( $key .
"-" . $val[
'key'] )
879 )->inContentLanguage()->plain();
889 if ( !isset( $text ) || $text ===
'' ) {
890 if ( $this->mParser->getOptions()->getIsSectionPreview() ) {
891 return $this->
warning(
'cite_warning_sectionpreview_no_text', $key,
'noparse' );
893 return $this->
error(
'cite_error_references_no_text', $key,
'noparse' );
895 return '<span class="reference-text">' . rtrim( $text,
"\n" ) .
"</span>\n";
912 $scope = strlen( $max );
914 sprintf(
"%s.%0{$scope}s",
$base, $offset )
930 if ( !isset( $this->mBacklinkLabels ) ) {
933 if ( isset( $this->mBacklinkLabels[$offset] ) ) {
934 return $this->mBacklinkLabels[$offset];
937 return $this->
error(
'cite_error_references_no_backlink_label',
null,
'noparse' );
954 $message =
"cite_link_label_group-$group";
955 if ( !isset( $this->mLinkLabels[$group] ) ) {
958 if ( $this->mLinkLabels[$group] ===
false ) {
963 if ( isset( $this->mLinkLabels[$group][$offset - 1] ) ) {
964 return $this->mLinkLabels[$group][$offset - 1];
967 return $this->
error(
'cite_error_no_link_label_group', [ $group, $message ],
'noparse' );
982 private function refKey( $key, $num =
null ) {
983 $prefix =
wfMessage(
'cite_reference_link_prefix' )->inContentLanguage()->text();
984 $suffix =
wfMessage(
'cite_reference_link_suffix' )->inContentLanguage()->text();
985 if ( isset( $num ) ) {
986 $key =
wfMessage(
'cite_reference_link_key_with_num', $key, $num )
987 ->inContentLanguage()->plain();
990 return "$prefix$key$suffix";
1004 $prefix =
wfMessage(
'cite_references_link_prefix' )->inContentLanguage()->text();
1005 $suffix =
wfMessage(
'cite_references_link_suffix' )->inContentLanguage()->text();
1007 return "$prefix$key$suffix";
1025 private function linkRef( $group, $key, $count =
null, $label =
null, $subkey =
'' ) {
1027 $label = is_null( $label ) ? ++$this->mGroupCnt[$group] : $label;
1029 return $this->mParser->recursiveTagParse(
1031 'cite_reference_link',
1033 $this->
refKey( $key, $count )
1036 self::getReferencesKey( $key . $subkey )
1038 Sanitizer::safeEncodeAttribute(
1040 ( ( $group === self::DEFAULT_GROUP ) ?
'' :
"$group " ) .
$wgContLang->formatNum( $label ) )
1042 )->inContentLanguage()->plain()
1053 $key = Sanitizer::escapeIdForAttribute( $key );
1054 $key = Sanitizer::safeEncodeAttribute( $key );
1072 $cnt = count( $arr );
1074 $sep =
wfMessage(
'cite_references_link_many_sep' )->inContentLanguage()->plain();
1075 $and =
wfMessage(
'cite_references_link_many_and' )->inContentLanguage()->plain();
1079 return (
string)$arr[0];
1081 $t = array_slice( $arr, 0, $cnt - 1 );
1082 return implode( $sep,
$t ) . $and . $arr[$cnt - 1];
1092 $text =
wfMessage(
'cite_references_link_many_format_backlink_labels' )
1093 ->inContentLanguage()->plain();
1094 $this->mBacklinkLabels = preg_split(
'#[\n\t ]#', $text );
1107 $msg =
wfMessage( $message )->inContentLanguage();
1108 if ( $msg->exists() ) {
1109 $text = $msg->plain();
1111 $this->mLinkLabels[$group] = ( !$text ) ?
false : preg_split(
'#[\n\t ]#', $text );
1123 if (
$parser->extCite !== $this ) {
1127 # Don't clear state when we're in the middle of parsing
1129 if ( $this->mInCite || $this->mInReferences ) {
1133 $this->mGroupCnt = [];
1135 $this->mCallCnt = 0;
1137 $this->mReferencesErrors = [];
1138 $this->mRefCallStack = [];
1151 if (
$parser->extCite !== $this ) {
1155 $parser->extCite = clone $this;
1157 $parser->setHook(
'references', [
$parser->extCite,
'references' ] );
1160 $parser->extCite->mInCite =
false;
1161 $parser->extCite->mInReferences =
false;
1182 global $wgCiteResponsiveReferences;
1183 if ( is_null(
$parser->extCite ) ) {
1186 if (
$parser->extCite !== $this ) {
1187 return $parser->extCite->checkRefsNoReferences( $afterParse,
$parser, $text );
1190 if ( $afterParse ) {
1191 $this->mHaveAfterParse =
true;
1192 } elseif ( $this->mHaveAfterParse ) {
1196 if ( !
$parser->getOptions()->getIsPreview() ) {
1198 if ( $this->mRefs && isset( $this->mRefs[self::DEFAULT_GROUP] ) ) {
1201 $isSectionPreview =
false;
1203 $isSectionPreview =
$parser->getOptions()->getIsSectionPreview();
1207 foreach ( $this->mRefs as $group => $refs ) {
1211 if ( $group === self::DEFAULT_GROUP || $isSectionPreview ) {
1216 'cite_error_group_refs_without_references',
1217 Sanitizer::safeEncodeAttribute( $group )
1221 if ( $isSectionPreview &&
$s !==
'' ) {
1223 $text .=
"\n" .
'<div class="mw-ext-cite-cite_section_preview_references" >';
1224 $headerMsg =
wfMessage(
'cite_section_preview_references' );
1225 if ( !$headerMsg->isDisabled() ) {
1226 $text .=
'<h2 id="mw-ext-cite-cite_section_preview_references_header" >'
1227 . $headerMsg->escaped()
1230 $text .=
$s .
'</div>';
1245 global $wgCiteStoreReferencesData;
1246 if ( !$wgCiteStoreReferencesData ) {
1249 $savedRefs = $this->mParser->getOutput()->getExtensionData( self::EXT_DATA_KEY );
1250 if ( $savedRefs ===
null ) {
1257 if ( $this->mBumpRefData ) {
1261 $savedRefs[
'refs'][] = [];
1262 $this->mBumpRefData =
false;
1264 $n = count( $savedRefs[
'refs'] ) - 1;
1266 $savedRefs[
'refs'][$n][$group] = $this->mRefs[$group];
1268 $this->mParser->getOutput()->setExtensionData( self::EXT_DATA_KEY, $savedRefs );
1283 return (
$wgParser->extCite->mCallCnt <= 0 );
1296 $parser->extCite =
new self();
1298 if ( !self::$hooksInstalled ) {
1303 $wgHooks[
'InlineEditorPartialAfterParse'][] = [
$parser->extCite,
'checkAnyCalls' ];
1304 self::$hooksInstalled =
true;
1307 $parser->setHook(
'references', [
$parser->extCite,
'references' ] );
1320 private function error( $key, $param =
null, $parse =
'parse' ) {
1321 # For ease of debugging and because errors are rare, we
1322 # use the user language and split the parser cache.
1323 $lang = $this->mParser->getOptions()->getUserLangObj();
1324 $dir =
$lang->getDir();
1326 # We rely on the fact that PHP is okay with passing unused argu-
1327 # ments to functions. If $1 is not used in the message, wfMessage will
1328 # just ignore the extra parameter.
1333 ->inLanguage(
$lang )
1336 $this->mParser->addTrackingCategory(
'cite-tracking-category-cite-error' );
1338 $ret = Html::rawElement(
1341 'class' =>
'error mw-ext-cite-error',
1342 'lang' =>
$lang->getHtmlCode(),
1348 if ( $parse ===
'parse' ) {
1349 $ret = $this->mParser->recursiveTagParse(
$ret );
1363 private function warning( $key, $param =
null, $parse =
'parse' ) {
1364 # For ease of debugging and because errors are rare, we
1365 # use the user language and split the parser cache.
1366 $lang = $this->mParser->getOptions()->getUserLangObj();
1367 $dir =
$lang->getDir();
1369 # We rely on the fact that PHP is okay with passing unused argu-
1370 # ments to functions. If $1 is not used in the message, wfMessage will
1371 # just ignore the extra parameter.
1376 ->inLanguage(
$lang )
1379 $key = preg_replace(
'/^cite_warning_/',
'', $key ) .
'';
1380 $ret = Html::rawElement(
1383 'class' =>
'warning mw-ext-cite-warning mw-ext-cite-warning-' .
1384 Sanitizer::escapeClass( $key ),
1385 'lang' =>
$lang->getHtmlCode(),
1391 if ( $parse ===
'parse' ) {
1392 $ret = $this->mParser->recursiveTagParse(
$ret );
1406 global $wgCiteStoreReferencesData;
1407 if ( !$wgCiteStoreReferencesData ) {
1410 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1411 $key =
$cache->makeKey( self::EXT_DATA_KEY, $title->getArticleID() );
1412 return $cache->getWithSetCallback(
1414 self::CACHE_DURATION_ONFETCH,
1415 function ( $oldValue, &$ttl, array &$setOpts ) use ( $title ) {
1417 $setOpts += Database::getCacheSetOptions(
$dbr );
1421 'checkKeys' => [ $key ],
1439 $string =
'', $i = 1 ) {
1440 $id = $title->getArticleID();
1441 $result =
$dbr->selectField(
1446 'pp_propname' =>
'references-' . $i
1450 if ( $result !==
false ) {
1452 $decodedString = gzdecode( $string );
1453 if ( $decodedString !==
false ) {
1454 $json = json_decode( $decodedString,
true );
1455 if ( json_last_error() === JSON_ERROR_NONE ) {
1460 wfDebug(
"Corrupted json detected when retrieving stored references for title id $id" );
1469 wfDebug(
"Failed to retrieve stored references for title id $id" );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
WARNING: MediaWiki core hardcodes this class name to check if the Cite extension is installed.
const CACHE_DURATION_ONFETCH
Cache duration set when fetching references from db.
const DATA_VERSION_NUMBER
Version number in case we change the data structure in the future.
getLinkLabel( $offset, $group, $label)
Generate a custom format link for a group given an offset, e.g.
guardedReferences( $str, array $argv, Parser $parser, $group=self::DEFAULT_GROUP)
array $mLinkLabels
The links to use per group, in order.
const EXT_DATA_KEY
Key used for storage in parser output's ExtensionData and ObjectCache.
refArg(array $argv)
Parse the arguments to the <ref> tag.
linkRef( $group, $key, $count=null, $label=null, $subkey='')
Generate a link (<sup ...) for the <ref> element from a key and return XHTML ready for output.
referenceText( $key, $text)
Returns formatted reference text.
error( $key, $param=null, $parse='parse')
Return an error message based on an error ID.
const MAX_STORAGE_LENGTH
Maximum storage capacity for pp_value field of page_props table.
genLinkLabels( $group, $message)
Generate the labels to pass to the 'cite_reference_link' message instead of numbers,...
genBacklinkLabels()
Generate the labels to pass to the 'cite_references_link_many_format' message, the format is an arbit...
references( $str, array $argv, Parser $parser, PPFrame $frame)
Callback function for <references>
ref( $str, array $argv, Parser $parser, PPFrame $frame)
Callback function for <ref>
int $mCallCnt
Counter to track the total number of (useful) calls to either the ref or references tag hook.
checkRefsNoReferences( $afterParse, &$parser, &$text)
Called at the end of page processing to append a default references section, if refs were used withou...
stack( $str, $key, $group, $follow, array $call)
Populate $this->mRefs based on input and arguments to <ref>
string[] $mReferencesErrors
Error stack used when defining refs in <references>
static Boolean $hooksInstalled
Did we install us into $wgHooks yet?
saveReferencesData( $group=self::DEFAULT_GROUP)
Saves references in parser extension data This is called by each <references> tag,...
guardedRef( $str, array $argv, Parser $parser, $default_group=self::DEFAULT_GROUP)
clearState(Parser &$parser)
Gets run when Parser::clearState() gets run, since we don't want the counts to transcend pages and ot...
listToText( $arr)
This does approximately the same thing as Language::listToText() but due to this being used for a sli...
string[] $mBacklinkLabels
The backlinks, in order, to pass as $3 to 'cite_references_link_many_format', defined in 'cite_refere...
array $mRefCallStack
<ref> call stack Used to cleanup out of sequence ref calls created by #tag See description of functio...
static getStoredReferences(Title $title)
Fetch references stored for the given title in page_props For performance, results are cached.
refKey( $key, $num=null)
Return an id for use in wikitext output based on a key and optionally the number of it,...
const CACHE_DURATION_ONPARSE
Cache duration set when parsing a page with references.
static recursiveFetchRefsFromDB(Title $title, IDatabase $dbr, $string='', $i=1)
Reconstructs compressed json by successively retrieving the properties references-1,...
boolean $mHaveAfterParse
True when the ParserAfterParse hook has been called.
cloneState(Parser $parser)
Gets run when the parser is cloned.
referencesFormatEntryAlternateBacklinkLabel( $offset)
Generate a custom format backlink given an offset, e.g.
referencesFormat( $group, $responsive)
Make output to be returned from the references() function.
int $mOutCnt
Count for user displayed output (ref[1], ref[2], ...)
referencesFormatEntryNumericBacklinkLabel( $base, $offset, $max)
Generate a numeric backlink given a base number and an offset, e.g.
normalizeKey( $key)
Normalizes and sanitizes a reference key.
static setHooks(Parser $parser)
Initialize the parser hooks.
boolean $mInCite
True when a <ref> tag is being processed.
static getReferencesKey( $key)
Return an id for use in wikitext output based on a key and optionally the number of it,...
boolean $mInReferences
True when a <references> tag is being processed.
string $mReferencesGroup
Group used when in <references> block.
referencesFormatEntry( $key, $val)
Format a single entry for the referencesFormat() function.
array[] $mRefs
Datastructure representing <ref> input, in the format of: [ 'user supplied' => [ 'text' => 'user sup...
rollbackRef( $type, $key, $group, $index)
Partially undoes the effect of calls to stack()
checkAnyCalls(&$output)
Hook for the InlineEditor extension.
warning( $key, $param=null, $parse='parse')
Return a warning message based on a warning ID.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Represents a title within MediaWiki.
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
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 local content language as $wgContLang
namespace being checked & $result
do that in ParserLimitReportFormat instead $parser
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
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
$wgHooks['ArticleShow'][]
processing should stop and the error should be shown to the user * false
setVolatile( $flag=true)
Set the "volatile" flag.
if(!isset( $args[0])) $lang