mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added the ability to disable auto linking urls when parsed in bbcode.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.1.0@42514 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1f9e063180
commit
d40c04e1a3
@ -9,14 +9,19 @@ $options = $config['HTML_BBCodeParser'];
|
||||
//Debug::show($options);
|
||||
unset($options);
|
||||
|
||||
/**
|
||||
* TODO Investigate whether SSViewer will be fast enough to handle hundreds of little template files.
|
||||
*
|
||||
* A better (more SS) way of doing the HTML code in here is to place them all in small template files
|
||||
* (eg. BBCodeParser_Code.ss contains the HTML for BBCodeParser::parseCode()), but the overhead this
|
||||
* would cause is likely to make this very unusable, as nice as it would be.
|
||||
*/
|
||||
|
||||
class BBCodeParser extends TextParser {
|
||||
|
||||
protected static $autolinkUrls = true;
|
||||
|
||||
static function autolinkUrls() {
|
||||
return (self::$autolinkUrls != null) ? true : false;
|
||||
}
|
||||
|
||||
static function disable_autolink_urls($autolink = false) {
|
||||
BBCodeParser::$autolinkUrls = $autolink;
|
||||
}
|
||||
|
||||
static function usable_tags() {
|
||||
return new DataObjectSet(
|
||||
new ArrayData(array(
|
||||
@ -94,16 +99,14 @@ class BBCodeParser extends TextParser {
|
||||
return $useabletags."</ul>";
|
||||
}
|
||||
|
||||
|
||||
function parse() {
|
||||
$this->content = str_replace(array('&', '<', '>'), array('&', '<', '>'), $this->content);
|
||||
$this->content = HTML_BBCodeParser::staticQparse($this->content);
|
||||
$this->content = "<p>".$this->content."</p>";
|
||||
$this->content = str_replace("\n\n", "</p><p>", $this->content);
|
||||
$this->content = str_replace("\n", "<br />", $this->content);
|
||||
$this->content = str_replace("\n", "<br />", $this->content);
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -118,6 +118,11 @@ class HTML_BBCodeParser_Filter_Links extends HTML_BBCodeParser_Filter
|
||||
if ($matches[1] == $o.'url'.$c) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if(!BBCodeParser::autolinkUrls()){
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
|
||||
$punctuation = '.,;:'; // Links can't end with these chars
|
||||
$trailing = '';
|
||||
|
Loading…
Reference in New Issue
Block a user