make things use SimpleExtension

This commit is contained in:
Shish
2009-05-11 14:09:24 -07:00
parent 8dd3f8cbc0
commit 389eed5867
19 changed files with 457 additions and 538 deletions

View File

@ -1,14 +1,7 @@
<?php
class BBCode implements Extension {
public function receive_event(Event $event) {
if($event instanceof TextFormattingEvent) {
$event->formatted = $this->bbcode_to_html($event->formatted);
$event->stripped = $this->bbcode_to_text($event->stripped);
}
}
private function bbcode_to_html($text) {
class BBCode extends FormatterExtension {
public function format($text) {
$text = $this->extract_code($text);
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
@ -42,7 +35,7 @@ class BBCode implements Extension {
return $text;
}
private function bbcode_to_text($text) {
public function strip($text) {
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text);
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text);
@ -65,6 +58,7 @@ class BBCode implements Extension {
return $text;
}
private function filter_spoiler($text) {
return str_replace(
array("[spoiler]","[/spoiler]"),