Skip to content

Commit 16d7200

Browse files
authored
Merge pull request #23 from Elsensee/fixnestingimgtag
Fix nesting IMG tags within URL tags
2 parents e936ddb + 2ba84f5 commit 16d7200

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

event/listener.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class listener implements EventSubscriberInterface
4040
* Constructor
4141
*
4242
* @param config $config
43-
* @param Container $container
4443
* @param helper $helper
4544
* @param template $template
4645
* @param user $user
@@ -59,8 +58,6 @@ public function __construct(config $config, helper $helper, template $template,
5958
* Assign functions defined in this class to event listeners in the core
6059
*
6160
* @return array
62-
* @static
63-
* @access public
6461
*/
6562
static public function getSubscribedEvents()
6663
{
@@ -78,7 +75,6 @@ static public function getSubscribedEvents()
7875
*
7976
* @param \phpbb\event\data $event
8077
* @return null
81-
* @access public
8278
*/
8379
public function acp_add_config($event)
8480
{
@@ -108,7 +104,6 @@ public function acp_add_config($event)
108104
*
109105
* @param \phpbb\event\data $event
110106
* @return null
111-
* @access public
112107
*/
113108
public function configure_textformatter($event)
114109
{
@@ -117,21 +112,24 @@ public function configure_textformatter($event)
117112

118113
$condition = 'starts-with(@src, \'' . generate_board_url(true) . '\') or ($S_IMG_SECURE_URLS and starts-with(@src, \'https://\'))';
119114

120-
// Prepare fetched URL template
115+
// Prepare URL template
121116
$url_template = str_replace(array('@url', '<xsl:apply-templates/>'), array('@src', '<xsl:value-of select="$L_EXTIMGLINK"/>'), $configurator->tags['URL']->template);
122117

123118
$configurator->tags['IMG']->template = '<xsl:choose>'
124119
. '<xsl:when test="' . $condition . '">' . $configurator->tags['IMG']->template . '</xsl:when>'
125120
. '<xsl:otherwise>' . $url_template . '</xsl:otherwise>'
126121
. '</xsl:choose>';
122+
123+
// Fix behaviour when [img] tag is within [url] tag
124+
$configurator->tags['URL']->rules->allowChild('IMG');
125+
$configurator->tags['URL']->rules->allowDescendant('IMG');
127126
}
128127

129128
/**
130129
* Changes the regex replacement for second pass
131130
*
132131
* @param \phpbb\event\data $event
133132
* @return null
134-
* @access public
135133
*/
136134
public function modify_case_img($event)
137135
{
@@ -178,7 +176,6 @@ public function modify_case_img($event)
178176
*
179177
* @param \phpbb\event\data $event
180178
* @return null
181-
* @access public
182179
*/
183180
public function setup_textformatter_renderer($event)
184181
{

0 commit comments

Comments
 (0)