[^[]+)\[/img:{$this->seed}\]#",
function ($i) {
return "";
},
$text
);
}
public function parseList($text)
{
$text = preg_replace("#\[list=\d+:{$this->seed}\]#", '', $text);
$text = preg_replace("#\[list(=.?)?:{$this->seed}\]#", "", $text);
$text = preg_replace("#\[/\*(:m)?:{$this->seed}\]\n?#", '', $text);
$text = str_replace("[*:{$this->seed}]", '- ', $text);
$text = str_replace("[/list:o:{$this->seed}]", '
', $text);
$text = str_replace("[/list:u:{$this->seed}]", '
', $text);
return $text;
}
public function parseCode($text)
{
return preg_replace_callback(
"#[\r|\n]*\[code:{$this->seed}\][\r|\n]*(.*?)[\r|\n]*\[/code:{$this->seed}\][\r|\n]*#s",
function ($c) {
return '' . str_replace('
', '', $c[1]) . '
';
},
$text
);
}
public function parseQuote($text)
{
$text = preg_replace("#\[quote="([^:]+)":{$this->seed}\]#", '\\1 wrote:
', $text);
$text = str_replace("[quote:{$this->seed}]", '', $text);
$text = str_replace("[/quote:{$this->seed}]", '
', $text);
return $text;
}
public function parseSimple($text)
{
// Parse all simple tags
foreach ($this->simple as $code => $tag) {
$text = str_replace("[{$code}:{$this->seed}]", "<{$tag}>", $text);
$text = str_replace("[/{$code}:{$this->seed}]", "{$tag}>", $text);
}
return $text;
}
public function parseAdvanced($text)
{
// Parse all advanced tags
foreach ($this->advanced as $code => $tags) {
$tags = explode('|', $tags);
$text = str_replace("[{$code}:{$this->seed}]", $tags[0], $text);
$text = str_replace("[/{$code}:{$this->seed}]", $tags[1], $text);
}
return $text;
}
public function parseColour($text)
{
$text = preg_replace("#\[color=([^:]+):{$this->seed}\]#", "", $text);
$text = str_replace("[/color:{$this->seed}]", '', $text);
return $text;
}
public function parseUrl($text)
{
$text = preg_replace("#\[url:{$this->seed}\](.+?)\[/url:{$this->seed}\]#", "\\1", $text);
$text = preg_replace("#\[url=(.+?):{$this->seed}\]#", "", $text);
$text = str_replace("[/url:{$this->seed}]", '', $text);
return $text;
}
public function parse()
{
// Get text
$text = $this->text;
$text = str_replace("\n", '
', $text);
$text = $this->parseCode($text);
$text = $this->parseList($text);
$text = $this->parseQuote($text);
$text = $this->parseAdvanced($text);
$text = $this->parseColour($text);
$text = $this->parseImage($text);
$text = $this->parseSimple($text);
$text = $this->parseUrl($text);
return $text;
}
}