mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:37:02 +02:00
highlight searched terms in the message view pane
This commit is contained in:
@ -229,7 +229,7 @@ class ModelSearchMessage extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function extract_message($id = '') {
|
||||
public function extract_message($id = '', $terms = '') {
|
||||
$header = "";
|
||||
$body_chunk = "";
|
||||
$is_header = 1;
|
||||
@ -363,13 +363,26 @@ class ModelSearchMessage extends Model {
|
||||
|
||||
return array('from' => $this->decode_my_str($from),
|
||||
'to' => $this->decode_my_str($to),
|
||||
'subject' => $this->decode_my_str($subject),
|
||||
'subject' => $this->highlight_search_terms($this->decode_my_str($subject), $terms),
|
||||
'date' => $this->decode_my_str($date),
|
||||
'message' => $message
|
||||
'message' => $this->highlight_search_terms($message, $terms)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function highlight_search_terms($s = '', $terms = array()) {
|
||||
$terms = explode(" ", $terms);
|
||||
|
||||
if(count($terms) <= 0) { return $s; }
|
||||
|
||||
while(list($k, $v) = each($terms)) {
|
||||
$s = preg_replace("/$v/i", "<span class=\"message_highlight\">$v</span>", $s);
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
private function check_boundary($boundary, $line) {
|
||||
|
||||
for($i=0; $i<count($boundary); $i++){
|
||||
|
Reference in New Issue
Block a user