mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-30 17:54:20 +00:00
Merge "Constants for internal enum"
This commit is contained in:
commit
dda42b9aed
|
@ -73,6 +73,11 @@ class ReferenceStack {
|
||||||
*/
|
*/
|
||||||
private ErrorReporter $errorReporter;
|
private ErrorReporter $errorReporter;
|
||||||
|
|
||||||
|
private const ACTION_ASSIGN = 'assign';
|
||||||
|
private const ACTION_INCREMENT = 'increment';
|
||||||
|
private const ACTION_NEW_FROM_PLACEHOLDER = 'new-from-placeholder';
|
||||||
|
private const ACTION_NEW = 'new';
|
||||||
|
|
||||||
public function __construct( ErrorReporter $errorReporter ) {
|
public function __construct( ErrorReporter $errorReporter ) {
|
||||||
$this->errorReporter = $errorReporter;
|
$this->errorReporter = $errorReporter;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +137,7 @@ class ReferenceStack {
|
||||||
// Mark an incomplete follow="…" as such. This is valid e.g. in the Page:… namespace
|
// Mark an incomplete follow="…" as such. This is valid e.g. in the Page:… namespace
|
||||||
// on Wikisource.
|
// on Wikisource.
|
||||||
$this->refs[$group][] = $ref + [ 'follow' => $follow ];
|
$this->refs[$group][] = $ref + [ 'follow' => $follow ];
|
||||||
$this->refCallStack[] = [ 'new', $this->refSequence, $group, $name, $extends, $text,
|
$this->refCallStack[] = [ self::ACTION_NEW, $this->refSequence, $group, $name, $extends, $text,
|
||||||
$argv ];
|
$argv ];
|
||||||
} elseif ( $text !== null ) {
|
} elseif ( $text !== null ) {
|
||||||
// We know the parent already, so just perform the follow="…" and bail out
|
// We know the parent already, so just perform the follow="…" and bail out
|
||||||
|
@ -146,18 +151,18 @@ class ReferenceStack {
|
||||||
if ( !$name ) {
|
if ( !$name ) {
|
||||||
// This is an anonymous reference, which will be given a numeric index.
|
// This is an anonymous reference, which will be given a numeric index.
|
||||||
$this->refs[$group][] = &$ref;
|
$this->refs[$group][] = &$ref;
|
||||||
$action = 'new';
|
$action = self::ACTION_NEW;
|
||||||
} elseif ( isset( $this->refs[$group][$name]['__placeholder__'] ) ) {
|
} elseif ( isset( $this->refs[$group][$name]['__placeholder__'] ) ) {
|
||||||
// Populate a placeholder.
|
// Populate a placeholder.
|
||||||
unset( $this->refs[$group][$name]['__placeholder__'] );
|
unset( $this->refs[$group][$name]['__placeholder__'] );
|
||||||
unset( $ref['number'] );
|
unset( $ref['number'] );
|
||||||
$ref = array_merge( $ref, $this->refs[$group][$name] );
|
$ref = array_merge( $ref, $this->refs[$group][$name] );
|
||||||
$this->refs[$group][$name] =& $ref;
|
$this->refs[$group][$name] =& $ref;
|
||||||
$action = 'new-from-placeholder';
|
$action = self::ACTION_NEW_FROM_PLACEHOLDER;
|
||||||
} elseif ( !isset( $this->refs[$group][$name] ) ) {
|
} elseif ( !isset( $this->refs[$group][$name] ) ) {
|
||||||
// Valid key with first occurrence
|
// Valid key with first occurrence
|
||||||
$this->refs[$group][$name] = &$ref;
|
$this->refs[$group][$name] = &$ref;
|
||||||
$action = 'new';
|
$action = self::ACTION_NEW;
|
||||||
} else {
|
} else {
|
||||||
// Change an existing entry.
|
// Change an existing entry.
|
||||||
$ref = &$this->refs[$group][$name];
|
$ref = &$this->refs[$group][$name];
|
||||||
|
@ -169,7 +174,7 @@ class ReferenceStack {
|
||||||
$ref['text'] = $text;
|
$ref['text'] = $text;
|
||||||
// Use the dir parameter only from the full definition of a named ref tag
|
// Use the dir parameter only from the full definition of a named ref tag
|
||||||
$ref['dir'] = $dir;
|
$ref['dir'] = $dir;
|
||||||
$action = 'assign';
|
$action = self::ACTION_ASSIGN;
|
||||||
} else {
|
} else {
|
||||||
if ( $text !== null
|
if ( $text !== null
|
||||||
// T205803 different strip markers might hide the same text
|
// T205803 different strip markers might hide the same text
|
||||||
|
@ -183,7 +188,7 @@ class ReferenceStack {
|
||||||
$parser, 'cite_error_references_duplicate_key', $name
|
$parser, 'cite_error_references_duplicate_key', $name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$action = 'increment';
|
$action = self::ACTION_INCREMENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +321,7 @@ class ReferenceStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( $action ) {
|
switch ( $action ) {
|
||||||
case 'new':
|
case self::ACTION_NEW:
|
||||||
// Rollback the addition of new elements to the stack
|
// Rollback the addition of new elements to the stack
|
||||||
unset( $this->refs[$group][$lookup] );
|
unset( $this->refs[$group][$lookup] );
|
||||||
if ( !$this->refs[$group] ) {
|
if ( !$this->refs[$group] ) {
|
||||||
|
@ -326,16 +331,16 @@ class ReferenceStack {
|
||||||
}
|
}
|
||||||
// TODO: Don't we need to rollback extendsCount as well?
|
// TODO: Don't we need to rollback extendsCount as well?
|
||||||
break;
|
break;
|
||||||
case 'new-from-placeholder':
|
case self::ACTION_NEW_FROM_PLACEHOLDER:
|
||||||
$this->refs[$group][$lookup]['__placeholder__'] = true;
|
$this->refs[$group][$lookup]['__placeholder__'] = true;
|
||||||
unset( $this->refs[$group][$lookup]['count'] );
|
unset( $this->refs[$group][$lookup]['count'] );
|
||||||
break;
|
break;
|
||||||
case 'assign':
|
case self::ACTION_ASSIGN:
|
||||||
// Rollback assignment of text to pre-existing elements
|
// Rollback assignment of text to pre-existing elements
|
||||||
$this->refs[$group][$lookup]['text'] = null;
|
$this->refs[$group][$lookup]['text'] = null;
|
||||||
$this->refs[$group][$lookup]['count']--;
|
$this->refs[$group][$lookup]['count']--;
|
||||||
break;
|
break;
|
||||||
case 'increment':
|
case self::ACTION_INCREMENT:
|
||||||
// Rollback increase in named ref occurrences
|
// Rollback increase in named ref occurrences
|
||||||
$this->refs[$group][$lookup]['count']--;
|
$this->refs[$group][$lookup]['count']--;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue