Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_format_note.php
Show All 38 Lines | class kolab_format_note extends kolab_format | ||||
* @param array Object data as hash array | * @param array Object data as hash array | ||||
*/ | */ | ||||
public function set(&$object) | public function set(&$object) | ||||
{ | { | ||||
// set common object properties | // set common object properties | ||||
parent::set($object); | parent::set($object); | ||||
$this->obj->setSummary($object['title']); | $this->obj->setSummary($object['title']); | ||||
$this->obj->setDescription($object['description']); | $this->obj->setDescription($object['description'] ?? null); | ||||
$this->obj->setCategories(self::array2vector($object['categories'])); | $this->obj->setCategories(self::array2vector($object['categories'] ?? null)); | ||||
$this->set_attachments($object); | $this->set_attachments($object); | ||||
// cache this data | // cache this data | ||||
$this->data = $object; | $this->data = $object; | ||||
unset($this->data['_formatobj']); | unset($this->data['_formatobj']); | ||||
} | } | ||||
Show All 37 Lines | class kolab_format_note extends kolab_format | ||||
* Callback for kolab_storage_cache to get object specific tags to cache | * Callback for kolab_storage_cache to get object specific tags to cache | ||||
* | * | ||||
* @return array List of tags to save in cache | * @return array List of tags to save in cache | ||||
*/ | */ | ||||
public function get_tags() | public function get_tags() | ||||
{ | { | ||||
$tags = array(); | $tags = array(); | ||||
foreach ((array)$this->data['categories'] as $cat) { | foreach ((array)($this->data['categories'] ?? null) as $cat) { | ||||
$tags[] = rcube_utils::normalize_string($cat); | $tags[] = rcube_utils::normalize_string($cat); | ||||
} | } | ||||
// add tag for message references | // add tag for message references | ||||
foreach ((array)$this->data['links'] as $link) { | foreach ((array)($this->data['links'] ?? []) as $link) { | ||||
$url = parse_url($link); | $url = parse_url($link); | ||||
if ($url['scheme'] == 'imap') { | if ($url['scheme'] == 'imap') { | ||||
parse_str($url['query'], $param); | parse_str($url['query'], $param); | ||||
$tags[] = 'ref:' . trim($param['message-id'] ?: urldecode($url['fragment']), '<> '); | $tags[] = 'ref:' . trim($param['message-id'] ?: urldecode($url['fragment']), '<> '); | ||||
} | } | ||||
} | } | ||||
return $tags; | return $tags; | ||||
} | } | ||||
/** | /** | ||||
* Callback for kolab_storage_cache to get words to index for fulltext search | * Callback for kolab_storage_cache to get words to index for fulltext search | ||||
* | * | ||||
* @return array List of words to save in cache | * @return array List of words to save in cache | ||||
*/ | */ | ||||
public function get_words() | public function get_words() | ||||
{ | { | ||||
$data = ''; | $data = ''; | ||||
foreach (self::$fulltext_cols as $col) { | foreach (self::$fulltext_cols as $col) { | ||||
// convert HTML content to plain text | // convert HTML content to plain text | ||||
if ($col == 'description' && preg_match('/<(html|body)(\s[a-z]|>)/', $this->data[$col], $m) && strpos($this->data[$col], '</'.$m[1].'>')) { | if ($col == 'description' && preg_match('/<(html|body)(\s[a-z]|>)/', $this->data[$col], $m) && strpos($this->data[$col], '</'.$m[1].'>')) { | ||||
$converter = new rcube_html2text($this->data[$col], false, false, 0); | $converter = new rcube_html2text($this->data[$col] ?? null, false, false, 0); | ||||
$val = $converter->get_text(); | $val = $converter->get_text(); | ||||
} | } | ||||
else { | else { | ||||
$val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col]; | $val = is_array($this->data[$col] ?? null) ? join(' ', $this->data[$col] ?? null) : ($this->data[$col] ?? null); | ||||
} | } | ||||
if (strlen($val)) | if (strlen($val)) | ||||
$data .= $val . ' '; | $data .= $val . ' '; | ||||
} | } | ||||
return array_filter(array_unique(rcube_utils::normalize_string($data, true))); | return array_filter(array_unique(rcube_utils::normalize_string($data, true))); | ||||
} | } | ||||
} | } |