mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
W.I.P. implementing TinyMCE editor and deprecating CKEditor:
- Add d-n-d image upload
This commit is contained in:
parent
f62c5d8ea5
commit
345c3c2611
@ -98,6 +98,18 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
|
||||
doLoadingFinished: function() {
|
||||
this._super.apply(this, arguments);
|
||||
if(this.mode == 'ascii' || this.editor != null) return;
|
||||
var imageUpload = '';
|
||||
|
||||
if (this.options.imageUpload[0] !== '/' && this.options.imageUpload.substr(0, 4) != 'http')
|
||||
{
|
||||
imageUpload = egw.ajaxUrl("EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_htmlarea_upload")+
|
||||
'&request_id='+this.getInstanceManager().etemplate_exec_id+'&widget_id='+this.options.imageUpload+'&type=htmlarea';
|
||||
imageUpload = imageUpload.substr(egw.webserverUrl.length+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageUpload = this.options.imageUpload.substr(egw.webserverUrl.length+1);
|
||||
}
|
||||
|
||||
// default settings for initialization
|
||||
var settings = {
|
||||
@ -113,9 +125,9 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
|
||||
paste_data_images: true,
|
||||
browser_spellcheck: true,
|
||||
contextmenu: false,
|
||||
images_upload_url: this.options.imageUpload,
|
||||
images_upload_url: imageUpload,
|
||||
file_picker_callback: jQuery.proxy(this._file_picker_callback, this),
|
||||
images_upload_handler: jQuery.proxy(this._images_upload_handler, this),
|
||||
images_upload_handler: this.options.images_upload_handler,
|
||||
init_instance_callback : jQuery.proxy(this._instanceIsReady, this),
|
||||
plugins: [
|
||||
"print fullpage searchreplace autolink directionality "+
|
||||
@ -189,17 +201,6 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
|
||||
vfsSelect.click();
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {type} _blobInfo image blob info
|
||||
* @param {type} _success success callback
|
||||
* @param {type} _failure failure callback
|
||||
* @returns {}
|
||||
*/
|
||||
_images_upload_handler: function(_blobInfo, _success, _failure) {
|
||||
if (typeof this.images_upload_handler == 'function') return this.images_upload_handler.call(arguments, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback when instance is ready
|
||||
*
|
||||
|
@ -140,12 +140,14 @@ class Vfs extends File
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload via dragging images into ckeditor
|
||||
* Upload via dragging images into ckeditor/htmlarea(tinymce)
|
||||
*/
|
||||
public static function ajax_htmlarea_upload()
|
||||
{
|
||||
$request_id = urldecode($_REQUEST['request_id']);
|
||||
$type = $_REQUEST['type'];
|
||||
$widget_id = $_REQUEST['widget_id'];
|
||||
$file = $type == 'htmlarea' ? $_FILES['file'] : $_FILES['upload'];
|
||||
if(!self::$request = Etemplate\Request::read($request_id))
|
||||
{
|
||||
$error = lang("Could not read session");
|
||||
@ -156,7 +158,7 @@ class Vfs extends File
|
||||
// Can't use callback
|
||||
$error = lang("Could not get template for file upload, callback skipped");
|
||||
}
|
||||
elseif (!isset($_FILES['upload']))
|
||||
elseif (!isset($file))
|
||||
{
|
||||
$error = lang('No _FILES[upload] found!');
|
||||
}
|
||||
@ -164,14 +166,14 @@ class Vfs extends File
|
||||
{
|
||||
$data = self::$request->content[$widget_id];
|
||||
$path = self::store_file($path = (!is_array($data) && $data[0] == '/' ? $data :
|
||||
self::get_vfs_path($data['to_app'].':'.$data['to_id'])).'/', $_FILES['upload']);
|
||||
self::get_vfs_path($data['to_app'].':'.$data['to_id'])).'/', $file);
|
||||
|
||||
// store temp. vfs-path like links to be able to move it to correct location after entry is stored
|
||||
if (!$data['to_id'] || is_array($data['to_id']))
|
||||
{
|
||||
Api\Link::link($data['to_app'], $data['to_id'], Api\Link::VFS_APPNAME, array(
|
||||
'name' => $_FILES['upload']['name'],
|
||||
'type' => $_FILES['upload']['type'],
|
||||
'name' => $file['name'],
|
||||
'type' => $file['upload']['type'],
|
||||
'tmp_name' => Api\Vfs::PREFIX.$path,
|
||||
));
|
||||
self::$request->content = array_merge(self::$request->content, array($widget_id => $data));
|
||||
@ -180,17 +182,24 @@ class Vfs extends File
|
||||
// switch regular JSON response handling off
|
||||
Api\Json\Request::isJSONRequest(false);
|
||||
|
||||
$file = array(
|
||||
if ($type == 'htmlarea')
|
||||
{
|
||||
$result = array ('location' => Api\Framework::link(Api\Vfs::download_url($path)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = array(
|
||||
"uploaded" => (int)empty($error),
|
||||
"fileName" => Api\Html::htmlspecialchars($_FILES['upload']['name']),
|
||||
"fileName" => Api\Html::htmlspecialchars($file['name']),
|
||||
"url" => Api\Framework::link(Api\Vfs::download_url($path)),
|
||||
"error" => array(
|
||||
"message" => $error,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($file);
|
||||
echo json_encode($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user