mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
Merge two more code paths in Cite::referencesFormatEntry()
There was another, duplicated special case for previews. It was using the same message as a <ref> with multiple uses. Now it's only one code path. The goal here is to reduce the number of code paths to make it much easier to implement proper rendering for the extends="…" use cases. Bug: T237241 Change-Id: I863ac3b5234d3a6f7f2371a2a85385c3aea276e5
This commit is contained in:
parent
7f4cff9523
commit
a823fa23d9
33
src/Cite.php
33
src/Cite.php
|
@ -809,21 +809,8 @@ class Cite {
|
|||
)->inContentLanguage()->plain();
|
||||
}
|
||||
|
||||
if ( !isset( $val['count'] ) ) {
|
||||
// this handles the case of section preview for list-defined references
|
||||
return wfMessage(
|
||||
'cite_references_link_many',
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key . "-" . ( $val['key'] ?? '' ) )
|
||||
),
|
||||
'',
|
||||
$text . $error,
|
||||
$extraAttributes
|
||||
)->inContentLanguage()->plain();
|
||||
}
|
||||
|
||||
// This counts the number of reuses. 0 means the reference appears only 1 time.
|
||||
if ( $val['count'] < 1 ) {
|
||||
if ( isset( $val['count'] ) && $val['count'] < 1 ) {
|
||||
// Anonymous, auto-numbered references can't be reused and get marked with a -1.
|
||||
if ( $val['count'] < 0 ) {
|
||||
$id = $val['key'];
|
||||
|
@ -843,21 +830,25 @@ class Cite {
|
|||
|
||||
// Named references with >1 occurrences
|
||||
$backlinks = [];
|
||||
// for group handling, we have an extra key here.
|
||||
for ( $i = 0; $i <= $val['count']; $i++ ) {
|
||||
// There is no count in case of a section preview
|
||||
for ( $i = 0; $i <= ( $val['count'] ?? -1 ); $i++ ) {
|
||||
$backlinks[] = wfMessage(
|
||||
'cite_references_link_many_format',
|
||||
$this->normalizeKey(
|
||||
$this->refKey( $key, $val['key'] . "-$i" )
|
||||
$this->refKey( $key, $val['key'] . '-' . $i )
|
||||
),
|
||||
$this->referencesFormatEntryNumericBacklinkLabel(
|
||||
$val['number'],
|
||||
$i,
|
||||
$val['count']
|
||||
),
|
||||
$this->referencesFormatEntryNumericBacklinkLabel( $val['number'], $i, $val['count'] ),
|
||||
$this->referencesFormatEntryAlternateBacklinkLabel( $i )
|
||||
)->inContentLanguage()->plain();
|
||||
}
|
||||
|
||||
return wfMessage( 'cite_references_link_many',
|
||||
return wfMessage(
|
||||
'cite_references_link_many',
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key . "-" . $val['key'] )
|
||||
self::getReferencesKey( $key . '-' . ( $val['key'] ?? '' ) )
|
||||
),
|
||||
$this->listToText( $backlinks ),
|
||||
$text . $error,
|
||||
|
|
Loading…
Reference in a new issue