Changeset View
Changeset View
Standalone View
Standalone View
plugins/kolab_notes/kolab_notes_ui.php
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | public function init_templates() | ||||
$this->rc->output->set_env('kolab_notes_settings', $settings); | $this->rc->output->set_env('kolab_notes_settings', $settings); | ||||
$this->rc->output->add_label('save','cancel','delete','close','listoptionstitle'); | $this->rc->output->add_label('save','cancel','delete','close','listoptionstitle'); | ||||
} | } | ||||
public function folders($attrib) | public function folders($attrib) | ||||
{ | { | ||||
$attrib += array('id' => 'rcmkolabnotebooks'); | $attrib += array('id' => 'rcmkolabnotebooks'); | ||||
if ($attrib['type'] == 'select') { | if (($attrib['type'] ?? null) == 'select') { | ||||
$attrib['is_escaped'] = true; | $attrib['is_escaped'] = true; | ||||
$select = new html_select($attrib); | $select = new html_select($attrib); | ||||
} | } | ||||
$tree = $attrib['type'] != 'select' ? true : null; | $tree = ($attrib['type'] ?? null) != 'select' ? true : null; | ||||
$lists = $this->plugin->get_lists($tree); | $lists = $this->plugin->get_lists($tree); | ||||
$jsenv = array(); | $jsenv = array(); | ||||
if (is_object($tree)) { | if (is_object($tree)) { | ||||
$html = $this->folder_tree_html($tree, $lists, $jsenv, $attrib); | $html = $this->folder_tree_html($tree, $lists, $jsenv, $attrib); | ||||
} | } | ||||
else { | else { | ||||
$html = ''; | $html = ''; | ||||
Show All 16 Lines | public function folders($attrib) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$this->rc->output->set_env('kolab_notebooks', $jsenv); | $this->rc->output->set_env('kolab_notebooks', $jsenv); | ||||
$this->rc->output->add_gui_object('notebooks', $attrib['id']); | $this->rc->output->add_gui_object('notebooks', $attrib['id']); | ||||
return $attrib['type'] == 'select' ? $select->show() : html::tag('ul', $attrib, $html, html::$common_attrib); | return ($attrib['type'] ?? null) == 'select' ? $select->show() : html::tag('ul', $attrib, $html, html::$common_attrib); | ||||
} | } | ||||
/** | /** | ||||
* Return html for a structured list <ul> for the folder tree | * Return html for a structured list <ul> for the folder tree | ||||
*/ | */ | ||||
public function folder_tree_html($node, $data, &$jsenv, $attrib) | public function folder_tree_html($node, $data, &$jsenv, $attrib) | ||||
{ | { | ||||
$out = ''; | $out = ''; | ||||
foreach ($node->children as $folder) { | foreach ($node->children as $folder) { | ||||
$id = $folder->id; | $id = $folder->id; | ||||
$prop = $data[$id]; | $prop = $data[$id]; | ||||
$is_collapsed = false; // TODO: determine this somehow? | $is_collapsed = false; // TODO: determine this somehow? | ||||
$content = $this->folder_list_item($id, $prop, $jsenv); | $content = $this->folder_list_item($id, $prop, $jsenv); | ||||
if (!empty($folder->children)) { | if (!empty($folder->children)) { | ||||
$content .= html::tag('ul', array('style' => ($is_collapsed ? "display:none;" : null)), | $content .= html::tag('ul', array('style' => ($is_collapsed ? "display:none;" : null)), | ||||
$this->folder_tree_html($folder, $data, $jsenv, $attrib)); | $this->folder_tree_html($folder, $data, $jsenv, $attrib)); | ||||
} | } | ||||
if (strlen($content)) { | if (strlen($content)) { | ||||
$out .= html::tag('li', array( | $out .= html::tag('li', array( | ||||
'id' => 'rcmliknb' . rcube_utils::html_identifier($id), | 'id' => 'rcmliknb' . rcube_utils::html_identifier($id), | ||||
'class' => $prop['group'] . ($prop['virtual'] ? ' virtual' : ''), | 'class' => $prop['group'] . (($prop['virtual'] ?? false) ? ' virtual' : ''), | ||||
), | ), | ||||
$content); | $content); | ||||
} | } | ||||
} | } | ||||
return $out; | return $out; | ||||
} | } | ||||
/** | /** | ||||
* Helper method to build a tasklist item (HTML content and js data) | * Helper method to build a tasklist item (HTML content and js data) | ||||
*/ | */ | ||||
public function folder_list_item($id, $prop, &$jsenv, $checkbox = false) | public function folder_list_item($id, $prop, &$jsenv, $checkbox = false) | ||||
{ | { | ||||
if (!$prop['virtual']) { | if (!($prop['virtual'] ?? false)) { | ||||
unset($prop['user_id']); | unset($prop['user_id']); | ||||
$jsenv[$id] = $prop; | $jsenv[$id] = $prop; | ||||
} | } | ||||
$classes = array('folder'); | $classes = array('folder'); | ||||
if ($prop['virtual']) { | if ($prop['virtual'] ?? false) { | ||||
$classes[] = 'virtual'; | $classes[] = 'virtual'; | ||||
} | } | ||||
else if (!$prop['editable']) { | else if (!$prop['editable']) { | ||||
$classes[] = 'readonly'; | $classes[] = 'readonly'; | ||||
} | } | ||||
if ($prop['subscribed']) { | if ($prop['subscribed']) { | ||||
$classes[] = 'subscribed'; | $classes[] = 'subscribed'; | ||||
} | } | ||||
if ($prop['class']) { | if ($prop['class']) { | ||||
$classes[] = $prop['class']; | $classes[] = $prop['class']; | ||||
} | } | ||||
$title = $prop['title'] ?: ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ? | $title = $prop['title'] ?? ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ? | ||||
html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET) : ''); | html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET) : ''); | ||||
$label_id = 'nl:' . $id; | $label_id = 'nl:' . $id; | ||||
$attr = $prop['virtual'] ? array('tabindex' => '0') : array('href' => $this->rc->url(array('_list' => $id))); | $attr = ($prop['virtual'] ?? false) ? array('tabindex' => '0') : array('href' => $this->rc->url(array('_list' => $id))); | ||||
return html::div(join(' ', $classes), | return html::div(join(' ', $classes), | ||||
html::a($attr + array('class' => 'listname', 'title' => $title, 'id' => $label_id), $prop['listname'] ?: $prop['name']) . | html::a($attr + array('class' => 'listname', 'title' => $title, 'id' => $label_id), $prop['listname'] ?: $prop['name']) . | ||||
($prop['virtual'] ? '' : | (($prop['virtual'] ?? false) ? '' : | ||||
($checkbox ? | ($checkbox ? | ||||
html::tag('input', array('type' => 'checkbox', 'name' => '_list[]', 'value' => $id, 'checked' => $prop['active'], 'aria-labelledby' => $label_id)) : | html::tag('input', array('type' => 'checkbox', 'name' => '_list[]', 'value' => $id, 'checked' => $prop['active'], 'aria-labelledby' => $label_id)) : | ||||
'' | '' | ||||
) . | ) . | ||||
html::span('handle', '') . | html::span('handle', '') . | ||||
html::span('actions', | html::span('actions', | ||||
(!$prop['default'] ? | (!$prop['default'] ? | ||||
html::a(array('href' => '#', 'class' => 'remove', 'title' => $this->plugin->gettext('removelist')), ' ') : | html::a(array('href' => '#', 'class' => 'remove', 'title' => $this->plugin->gettext('removelist')), ' ') : | ||||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |