aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/textformatter/s9e/link_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/textformatter/s9e/link_helper.php')
-rw-r--r--phpBB/phpbb/textformatter/s9e/link_helper.php25
1 files changed, 10 insertions, 15 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/link_helper.php b/phpBB/phpbb/textformatter/s9e/link_helper.php
index 0f44603dec..1e113b6449 100644
--- a/phpBB/phpbb/textformatter/s9e/link_helper.php
+++ b/phpBB/phpbb/textformatter/s9e/link_helper.php
@@ -23,14 +23,16 @@ class link_helper
*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
* @param \s9e\TextFormatter\Parser $parser Parser
- * @return bool Whether the tag is valid
+ * @return void
*/
public function cleanup_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser)
{
// Invalidate if the content of the tag matches the text attribute
$text = substr($parser->getText(), $tag->getPos(), $tag->getLen());
-
- return ($text !== $tag->getAttribute('text'));
+ if ($text === $tag->getAttribute('text'))
+ {
+ $tag->invalidate();
+ }
}
/**
@@ -40,7 +42,7 @@ class link_helper
*
* @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag)
* @param \s9e\TextFormatter\Parser $parser Parser
- * @return bool Always true to indicate that the tag is valid
+ * @return void
*/
public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser)
{
@@ -49,7 +51,7 @@ class link_helper
// the [url] BBCode when its content is used for the URL
if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText()))
{
- return true;
+ return;
}
// Capture the text between the start tag and its end tag
@@ -60,8 +62,6 @@ class link_helper
// Create a tag that consumes the link's text
$parser->addSelfClosingTag('LINK_TEXT', $start, $length)->setAttribute('text', $text);
-
- return true;
}
/**
@@ -84,7 +84,7 @@ class link_helper
*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
* @param string $board_url Forum's root URL (with trailing slash)
- * @return bool Always true to indicate that the tag is valid
+ * @return void
*/
public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url)
{
@@ -93,15 +93,13 @@ class link_helper
{
$tag->setAttribute('text', substr($text, strlen($board_url)));
}
-
- return true;
}
/**
* Truncate the replacement text set in a LINK_TEXT tag
*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
- * @return bool Always true to indicate that the tag is valid
+ * @return void
*/
public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag)
{
@@ -109,10 +107,7 @@ class link_helper
if (utf8_strlen($text) > 55)
{
$text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10);
+ $tag->setAttribute('text', $text);
}
-
- $tag->setAttribute('text', $text);
-
- return true;
}
}