comparison plugins/thunderbird_labels/thunderbird_labels.php @ 26:b2b6c0af2383

remove _ from name, lots of other hacks to get label context menu working
author Charlie Root
date Sun, 28 Jan 2018 11:32:20 -0500
parents 4b2bc456ce42
children e097905863b9
comparison
equal deleted inserted replaced
25:4b2bc456ce42 26:b2b6c0af2383
42 42
43 $this->include_script('tb_label.js'); 43 $this->include_script('tb_label.js');
44 $this->add_hook('messages_list', array($this, 'read_flags')); 44 $this->add_hook('messages_list', array($this, 'read_flags'));
45 $this->add_hook('message_load', array($this, 'read_single_flags')); 45 $this->add_hook('message_load', array($this, 'read_single_flags'));
46 $this->add_hook('template_object_messageheaders', array($this, 'color_headers')); 46 $this->add_hook('template_object_messageheaders', array($this, 'color_headers'));
47 $this->add_hook('render_page', array($this, 'tb_label_popup')); 47 $this->add_hook('render_page', array($this, 'tblabelpopup'));
48 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css'); 48 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
49 49
50 $this->name = get_class($this); 50 $this->name = get_class($this);
51 # -- additional TB flags 51 # -- additional TB flags
52 $this->add_tb_flags = array(); 52 $this->add_tb_flags = array();
53 for ($i = 1; $i <= $max_id; $i++) { 53 for ($i = 1; $i <= $max_id; $i++) {
54 $this->add_tb_flags['LABEL'.$i]='$Label'.$i; 54 $this->add_tb_flags['LABEL'.$i]='$Label'.$i;
55 } 55 }
56 $this->message_tb_labels = array(); 56 $this->message_tb_labels = array();
57 57
58 # This builds the toolbar button, but
59 # it's also used by the ctxtmenu initialisation
60 # contextmenu.js:rcube_context_menu to build
61 # the context menu, and that somehow
62 # ends up with display: none???
63 # Bother, missed it, it's before this.container.show
64 # Afeter ul.appendnd -- inside menu.show on 307
65 # 567? Yes -- that's calling 'hide', but overriding
66 # doesn't fix :-(
67 rcube::write_log('lab','add_button');
58 $this->add_button( 68 $this->add_button(
59 array( 69 array(
60 'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu', 70 #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu',
61 'id' => 'tb_label_popuplink', 71 'name' => 'tblabellink',
72 'id' => 'tblabelpopuplink',
73 #'domain' => $this->ID,
74 'type' => 'link',
75 'class' => 'button tblabel',
76 'label' => $this->gettext('tb_label_button_label'),
62 'title' => 'tb_label_button_title', 77 'title' => 'tb_label_button_title',
63 'domain' => $this->ID, 78 'onclick' => "UI.toggle_popup('tblabelpopup',event);return false",
64 'type' => 'link', 79 'aria-haspopup' => true,
65 'content' => $this->gettext('tb_label_button_label'), 80 'aria-expanded' => false,
66 'class' => 'button buttonPas disabled', 81 'aria-owns' => 'plugin.thunderbird_labels.rcm_tb_label_submenu-menu'
67 'classact' => 'button', 82 #'classact' => 'listbutton add',
68 ), 83 ),
69 'toolbar' 84 'toolbar'
70 ); 85 );
71 86
72 // JS function "set_flags" => PHP function "set_flags" 87 // JS function "set_flags" => PHP function "set_flags"
73 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags')); 88 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags'));
74 89
75 90
76 if (method_exists($this, 'require_plugin') 91 if (method_exists($this, 'require_plugin')
78 && $this->require_plugin('contextmenu') 93 && $this->require_plugin('contextmenu')
79 && $this->rc->config->get('tb_label_enable_contextmenu')) 94 && $this->rc->config->get('tb_label_enable_contextmenu'))
80 { 95 {
81 if ($this->rc->action == 'list') 96 if ($this->rc->action == 'list')
82 $this->add_hook('render_mailboxlist', array($this, 'show_tb_label_contextmenu')); 97 $this->add_hook('render_mailboxlist', array($this, 'show_tb_label_contextmenu'));
83 #rcube::write_log('lab','ctxt: '.$this->rc->action); 98 rcube::write_log('lab','ctxt: '.$this->rc->action);
84 } 99 }
85 else { 100 else {
86 #rcube::write_log('lab','no ctxt'); 101 rcube::write_log('lab','no ctxt');
87 } 102 }
88 } 103 }
89 elseif ($this->rc->task == 'settings') 104 elseif ($this->rc->task == 'settings')
90 { 105 {
91 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css'); 106 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
262 277
263 return $args; 278 return $args;
264 } 279 }
265 280
266 public function show_tb_label_contextmenu($args) 281 public function show_tb_label_contextmenu($args)
282 # never called?
267 { 283 {
268 #$this->api->output->add_label('copymessage.copyingmessage'); 284 #$this->api->output->add_label('copymessage.copyingmessage');
269 #rcube::write_log('lab',"stblc");
270 $li = html::tag('li', 285 $li = html::tag('li',
271 array('class' => 'submenu'), 286 array('class' => 'submenu'),
272 '<span>'.rcube::Q($this->gettext('tb_label_contextmenu_title')).'</span>' . $this->_gen_label_submenu($args, 'tb_label_ctxm_submenu')); 287 '<span>'.rcube::Q($this->gettext('tb_label_contextmenu_title')).'</span>' . $this->_gen_label_submenu($args, 'tb_label_ctxm_submenu'));
273 $out .= html::tag('ul', array('id' => 'tb_label_ctxm_mainmenu'), $li); 288 $out .= html::tag('ul', array('id' => 'tb_label_ctxm_mainmenu'), $li);
289 rcube::write_log('lab',"stblc $out");
274 $this->api->output->add_footer(html::div(array('style' => 'display: none;'), $out)); 290 $this->api->output->add_footer(html::div(array('style' => 'display: none;'), $out));
275 } 291 }
276 292
277 private function _gen_label_submenu($args, $id) 293 private function _gen_label_submenu($args, $id)
294 # never called?
278 { 295 {
279 $out = ''; 296 $out = '';
280 $custom_labels = $this->rc->config->get('tb_label_custom_labels'); 297 $custom_labels = $this->rc->config->get('tb_label_custom_labels');
281 $max_id = $this->rc->config->get('tb_max_label'); 298 $max_id = $this->rc->config->get('tb_max_label');
282 for ($i = 0; $i <= $max_id; $i++) 299 for ($i = 0; $i <= $max_id; $i++)
511 } 528 }
512 } 529 }
513 $this->api->output->send(); 530 $this->api->output->send();
514 } 531 }
515 532
516 function tb_label_popup() 533 function tblabelpopup()
517 { 534 {
518 $custom_labels = $this->rc->config->get('tb_label_custom_labels'); 535 $custom_labels = $this->rc->config->get('tb_label_custom_labels');
519 $max_id = $this->rc->config->get('tb_max_label'); 536 $max_id = $this->rc->config->get('tb_max_label');
520 $out = '<div id="tb_label_popup" class="popupmenu"> 537 $out = '<div id="tblabelpopup" class="popupmenu">
521 <ul class="toolbarmenu">'; 538 <ul class="toolbarmenu">';
522 for ($i = 0; $i <= $max_id; $i++) 539 for ($i = 0; $i <= $max_id; $i++)
523 { 540 {
524 $separator = ($i == 0)? ' separator_below' :''; 541 $separator = ($i == 0)? ' separator_below' :'';
525 $out .= '<li class="label'.$i.$separator.'"><a href="#" class="active">'.$i.' '.$custom_labels[$i].'</a></li>'; 542 $out .= '<li class="label'.$i.$separator.'"><a href="#" id="tblabel'.$i.'" class="active">'.$i.' '.$custom_labels[$i].'</a></li>';
526 } 543 }
527 $out .= '</ul> 544 $out .= '</ul>
528 </div>'; 545 </div>';
529 $this->rc->output->add_gui_object('tb_label_popup_obj', 'tb_label_popup'); 546 $this->rc->output->add_gui_object('tblabelpopup_obj', 'tblabelpopup');
530 $this->rc->output->add_footer($out); 547 rcube::write_log('lab',"tblp $out");
548 $this->rc->output->add_footer($out);
531 } 549 }
532 } 550 }
533 551