From b00b37efa8e20601d39500babbd033af95b48d3b Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 25 Oct 2018 15:31:41 +0200 Subject: [PATCH] W.I.P. implementing TinyMCE editor and deprecating CKEditor: - Fix image upload via old file_selector for etemplate apps --- api/src/Html.php | 29 +++++++++++++++++-- .../inc/class.filemanager_select.inc.php | 10 ++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/api/src/Html.php b/api/src/Html.php index 791e2c8e13..51092b084f 100644 --- a/api/src/Html.php +++ b/api/src/Html.php @@ -442,6 +442,9 @@ class Html static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'), $_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='') { + //not used anymore but defined in function signature + unset ($_options); + if (!self::htmlarea_availible() || $_mode == 'ascii') { return self::textarea($_name,$_content,'style="width: '.$_width.'; height: '.$_height.';" id="'.htmlspecialchars($_name).'"'); @@ -490,9 +493,31 @@ tinymce.init({ browser_spellcheck: true, contextmenu: false, file_picker_callback: function(_callback, _value, _meta){ + var callback = _callback; + var attrs = { + menuaction: "filemanager.filemanager_select.select", + mode: "open", + method: "download_url", + path: "'. $_start_path.'" + }; - - + // Open the filemanager select in a popup + var popup = egw(window).open_link( + egw().link("/index.php", attrs), + "link_existing", + "680x400" + ); + if(popup) + { + // Safari and IE lose reference to global variables after window close + // Try to get updated data before window is closed then later we trigger + // change event on widget + egw().window.setTimeout(function(){ + jQuery(popup).bind("unload",function(){ + callback(this.selected_files, {alt:this.selected_files}); + }); + },1000); + } }, init_instance_callback : function(_editor){ console.log(_editor); diff --git a/filemanager/inc/class.filemanager_select.inc.php b/filemanager/inc/class.filemanager_select.inc.php index cf1d3a4725..d875f0cfe1 100644 --- a/filemanager/inc/class.filemanager_select.inc.php +++ b/filemanager/inc/class.filemanager_select.inc.php @@ -195,7 +195,15 @@ class filemanager_select if ($content['method'] && $content['method'] != 'ckeditor_return') { - $js = ExecMethod2($content['method'],$content['id'],$files); + if ($content['method'] == 'download_url' && !is_array($files)) + { + $files = Vfs::download_url($files); + if ($files[0] == '/') $files = Egw::link($files); + } + else + { + $js = ExecMethod2($content['method'],$content['id'],$files); + } } else if ($content['method'] == 'ckeditor_return') {