Fix CKEditor Browse Server button to open vfsSelect

This commit is contained in:
Hadi Nategh
2017-10-20 18:55:22 +02:00
parent 28d45e28cb
commit ff4396030a
4 changed files with 76 additions and 5 deletions

View File

@ -522,6 +522,14 @@ class Vfs extends File
$sel_options = array_merge($sel_options, array(
'app' => self::get_apps()
));
if ($content['method'] === 'ckeditor')
{
$download_baseUrl = \EGroupware\Api\Vfs::download_url($content['path']);
if ($download_baseUrl[0] == '/') $download_baseUrl = \EGroupware\Api\Egw::link($download_baseUrl);
$content['download_baseUrl'] = $download_baseUrl;
}
Api\Cache::setSession('filemanger', 'select_path', $content['path']);
// Response
$response->data(array(

View File

@ -60,6 +60,15 @@ class CkEditorConfig
'px' => 'px: display pixels',
);
/**
* Functions that can be called via menuaction
*
* @var array
*/
var $public_functions = array(
'vfsSelectHelper' => true,
);
/**
* Get available CKEditor Skins
*
@ -249,8 +258,10 @@ class CkEditorConfig
*/
private static function get_filebrowserBrowseUrl($start_path = '')
{
return $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=filemanager.filemanager_select.select&mode=open&method=ckeditor_return'
.($start_path != '' ? '&path='.$start_path : '');
return \EGroupware\Api\Egw::link('/index.php',array(
'menuaction' => 'api.EGroupware\\Api\\Html\\CkEditorConfig.vfsSelectHelper',
'path' => $start_path
));
}
/**
@ -508,4 +519,21 @@ class CkEditorConfig
// tell framework CK Editor needs eval and inline javascript :(
ContentSecurityPolicy::add('script-src', $attrs);
}
/**
* It helps to get CKEditor Browse server button to open VfsSelect widget
* in client side.
* @todo Once the ckeditor allows to overrride the Browse Server button handler
* we should remove this function and handle everything in htmlarea widget in
* client side.
*/
public function vfsSelectHelper()
{
$tmp = new \EGroupware\Api\Etemplate('api.vfsSelectUI');
$response = \EGroupware\Api\Json\Response::get();
$response->call('window.opener.et2_htmlarea.buildVfsSelectForCKEditor',
array('funcNum' => $_GET['CKEditorFuncNum']));
$response->call('window.close');
$tmp->exec('',array());
}
}