* Filemanager: Add new user preference in order to be able to exclude specific file extensions from being opened by document editor (eg. Collabora)

This commit is contained in:
Hadi Nategh 2018-02-08 14:15:51 +01:00
parent 0bbbad3a8c
commit 06ef14c78e
5 changed files with 54 additions and 13 deletions

View File

@ -1522,7 +1522,7 @@ var et2_link_string = (function(){ "use strict"; return expose(et2_valueWidget.e
.appendTo(this.list)
.addClass("et2_link loading")
.click( function(e){
var fe = egw.link_get_registry('filemanager-editor');
var fe = egw_get_file_editor_prefered_mimes();
if (self.options.expose_view && typeof _link_data.type !='undefined'
&& _link_data.type.match(self.mime_regexp,'ig'))
{

View File

@ -393,7 +393,7 @@ function expose (widget)
return;
}
var fe = egw.link_get_registry('filemanager-editor');
var fe = egw_get_file_editor_prefered_mimes();
var self=this;
// If the media type is not supported do not bind the click handler
if (!_value || typeof _value.mime != 'string' || (!_value.mime.match(mime_regex,'ig')

View File

@ -757,6 +757,24 @@ function addOption(id,label,value,do_onchange)
}
if (selectBox.onchange && do_onchange) selectBox.onchange();
}
function egw_get_file_editor_prefered_mimes(_data, _params)
{
var fe = jQuery.extend(true, {},egw.link_get_registry('filemanager-editor'));
var ex_mimes = egw.preference('collab_excluded_mimes', 'filemanager');
if (fe && fe.mime && ex_mimes)
{
ex_mimes = ex_mimes.split(',');
for (var mime in fe.mime)
{
for (var i in ex_mimes)
{
if (ex_mimes[i] == mime) delete(fe.mime[mime]);
}
}
}
return fe && fe.mime?fe:null;
}
/**
* Install click handlers for popup and multiple triggers of uiaccountselection
*/

View File

@ -234,6 +234,7 @@ class filemanager_hooks
'admin' => False,
);
}
$editorLink = self::getEditorLink();
$settings += array (
'sections.2' => array(
@ -251,7 +252,15 @@ class filemanager_hooks
'no_lang'=> true,
'xmlrpc' => True,
'admin' => False,
)
),
'collab_excluded_mimes' => array(
'type' => 'taglist',
'label' => 'Excludes selected mime types',
'help' => 'Excludes selected mime types from being opened by editor',
'name' => 'collab_excluded_mimes',
'values' => array_combine(array_keys($editorLink['mime']), array_keys($editorLink['mime'])),
'default' => '',
),
);
return $settings;

View File

@ -105,9 +105,17 @@ app.classes.filemanager = AppJS.extend(
if (name == 'filemanager.index')
{
var new_options = this.et2.getArrayMgr('sel_options').getEntry('new');
var fe = egw.link_get_registry('filemanager-editor');
var new_widget = this.et2.getWidgetById('new');
new_widget.set_select_options(new_options);
if (fe && fe.edit)
{
var new_options = this.et2.getArrayMgr('sel_options').getEntry('new');
new_widget.set_select_options(new_options);
}
else
{
new_widget.set_disabled(true);
}
}
},
@ -775,6 +783,7 @@ app.classes.filemanager = AppJS.extend(
var mime = this.et2._inst.widgetContainer.getWidgetById('$row');
// try to get mime widget DOM node out of the row DOM
var mime_dom = jQuery(_senders[0].iface.getDOMNode()).find("span#filemanager-index_\\$row");
var fe = egw_get_file_editor_prefered_mimes();
// symlinks dont have mime 'http/unix-directory', but server marks all directories with class 'isDir'
if (data.data.mime == 'httpd/unix-directory' || data.data['class'] && data.data['class'].split(/ +/).indexOf('isDir') != -1)
@ -785,12 +794,12 @@ app.classes.filemanager = AppJS.extend(
{
mime_dom.click();
}
else if (mime && this.isEditable(_action, _senders))
else if (mime && this.isEditable(_action, _senders) && fe && fe.edit)
{
egw.open_link(egw.link('/index.php', {
menuaction: 'filemanager.filemanager_ui.editor',
menuaction: fe.edit.menuaction,
path: decodeURIComponent(data.data.download_url)
}), '', egw.link_get_registry('filemanager','view_popup'));
}), '', fe.edit_popup);
}
else
{
@ -1278,7 +1287,8 @@ app.classes.filemanager = AppJS.extend(
if (_senders.length>1) return false;
var data = egw.dataGetUIDdata(_senders[0].id),
mime = this.et2._inst.widgetContainer.getWidgetById('$row');
var fe = egw_get_file_editor_prefered_mimes();
if (fe && fe.mime && !fe.mime[mime]) return false;
return data.data.mime.match(mime.mime_odf_regex)?true:false;
},
@ -1290,9 +1300,13 @@ app.classes.filemanager = AppJS.extend(
* @return {boolean} returns true
*/
create_new: function (_action, _selected) {
egw.open_link(egw.link('/index.php', {
menuaction: 'filemanager.filemanager_ui.editor'
}), '', egw.link_get_registry('filemanager','view_popup'));
var fe = egw.link_get_registry('filemanager-editor');
if (fe && fe.edit)
{
egw.open_link(egw.link('/index.php', {
menuaction: fe.edit.menuaction
}), '', fe.popup_edit);
}
return true;
}
});