209 if ( $this->mInCite ) {
214 $this->mInCite =
true;
218 $this->mInCite =
false;
220 $parserOutput =
$parser->getOutput();
221 $parserOutput->addModules(
'ext.cite.ux-enhancements' );
222 $parserOutput->addModuleStyles(
'ext.cite.styles' );
224 $frame->setVolatile();
228 $this->mBumpRefData =
true;
248 # The key here is the "name" attribute.
249 list( $key, $group, $follow, $dir ) = $this->
refArg( $argv );
251 if ( $dir ===
'' && $str !==
'' ) {
252 $str .= $this->
plainError(
'cite_error_ref_invalid_dir', $argv[
'dir'] );
254 # Split these into groups.
255 if ( $group ===
null ) {
256 if ( $this->mInReferences ) {
270 if ( $this->mInReferences ) {
271 $isSectionPreview =
$parser->getOptions()->getIsSectionPreview();
272 if ( $group != $this->mReferencesGroup ) {
273 # <ref> and <references> have conflicting group attributes.
274 $this->mReferencesErrors[] =
276 'cite_error_references_group_mismatch',
277 Sanitizer::safeEncodeAttribute( $group )
279 }
elseif ( $str !==
'' ) {
280 if ( !$isSectionPreview && !
isset( $this->mRefs[$group] ) ) {
281 # Called with group attribute not defined in text.
282 $this->mReferencesErrors[] =
284 'cite_error_references_missing_group',
285 Sanitizer::safeEncodeAttribute( $group )
287 }
elseif ( $key ===
null || $key ===
'' ) {
288 # <ref> calls inside <references> must be named
289 $this->mReferencesErrors[] =
290 $this->
error(
'cite_error_references_no_key' );
291 }
elseif ( !$isSectionPreview && !
isset( $this->mRefs[$group][$key] ) ) {
292 # Called with name attribute not defined in text.
293 $this->mReferencesErrors[] =
294 $this->
error(
'cite_error_references_missing_key', Sanitizer::safeEncodeAttribute( $key ) );
297 isset( $this->mRefs[$group][$key][
'text'] ) &&
298 $str !== $this->mRefs[$group][$key][
'text']
302 $this->mRefs[$group][$key][
'text'] .=
' ' . $this->
plainError(
303 'cite_error_references_duplicate_key', $key
306 # Assign the text to corresponding ref
307 $this->mRefs[$group][$key][
'text'] = $str;
311 # <ref> called in <references> has no content.
312 $this->mReferencesErrors[] =
313 $this->
error(
'cite_error_empty_references_define', Sanitizer::safeEncodeAttribute( $key ) );
319 # <ref ...></ref>. This construct is invalid if
320 # it's a contentful ref, but OK if it's a named duplicate and should
321 # be equivalent <ref ... />, for compatability with #tag.
322 if (
is_string( $key ) && $key !==
'' ) {
325 $this->mRefCallStack[] =
false;
327 return $this->
error(
'cite_error_ref_no_input' );
331 if ( $key ===
false ) {
332 # TODO: Comment this case; what does this condition mean?
333 $this->mRefCallStack[] =
false;
334 return $this->
error(
'cite_error_ref_too_many_keys' );
337 if ( $str ===
null && $key ===
null ) {
338 # Something like <ref />; this makes no sense.
339 $this->mRefCallStack[] =
false;
340 return $this->
error(
'cite_error_ref_no_key' );
346 # Numeric names mess up the resulting id's, potentially produ-
347 # cing duplicate id's in the XHTML. The Right Thing To Do
348 # would be to mangle them, but it's not really high-priority
349 # (and would produce weird id's anyway).
351 $this->mRefCallStack[] =
false;
352 return $this->
error(
'cite_error_ref_numeric_key' );
357 preg_replace(
'#<([^ ]+?).*?>.*?</\\1 *>|<!--.*?-->#',
'', $str )
359 # (bug T8199) This most likely implies that someone left off the
360 # closing </ref> tag, which will cause the entire article to be
361 # eaten up until the next <ref>. So we bail out early instead.
362 # The fancy regex above first tries chopping out anything that
363 # looks like a comment or SGML tag, which is a crude way to avoid
364 # false alarms for <nowiki>, <pre>, etc.
366 # Possible improvement: print the warning, followed by the contents
367 # of the <ref> tag. This way no part of the article will be eaten
370 $this->mRefCallStack[] =
false;
371 return $this->
error(
'cite_error_included_ref' );
375 # We don't care about the content: if the key exists, the ref
376 # is presumptively valid. Either it stores a new ref, or re-
377 # fers to an existing one. If it refers to a nonexistent ref,
378 # we'll figure that out later. Likewise it's definitely valid
379 # if there's any content, regardless of key.
381 return $this->
stack( $str, $key, $group, $follow, $argv, $dir,
$parser );
384 # Not clear how we could get here, but something is probably
385 # wrong with the types. Let's fail fast.
386 throw new Exception(
'Invalid $str and/or $key: ' .
serialize( [ $str, $key ] ) );
408 if (
isset( $argv[
'dir'] ) ) {
413 $dir = Html::expandAttributes( [
'class' =>
'mw-cite-dir-' .
strtolower( $argv[
'dir'] ) ] );
416 unset( $argv[
'dir'] );
419 if ( $argv === [] ) {
421 return [
null,
null,
false, $dir ];
424 if (
isset( $argv[
'name'] ) &&
isset( $argv[
'follow'] ) ) {
425 return [
false,
false,
false,
false ];
428 if (
isset( $argv[
'name'] ) ) {
430 $key =
trim( $argv[
'name'] );
431 unset( $argv[
'name'] );
433 if (
isset( $argv[
'follow'] ) ) {
435 $follow =
trim( $argv[
'follow'] );
436 unset( $argv[
'follow'] );
438 if (
isset( $argv[
'group'] ) ) {
440 $group = $argv[
'group'];
441 unset( $argv[
'group'] );
444 if ( $argv !== [] ) {
446 return [
false,
false,
false,
false ];
449 return [ $key, $group,
$follow, $dir ];
467 if ( !
isset( $this->mRefs[$group] ) ) {
468 $this->mRefs[$group] = [];
470 if ( !
isset( $this->mGroupCnt[$group] ) ) {
471 $this->mGroupCnt[$group] = 0;
473 if ( $follow !=
null ) {
474 if (
isset( $this->mRefs[$group][$follow] ) &&
is_array( $this->mRefs[$group][$follow] ) ) {
476 $this->mRefs[$group][
$follow][
'text'] .=
' ' . $str;
479 $groupsCount = count( $this->mRefs[$group] );
481 if ( !
isset( $this->mRefs[$group][$k][
'follow'] ) ) {
488 'key' => ++$this->mOutCnt,
493 [ [
'new', $call, $str, $key, $group, $this->mOutCnt ] ] );
499 if ( $key ===
null ) {
503 $this->mRefs[$group][] = [
509 $this->mRefCallStack[] = [
'new', $call, $str, $key, $group,
$this->mOutCnt ];
511 return $this->
linkRef( $group, $this->mOutCnt );
514 throw new Exception(
'Invalid stack key: ' .
serialize( $key ) );
518 if ( !
isset( $this->mRefs[$group][$key] ) || !
is_array( $this->mRefs[$group][$key] ) ) {
520 $this->mRefs[$group][$key] = [
524 'number' => ++$this->mGroupCnt[$group],
527 $this->mRefCallStack[] = [
'new', $call, $str, $key, $group,
$this->mOutCnt ];
532 $this->mRefs[$group][$key][
'key'] .
"-" . $this->mRefs[$group][$key][
'count'],
533 $this->mRefs[$group][$key][
'number'],
534 "-" . $this->mRefs[$group][$key][
'key']
539 if ( $this->mRefs[$group][$key][
'text'] ===
null && $str !==
'' ) {
541 $this->mRefs[$group][$key][
'text'] = $str;
543 $this->mRefs[$group][$key][
'dir'] = $dir;
544 $this->mRefCallStack[] = [
'assign', $call, $str, $key, $group,
545 $this->mRefs[$group][$key][
'key'] ];
547 if ( $str !=
null && $str !==
''
549 &&
$parser->mStripState->unstripBoth( $str )
550 !==
$parser->mStripState->unstripBoth( $this->mRefs[$group][$key][
'text'] )
554 $this->mRefs[$group][$key][
'text'] .=
' ' . $this->
plainError(
555 'cite_error_references_duplicate_key', $key
558 $this->mRefCallStack[] = [
'increment', $call, $str, $key, $group,
559 $this->mRefs[$group][$key][
'key'] ];
564 $this->mRefs[$group][$key][
'key'] .
"-" . ++$this->mRefs[$group][$key][
'count'],
565 $this->mRefs[$group][$key][
'number'],
566 "-" . $this->mRefs[$group][$key][
'key']
592 if ( !
isset( $this->mRefs[$group] ) ) {
596 if ( $key ===
null ) {
597 foreach ( $this->mRefs[$group] as $k => $v ) {
598 if ( $this->mRefs[$group][$k][
'key'] === $index ) {
606 if ( $key ===
null ) {
609 if ( !
isset( $this->mRefs[$group][$key] ) ) {
612 if ( $this->mRefs[$group][$key][
'key'] != $index ) {
618 # Rollback the addition of new elements to the stack.
619 unset( $this->mRefs[$group][$key] );
620 if ( $this->mRefs[$group] === [] ) {
621 unset( $this->mRefs[$group] );
622 unset( $this->mGroupCnt[$group] );
626 # Rollback assignment of text to pre-existing elements.
627 $this->mRefs[$group][$key][
'text'] =
null;
628 # continue without break
630 # Rollback increase in named ref occurrences.
631 $this->mRefs[$group][$key][
'count']--;
647 if ( $this->mInCite || $this->mInReferences ) {
648 if ( $str ===
null ) {
654 $this->mInReferences =
true;
656 $this->mInReferences =
false;
657 $frame->setVolatile();
679 if (
isset( $argv[
'group'] ) ) {
680 $group = $argv[
'group'];
681 unset( $argv[
'group'] );
686 if (
strval( $str ) !==
'' ) {
687 $this->mReferencesGroup = $group;
689 # Detect whether we were sent already rendered <ref>s.
690 # Mostly a side effect of using #tag to call references.
691 # The following assumes that the parsed <ref>s sent within
692 # the <references> block were the most recent calls to
693 # <ref>. This assumption is true for all known use cases,
694 # but not strictly enforced by the parser. It is possible
695 # that some unusual combination of #tag, <references> and
696 # conditional parser functions could be created that would
697 # lead to malformed references here.
698 $count =
substr_count( $str, Parser::MARKER_PREFIX .
"-ref-" );
701 # Undo effects of calling <ref> while unaware of containing <references>
702 for ( $i = 1; $i <= $count; $i++ ) {
703 if ( !$this->mRefCallStack ) {
707 $call =
array_pop( $this->mRefCallStack );
708 $redoStack[] = $call;
709 if ( $call !==
false ) {
711 $ref_key, $ref_group, $ref_index ) = $call;
716 # Rerun <ref> call now that mInReferences is set.
717 for ( $i = count( $redoStack ) - 1; $i >= 0; $i-- ) {
718 $call = $redoStack[
$i];
719 if ( $call !==
false ) {
721 $ref_key, $ref_group, $ref_index ) = $call;
726 # Parse $str to process any unparsed <ref> tags.
727 $parser->recursiveTagParse( $str );
730 $this->mRefCallStack = [];
733 if (
isset( $argv[
'responsive'] ) ) {
734 $responsive = $argv[
'responsive'] !==
'0';
735 unset( $argv[
'responsive'] );
742 return $this->
error(
'cite_error_references_invalid_parameters' );
747 # Append errors generated while processing <references>
748 if ( $this->mReferencesErrors ) {
749 $s .=
"\n" . implode(
"<br />\n", $this->mReferencesErrors );
750 $this->mReferencesErrors = [];
766 if ( !$this->mRefs || !
isset( $this->mRefs[$group] ) ) {
771 foreach ( $this->mRefs[$group] as $k => $v ) {
777 $parserInput = Html::rawElement(
'ol', [
'class' => [
'references' ] ],
778 "\n" . implode(
"\n", $ent ) .
"\n"
782 $ret =
rtrim( $this->mParser->recursiveTagParse( $parserInput ),
"\n" );
787 $wrapClasses = [
'mw-references-wrap' ];
788 if ( count( $this->mRefs[$group] ) > 10 ) {
789 $wrapClasses[] =
'mw-references-columns';
791 $ret = Html::rawElement(
'div', [
'class' => $wrapClasses ],
$ret );
794 if ( !$this->mParser->getOptions()->getIsPreview() ) {
800 unset( $this->mRefs[$group] );
801 unset( $this->mGroupCnt[$group] );
818 'cite_references_link_one',
820 self::getReferencesKey( $key )
827 )->inContentLanguage()->plain();
830 if (
isset( $val[
'follow'] ) ) {
832 'cite_references_no_link',
834 self::getReferencesKey( $val[
'follow'] )
837 )->inContentLanguage()->plain();
839 if ( !
isset( $val[
'count'] ) ) {
841 return wfMessage(
'cite_references_link_many',
843 self::getReferencesKey( $key .
"-" . ( $val[
'key'] ??
'' ) )
847 )->inContentLanguage()->plain();
849 if ( $val[
'count'] < 0 ) {
851 'cite_references_link_one',
853 self::getReferencesKey( $val[
'key'] )
856 # $this->
refKey( $val[
'key'], $val[
'count'] )
857 $this->
refKey( $val[
'key'] )
861 )->inContentLanguage()->plain();
867 if ( $val[
'count'] === 0 ) {
869 'cite_references_link_one',
871 self::getReferencesKey( $key .
"-" . $val[
'key'] )
874 # $this->
refKey( $key, $val[
'count'] ),
875 $this->
refKey( $key, $val[
'key'] .
"-" . $val[
'count'] )
879 )->inContentLanguage()->plain();
884 for ( $i = 0; $i <= $val[
'count']; ++
$i ) {
886 'cite_references_link_many_format',
888 $this->
refKey( $key, $val[
'key'] .
"-$i" )
892 )->inContentLanguage()->plain();
897 return wfMessage(
'cite_references_link_many',
899 self::getReferencesKey( $key .
"-" . $val[
'key'] )
904 )->inContentLanguage()->plain();
914 if ( $text ===
null || $text ===
'' ) {
915 if ( $this->mParser->getOptions()->getIsSectionPreview() ) {
916 return $this->
warning(
'cite_warning_sectionpreview_no_text', $key,
'noparse' );
918 return $this->
plainError(
'cite_error_references_no_text', $key );
920 return '<span class="reference-text">' .
rtrim( $text,
"\n" ) .
"</span>\n";
953 if ( !
isset( $this->mBacklinkLabels ) ) {
956 if (
isset( $this->mBacklinkLabels[$offset] ) ) {
957 return $this->mBacklinkLabels[$offset];
960 return $this->
plainError(
'cite_error_references_no_backlink_label',
null );
977 $message =
"cite_link_label_group-$group";
978 if ( !
isset( $this->mLinkLabels[$group] ) ) {
981 if ( $this->mLinkLabels[$group] ===
false ) {
986 if (
isset( $this->mLinkLabels[$group][$offset - 1] ) ) {
987 return $this->mLinkLabels[$group][$offset - 1];
990 return $this->
plainError(
'cite_error_no_link_label_group', [ $group, $message ] );
1003 private function refKey( $key, $num =
null ) {
1004 $prefix =
wfMessage(
'cite_reference_link_prefix' )->inContentLanguage()->text();
1005 $suffix =
wfMessage(
'cite_reference_link_suffix' )->inContentLanguage()->text();
1006 if ( $num !==
null ) {
1007 $key =
wfMessage(
'cite_reference_link_key_with_num', $key, $num )
1008 ->inContentLanguage()->plain();
1011 return "$prefix$key$suffix";
1023 $prefix =
wfMessage(
'cite_references_link_prefix' )->inContentLanguage()->text();
1024 $suffix =
wfMessage(
'cite_references_link_suffix' )->inContentLanguage()->text();
1026 return "$prefix$key$suffix";
1045 private function linkRef( $group, $key, $count =
null, $label =
null, $subkey =
'' ) {
1048 if ( $label ===
null ) {
1049 $label = ++$this->mGroupCnt[$group];
1052 return $this->mParser->recursiveTagParse(
1054 'cite_reference_link',
1056 $this->
refKey( $key, $count )
1059 self::getReferencesKey( $key . $subkey )
1061 Sanitizer::safeEncodeAttribute(
1063 ( ( $group === self::DEFAULT_GROUP ) ?
'' :
"$group " ) .
$wgContLang->formatNum( $label ) )
1065 )->inContentLanguage()->plain()
1076 $key = Sanitizer::escapeIdForAttribute( $key );
1078 $key = Sanitizer::safeEncodeAttribute( $key );
1094 $cnt = count( $arr );
1097 return (
string)$arr[0];
1100 $sep =
wfMessage(
'cite_references_link_many_sep' )->inContentLanguage()->plain();
1101 $and =
wfMessage(
'cite_references_link_many_and' )->inContentLanguage()->plain();
1103 return implode( $sep,
$t ) . $and . $arr[$cnt - 1];
1112 $text =
wfMessage(
'cite_references_link_many_format_backlink_labels' )
1113 ->inContentLanguage()->plain();
1114 $this->mBacklinkLabels =
preg_split(
'/\s+/', $text );
1127 $msg =
wfMessage( $message )->inContentLanguage();
1128 if ( $msg->exists() ) {
1129 $text = $msg->plain();
1131 $this->mLinkLabels[$group] = $text ?
preg_split(
'/\s+/', $text ) :
false;
1141 if (
$parser->extCite !== $this ) {
1146 # Don't clear state when we're in the middle of parsing
1148 if ( $this->mInCite || $this->mInReferences ) {
1152 $this->mGroupCnt = [];
1154 $this->mCallCnt = 0;
1156 $this->mReferencesErrors = [];
1157 $this->mRefCallStack = [];
1166 if (
$parser->extCite !== $this ) {
1173 $parser->setHook(
'references', [
$parser->extCite,
'references' ] );
1176 $parser->extCite->mInCite =
false;
1177 $parser->extCite->mInReferences =
false;
1195 if (
$parser->extCite ===
null ) {
1198 if (
$parser->extCite !== $this ) {
1199 $parser->extCite->checkRefsNoReferences( $afterParse,
$parser, $text );
1203 if ( $afterParse ) {
1204 $this->mHaveAfterParse =
true;
1205 }
elseif ( $this->mHaveAfterParse ) {
1209 if ( !
$parser->getOptions()->getIsPreview() ) {
1211 if ( $this->mRefs &&
isset( $this->mRefs[self::DEFAULT_GROUP] ) ) {
1214 $isSectionPreview =
false;
1216 $isSectionPreview =
$parser->getOptions()->getIsSectionPreview();
1220 foreach ( $this->mRefs as $group => $refs ) {
1224 if ( $group === self::DEFAULT_GROUP || $isSectionPreview ) {
1225 $this->mInReferences =
true;
1227 $this->mInReferences =
false;
1231 'cite_error_group_refs_without_references',
1232 Sanitizer::safeEncodeAttribute( $group )
1236 if ( $isSectionPreview &&
$s !==
'' ) {
1238 $text .=
"\n" .
'<div class="mw-ext-cite-cite_section_preview_references" >';
1239 $headerMsg =
wfMessage(
'cite_section_preview_references' );
1240 if ( !$headerMsg->isDisabled() ) {
1241 $text .=
'<h2 id="mw-ext-cite-cite_section_preview_references_header" >'
1242 . $headerMsg->escaped()
1245 $text .=
$s .
'</div>';
1260 if ( !$wgCiteStoreReferencesData ) {
1263 $savedRefs = $this->mParser->getOutput()->getExtensionData( self::EXT_DATA_KEY );
1264 if ( $savedRefs ===
null ) {
1271 if ( $this->mBumpRefData ) {
1275 $savedRefs[
'refs'][] = [];
1276 $this->mBumpRefData =
false;
1278 $n = count( $savedRefs[
'refs'] ) - 1;
1280 $savedRefs[
'refs'][$n][$group] = $this->mRefs[$group];
1282 $this->mParser->getOutput()->setExtensionData( self::EXT_DATA_KEY, $savedRefs );
1293 $parser->extCite =
new self();
1295 if ( !self::$hooksInstalled ) {
1300 self::$hooksInstalled =
true;
1303 $parser->setHook(
'references', [
$parser->extCite,
'references' ] );
1313 private function error( $key, $param =
null ) {
1315 return $this->mParser->recursiveTagParse( $error );
1327 # For ease of debugging and because errors are rare, we
1328 # use the user language and split the parser cache.
1329 $lang = $this->mParser->getOptions()->getUserLangObj();
1330 $dir =
$lang->getDir();
1332 # We rely on the fact that PHP is okay with passing unused argu-
1333 # ments to functions. If $1 is not used in the message, wfMessage will
1334 # just ignore the extra parameter.
1339 ->inLanguage(
$lang )
1342 $this->mParser->addTrackingCategory(
'cite-tracking-category-cite-error' );
1344 $ret = Html::rawElement(
1347 'class' =>
'error mw-ext-cite-error',
1348 'lang' =>
$lang->getHtmlCode(),
1365 private function warning( $key, $param =
null, $parse =
'parse' ) {
1366 # For ease of debugging and because errors are rare, we
1367 # use the user language and split the parser cache.
1368 $lang = $this->mParser->getOptions()->getUserLangObj();
1369 $dir =
$lang->getDir();
1371 # We rely on the fact that PHP is okay with passing unused argu-
1372 # ments to functions. If $1 is not used in the message, wfMessage will
1373 # just ignore the extra parameter.
1378 ->inLanguage(
$lang )
1381 $key =
preg_replace(
'/^cite_warning_/',
'', $key ) .
'';
1382 $ret = Html::rawElement(
1385 'class' =>
'warning mw-ext-cite-warning mw-ext-cite-warning-' .
1386 Sanitizer::escapeClass( $key ),
1387 'lang' =>
$lang->getHtmlCode(),
1393 if ( $parse ===
'parse' ) {
1394 $ret = $this->mParser->recursiveTagParse(
$ret );
1409 if ( !$wgCiteStoreReferencesData ) {
1412 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1413 $key =
$cache->makeKey( self::EXT_DATA_KEY, $title->getArticleID() );
1414 return $cache->getWithSetCallback(
1416 self::CACHE_DURATION_ONFETCH,
1417 function ( $oldValue, &$ttl,
array &$setOpts ) use ( $title ) {
1419 $setOpts += Database::getCacheSetOptions(
$dbr );
1423 'checkKeys' => [ $key ],
1441 $string =
'', $i = 1 ) {
1442 $id = $title->getArticleID();
1443 $result =
$dbr->selectField(
1448 'pp_propname' =>
'references-' . $i
1452 if ( $result !==
false ) {
1454 $decodedString =
gzdecode( $string );
1455 if ( $decodedString !==
false ) {
1462 wfDebug(
"Corrupted json detected when retrieving stored references for title id $id" );
1471 wfDebug(
"Failed to retrieve stored references for title id $id" );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
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.
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...
stack( $str, $key, $group, $follow, array $call, $dir, Parser $parser)
Populate $this->mRefs based on input and arguments to <ref>
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.
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,...
error( $key, $param=null)
Return an error message based on an error ID and parses it.
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...
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.
plainError( $key, $param=null)
Return an error message based on an error ID as unescaped plaintext.
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.
string[] false[] $mLinkLabels
The links to use per group, in order.
array false[] $mRefCallStack
<ref> call stack Used to cleanup out of sequence ref calls created by #tag See description of functio...
int $mOutCnt
Count for user displayed output (ref[1], ref[2], ...)
checkRefsNoReferences( $afterParse, $parser, &$text)
Called at the end of page processing to append a default references section, if refs were used withou...
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.
guardedRef( $str, array $argv, Parser $parser)
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.
clearState(Parser $parser)
Gets run when Parser::clearState() gets run, since we don't want the counts to transcend pages and ot...
string $mReferencesGroup
Group used when in <references> block.
referencesFormatEntry( $key, $val)
Format a single entry for the referencesFormat() function.
guardedReferences( $str, array $argv, Parser $parser)
Must only be called from references().
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()
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
namespace being checked & $result
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
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
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
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 use $formDescriptor instead 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
$wgHooks['ArticleShow'][]
processing should stop and the error should be shown to the user * false
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!isset( $args[0])) $lang