mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-13 17:53:09 +00:00
Collapse duplicate code in Cite::referencesFormatEntry()
Bug: T237241 Change-Id: Id4d9b453244f9c1d1577497439e39d3d7b58b5ff
This commit is contained in:
parent
97ba23aae9
commit
c4c6eaa8df
|
@ -806,38 +806,26 @@ class Cite {
|
||||||
)->inContentLanguage()->plain();
|
)->inContentLanguage()->plain();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anonymous, auto-numbered references can't be reused and get marked with a -1.
|
// This counts the number of reuses. 0 means the reference appears only 1 time.
|
||||||
if ( $val['count'] < 0 ) {
|
if ( $val['count'] < 1 ) {
|
||||||
|
// Anonymous, auto-numbered references can't be reused and get marked with a -1.
|
||||||
|
if ( $val['count'] < 0 ) {
|
||||||
|
$id = $val['key'];
|
||||||
|
$backlinkId = $this->refKey( $val['key'] );
|
||||||
|
} else {
|
||||||
|
$id = $key . '-' . $val['key'];
|
||||||
|
$backlinkId = $this->refKey( $key, $val['key'] . '-' . $val['count'] );
|
||||||
|
}
|
||||||
return wfMessage(
|
return wfMessage(
|
||||||
'cite_references_link_one',
|
'cite_references_link_one',
|
||||||
$this->normalizeKey(
|
$this->normalizeKey( self::getReferencesKey( $id ) ),
|
||||||
self::getReferencesKey( $val['key'] )
|
$this->normalizeKey( $backlinkId ),
|
||||||
),
|
|
||||||
$this->normalizeKey(
|
|
||||||
$this->refKey( $val['key'] )
|
|
||||||
),
|
|
||||||
$text,
|
$text,
|
||||||
$val['dir']
|
$val['dir']
|
||||||
)->inContentLanguage()->plain();
|
)->inContentLanguage()->plain();
|
||||||
// Standalone named reference, I want to format this like an
|
|
||||||
// anonymous reference because displaying "1. 1.1 Ref text" is
|
|
||||||
// overkill and users frequently use named references when they
|
|
||||||
// don't need them for convenience
|
|
||||||
}
|
}
|
||||||
if ( $val['count'] === 0 ) {
|
|
||||||
return wfMessage(
|
|
||||||
'cite_references_link_one',
|
|
||||||
$this->normalizeKey(
|
|
||||||
self::getReferencesKey( $key . "-" . $val['key'] )
|
|
||||||
),
|
|
||||||
$this->normalizeKey(
|
|
||||||
$this->refKey( $key, $val['key'] . "-" . $val['count'] )
|
|
||||||
),
|
|
||||||
$text,
|
|
||||||
$val['dir']
|
|
||||||
)->inContentLanguage()->plain();
|
|
||||||
// Named references with >1 occurrences
|
// Named references with >1 occurrences
|
||||||
}
|
|
||||||
$backlinks = [];
|
$backlinks = [];
|
||||||
// for group handling, we have an extra key here.
|
// for group handling, we have an extra key here.
|
||||||
for ( $i = 0; $i <= $val['count']; ++$i ) {
|
for ( $i = 0; $i <= $val['count']; ++$i ) {
|
||||||
|
|
Loading…
Reference in a new issue