site:// protocol support

This commit is contained in:
Shish 2012-03-13 16:01:13 +00:00
parent c887580074
commit e31b6af28b

View file

@ -28,6 +28,7 @@
class BBCode extends FormatterExtension {
public function format(/*string*/ $text) {
$text = $this->extract_code($text);
$text = preg_replace("/site:\/\//s", make_http(get_base_href())."/", $text);
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "<u>\\1</u>", $text);
@ -37,8 +38,8 @@ class BBCode extends FormatterExtension {
$text = preg_replace("/&gt;&gt;(\d+)(#c?(\d+))?/s", "<a class='comment_link' href=\"".make_link("post/view/\\1#c\\3")."\" onclick=\"$('#c\\3').effect('highlight', {}, 5000);\">&gt;&gt;\\1\\2</a>", $text);
$text = preg_replace("/(^|\s)#(\d+)/s", "\\1<a href=\"#\\2\">#\\2</a>", $text);
$text = preg_replace("/&gt;&gt;([^\d].+)/", "<blockquote><small>\\1</small></blockquote>", $text);
$text = preg_replace("/\[url=((?:https?|ftp|irc|mailto):\/\/.*?)\](.*?)\[\/url\]/s", "<a href=\"\\1\">\\2</a>", $text);
$text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto):\/\/.*?)\[\/url\]/s", "<a href=\"\\1\">\\1</a>", $text);
$text = preg_replace("/\[url=((?:https?|ftp|irc|mailto|site):\/\/.*?)\](.*?)\[\/url\]/s", "<a href=\"\\1\">\\2</a>", $text);
$text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto|site):\/\/.*?)\[\/url\]/s", "<a href=\"\\1\">\\1</a>", $text);
$text = preg_replace("/\[email\](.*?)\[\/email\]/s", "<a href=\"mailto:\\1\">\\1</a>", $text);
$text = preg_replace("/\[img\](https?:\/\/.*?)\[\/img\]/s", "<img src=\"\\1\">", $text);
$text = preg_replace("/\[\[([^\|\]]+)\|([^\]]+)\]\]/s", "<a href=\"".make_link("wiki/\\1")."\">\\2</a>", $text);