Improvements to options menu link template object (#7237)

pull/7283/head
johndoh 5 years ago committed by GitHub
parent 623a642457
commit 11aa9633b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1529,12 +1529,17 @@ EOF;
*/ */
protected function prepare_object_attribs(&$attribs) protected function prepare_object_attribs(&$attribs)
{ {
// Localize data-label-* attributes foreach ($attribs as $key => &$value) {
array_walk($attribs, function(&$value, $key, $rcube) {
if (strpos($key, 'data-label-') === 0) { if (strpos($key, 'data-label-') === 0) {
$value = $rcube->gettext($value); // Localize data-label-* attributes
$value = $this->app->gettext($value);
} }
}, $this->app); elseif ($key[0] == ':') {
// Evaluate attributes with expressions and remove special character from attribute name
$attribs[substr($key, 1)] = $this->eval_expression($value);
unset($attribs[$key]);
}
}
} }
/** /**

@ -591,7 +591,14 @@ function rcmail_message_list_head($attrib, $a_show_cols)
$a_sort_cols = array('subject', 'date', 'from', 'to', 'fromto', 'size', 'cc'); $a_sort_cols = array('subject', 'date', 'from', 'to', 'fromto', 'size', 'cc');
if (!empty($attrib['optionsmenuicon'])) { if (!empty($attrib['optionsmenuicon'])) {
$list_menu = rcmail_options_menu_link(); $params = array();
foreach ($attrib as $key => $val) {
if (preg_match('/^optionsmenu(.+)$/', $key, $matches)) {
$params[$matches[1]] = $val;
}
}
$list_menu = rcmail_options_menu_link($params);
} }
$cells = $coltypes = array(); $cells = $coltypes = array();
@ -660,11 +667,16 @@ function rcmail_options_menu_link($attrib = array())
{ {
global $RCMAIL; global $RCMAIL;
$onclick = 'return ' . rcmail_output::JS_OBJECT_NAME . ".command('menu-open', 'messagelistmenu', this, event)"; $onclick = 'return ' . rcmail_output::JS_OBJECT_NAME . ".command('menu-open', '" . ($attrib['ref'] ?: 'messagelistmenu') ."', this, event)";
$inner = $title = $RCMAIL->gettext($attrib['label'] ?: 'listoptions'); $inner = $title = $RCMAIL->gettext($attrib['label'] ?: 'listoptions');
if (is_string($attrib['optionsmenuicon']) && $attrib['optionsmenuicon'] != 'true') { // Backwards compatibility, attribute renamed in v1.5
$inner = html::img(array('src' => $RCMAIL->output->asset_url($attrib['optionsmenuicon'], true), 'alt' => $title)); if (isset($attrib['optionsmenuicon'])) {
$attrib['icon'] = $attrib['optionsmenuicon'];
}
if (is_string($attrib['icon']) && $attrib['icon'] != 'true') {
$inner = html::img(array('src' => $RCMAIL->output->asset_url($attrib['icon'], true), 'alt' => $title));
} }
else if ($attrib['innerclass']) { else if ($attrib['innerclass']) {
$inner = html::span($attrib['innerclass'], $inner); $inner = html::span($attrib['innerclass'], $inner);
@ -674,7 +686,7 @@ function rcmail_options_menu_link($attrib = array())
'href' => '#list-options', 'href' => '#list-options',
'onclick' => $onclick, 'onclick' => $onclick,
'class' => isset($attrib['class']) ? $attrib['class'] : 'listmenu', 'class' => isset($attrib['class']) ? $attrib['class'] : 'listmenu',
'id' => 'listmenulink', 'id' => isset($attrib['id']) ? $attrib['id'] : 'listmenulink',
'title' => $title, 'title' => $title,
'tabindex' => '0', 'tabindex' => '0',
), $inner); ), $inner);

Loading…
Cancel
Save