Skip to content
Snippets Groups Projects
Commit a00876a2 authored by Jared Hancock's avatar Jared Hancock
Browse files

thread: Add searchable view to ThreadBody

This will be useful for plugins which might need to scan the message body
regardless of its encoding. This will also be required for full-text indexes
which will not need to index HTML tags, for instance.
parent 657a8914
No related branches found
No related tags found
No related merge requests found
......@@ -1352,6 +1352,11 @@ class ThreadBody /* extends SplString */ {
throw new Exception('display: Abstract dispplay() method not implemented');
}
function getSearchable() {
return $this->body;
// TODO: Normalize Unicode string
}
static function fromFormattedText($text, $format=false) {
switch ($format) {
case 'text':
......@@ -1419,6 +1424,13 @@ class HtmlThreadBody extends ThreadBody {
return trim($this->body, " <>br/\t\n\r") ? Format::sanitize($this->body) : '';
}
function getSearchable() {
// <br> -> \n
$body = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $this->body);
return Format::striptags($body);
// TODO: Normalize Unicode string
}
function display($output=false) {
if ($this->isEmpty())
return '(empty)';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment