Mercurial > hg > rc1
comparison plugins/contextmenu/contextmenu.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
| author | Charlie Root |
|---|---|
| date | Thu, 04 Jan 2018 15:50:29 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1e000243b222 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 /** | |
| 4 * ContextMenu | |
| 5 * | |
| 6 * Plugin to add a context menu to various parts of the interface | |
| 7 * | |
| 8 * @author Philip Weir | |
| 9 * | |
| 10 * Copyright (C) 2009-2014 Philip Weir | |
| 11 * | |
| 12 * This program is a Roundcube (http://www.roundcube.net) plugin. | |
| 13 * For more information see README.md. | |
| 14 * See MANUAL.md for information about extending this plugin. | |
| 15 * | |
| 16 * This program is free software: you can redistribute it and/or modify | |
| 17 * it under the terms of the GNU General Public License as published by | |
| 18 * the Free Software Foundation, either version 3 of the License, or | |
| 19 * (at your option) any later version. | |
| 20 * | |
| 21 * This program is distributed in the hope that it will be useful, | |
| 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 24 * GNU General Public License for more details. | |
| 25 * | |
| 26 * You should have received a copy of the GNU General Public License | |
| 27 * along with Roundcube. If not, see http://www.gnu.org/licenses/. | |
| 28 */ | |
| 29 class contextmenu extends rcube_plugin | |
| 30 { | |
| 31 public $task = 'mail|addressbook'; | |
| 32 | |
| 33 function init() | |
| 34 { | |
| 35 $rcmail = rcube::get_instance(); | |
| 36 | |
| 37 if ($rcmail->output->type == 'html') { | |
| 38 $this->include_script('contextmenu.js'); | |
| 39 $this->include_stylesheet($this->local_skin_path() . '/contextmenu.css'); | |
| 40 $this->include_script($this->local_skin_path() . '/functions.js'); | |
| 41 $this->api->output->set_env('contextmenu', true); | |
| 42 } | |
| 43 | |
| 44 if ($rcmail->task == 'mail') { | |
| 45 $this->register_action('plugin.contextmenu.messagecount', array($this, 'messagecount')); | |
| 46 | |
| 47 // on the mailbox screen only add some additional options for the folder menu | |
| 48 if ($rcmail->action == '') { | |
| 49 $this->addition_folder_options(); | |
| 50 } | |
| 51 } | |
| 52 elseif ($rcmail->task == 'addressbook' && $rcmail->action == '') { | |
| 53 // give other plugins a change to add address books before checking if they exist for the menu | |
| 54 $this->add_hook('render_page', array($this, 'addition_addressbook_options')); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 public function addition_folder_options() | |
| 59 { | |
| 60 $this->add_texts('localization/'); | |
| 61 | |
| 62 $li = ''; | |
| 63 $li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.collapseall', 'type' => 'link', 'class' => 'collapseall rcm_active', 'label' => 'contextmenu.collapseall', 'tabindex' => '-1', 'aria-disabled' => 'true'))); | |
| 64 $li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.expandall', 'type' => 'link', 'class' => 'expandall rcm_active', 'label' => 'contextmenu.expandall', 'tabindex' => '-1', 'aria-disabled' => 'true'))); | |
| 65 $li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.openfolder', 'type' => 'link', 'class' => 'openfolder rcm_active', 'label' => 'openinextwin', 'tabindex' => '-1', 'aria-disabled' => 'true'))); | |
| 66 | |
| 67 $out = html::tag('ul', array('id' => 'rcmFolderMenu', 'role' => 'menu'), $li); | |
| 68 $this->api->output->add_footer(html::div(array('style' => 'display: none;', 'aria-hidden' => 'true'), $out)); | |
| 69 } | |
| 70 | |
| 71 public function addition_addressbook_options() | |
| 72 { | |
| 73 $this->add_texts('localization/'); | |
| 74 | |
| 75 $li = ''; | |
| 76 $li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.assigngroup', 'type' => 'link', 'class' => 'assigngroup disabled', 'classact' => 'assigngroup active', 'label' => 'contextmenu.assigngroup', 'tabindex' => '-1', 'aria-disabled' => 'true'))); | |
| 77 | |
| 78 if (count(rcube::get_instance()->get_address_sources(true)) > 1) { | |
| 79 // only show the move option if there are sources to move between | |
| 80 $li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'move', 'type' => 'link', 'class' => 'movecontact disabled', 'classact' => 'movecontact active', 'label' => 'moveto', 'tabindex' => '-1', 'aria-disabled' => 'true'))); | |
| 81 $li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'copy', 'type' => 'link', 'class' => 'copycontact disabled', 'classact' => 'copycontact active', 'label' => 'copyto', 'tabindex' => '-1', 'aria-disabled' => 'true'))); | |
| 82 } | |
| 83 | |
| 84 $out = html::tag('ul', array('id' => 'rcmAddressBookMenu', 'role' => 'menu'), $li); | |
| 85 $this->api->output->add_footer(html::div(array('style' => 'display: none;', 'aria-hidden' => 'true'), $out)); | |
| 86 } | |
| 87 | |
| 88 public function messagecount() | |
| 89 { | |
| 90 $storage = rcube::get_instance()->storage; | |
| 91 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST); | |
| 92 | |
| 93 // send output | |
| 94 header("Content-Type: application/json; charset=".RCUBE_CHARSET); | |
| 95 echo json_encode(array('messagecount' => $storage->count($mbox, 'EXISTS'))); | |
| 96 exit; | |
| 97 } | |
| 98 } | |
| 99 | |
| 100 ?> |
