mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-18 22:50:29 +01:00
Merge branch '3.2.x' into 3.3.x
This commit is contained in:
commit
ac6676a144
@ -50,7 +50,7 @@ class bbcode_merger
|
||||
$with = $this->create_bbcode($with);
|
||||
|
||||
// Select the appropriate strategy for merging this BBCode
|
||||
if ($this->is_content_bbcode($without, $with))
|
||||
if (!$this->is_optional_bbcode($without, $with) && $this->is_content_bbcode($without, $with))
|
||||
{
|
||||
$merged = $this->merge_content_bbcode($without, $with);
|
||||
}
|
||||
@ -107,12 +107,12 @@ class bbcode_merger
|
||||
/**
|
||||
* Test whether the two definitions form a "content"-style BBCode
|
||||
*
|
||||
* Such BBCodes include the [URL] BBCode, which uses its text content as
|
||||
* Such BBCodes include the [url] BBCode, which uses its text content as
|
||||
* attribute if none is provided
|
||||
*
|
||||
* @param array $without BBCode definition without an attribute
|
||||
* @param array $with BBCode definition with an attribute
|
||||
* @return array Merged definition
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_content_bbcode(array $without, array $with)
|
||||
{
|
||||
@ -122,6 +122,22 @@ class bbcode_merger
|
||||
&& preg_match('(>[^<]*?' . preg_quote($m[1]) . '[^>]*?<)s', $without['template']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the two definitions form BBCode with an optional attribute
|
||||
*
|
||||
* @param array $without BBCode definition without an attribute
|
||||
* @param array $with BBCode definition with an attribute
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_optional_bbcode(array $without, array $with)
|
||||
{
|
||||
// Remove the default attribute from the definition
|
||||
$with['usage'] = preg_replace('(=[^\\]]++)', '', $with['usage']);
|
||||
|
||||
// Test whether both definitions are the same, regardless of case
|
||||
return strcasecmp($without['usage'], $with['usage']) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the two BBCode definitions of a "content"-style BBCode
|
||||
*
|
||||
@ -131,7 +147,7 @@ class bbcode_merger
|
||||
*/
|
||||
protected function merge_content_bbcode(array $without, array $with)
|
||||
{
|
||||
// Convert [X={X}] into [X={X;useContent}]
|
||||
// Convert [x={X}] into [x={X;useContent}]
|
||||
$usage = preg_replace('(\\})', ';useContent}', $with['usage'], 1);
|
||||
|
||||
// Use the template from the definition that uses an attribute
|
||||
@ -143,7 +159,7 @@ class bbcode_merger
|
||||
/**
|
||||
* Merge the two BBCode definitions of a BBCode with an optional argument
|
||||
*
|
||||
* Such BBCodes include the [QUOTE] BBCode, which takes an optional argument
|
||||
* Such BBCodes include the [quote] BBCode, which takes an optional argument
|
||||
* but otherwise does not behave differently
|
||||
*
|
||||
* @param array $without BBCode definition without an attribute
|
||||
|
@ -275,6 +275,22 @@ class phpbb_textformatter_s9e_bbcode_merger_test extends phpbb_test_case
|
||||
</table>
|
||||
<p> </p>'
|
||||
],
|
||||
[
|
||||
// https://www.phpbb.com/community/viewtopic.php?f=438&t=2530451
|
||||
'[issue]{NUMBER}[/issue]',
|
||||
'<a href="/default/issues/{NUMBER}"> Issue #{NUMBER}</a>',
|
||||
|
||||
'[issue={SIMPLETEXT}]{NUMBER}[/issue]',
|
||||
'<a href="/{SIMPLETEXT}/issues/{NUMBER}"> Issue #{NUMBER} ({SIMPLETEXT})</a>',
|
||||
|
||||
'[issue={SIMPLETEXT?}]{NUMBER}[/issue]',
|
||||
'<a>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@issue"><xsl:attribute name="href">/<xsl:value-of select="@issue"/>/issues/<xsl:value-of select="@content"/></xsl:attribute> Issue #<xsl:value-of select="@content"/> (<xsl:value-of select="@issue"/>)</xsl:when>
|
||||
<xsl:otherwise><xsl:attribute name="href">/default/issues/<xsl:value-of select="@content"/></xsl:attribute> Issue #<xsl:value-of select="@content"/></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</a>'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user