mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 14:36:51 +00:00
No-op wiring to get ref "extends" into Parsoid
This doesn't change behavior yet, it's pure wiring to make the attribute available to Parsoid logic. Bug: T378567 Change-Id: I6182b601f6fee66a9c32d5006d0a36150eb47e7f
This commit is contained in:
parent
373ed01123
commit
e4e6b59306
|
@ -27,6 +27,7 @@ class RefGroupItem {
|
||||||
public string $dir = '';
|
public string $dir = '';
|
||||||
public string $group = '';
|
public string $group = '';
|
||||||
public int $groupIndex = 1;
|
public int $groupIndex = 1;
|
||||||
|
public ?string $extendsRef = null;
|
||||||
public int $index = 0;
|
public int $index = 0;
|
||||||
public string $key;
|
public string $key;
|
||||||
public string $id;
|
public string $id;
|
||||||
|
|
|
@ -163,6 +163,7 @@ class References extends ExtensionTagHandler {
|
||||||
$refName = $refDmw->attrs->name ?? '';
|
$refName = $refDmw->attrs->name ?? '';
|
||||||
$followName = $refDmw->attrs->follow ?? '';
|
$followName = $refDmw->attrs->follow ?? '';
|
||||||
$refDir = strtolower( $refDmw->attrs->dir ?? '' );
|
$refDir = strtolower( $refDmw->attrs->dir ?? '' );
|
||||||
|
$extendsRef = $refDmw->attrs->extends ?? null;
|
||||||
|
|
||||||
// Add ref-index linkback
|
// Add ref-index linkback
|
||||||
$linkBack = $doc->createElement( 'sup' );
|
$linkBack = $doc->createElement( 'sup' );
|
||||||
|
@ -285,7 +286,7 @@ class References extends ExtensionTagHandler {
|
||||||
// Even worse would be if it tried to redefine itself!
|
// Even worse would be if it tried to redefine itself!
|
||||||
|
|
||||||
if ( !$ref ) {
|
if ( !$ref ) {
|
||||||
$ref = $refsData->add( $extApi, $groupName, $refName, $refDir );
|
$ref = $refsData->add( $extApi, $groupName, $refName, $extendsRef, $refDir );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle linkbacks
|
// Handle linkbacks
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ReferencesData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add(
|
public function add(
|
||||||
ParsoidExtensionAPI $extApi, string $groupName, string $refName, string $refDir
|
ParsoidExtensionAPI $extApi, string $groupName, string $refName, ?string $extendsRef, string $refDir
|
||||||
): RefGroupItem {
|
): RefGroupItem {
|
||||||
$group = $this->getRefGroup( $groupName, true );
|
$group = $this->getRefGroup( $groupName, true );
|
||||||
$hasRefName = $refName !== '';
|
$hasRefName = $refName !== '';
|
||||||
|
@ -93,6 +93,9 @@ class ReferencesData {
|
||||||
$ref->dir = $refDir;
|
$ref->dir = $refDir;
|
||||||
$ref->group = $group->name;
|
$ref->group = $group->name;
|
||||||
$ref->groupIndex = count( $group->refs ) + 1;
|
$ref->groupIndex = count( $group->refs ) + 1;
|
||||||
|
if ( $extendsRef ) {
|
||||||
|
$ref->extendsRef = $extendsRef;
|
||||||
|
}
|
||||||
$ref->index = $n;
|
$ref->index = $n;
|
||||||
$ref->key = $refIdBase;
|
$ref->key = $refIdBase;
|
||||||
$ref->id = $hasRefName ? $refIdBase . '-0' : $refIdBase;
|
$ref->id = $hasRefName ? $refIdBase . '-0' : $refIdBase;
|
||||||
|
|
|
@ -56,6 +56,7 @@ class ReferencesDataTest extends MediaWikiUnitTestCase {
|
||||||
$this->createNoOpMock( ParsoidExtensionAPI::class ),
|
$this->createNoOpMock( ParsoidExtensionAPI::class ),
|
||||||
Cite::DEFAULT_GROUP,
|
Cite::DEFAULT_GROUP,
|
||||||
'',
|
'',
|
||||||
|
null,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ class ReferencesDataTest extends MediaWikiUnitTestCase {
|
||||||
$this->createNoOpMock( ParsoidExtensionAPI::class ),
|
$this->createNoOpMock( ParsoidExtensionAPI::class ),
|
||||||
'note',
|
'note',
|
||||||
'wales',
|
'wales',
|
||||||
|
'main',
|
||||||
'rtl'
|
'rtl'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -85,6 +87,7 @@ class ReferencesDataTest extends MediaWikiUnitTestCase {
|
||||||
$expected->key = 'cite_ref-wales_1';
|
$expected->key = 'cite_ref-wales_1';
|
||||||
$expected->id = 'cite_ref-wales_1-0';
|
$expected->id = 'cite_ref-wales_1-0';
|
||||||
$expected->name = 'wales';
|
$expected->name = 'wales';
|
||||||
|
$expected->extendsRef = 'main';
|
||||||
$expected->target = 'cite_note-wales-1';
|
$expected->target = 'cite_note-wales-1';
|
||||||
$this->assertEquals( $expected, $ref );
|
$this->assertEquals( $expected, $ref );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue