205 if ( $this->mInCite ) {
206 return htmlspecialchars(
"<ref>$str</ref>" );
210 $this->mInCite =
true;
214 $this->mInCite =
false;
216 $parserOutput =
$parser->getOutput();
217 $parserOutput->addModules(
'ext.cite.a11y' );
218 $parserOutput->addModuleStyles(
'ext.cite.styles' );
220 if ( is_callable( [ $frame,
'setVolatile' ] ) ) {
226 $this->mBumpRefData =
true;
244 $default_group = self::DEFAULT_GROUP
248 # The key here is the "name" attribute.
249 list( $key, $group, $follow ) = $this->
refArg( $argv );
251 # Split these into groups.
252 if ( $group ===
null ) {
253 if ( $this->mInReferences ) {
256 $group = $default_group;
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 );
288 isset( $this->mRefs[$group][$key][
'text'] ) &&
289 $str !== $this->mRefs[$group][$key][
'text']
293 $this->mRefs[$group][$key][
'text'] .=
' ' . $this->
error(
294 'cite_error_references_duplicate_key', $key,
'noparse'
297 # Assign the text to corresponding ref
298 $this->mRefs[$group][$key][
'text'] = $str;
302 # <ref> called in <references> has no content.
303 $this->mReferencesErrors[] =
304 $this->
error(
'cite_error_empty_references_define', $key );
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 !==
'' ) {
316 $this->mRefCallStack[] =
false;
318 return $this->
error(
'cite_error_ref_no_input' );
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' );
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' );
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).
340 $this->mRefCallStack[] =
false;
341 return $this->
error(
'cite_error_ref_numeric_key' );
346 preg_replace(
'#<([^ ]+?).*?>.*?</\\1 *>|<!--.*?-->#',
'', $str )
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.
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
359 $this->mRefCallStack[] =
false;
360 return $this->
error(
'cite_error_included_ref' );
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.
370 return $this->
stack( $str, $key, $group, $follow,
$argv );
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 ] ) );
391 $cnt = count(
$argv );
400 } elseif ( $cnt >= 1 ) {
401 if ( isset(
$argv[
'name'] ) && isset(
$argv[
'follow'] ) ) {
402 return [
false,
false,
false ];
404 if ( isset(
$argv[
'name'] ) ) {
406 $key = Sanitizer::escapeId(
$argv[
'name'],
'noninitial' );
407 unset(
$argv[
'name'] );
410 if ( isset(
$argv[
'follow'] ) ) {
412 $follow = Sanitizer::escapeId(
$argv[
'follow'],
'noninitial' );
413 unset(
$argv[
'follow'] );
416 if ( isset(
$argv[
'group'] ) ) {
418 $group =
$argv[
'group'];
419 unset(
$argv[
'group'] );
424 return [ $key, $group, $follow ];
427 return [
false,
false,
false ];
431 return [
null, $group,
false ];
447 private function stack( $str, $key =
null, $group, $follow, array $call ) {
448 if ( !isset( $this->mRefs[$group] ) ) {
449 $this->mRefs[$group] = [];
451 if ( !isset( $this->mGroupCnt[$group] ) ) {
452 $this->mGroupCnt[$group] = 0;
454 if ( $follow !=
null ) {
455 if ( isset( $this->mRefs[$group][$follow] ) && is_array( $this->mRefs[$group][$follow] ) ) {
457 $this->mRefs[$group][$follow][
'text'] .=
' ' . $str;
460 $groupsCount = count( $this->mRefs[$group] );
461 for ( $k = 0; $k < $groupsCount; $k++ ) {
462 if ( !isset( $this->mRefs[$group][$k][
'follow'] ) ) {
466 array_splice( $this->mRefs[$group], $k, 0, [ [
469 'key' => ++$this->mOutCnt,
472 array_splice( $this->mRefCallStack, $k, 0,
473 [ [
'new', $call, $str, $key, $group, $this->mOutCnt ] ] );
479 if ( $key ===
null ) {
482 $this->mRefs[$group][] = [
487 $this->mRefCallStack[] = [
'new', $call, $str, $key, $group,
$this->mOutCnt ];
489 return $this->
linkRef( $group, $this->mOutCnt );
491 if ( !is_string( $key ) ) {
492 throw new Exception(
'Invalid stack key: ' .
serialize( $key ) );
496 if ( !isset( $this->mRefs[$group][$key] ) || !is_array( $this->mRefs[$group][$key] ) ) {
498 $this->mRefs[$group][$key] = [
502 'number' => ++$this->mGroupCnt[$group]
504 $this->mRefCallStack[] = [
'new', $call, $str, $key, $group,
$this->mOutCnt ];
509 $this->mRefs[$group][$key][
'key'] .
"-" . $this->mRefs[$group][$key][
'count'],
510 $this->mRefs[$group][$key][
'number'],
511 "-" . $this->mRefs[$group][$key][
'key']
516 if ( $this->mRefs[$group][$key][
'text'] ===
null && $str !==
'' ) {
518 $this->mRefs[$group][$key][
'text'] = $str;
519 $this->mRefCallStack[] = [
'assign', $call, $str, $key, $group,
520 $this->mRefs[$group][$key][
'key'] ];
522 if ( $str !=
null && $str !==
'' && $str !== $this->mRefs[$group][$key][
'text'] ) {
525 $this->mRefs[$group][$key][
'text'] .=
' ' . $this->
error(
526 'cite_error_references_duplicate_key', $key,
'noparse'
529 $this->mRefCallStack[] = [
'increment', $call, $str, $key, $group,
530 $this->mRefs[$group][$key][
'key'] ];
535 $this->mRefs[$group][$key][
'key'] .
"-" . ++$this->mRefs[$group][$key][
'count'],
536 $this->mRefs[$group][$key][
'number'],
537 "-" . $this->mRefs[$group][$key][
'key']
563 if ( !isset( $this->mRefs[$group] ) ) {
567 if ( $key ===
null ) {
568 foreach ( $this->mRefs[$group] as $k => $v ) {
569 if ( $this->mRefs[$group][$k][
'key'] === $index ) {
577 if ( $key ===
null ) {
580 if ( !isset( $this->mRefs[$group][$key] ) ) {
583 if ( $this->mRefs[$group][$key][
'key'] != $index ) {
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] );
597 # Rollback assignment of text to pre-existing elements.
598 $this->mRefs[$group][$key][
'text'] =
null;
599 # continue without break
601 # Rollback increase in named ref occurrences.
602 $this->mRefs[$group][$key][
'count']--;
618 if ( $this->mInCite || $this->mInReferences ) {
619 if ( is_null( $str ) ) {
620 return htmlspecialchars(
"<references/>" );
622 return htmlspecialchars(
"<references>$str</references>" );
625 $this->mInReferences =
true;
627 $this->mInReferences =
false;
628 if ( is_callable( [ $frame,
'setVolatile' ] ) ) {
646 $group = self::DEFAULT_GROUP
648 global $wgCiteResponsiveReferences;
652 if ( isset(
$argv[
'group'] ) ) {
653 $group =
$argv[
'group'];
654 unset(
$argv[
'group'] );
657 if ( strval( $str ) !==
'' ) {
658 $this->mReferencesGroup = $group;
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-" );
672 # Undo effects of calling <ref> while unaware of containing <references>
673 for ( $i = 1; $i <= $count; $i++ ) {
674 if ( !$this->mRefCallStack ) {
678 $call = array_pop( $this->mRefCallStack );
679 $redoStack[] = $call;
680 if ( $call !==
false ) {
682 $ref_key, $ref_group, $ref_index ) = $call;
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 ) {
692 $ref_key, $ref_group, $ref_index ) = $call;
697 # Parse $str to process any unparsed <ref> tags.
698 $parser->recursiveTagParse( $str );
701 $this->mRefCallStack = [];
704 if ( isset(
$argv[
'responsive'] ) ) {
705 $responsive =
$argv[
'responsive'] !==
'0';
706 unset(
$argv[
'responsive'] );
708 $responsive = $wgCiteResponsiveReferences;
713 return $this->
error(
'cite_error_references_invalid_parameters' );
718 # Append errors generated while processing <references>
719 if ( $this->mReferencesErrors ) {
720 $s .=
"\n" . implode(
"<br />\n", $this->mReferencesErrors );
721 $this->mReferencesErrors = [];
734 if ( !$this->mRefs || !isset( $this->mRefs[$group] ) ) {
739 foreach ( $this->mRefs[$group] as $k => $v ) {
745 $parserInput = Html::rawElement(
'ol', [
'class' => [
'references' ] ],
746 "\n" . implode(
"\n", $ent ) .
"\n"
750 global $wgCiteCacheReferences,
$wgMemc;
752 if ( $wgCiteCacheReferences ) {
756 $this->mParser->Title()->getArticleID()
758 $data =
$wgMemc->get( $cacheKey );
761 if ( !$data || !$this->mParser->isValidHalfParsedText( $data ) ) {
763 $ret = rtrim( $this->mParser->recursiveTagParse( $parserInput ),
"\n" );
765 if ( $wgCiteCacheReferences ) {
766 $serData = $this->mParser->serializeHalfParsedText(
$ret );
767 $wgMemc->set( $cacheKey, $serData, 86400 );
771 $ret = $this->mParser->unserializeHalfParsedText( $data );
777 $wrapClasses = [
'mw-references-wrap' ];
778 if ( count( $this->mRefs[$group] ) > 10 ) {
779 $wrapClasses[] =
'mw-references-columns';
781 $ret = Html::rawElement(
'div', [
'class' => $wrapClasses ],
$ret );
784 if ( !$this->mParser->getOptions()->getIsPreview() ) {
790 unset( $this->mRefs[$group] );
791 unset( $this->mGroupCnt[$group] );
806 if ( !is_array( $val ) ) {
808 'cite_references_link_one',
809 self::getReferencesKey( $key ),
812 )->inContentLanguage()->plain();
815 if ( isset( $val[
'follow'] ) ) {
817 'cite_references_no_link',
818 self::getReferencesKey( $val[
'follow'] ),
820 )->inContentLanguage()->plain();
822 if ( !isset( $val[
'count'] ) ) {
824 return wfMessage(
'cite_references_link_many',
825 self::getReferencesKey( $key .
"-" . ( isset( $val[
'key'] ) ? $val[
'key'] :
'' ) ),
828 )->inContentLanguage()->plain();
830 if ( $val[
'count'] < 0 ) {
832 'cite_references_link_one',
833 self::getReferencesKey( $val[
'key'] ),
834 # $this->
refKey( $val[
'key'], $val[
'count'] ),
835 $this->
refKey( $val[
'key'] ),
837 )->inContentLanguage()->plain();
843 if ( $val[
'count'] === 0 ) {
845 'cite_references_link_one',
846 self::getReferencesKey( $key .
"-" . $val[
'key'] ),
847 # $this->
refKey( $key, $val[
'count'] ),
848 $this->
refKey( $key, $val[
'key'] .
"-" . $val[
'count'] ),
850 )->inContentLanguage()->plain();
855 for ( $i = 0; $i <= $val[
'count']; ++$i ) {
857 'cite_references_link_many_format',
858 $this->
refKey( $key, $val[
'key'] .
"-$i" ),
861 )->inContentLanguage()->plain();
866 return wfMessage(
'cite_references_link_many',
867 self::getReferencesKey( $key .
"-" . $val[
'key'] ),
870 )->inContentLanguage()->plain();
880 if ( !isset( $text ) || $text ===
'' ) {
881 if ( $this->mParser->getOptions()->getIsSectionPreview() ) {
882 return $this->
warning(
'cite_warning_sectionpreview_no_text', $key,
'noparse' );
884 return $this->
error(
'cite_error_references_no_text', $key,
'noparse' );
886 return '<span class="reference-text">' . rtrim( $text,
"\n" ) .
"</span>\n";
903 $scope = strlen( $max );
905 sprintf(
"%s.%0{$scope}s",
$base, $offset )
921 if ( !isset( $this->mBacklinkLabels ) ) {
924 if ( isset( $this->mBacklinkLabels[$offset] ) ) {
925 return $this->mBacklinkLabels[$offset];
928 return $this->
error(
'cite_error_references_no_backlink_label',
null,
'noparse' );
945 $message =
"cite_link_label_group-$group";
946 if ( !isset( $this->mLinkLabels[$group] ) ) {
949 if ( $this->mLinkLabels[$group] ===
false ) {
954 if ( isset( $this->mLinkLabels[$group][$offset - 1] ) ) {
955 return $this->mLinkLabels[$group][$offset - 1];
958 return $this->
error(
'cite_error_no_link_label_group', [ $group, $message ],
'noparse' );
973 private function refKey( $key, $num =
null ) {
974 $prefix =
wfMessage(
'cite_reference_link_prefix' )->inContentLanguage()->text();
975 $suffix =
wfMessage(
'cite_reference_link_suffix' )->inContentLanguage()->text();
976 if ( isset( $num ) ) {
977 $key =
wfMessage(
'cite_reference_link_key_with_num', $key, $num )
978 ->inContentLanguage()->plain();
981 return "$prefix$key$suffix";
995 $prefix =
wfMessage(
'cite_references_link_prefix' )->inContentLanguage()->text();
996 $suffix =
wfMessage(
'cite_references_link_suffix' )->inContentLanguage()->text();
998 return "$prefix$key$suffix";
1016 private function linkRef( $group, $key, $count =
null, $label =
null, $subkey =
'' ) {
1018 $label = is_null( $label ) ? ++$this->mGroupCnt[$group] : $label;
1021 $this->mParser->recursiveTagParse(
1023 'cite_reference_link',
1024 $this->
refKey( $key, $count ),
1025 self::getReferencesKey( $key . $subkey ),
1027 ( ( $group === self::DEFAULT_GROUP ) ?
'' :
"$group " ) .
$wgContLang->formatNum( $label ) )
1028 )->inContentLanguage()->plain()
1045 $cnt = count( $arr );
1047 $sep =
wfMessage(
'cite_references_link_many_sep' )->inContentLanguage()->plain();
1048 $and =
wfMessage(
'cite_references_link_many_and' )->inContentLanguage()->plain();
1052 return (
string)$arr[0];
1054 $t = array_slice( $arr, 0, $cnt - 1 );
1055 return implode( $sep,
$t ) . $and . $arr[$cnt - 1];
1065 $text =
wfMessage(
'cite_references_link_many_format_backlink_labels' )
1066 ->inContentLanguage()->plain();
1067 $this->mBacklinkLabels = preg_split(
'#[\n\t ]#', $text );
1080 $msg =
wfMessage( $message )->inContentLanguage();
1081 if ( $msg->exists() ) {
1082 $text = $msg->plain();
1084 $this->mLinkLabels[$group] = ( !$text ) ?
false : preg_split(
'#[\n\t ]#', $text );
1096 if (
$parser->extCite !== $this ) {
1100 # Don't clear state when we're in the middle of parsing
1102 if ( $this->mInCite || $this->mInReferences ) {
1106 $this->mGroupCnt = [];
1108 $this->mCallCnt = 0;
1110 $this->mReferencesErrors = [];
1111 $this->mRefCallStack = [];
1124 if (
$parser->extCite !== $this ) {
1128 $parser->extCite = clone $this;
1130 $parser->setHook(
'references', [
$parser->extCite,
'references' ] );
1133 $parser->extCite->mInCite =
false;
1134 $parser->extCite->mInReferences =
false;
1155 global $wgCiteResponsiveReferences;
1156 if ( is_null(
$parser->extCite ) ) {
1159 if (
$parser->extCite !== $this ) {
1160 return $parser->extCite->checkRefsNoReferences( $afterParse,
$parser, $text );
1163 if ( $afterParse ) {
1164 $this->mHaveAfterParse =
true;
1165 } elseif ( $this->mHaveAfterParse ) {
1169 if ( !
$parser->getOptions()->getIsPreview() ) {
1171 if ( $this->mRefs && isset( $this->mRefs[self::DEFAULT_GROUP] ) ) {
1174 $isSectionPreview =
false;
1176 $isSectionPreview =
$parser->getOptions()->getIsSectionPreview();
1180 foreach ( $this->mRefs as $group => $refs ) {
1184 if ( $group === self::DEFAULT_GROUP || $isSectionPreview ) {
1188 $this->
error(
'cite_error_group_refs_without_references', htmlspecialchars( $group ) );
1191 if ( $isSectionPreview &&
$s !==
'' ) {
1193 $text .=
"\n" .
'<div class="mw-ext-cite-cite_section_preview_references" >';
1194 $headerMsg =
wfMessage(
'cite_section_preview_references' );
1195 if ( !$headerMsg->isDisabled() ) {
1196 $text .=
'<h2 id="mw-ext-cite-cite_section_preview_references_header" >'
1197 . $headerMsg->escaped()
1200 $text .=
$s .
'</div>';
1215 global $wgCiteStoreReferencesData;
1216 if ( !$wgCiteStoreReferencesData ) {
1219 $savedRefs = $this->mParser->getOutput()->getExtensionData( self::EXT_DATA_KEY );
1220 if ( $savedRefs ===
null ) {
1227 if ( $this->mBumpRefData ) {
1231 $savedRefs[
'refs'][] = [];
1232 $this->mBumpRefData =
false;
1234 $n = count( $savedRefs[
'refs'] ) - 1;
1236 $savedRefs[
'refs'][$n][$group] = $this->mRefs[$group];
1238 $this->mParser->getOutput()->setExtensionData( self::EXT_DATA_KEY, $savedRefs );
1253 return (
$wgParser->extCite->mCallCnt <= 0 );
1266 $parser->extCite =
new self();
1268 if ( !self::$hooksInstalled ) {
1273 $wgHooks[
'InlineEditorPartialAfterParse'][] = [
$parser->extCite,
'checkAnyCalls' ];
1274 self::$hooksInstalled =
true;
1277 $parser->setHook(
'references', [
$parser->extCite,
'references' ] );
1290 private function error( $key, $param =
null, $parse =
'parse' ) {
1291 # For ease of debugging and because errors are rare, we
1292 # use the user language and split the parser cache.
1293 $lang = $this->mParser->getOptions()->getUserLangObj();
1296 # We rely on the fact that PHP is okay with passing unused argu-
1297 # ments to functions. If $1 is not used in the message, wfMessage will
1298 # just ignore the extra parameter.
1303 ->inLanguage(
$lang )
1306 $this->mParser->addTrackingCategory(
'cite-tracking-category-cite-error' );
1308 $ret = Html::rawElement(
1311 'class' =>
'error mw-ext-cite-error',
1312 'lang' =>
$lang->getHtmlCode(),
1318 if ( $parse ===
'parse' ) {
1319 $ret = $this->mParser->recursiveTagParse(
$ret );
1333 private function warning( $key, $param =
null, $parse =
'parse' ) {
1334 # For ease of debugging and because errors are rare, we
1335 # use the user language and split the parser cache.
1336 $lang = $this->mParser->getOptions()->getUserLangObj();
1339 # We rely on the fact that PHP is okay with passing unused argu-
1340 # ments to functions. If $1 is not used in the message, wfMessage will
1341 # just ignore the extra parameter.
1346 ->inLanguage(
$lang )
1349 $key = preg_replace(
'/^cite_warning_/',
'', $key ) .
'';
1350 $ret = Html::rawElement(
1353 'class' =>
'warning mw-ext-cite-warning mw-ext-cite-warning-' .
1354 Sanitizer::escapeClass( $key ),
1355 'lang' =>
$lang->getHtmlCode(),
1361 if ( $parse ===
'parse' ) {
1362 $ret = $this->mParser->recursiveTagParse(
$ret );
1376 global $wgCiteStoreReferencesData;
1377 if ( !$wgCiteStoreReferencesData ) {
1380 $cache = ObjectCache::getMainWANInstance();
1381 $key =
$cache->makeKey( self::EXT_DATA_KEY, $title->getArticleID() );
1382 return $cache->getWithSetCallback(
1384 self::CACHE_DURATION_ONFETCH,
1385 function ( $oldValue, &$ttl, array &$setOpts ) use ( $title ) {
1387 $setOpts += Database::getCacheSetOptions(
$dbr );
1391 'checkKeys' => [ $key ],
1409 $string =
'', $i = 1 ) {
1410 $id = $title->getArticleID();
1411 $result =
$dbr->selectField(
1416 'pp_propname' =>
'references-' . $i
1420 if ( $result !==
false ) {
1422 $decodedString = gzdecode( $string );
1423 if ( $decodedString !==
false ) {
1424 $json = json_decode( $decodedString,
true );
1425 if ( json_last_error() === JSON_ERROR_NONE ) {
1430 wfDebug(
"Corrupted json detected when retrieving stored references for title id $id" );
1439 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.
wfMemcKey()
Make a cache key for the local wiki.
A parser extension that adds two tags, <ref> and <references> for adding citations to pages.
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.
static recursiveFetchRefsFromDB(Title $title, DatabaseBase $dbr, $string='', $i=1)
Reconstructs compressed json by successively retrieving the properties references-1,...
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...
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.
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.
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.
stack( $str, $key=null, $group, $follow, array $call)
Populate $this->mRefs based on input and arguments to <ref>
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
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
setVolatile( $flag=true)
Set the "volatile" flag.
if(!isset( $args[0])) $lang