Manticore -> Document Editor, with more WOPI support
This commit is contained in:
parent
4889334d13
commit
7adf82a0c6
2 changed files with 54 additions and 34 deletions
|
@ -142,7 +142,7 @@ function kolab_files_init()
|
||||||
if (window.file_api)
|
if (window.file_api)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var manticore_config = {};
|
var editor_config = {};
|
||||||
|
|
||||||
// Initialize application object (don't change var name!)
|
// Initialize application object (don't change var name!)
|
||||||
file_api = $.extend(new files_api(), new kolab_files_ui());
|
file_api = $.extend(new files_api(), new kolab_files_ui());
|
||||||
|
@ -161,22 +161,29 @@ function kolab_files_init()
|
||||||
file_api.translations = rcmail.labels;
|
file_api.translations = rcmail.labels;
|
||||||
|
|
||||||
if (rcmail.task == 'files') {
|
if (rcmail.task == 'files') {
|
||||||
if (rcmail.env.action == 'edit' && rcmail.env.file_data.viewer && rcmail.env.file_data.viewer.manticore) {
|
if (rcmail.env.action == 'edit' && rcmail.env.editor_type) {
|
||||||
manticore_config = {
|
// Extract the domain here, it can't be done by Chwala
|
||||||
|
// when using WOPI, which does not set iframe src attribute
|
||||||
|
var domain, href = rcmail.env.file_data.viewer.href;
|
||||||
|
if (href && /^(https?:\/\/[^/]+)/i.test(href))
|
||||||
|
domain = RegExp.$1;
|
||||||
|
|
||||||
|
editor_config = {
|
||||||
// UI elements
|
// UI elements
|
||||||
iframe: $('#fileframe').get(0),
|
iframe: $('#fileframe').get(0),
|
||||||
|
domain: domain,
|
||||||
export_menu: rcmail.gui_objects.exportmenu ? $('ul', rcmail.gui_objects.exportmenu).get(0) : null,
|
export_menu: rcmail.gui_objects.exportmenu ? $('ul', rcmail.gui_objects.exportmenu).get(0) : null,
|
||||||
title_input: $('#document-title').get(0),
|
title_input: $('#document-title').get(0),
|
||||||
members_list: $('#members').get(0),
|
members_list: $('#members').get(0),
|
||||||
photo_url: '?_task=addressbook&_action=photo&_error=1&_email=%email',
|
photo_url: '?_task=addressbook&_action=photo&_error=1&_email=%email',
|
||||||
photo_default_url: rcmail.env.photo_placeholder,
|
photo_default_url: rcmail.env.photo_placeholder,
|
||||||
// events
|
// events
|
||||||
ready: function(data) { manticore_init(); },
|
ready: function(data) { document_editor_init(); },
|
||||||
sessionClosed: function(data) { return manticore_close(); }
|
sessionClosed: function(data) { return document_editor_close(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (rcmail.env.file_data.writable)
|
if (rcmail.env.file_data.writable)
|
||||||
manticore_config.documentChanged = function(data) { rcmail.enable_command('document-save', true); };
|
editor_config.documentChanged = function(data) { rcmail.enable_command('document-save', true); };
|
||||||
}
|
}
|
||||||
else if (rcmail.env.action == 'open') {
|
else if (rcmail.env.action == 'open') {
|
||||||
// initialize folders list (for dialogs)
|
// initialize folders list (for dialogs)
|
||||||
|
@ -191,17 +198,17 @@ function kolab_files_init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rcmail.env.files_caps && rcmail.env.files_caps.MANTICORE && !rcmail.env.framed)
|
if (rcmail.env.files_caps && !rcmail.env.framed && rcmail.env.files_caps.DOCEDIT)
|
||||||
$.extend(manticore_config, {
|
$.extend(editor_config, {
|
||||||
// invitation notifications
|
// invitation notifications
|
||||||
api: file_api,
|
api: file_api,
|
||||||
owner: rcmail.env.files_user,
|
owner: rcmail.env.files_user,
|
||||||
interval: rcmail.env.files_interval || 60,
|
interval: rcmail.env.files_interval || 60,
|
||||||
invitationMore: true,
|
invitationMore: true,
|
||||||
invitationChange: manticore_invitation_handler
|
invitationChange: document_editor_invitation_handler
|
||||||
});
|
});
|
||||||
|
|
||||||
$.extend(manticore_config, {
|
$.extend(editor_config, {
|
||||||
// notifications/alerts
|
// notifications/alerts
|
||||||
gettext: function(label) { return rcmail.get_label('kolab_files.' + label); },
|
gettext: function(label) { return rcmail.get_label('kolab_files.' + label); },
|
||||||
set_busy: function(state, message) { return rcmail.set_busy(state, message ? 'kolab_files.' + message : ''); },
|
set_busy: function(state, message) { return rcmail.set_busy(state, message ? 'kolab_files.' + message : ''); },
|
||||||
|
@ -213,7 +220,10 @@ function kolab_files_init()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
manticore = new manticore_api(manticore_config);
|
if (window.document_editor_api)
|
||||||
|
document_editor = new document_editor_api(editor_config);
|
||||||
|
else
|
||||||
|
document_editor = new manticore_api(editor_config);
|
||||||
};
|
};
|
||||||
|
|
||||||
// returns API authorization token
|
// returns API authorization token
|
||||||
|
@ -577,7 +587,7 @@ function kolab_files_file_edit_dialog(file, sessions, readonly)
|
||||||
kolab_dialog_close(dlg);
|
kolab_dialog_close(dlg);
|
||||||
|
|
||||||
if (id && input.parent().is('.session.request')) {
|
if (id && input.parent().is('.session.request')) {
|
||||||
manticore.invitation_request({session_id: id});
|
document_editor.invitation_request({session_id: id});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,7 +809,7 @@ function kolab_files_session_dialog(session)
|
||||||
buttons[rcmail.gettext('kolab_files.request')] = function() {
|
buttons[rcmail.gettext('kolab_files.request')] = function() {
|
||||||
kolab_dialog_close(this);
|
kolab_dialog_close(this);
|
||||||
// @TODO: Add comment field to the dialog
|
// @TODO: Add comment field to the dialog
|
||||||
manticore.invitation_request({session_id: session.id});
|
document_editor.invitation_request({session_id: session.id});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,7 +1185,7 @@ function kolab_files_frame_load(frame)
|
||||||
rcmail.files_edit();
|
rcmail.files_edit();
|
||||||
|
|
||||||
rcmail.enable_command('files-edit', (rcmail.file_editor && rcmail.file_editor.editable)
|
rcmail.enable_command('files-edit', (rcmail.file_editor && rcmail.file_editor.editable)
|
||||||
|| (info && info.viewer && (info.viewer.manticore || info.viewer.wopi))
|
|| rcmail.env.editor_type
|
||||||
|| (file_api.file_type_supported(rcmail.env.file_data.type, rcmail.env.files_caps) & 4));
|
|| (file_api.file_type_supported(rcmail.env.file_data.type, rcmail.env.files_caps) & 4));
|
||||||
|
|
||||||
rcmail.enable_command('files-print', (rcmail.file_editor && rcmail.file_editor.printable)
|
rcmail.enable_command('files-print', (rcmail.file_editor && rcmail.file_editor.printable)
|
||||||
|
@ -1274,11 +1284,11 @@ function kolab_files_progress_str(param)
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
/********* Manticore editor functionality **********/
|
/********* document editor functionality **********/
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
||||||
// Initialize document toolbar functionality
|
// Initialize document toolbar functionality
|
||||||
function manticore_init()
|
function document_editor_init()
|
||||||
{
|
{
|
||||||
var info = rcmail.env.file_data;
|
var info = rcmail.env.file_data;
|
||||||
|
|
||||||
|
@ -1289,7 +1299,7 @@ function manticore_init()
|
||||||
};
|
};
|
||||||
|
|
||||||
// executed on editing session termination
|
// executed on editing session termination
|
||||||
function manticore_close()
|
function document_editor_close()
|
||||||
{
|
{
|
||||||
$('<div>').addClass('popupdialog').attr('role', 'alertdialog')
|
$('<div>').addClass('popupdialog').attr('role', 'alertdialog')
|
||||||
.html($('<span>').text(rcmail.gettext('kolab_files.sessionterminated')))
|
.html($('<span>').text(rcmail.gettext('kolab_files.sessionterminated')))
|
||||||
|
@ -1308,14 +1318,14 @@ function manticore_close()
|
||||||
|
|
||||||
rcube_webmail.prototype.document_save = function()
|
rcube_webmail.prototype.document_save = function()
|
||||||
{
|
{
|
||||||
manticore.save(function(data) {
|
document_editor.save(function(data) {
|
||||||
rcmail.enable_command('document-save', false);
|
rcmail.enable_command('document-save', false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
rcube_webmail.prototype.document_export = function(type)
|
rcube_webmail.prototype.document_export = function(type)
|
||||||
{
|
{
|
||||||
manticore.export(type || 'odt');
|
document_editor.export(type || 'odt');
|
||||||
};
|
};
|
||||||
|
|
||||||
rcube_webmail.prototype.document_editors = function()
|
rcube_webmail.prototype.document_editors = function()
|
||||||
|
@ -1461,7 +1471,7 @@ function kolab_files_attendee_record(user, status, username)
|
||||||
select = $('<select>').change(function() {
|
select = $('<select>').change(function() {
|
||||||
var val = $(this).val(), map = {accepted: 'invitation_accept', declined: 'invitation_decline'};
|
var val = $(this).val(), map = {accepted: 'invitation_accept', declined: 'invitation_decline'};
|
||||||
if (map[val])
|
if (map[val])
|
||||||
manticore[map[val]]({user: user, session_id: rcmail.env.file_data.session.id});
|
document_editor[map[val]]({user: user, session_id: rcmail.env.file_data.session.id});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (type == 'requested')
|
if (type == 'requested')
|
||||||
|
@ -1490,7 +1500,7 @@ function kolab_files_attendee_record(user, status, username)
|
||||||
.append(name).append(state).append(buttons);
|
.append(name).append(state).append(buttons);
|
||||||
};
|
};
|
||||||
|
|
||||||
function manticore_invitation_handler(invitation)
|
function document_editor_invitation_handler(invitation)
|
||||||
{
|
{
|
||||||
// make the "More" link clickable
|
// make the "More" link clickable
|
||||||
$('#' + invitation.id).parent('div').click(function() { kolab_files_invitation_dialog(invitation); });
|
$('#' + invitation.id).parent('div').click(function() { kolab_files_invitation_dialog(invitation); });
|
||||||
|
@ -1521,27 +1531,27 @@ function kolab_files_invitation_dialog(invitation)
|
||||||
|
|
||||||
if (!invitation.is_session_owner) {
|
if (!invitation.is_session_owner) {
|
||||||
if (invitation.status == 'invited') {
|
if (invitation.status == 'invited') {
|
||||||
text = manticore.invitation_msg(invitation);
|
text = document_editor.invitation_msg(invitation);
|
||||||
|
|
||||||
buttons[rcmail.gettext('kolab_files.join')] = function() {
|
buttons[rcmail.gettext('kolab_files.join')] = function() {
|
||||||
join_session();
|
join_session();
|
||||||
kolab_dialog_close(this);
|
kolab_dialog_close(this);
|
||||||
};
|
};
|
||||||
buttons[rcmail.gettext('kolab_files.accept')] = function() {
|
buttons[rcmail.gettext('kolab_files.accept')] = function() {
|
||||||
manticore.invitation_accept(invitation);
|
document_editor.invitation_accept(invitation);
|
||||||
kolab_dialog_close(this);
|
kolab_dialog_close(this);
|
||||||
};
|
};
|
||||||
buttons[rcmail.gettext('kolab_files.decline')] = function() {
|
buttons[rcmail.gettext('kolab_files.decline')] = function() {
|
||||||
manticore.invitation_decline(invitation);
|
document_editor.invitation_decline(invitation);
|
||||||
kolab_dialog_close(this);
|
kolab_dialog_close(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (invitation.status == 'declined-owner') {
|
else if (invitation.status == 'declined-owner') {
|
||||||
// @todo: add option to request for an invitation again?
|
// @todo: add option to request for an invitation again?
|
||||||
text = manticore.invitation_msg(invitation);
|
text = document_editor.invitation_msg(invitation);
|
||||||
}
|
}
|
||||||
else if (invitation.status == 'accepted-owner') {
|
else if (invitation.status == 'accepted-owner') {
|
||||||
text = manticore.invitation_msg(invitation);
|
text = document_editor.invitation_msg(invitation);
|
||||||
|
|
||||||
buttons[rcmail.gettext('kolab_files.join')] = function() {
|
buttons[rcmail.gettext('kolab_files.join')] = function() {
|
||||||
join_session();
|
join_session();
|
||||||
|
@ -1551,21 +1561,21 @@ function kolab_files_invitation_dialog(invitation)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (invitation.status == 'accepted') {
|
if (invitation.status == 'accepted') {
|
||||||
text = manticore.invitation_msg(invitation);
|
text = document_editor.invitation_msg(invitation);
|
||||||
}
|
}
|
||||||
else if (invitation.status == 'declined') {
|
else if (invitation.status == 'declined') {
|
||||||
// @todo: add option to invite the user again?
|
// @todo: add option to invite the user again?
|
||||||
text = manticore.invitation_msg(invitation);
|
text = document_editor.invitation_msg(invitation);
|
||||||
}
|
}
|
||||||
else if (invitation.status == 'requested') {
|
else if (invitation.status == 'requested') {
|
||||||
text = manticore.invitation_msg(invitation);
|
text = document_editor.invitation_msg(invitation);
|
||||||
|
|
||||||
buttons[rcmail.gettext('kolab_files.accept')] = function() {
|
buttons[rcmail.gettext('kolab_files.accept')] = function() {
|
||||||
manticore.invitation_accept(invitation);
|
document_editor.invitation_accept(invitation);
|
||||||
kolab_dialog_close(this);
|
kolab_dialog_close(this);
|
||||||
};
|
};
|
||||||
buttons[rcmail.gettext('kolab_files.decline')] = function() {
|
buttons[rcmail.gettext('kolab_files.decline')] = function() {
|
||||||
manticore.invitation_decline(invitation);
|
document_editor.invitation_decline(invitation);
|
||||||
kolab_dialog_close(this);
|
kolab_dialog_close(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1999,7 +2009,7 @@ function kolab_files_ui()
|
||||||
});
|
});
|
||||||
|
|
||||||
// add Sessions entry
|
// add Sessions entry
|
||||||
if (rcmail.task == 'files' && !rcmail.env.action && rcmail.env.files_caps && rcmail.env.files_caps.MANTICORE) {
|
if (rcmail.task == 'files' && !rcmail.env.action && rcmail.env.files_caps && rcmail.env.files_caps.DOCEDIT) {
|
||||||
rows.push($('<li class="mailbox collection sessions"></li>')
|
rows.push($('<li class="mailbox collection sessions"></li>')
|
||||||
.attr('id', 'rcmli' + rcmail.html_identifier_encode('folder-collection-sessions'))
|
.attr('id', 'rcmli' + rcmail.html_identifier_encode('folder-collection-sessions'))
|
||||||
.append($('<a class="name"></a>').text(rcmail.gettext('kolab_files.sessions')))
|
.append($('<a class="name"></a>').text(rcmail.gettext('kolab_files.sessions')))
|
||||||
|
@ -2973,7 +2983,7 @@ function kolab_files_ui()
|
||||||
});
|
});
|
||||||
|
|
||||||
// refresh sessions info in time intervals
|
// refresh sessions info in time intervals
|
||||||
if (rcmail.env.files_caps && rcmail.env.files_caps.MANTICORE && (rcmail.fileslist || rcmail.env.file))
|
if (rcmail.env.files_caps && rcmail.env.files_caps.DOCEDIT && (rcmail.fileslist || rcmail.env.file))
|
||||||
this.workers[folder] = setTimeout(function() {
|
this.workers[folder] = setTimeout(function() {
|
||||||
file_api.request('folder_info', {folder: folder, sessions: 1}, 'folder_info_response');
|
file_api.request('folder_info', {folder: folder, sessions: 1}, 'folder_info_response');
|
||||||
}, (rcmail.env.files_interval || 60) * 1000);
|
}, (rcmail.env.files_interval || 60) * 1000);
|
||||||
|
|
|
@ -127,6 +127,11 @@ class kolab_files_engine
|
||||||
), 'taskbar');
|
), 'taskbar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_SESSION['kolab_files_caps']['MANTICORE'] || $_SESSION['kolab_files_caps']['WOPI']) {
|
||||||
|
$_SESSION['kolab_files_caps']['DOCEDIT'] = true;
|
||||||
|
$_SESSION['kolab_files_caps']['DOCTYPE'] = $_SESSION['kolab_files_caps']['MANTICORE'] ? 'manticore' : 'wopi';
|
||||||
|
}
|
||||||
|
|
||||||
$this->plugin->include_stylesheet($this->plugin->local_skin_path().'/style.css');
|
$this->plugin->include_stylesheet($this->plugin->local_skin_path().'/style.css');
|
||||||
$this->plugin->include_script($this->url . '/js/files_api.js');
|
$this->plugin->include_script($this->url . '/js/files_api.js');
|
||||||
$this->plugin->include_script('kolab_files.js');
|
$this->plugin->include_script('kolab_files.js');
|
||||||
|
@ -136,7 +141,7 @@ class kolab_files_engine
|
||||||
$this->rc->output->set_env('files_caps', $_SESSION['kolab_files_caps']);
|
$this->rc->output->set_env('files_caps', $_SESSION['kolab_files_caps']);
|
||||||
$this->rc->output->set_env('files_user', $this->rc->get_user_name());
|
$this->rc->output->set_env('files_user', $this->rc->get_user_name());
|
||||||
|
|
||||||
if ($_SESSION['kolab_files_caps']['MANTICORE']) {
|
if ($_SESSION['kolab_files_caps']['DOCEDIT']) {
|
||||||
$this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice',
|
$this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice',
|
||||||
'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice',
|
'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice',
|
||||||
'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment',
|
'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment',
|
||||||
|
@ -931,6 +936,11 @@ class kolab_files_engine
|
||||||
// some HTTP server configurations require this header
|
// some HTTP server configurations require this header
|
||||||
$this->request->setHeader('accept', "application/json,text/javascript,*/*");
|
$this->request->setHeader('accept', "application/json,text/javascript,*/*");
|
||||||
|
|
||||||
|
// set Referer which is used as an origin for cross-window
|
||||||
|
// communication with document editor iframe
|
||||||
|
$host = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||||
|
$this->request->setHeader('referer', $host);
|
||||||
|
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue