diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js index 13bcca53..d6ad0774 100644 --- a/plugins/kolab_files/kolab_files.js +++ b/plugins/kolab_files/kolab_files.js @@ -108,14 +108,17 @@ window.rcmail && window.files_api && rcmail.addEventListener('init', function() kolab_files_init(); - if (rcmail.env.action == 'open') { + if (rcmail.env.action == 'open' || rcmail.env.action == 'edit') { rcmail.enable_command('files-get', 'files-delete', rcmail.env.file); - if (rcmail.env.file_data.viewer && rcmail.env.file_data.viewer.manticore) + if (rcmail.env.action == 'edit' && rcmail.env.file_data.viewer && rcmail.env.file_data.viewer.manticore) manticore = new manticore_api({ iframe: $('#fileframe').get(0), export_menu: rcmail.gui_objects.exportmenu ? $('ul', rcmail.gui_objects.exportmenu).get(0) : null, title_input: $('#document-title').get(0), + members_list: $('#members').get(0), + photo_url: '?_task=addressbook&_action=photo&_email=%email', + photo_default_url: rcmail.env.photo_placeholder, ready: function(data) { manticore_init(); }, set_busy: function(state, message) { return rcmail.set_busy(state, message ? 'kolab_files.' + message : ''); }, hide_message: function(id) { return rcmail.hide_message(id); }, @@ -825,6 +828,7 @@ function kolab_files_list_select(list) else rcmail.env.viewer = 0; + rcmail.enable_command('files-edit', (rcmail.env.viewer & 4) == 4); rcmail.enable_command('files-open', rcmail.env.viewer); }; @@ -910,11 +914,10 @@ function kolab_files_frame_load(frame) } catch (e) {}; - if (rcmail.file_editor) - rcmail.enable_command('files-edit', true); - - rcmail.enable_command('files-print', (rcmail.file_editor && rcmail.file_editor.printable) || - (rcmail.env.file_data && /^image\//i.test(rcmail.env.file_data.type))); + rcmail.enable_command('files-edit', rcmail.file_editor + || (rcmail.env.file_data.viewer && rcmail.env.file_data.viewer.manticore)); + rcmail.enable_command('files-print', (rcmail.file_editor && rcmail.file_editor.printable) + || (rcmail.env.file_data && /^image\//i.test(rcmail.env.file_data.type))); // detect Print button and check if it can be accessed try { @@ -1143,6 +1146,16 @@ rcube_webmail.prototype.files_edit = function() this.file_editor.enable(); this.enable_command('files-save', true); } + else if (this.env.file) { + var viewer = file_api.file_type_supported(this.env.file_data.type, this.env.files_caps); + file_api.file_open(this.env.file, viewer, 'edit', true); + } + else if (!this.env.action) { + var files = kolab_files_selected(); + + if (files.length == 1) + file_api.file_open(files[0], this.env.viewer, 'edit'); + } }; rcube_webmail.prototype.files_save = function() @@ -2657,10 +2670,17 @@ function kolab_files_ui() }; // open file in new window, using file API viewer - this.file_open = function(file, viewer) + this.file_open = function(file, viewer, action, local) { - var href = '?' + $.param({_task: 'files', _action: 'open', file: file, viewer: viewer || 0}); - rcmail.open_window(href, false, true); + var href = '?' + $.param({_task: 'files', _action: action || 'open', file: file, viewer: viewer || 0}); + + if (rcmail.env.extwin) + href += '&_extwin=1'; + + if (local) + location.href = href; + else + rcmail.open_window(href, false, true); }; // save file diff --git a/plugins/kolab_files/kolab_files.php b/plugins/kolab_files/kolab_files.php index 9ff9a2a3..8efad587 100644 --- a/plugins/kolab_files/kolab_files.php +++ b/plugins/kolab_files/kolab_files.php @@ -49,6 +49,7 @@ class kolab_files extends rcube_plugin $this->register_action('index', array($this, 'actions')); $this->register_action('prefs', array($this, 'actions')); $this->register_action('open', array($this, 'actions')); + $this->register_action('edit', array($this, 'actions')); // we use libkolab::http_request() from libkolab with its configuration $this->require_plugin('libkolab'); diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php index 611af95c..add82156 100644 --- a/plugins/kolab_files/lib/kolab_files_engine.php +++ b/plugins/kolab_files/lib/kolab_files_engine.php @@ -892,56 +892,16 @@ class kolab_files_engine */ protected function action_open() { - $file = rcube_utils::get_input_value('file', rcube_utils::INPUT_GET); - $viewer = intval($_GET['viewer']); + $this->rc->output->set_env('files_caps', $_SESSION['kolab_files_caps']); + $this->file_opener(intval($_GET['viewer']) & ~4); + } - // get file info - $token = $this->get_api_token(); - $request = $this->get_request(array( - 'method' => 'file_info', - 'file' => $file, - 'viewer' => $viewer, - ), $token); - - // send request to the API - try { - $response = $request->send(); - $status = $response->getStatus(); - $body = @json_decode($response->getBody(), true); - - if ($status == 200 && $body['status'] == 'OK') { - $this->file_data = $body['result']; - } - else { - throw new Exception($body['reason']); - } - } - catch (Exception $e) { - rcube::raise_error(array( - 'code' => 500, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__, - 'message' => $e->getMessage()), - true, true); - } - - $this->file_data['filename'] = $file; - - $this->plugin->add_label('filedeleteconfirm', 'filedeleting', 'filedeletenotice'); - - // register template objects for dialogs (and main interface) - $this->rc->output->add_handlers(array( - 'fileinfobox' => array($this, 'file_info_box'), - 'filepreviewframe' => array($this, 'file_preview_frame'), - )); - - $placeholder = $this->rc->output->asset_url('program/resources/blank.gif'); - - // this one is for styling purpose - $this->rc->output->set_env('extwin', true); - $this->rc->output->set_env('file', $file); - $this->rc->output->set_env('file_data', $this->file_data); - $this->rc->output->set_env('photo_placeholder', $placeholder); - $this->rc->output->set_pagetitle(rcube::Q($file)); - $this->rc->output->send('kolab_files.' . ($viewer & 4 ? 'docedit' : 'filepreview')); + /** + * Handler for file open action + */ + protected function action_edit() + { + $this->file_opener(intval($_GET['viewer'])); } /** @@ -1226,6 +1186,62 @@ class kolab_files_engine $this->rc->output->send(); } + /** + * Handler for file open/edit action + */ + protected function file_opener($viewer) + { + $file = rcube_utils::get_input_value('file', rcube_utils::INPUT_GET); + + // get file info + $token = $this->get_api_token(); + $request = $this->get_request(array( + 'method' => 'file_info', + 'file' => $file, + 'viewer' => $viewer, + ), $token); + + // send request to the API + try { + $response = $request->send(); + $status = $response->getStatus(); + $body = @json_decode($response->getBody(), true); + + if ($status == 200 && $body['status'] == 'OK') { + $this->file_data = $body['result']; + } + else { + throw new Exception($body['reason']); + } + } + catch (Exception $e) { + rcube::raise_error(array( + 'code' => 500, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__, + 'message' => $e->getMessage()), + true, true); + } + + $this->file_data['filename'] = $file; + + $this->plugin->add_label('filedeleteconfirm', 'filedeleting', 'filedeletenotice'); + + // register template objects for dialogs (and main interface) + $this->rc->output->add_handlers(array( + 'fileinfobox' => array($this, 'file_info_box'), + 'filepreviewframe' => array($this, 'file_preview_frame'), + )); + + $placeholder = $this->rc->output->asset_url('program/resources/blank.gif'); + + // this one is for styling purpose + $this->rc->output->set_env('extwin', true); + $this->rc->output->set_env('file', $file); + $this->rc->output->set_env('file_data', $this->file_data); + $this->rc->output->set_env('photo_placeholder', $placeholder); + $this->rc->output->set_pagetitle(rcube::Q($file)); + $this->rc->output->send('kolab_files.' . ($viewer & 4 ? 'docedit' : 'filepreview')); + } + /** * Returns mimetypes supported by File API viewers */ diff --git a/plugins/kolab_files/skins/larry/images/buttons.png b/plugins/kolab_files/skins/larry/images/buttons.png index abd9b548..a1dbccf5 100644 Binary files a/plugins/kolab_files/skins/larry/images/buttons.png and b/plugins/kolab_files/skins/larry/images/buttons.png differ diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css index 1a5db7b8..c992f090 100644 --- a/plugins/kolab_files/skins/larry/style.css +++ b/plugins/kolab_files/skins/larry/style.css @@ -49,7 +49,10 @@ background-image: url(../../../../skins/larry/images/buttons.png); } -#filestoolbar a.button.create, +#filestoolbar a.button.create { + background-position: center -315px; +} + #filestoolbar a.button.edit { background-position: center -173px; } diff --git a/plugins/kolab_files/skins/larry/templates/docedit.html b/plugins/kolab_files/skins/larry/templates/docedit.html index fdba1c96..468ebd0c 100644 --- a/plugins/kolab_files/skins/larry/templates/docedit.html +++ b/plugins/kolab_files/skins/larry/templates/docedit.html @@ -15,15 +15,17 @@

- +