diff options
author | JoshyPHP <s9e.dev@gmail.com> | 2015-02-17 09:18:31 +0100 |
---|---|---|
committer | JoshyPHP <s9e.dev@gmail.com> | 2015-04-02 19:16:01 +0200 |
commit | 6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1 (patch) | |
tree | 37d01016d8fb6f3d65be089dcc69bca34af49417 /phpBB/phpbb/textformatter | |
parent | 42c1297345cf7b025a82a7c1de7b7f6714de7cb8 (diff) | |
download | forums-6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1.tar forums-6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1.tar.gz forums-6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1.tar.bz2 forums-6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1.tar.xz forums-6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1.zip |
[ticket/11768] Added limited support for [url] in [quote] author
PHPBB3-11768
Diffstat (limited to 'phpBB/phpbb/textformatter')
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/factory.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index ed99bba4a1..47da3e3eb7 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -74,7 +74,14 @@ class factory implements \phpbb\textformatter\cache 'img' => '[IMG src={IMAGEURL;useContent}]', 'list' => '[LIST type={HASHMAP=1:decimal,a:lower-alpha,A:upper-alpha,i:lower-roman,I:upper-roman;optional;postFilter=#simpletext}]{TEXT}[/LIST]', 'li' => '[* $tagName=LI]{TEXT}[/*]', - 'quote' => '[QUOTE author={TEXT1;optional}]{TEXT2}[/QUOTE]', + 'quote' => + "[QUOTE + author={TEXT1;optional} + url={URL;optional} + author={PARSE=/^\\[url=(?'url'.*?)](?'author'.*)\\[\\/url]$/i} + author={PARSE=/^\\[url](?'author'(?'url'.*?))\\[\\/url]$/i} + author={PARSE=/(?'url'https?:\\/\\/[^[\\]]+)/i} + ]{TEXT2}[/QUOTE]", 'size' => '[SIZE={FONTSIZE}]{TEXT}[/SIZE]', 'u' => '[U]{TEXT}[/U]', 'url' => '[URL={URL;useContent}]{TEXT}[/URL]', @@ -424,6 +431,15 @@ class factory implements \phpbb\textformatter\cache $templates['li'] = $fragments['listitem'] . '<xsl:apply-templates/>' . $fragments['listitem_close']; + $fragments['quote_username_open'] = str_replace( + '{USERNAME}', + '<xsl:choose> + <xsl:when test="@url">' . str_replace('{DESCRIPTION}', '{USERNAME}', $fragments['url']) . '</xsl:when> + <xsl:otherwise>{USERNAME}</xsl:otherwise> + </xsl:choose>', + $fragments['quote_username_open'] + ); + $templates['quote'] = '<xsl:choose> <xsl:when test="@author"> @@ -438,7 +454,7 @@ class factory implements \phpbb\textformatter\cache // is post-processed by parse_attachments() $templates['attachment'] = $fragments['inline_attachment_open'] . '<xsl:comment> ia<xsl:value-of select="@index"/> </xsl:comment><xsl:value-of select="@filename"/><xsl:comment> ia<xsl:value-of select="@index"/> </xsl:comment>' . $fragments['inline_attachment_close']; - // Finally save fragments whose names look like the name of a BBCode, e.g. "flash" + // Add fragments as templates foreach ($fragments as $fragment_name => $fragment) { if (preg_match('#^\\w+$#', $fragment_name)) @@ -447,6 +463,9 @@ class factory implements \phpbb\textformatter\cache } } + // Keep only templates that are named after an existing BBCode + $templates = array_intersect_key($templates, $this->default_definitions); + return $templates; } |