diff --git a/api/js/etemplate/et2_widget_htmlarea.js b/api/js/etemplate/et2_widget_htmlarea.js index 27bf431ed7..6a25b6c9c5 100644 --- a/api/js/etemplate/et2_widget_htmlarea.js +++ b/api/js/etemplate/et2_widget_htmlarea.js @@ -318,7 +318,20 @@ jQuery.extend(et2_htmlarea, buildVfsSelectForCKEditor: function(_data) { if (!_data) return; - var et2 = app[egw(window).app_name()].et2; + + // Don't rely only on app_name to fetch et2 object as app_name may not + // always represent current app of the window, e.g.: mail admin account. + // Try to fetch et2 from its template name. + var etemplate = jQuery('form').data('etemplate'); + var et2 = {}; + if (etemplate && etemplate.name && !app[egw(window).app_name()]) + { + et2 = etemplate2.getByTemplate(etemplate.name)[0]['widgetContainer']; + } + else + { + et2 = app[egw(window).app_name()].et2; + } var vfsSelect = et2_createWidget('vfs-select', { id:'upload', diff --git a/api/js/etemplate/et2_widget_vfs.js b/api/js/etemplate/et2_widget_vfs.js index b383a64bc5..108a3946db 100644 --- a/api/js/etemplate/et2_widget_vfs.js +++ b/api/js/etemplate/et2_widget_vfs.js @@ -1064,10 +1064,25 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( resizable: false }, et2_dialog._create_parent('api')); this.dialog.template.uniqueId = 'api.vfsSelectUI'; + + // Don't rely only on app_name to fetch et2 object as app_name may not + // always represent current app of the window, e.g.: mail admin account. + // Try to fetch et2 from its template name. + var etemplate = jQuery('form').data('etemplate'); + var et2 = {}; + if (etemplate && etemplate.name && !app[egw(window).app_name()]) + { + et2 = etemplate2.getByTemplate(etemplate.name)[0] + } + else + { + et2 = etemplate2.getByApplication(egw(window).app_name())[0]; + } // we need an etemplate_exec_id for better handling serverside parts of // widgets and since we can not have a etemplate_exec_id specifically // for dialog template our best shot is to inherit its parent etemplate_exec_id. - this.dialog.template.etemplate_exec_id = etemplate2.getByApplication(egw(window).app_name())[0].etemplate_exec_id; + this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id; + app.vfsSelectUI.et2 = this.dialog.template.widgetContainer; // Keep the dialog always at the top, seems CKEDITOR dialogs have very // high z-index set. diff --git a/api/src/Html/CkEditorConfig.php b/api/src/Html/CkEditorConfig.php index 5000df0860..b157b2680b 100644 --- a/api/src/Html/CkEditorConfig.php +++ b/api/src/Html/CkEditorConfig.php @@ -259,8 +259,9 @@ class CkEditorConfig private static function get_filebrowserBrowseUrl($start_path = '') { // Still need to treat old etemplate app to use filemanager_select. + // *Admin: admin app also still have some old etmplate apps like login_message. // @TODO: this should be removed when we don't have any old etemplate app anymore. - if (in_array($GLOBALS['app'], array('phpbrain', 'sitemgr'))) + if (in_array($GLOBALS['app'], array('phpbrain', 'sitemgr', 'admin'))) { return $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=filemanager.filemanager_select.select&mode=open&method=ckeditor_return' .($start_path != '' ? '&path='.$start_path : '');