Implement proposed filemanager mime type open handler based on user preferences

This commit is contained in:
Hadi Nategh 2018-02-06 18:00:36 +01:00
parent d934f33ea6
commit 8e0243294c
5 changed files with 34 additions and 6 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 = 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

@ -783,7 +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.link_get_registry('filemanager-editor');
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)
@ -1288,7 +1288,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;
},