mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 14:48:53 +00:00
[ticket/13713] Add mention BBCode
PHPBB3-13713
This commit is contained in:
parent
41b1b32e29
commit
6c42563b4d
6 changed files with 51 additions and 0 deletions
|
@ -52,6 +52,12 @@ services:
|
||||||
text_formatter.s9e.link_helper:
|
text_formatter.s9e.link_helper:
|
||||||
class: phpbb\textformatter\s9e\link_helper
|
class: phpbb\textformatter\s9e\link_helper
|
||||||
|
|
||||||
|
text_formatter.s9e.mention_helper:
|
||||||
|
class: phpbb\textformatter\s9e\mention_helper
|
||||||
|
arguments:
|
||||||
|
- '%core.root_path%'
|
||||||
|
- '%core.php_ext%'
|
||||||
|
|
||||||
text_formatter.s9e.parser:
|
text_formatter.s9e.parser:
|
||||||
class: phpbb\textformatter\s9e\parser
|
class: phpbb\textformatter\s9e\parser
|
||||||
arguments:
|
arguments:
|
||||||
|
@ -76,6 +82,7 @@ services:
|
||||||
- '@text_formatter.s9e.factory'
|
- '@text_formatter.s9e.factory'
|
||||||
- '@dispatcher'
|
- '@dispatcher'
|
||||||
calls:
|
calls:
|
||||||
|
- [configure_mention_helper, ['@text_formatter.s9e.mention_helper']]
|
||||||
- [configure_quote_helper, ['@text_formatter.s9e.quote_helper']]
|
- [configure_quote_helper, ['@text_formatter.s9e.quote_helper']]
|
||||||
- [configure_smilies_path, ['@config', '@path_helper']]
|
- [configure_smilies_path, ['@config', '@path_helper']]
|
||||||
- [configure_user, ['@user', '@config', '@auth']]
|
- [configure_user, ['@user', '@config', '@auth']]
|
||||||
|
|
|
@ -183,6 +183,7 @@ define('BBCODE_ID_LIST', 9);
|
||||||
define('BBCODE_ID_EMAIL', 10);
|
define('BBCODE_ID_EMAIL', 10);
|
||||||
define('BBCODE_ID_FLASH', 11);
|
define('BBCODE_ID_FLASH', 11);
|
||||||
define('BBCODE_ID_ATTACH', 12);
|
define('BBCODE_ID_ATTACH', 12);
|
||||||
|
define('BBCODE_ID_MENTION', 13);
|
||||||
|
|
||||||
// BBCode hard limit
|
// BBCode hard limit
|
||||||
define('BBCODE_LIMIT', 1511);
|
define('BBCODE_LIMIT', 1511);
|
||||||
|
|
|
@ -138,6 +138,7 @@ class data_access
|
||||||
'email' => 10,
|
'email' => 10,
|
||||||
'flash' => 11,
|
'flash' => 11,
|
||||||
'attachment' => 12,
|
'attachment' => 12,
|
||||||
|
'mention' => 13,
|
||||||
);
|
);
|
||||||
|
|
||||||
$styles = array();
|
$styles = array();
|
||||||
|
|
|
@ -84,6 +84,12 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
'img' => '[IMG src={IMAGEURL;useContent}]',
|
'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} #createChild=LI]{TEXT}[/LIST]',
|
'list' => '[LIST type={HASHMAP=1:decimal,a:lower-alpha,A:upper-alpha,i:lower-roman,I:upper-roman;optional;postFilter=#simpletext} #createChild=LI]{TEXT}[/LIST]',
|
||||||
'li' => '[* $tagName=LI]{TEXT}[/*]',
|
'li' => '[* $tagName=LI]{TEXT}[/*]',
|
||||||
|
'mention' =>
|
||||||
|
"[MENTION
|
||||||
|
group_id={UINT;optional}
|
||||||
|
profile_url={URL;optional;postFilter=#false}
|
||||||
|
user_id={UINT;optional}
|
||||||
|
]{TEXT}[/MENTION]",
|
||||||
'quote' =>
|
'quote' =>
|
||||||
"[QUOTE
|
"[QUOTE
|
||||||
author={TEXT1;optional}
|
author={TEXT1;optional}
|
||||||
|
|
|
@ -28,6 +28,11 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||||
*/
|
*/
|
||||||
protected $dispatcher;
|
protected $dispatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mention_helper
|
||||||
|
*/
|
||||||
|
protected $mention_helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var quote_helper
|
* @var quote_helper
|
||||||
*/
|
*/
|
||||||
|
@ -117,6 +122,16 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||||
extract($dispatcher->trigger_event('core.text_formatter_s9e_renderer_setup', compact($vars)));
|
extract($dispatcher->trigger_event('core.text_formatter_s9e_renderer_setup', compact($vars)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the mention_helper object used to display extended information in mentions
|
||||||
|
*
|
||||||
|
* @param mention_helper $mention_helper
|
||||||
|
*/
|
||||||
|
public function configure_mention_helper(mention_helper $mention_helper)
|
||||||
|
{
|
||||||
|
$this->mention_helper = $mention_helper;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the quote_helper object used to display extended information in quotes
|
* Configure the quote_helper object used to display extended information in quotes
|
||||||
*
|
*
|
||||||
|
@ -229,6 +244,11 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||||
*/
|
*/
|
||||||
public function render($xml)
|
public function render($xml)
|
||||||
{
|
{
|
||||||
|
if (isset($this->mention_helper))
|
||||||
|
{
|
||||||
|
$xml = $this->mention_helper->inject_metadata($xml);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->quote_helper))
|
if (isset($this->quote_helper))
|
||||||
{
|
{
|
||||||
$xml = $this->quote_helper->inject_metadata($xml);
|
$xml = $this->quote_helper->inject_metadata($xml);
|
||||||
|
|
|
@ -8,6 +8,22 @@
|
||||||
<!-- BEGIN listitem --><li><!-- END listitem -->
|
<!-- BEGIN listitem --><li><!-- END listitem -->
|
||||||
<!-- BEGIN listitem_close --></li><!-- END listitem_close -->
|
<!-- BEGIN listitem_close --></li><!-- END listitem_close -->
|
||||||
|
|
||||||
|
<!-- BEGIN mention -->
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@profile_url">
|
||||||
|
<a>
|
||||||
|
<xsl:attribute name="href"><xsl:value-of select="@profile_url"/></xsl:attribute>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</a>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<span>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</span>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
<!-- END mention -->
|
||||||
|
|
||||||
<!-- BEGIN quote_username_open --><blockquote><div><cite>{USERNAME} {L_WROTE}{L_COLON}</cite><!-- END quote_username_open -->
|
<!-- BEGIN quote_username_open --><blockquote><div><cite>{USERNAME} {L_WROTE}{L_COLON}</cite><!-- END quote_username_open -->
|
||||||
<!-- BEGIN quote_open --><blockquote class="uncited"><div><!-- END quote_open -->
|
<!-- BEGIN quote_open --><blockquote class="uncited"><div><!-- END quote_open -->
|
||||||
<!-- BEGIN quote_close --></div></blockquote><!-- END quote_close -->
|
<!-- BEGIN quote_close --></div></blockquote><!-- END quote_close -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue