diff --git a/api/js/etemplate/et2_widget_link.js b/api/js/etemplate/et2_widget_link.js index a171445468..1cb948ee62 100644 --- a/api/js/etemplate/et2_widget_link.js +++ b/api/js/etemplate/et2_widget_link.js @@ -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')) { diff --git a/api/js/etemplate/expose.js b/api/js/etemplate/expose.js index 28aac146b4..59152caab7 100644 --- a/api/js/etemplate/expose.js +++ b/api/js/etemplate/expose.js @@ -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') diff --git a/api/js/jsapi/jsapi.js b/api/js/jsapi/jsapi.js index 29ddc06f29..60475e4c55 100644 --- a/api/js/jsapi/jsapi.js +++ b/api/js/jsapi/jsapi.js @@ -60,7 +60,7 @@ if (typeof window.console == 'undefined') /** * Seperates all script tags from the given html code and returns the seperately - * + * * @param object _html object that the html code * from which the script should be seperated * The html code has to be stored in _html.html, @@ -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 */ diff --git a/filemanager/inc/class.filemanager_hooks.inc.php b/filemanager/inc/class.filemanager_hooks.inc.php index 3c00cd2b94..8654654552 100644 --- a/filemanager/inc/class.filemanager_hooks.inc.php +++ b/filemanager/inc/class.filemanager_hooks.inc.php @@ -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; diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 84edb355d6..07d590169b 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -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; } });