comparison plugins/thunderbird_labels/thunderbird_labels.php @ 29:ea061c743982

localise title and label exactly once each :-)
author Charlie Root
date Sun, 28 Jan 2018 13:44:10 -0500
parents e097905863b9
children b2d0a9781472
comparison
equal deleted inserted replaced
28:538b3d58eb89 29:ea061c743982
62 # ends up with display: none??? 62 # ends up with display: none???
63 # Bother, missed it, it's before this.container.show 63 # Bother, missed it, it's before this.container.show
64 # Afeter ul.appendnd -- inside menu.show on 307 64 # Afeter ul.appendnd -- inside menu.show on 307
65 # 567? Yes -- that's calling 'hide', but overriding 65 # 567? Yes -- that's calling 'hide', but overriding
66 # doesn't fix :-( 66 # doesn't fix :-(
67 rcube::write_log('lab','add_button'); 67 #rcube::write_log('lab','add_button');
68 $this->add_button( 68 $this->add_button(
69 array( 69 array(
70 #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu', 70 #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu',
71 'name' => 'tblabellink', 71 'name' => 'tblabellink',
72 'id' => 'tblabelpopuplink', 72 'id' => 'tblabelpopuplink',
73 #'domain' => $this->ID, 73 'domain' => $this->ID,
74 'type' => 'link', 74 'type' => 'link',
75 'class' => 'button tblabel', 75 'class' => 'button tblabel',
76 'label' => $this->gettext('tb_label_button_label'), 76 'label' => 'tb_label_button_label',
77 'title' => 'tb_label_button_title', 77 'title' => 'tb_label_button_title',
78 'onclick' => "UI.toggle_popup('tblabelpopup',event);return false", 78 'onclick' => "UI.toggle_popup('tblabelpopup',event);return false",
79 'aria-haspopup' => true, 79 'aria-haspopup' => true,
80 'aria-expanded' => false, 80 'aria-expanded' => false,
81 'aria-owns' => 'plugin.thunderbird_labels.rcm_tb_label_submenu-menu' 81 'aria-owns' => 'plugin.thunderbird_labels.rcm_tb_label_submenu-menu'
82 #'classact' => 'listbutton add', 82 #'classact' => 'listbutton add',
284 #$this->api->output->add_label('copymessage.copyingmessage'); 284 #$this->api->output->add_label('copymessage.copyingmessage');
285 $li = html::tag('li', 285 $li = html::tag('li',
286 array('class' => 'submenu'), 286 array('class' => 'submenu'),
287 '<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'));
288 $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"); 289 #rcube::write_log('lab',"stblc $out");
290 $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));
291 } 291 }
292 292
293 private function _gen_label_submenu($args, $id) 293 private function _gen_label_submenu($args, $id)
294 # never called? 294 # never called?
323 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 323 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4
324 $flag = strtolower($flag); 324 $flag = strtolower($flag);
325 if (preg_match('/^\$?label/', $flag)) 325 if (preg_match('/^\$?label/', $flag))
326 { 326 {
327 $flag_no = preg_replace('/^\$?label/', '', $flag); 327 $flag_no = preg_replace('/^\$?label/', '', $flag);
328 rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); 328 #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no);
329 $this->message_tb_labels[] = (int)$flag_no; 329 $this->message_tb_labels[] = (int)$flag_no;
330 } 330 }
331 } 331 }
332 } 332 }
333 # -- no return value for this hook 333 # -- no return value for this hook
354 if (!isset($args['messages']) or !is_array($args['messages'])) { 354 if (!isset($args['messages']) or !is_array($args['messages'])) {
355 return $args; 355 return $args;
356 } 356 }
357 // loop over all messages and add $LabelX info to the extra_flags 357 // loop over all messages and add $LabelX info to the extra_flags
358 $mbox = $this->rc->output->get_env('mailbox') ?: $this->rc->storage->get_folder(); 358 $mbox = $this->rc->output->get_env('mailbox') ?: $this->rc->storage->get_folder();
359 rcube::write_log($this->name, "mbox: $mbox"); 359 #rcube::write_log($this->name, "mbox: $mbox");
360 foreach($args['messages'] as $message) 360 foreach($args['messages'] as $message)
361 { 361 {
362 $message->list_flags['extra_flags']['tb_labels'] = array(); # always set extra_flags, needed for javascript later! 362 $message->list_flags['extra_flags']['tb_labels'] = array(); # always set extra_flags, needed for javascript later!
363 $message->list_flags['extra_flags']['tb_lparms'] = array(); 363 $message->list_flags['extra_flags']['tb_lparms'] = array();
364 $keyPos = array_search($_SESSION['sort_col'],$this->rc->config->get('tb_label_parm_labels')); 364 $keyPos = array_search($_SESSION['sort_col'],$this->rc->config->get('tb_label_parm_labels'));
365 rcube::write_log($this->name,"sort? $keyPos ".$_SESSION['sort_order']." ".print_r($this->rc->config->get('tb_label_parm_labels'),true)); 365 #rcube::write_log($this->name,"sort? $keyPos ".$_SESSION['sort_order']." ".print_r($this->rc->config->get('tb_label_parm_labels'),true));
366 if (is_array($message->flags)) 366 if (is_array($message->flags))
367 foreach ($message->flags as $flagname => $flagvalue) 367 foreach ($message->flags as $flagname => $flagvalue)
368 { 368 {
369 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 369 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4
370 $flag = strtolower($flag); 370 $flag = strtolower($flag);
371 if (preg_match('/^\$?label/', $flag)) 371 if (preg_match('/^\$?label/', $flag))
372 { 372 {
373 $flag_no = preg_replace('/^\$?label/', '', $flag); 373 $flag_no = preg_replace('/^\$?label/', '', $flag);
374 rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); 374 #rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no);
375 if ($ppos = strpos($flag_no,'_') > -1) { 375 if ($ppos = strpos($flag_no,'_') > -1) {
376 // We have a flag parameter value... 376 // We have a flag parameter value...
377 $pn=(int)substr($flag_no,0,$ppos); 377 $pn=(int)substr($flag_no,0,$ppos);
378 $pv=substr($flag_no,$ppos+1); 378 $pv=substr($flag_no,$ppos+1);
379 $message->list_flags['extra_flags']['tb_lparms'][]=array( 379 $message->list_flags['extra_flags']['tb_lparms'][]=array(
479 } 479 }
480 480
481 // set flags in IMAP server 481 // set flags in IMAP server
482 function set_flags() 482 function set_flags()
483 { 483 {
484 rcube::write_log($this->name, "set: ".print_r($_GET, true)); 484 #rcube::write_log($this->name, "set: ".print_r($_GET, true));
485 485
486 $imap = $this->rc->imap; 486 $imap = $this->rc->imap;
487 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET); 487 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET);
488 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET); 488 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET);
489 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET); 489 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET);