2007-07-08 19:57:57 +00:00
|
|
|
<?php
|
2007-07-08 20:21:21 +00:00
|
|
|
/**
|
|
|
|
* Name: Emoticon Filter
|
|
|
|
* Author: Shish <webmaster@shishnet.org>
|
|
|
|
* License: GPLv2
|
|
|
|
* Description: Turn :smile: into a link to smile.gif
|
|
|
|
*/
|
2007-07-08 19:57:57 +00:00
|
|
|
|
|
|
|
class Emoticons extends Extension {
|
|
|
|
public function receive_event($event) {
|
|
|
|
if(is_a($event, 'TextFormattingEvent')) {
|
|
|
|
$event->formatted = $this->bbcode_to_html($event->formatted);
|
|
|
|
$event->stripped = $this->bbcode_to_text($event->stripped);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function bbcode_to_html($text) {
|
|
|
|
global $config;
|
2007-07-16 21:30:28 +00:00
|
|
|
$data_href = get_base_href();
|
2007-07-08 19:57:57 +00:00
|
|
|
$text = preg_replace("/:([a-z]*?):/s", "<img src='$data_href/ext/emoticons/default/\\1.gif'>", $text);
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function bbcode_to_text($text) {
|
2007-07-09 01:06:08 +00:00
|
|
|
// $text = preg_replace("/:([a-z]*?):/s", "\\1", $text);
|
2007-07-08 19:57:57 +00:00
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_event_listener(new Emoticons());
|
|
|
|
?>
|