phpBB

Code Changes

File: phpbb/textformatter/s9e/link_helper.php

  Unmodified   Added   Modified   Removed
Line 23Line 23
	*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
* @param \s9e\TextFormatter\Parser $parser Parser

	*
* @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());

	*/
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();
}

	}

/**

	}

/**

Line 40Line 42
	*
* @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag)
* @param \s9e\TextFormatter\Parser $parser Parser

	*
* @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)
{

	*/
public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser)
{

Line 49Line 51
		// the [url] BBCode when its content is used for the URL
if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText()))
{

		// 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

		}

// Capture the text between the start tag and its end tag

Line 58Line 60
		$length = $end - $start;
$text = substr($parser->getText(), $start, $length);


		$length = $end - $start;
$text = substr($parser->getText(), $start, $length);


		// Create a tag that consumes the link's text
$parser->addSelfClosingTag('LINK_TEXT', $start, $length)->setAttribute('text', $text);

return true;

		// Create a tag that consumes the link's text and make it depends on this tag
$link_text_tag = $parser->addSelfClosingTag('LINK_TEXT', $start, $length);
$link_text_tag->setAttribute('text', $text);
$tag->cascadeInvalidationTo($link_text_tag);

	}

/**

	}

/**

Line 84Line 86
	*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
* @param string $board_url Forum's root URL (with trailing slash)

	*
* @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)
{

	*/
public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url)
{

Line 93Line 95
		{
$tag->setAttribute('text', substr($text, strlen($board_url)));
}

		{
$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

	}

/**
* 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)
{

	*/
public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag)
{

Line 109Line 109
		if (utf8_strlen($text) > 55)
{
$text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10);

		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;

 
	}
}


	}
}