Editor : Add option to activate plugin uploadimage in ckeditor - BT18997

pull/3940/head
Christian 4 years ago
parent cedce09205
commit 6557283dfa
  1. 29
      main/inc/ajax/document.ajax.php
  2. 3
      main/install/configuration.dist.php
  3. 8
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php

@ -85,13 +85,18 @@ switch ($action) {
}
if (!empty($_FILES)) {
$files = $_FILES['files'];
$isCkUploadImage = ($_COOKIE['ckCsrfToken'] == $_POST['ckCsrfToken']); // it comes from uploaimage drag and drop ckeditor
$fileList = [];
foreach ($files as $name => $array) {
$counter = 0;
foreach ($array as $data) {
$fileList[$counter][$name] = $data;
$counter++;
if ($isCkUploadImage) {
$fileList[0] = $_FILES['upload'];
} else {
$files = $_FILES['files'];
foreach ($files as $name => $array) {
$counter = 0;
foreach ($array as $data) {
$fileList[$counter][$name] = $data;
$counter++;
}
}
}
@ -134,7 +139,17 @@ switch ($action) {
$resultList[] = $json;
}
echo json_encode(['files' => $resultList]);
if ($isCkUploadImage) {
$ckResult = $resultList[0];
$courseInfo = api_get_course_info();
$courseDir = $courseInfo['path'].'/document';
$webCoursePath = api_get_path(WEB_COURSE_PATH);
$url = $webCoursePath.$courseDir.$currentDirectory.$ckResult['name'];
$data = ['uploaded' => 1, 'fileName' => $ckResult['name'], 'url' => $url];
echo json_encode($data);
} else {
echo json_encode(['files' => $resultList]);
}
}
exit;
break;

@ -1974,6 +1974,9 @@ ALTER TABLE gradebook_comment ADD CONSTRAINT FK_C3B70763AD3ED51C FOREIGN KEY (gr
// and showing them in the SCORM upload form
//$_configuration['scorm_upload_from_cache'] = false;
// Enable image upload as file when doing a copy in the content or a drag and drop.
//$_configuration['enable_uploadimage_editor'] = false;
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email

@ -150,6 +150,11 @@ class Basic extends Toolbar
$plugins[] = 'blockimagepaste';
}
// it should be disabled first the option ck_editor_block_image_copy_paste to allow copy and drag in editor content
if (api_get_configuration_value('enable_uploadimage_editor')) {
$plugins[] = 'uploadimage';
}
$this->defaultPlugins = array_unique(array_merge($this->defaultPlugins, $plugins));
parent::__construct($toolbar, $config, $prefix);
@ -171,6 +176,9 @@ class Basic extends Toolbar
$config['customConfig'] = api_get_path(WEB_LIBRARY_JS_PATH).'ckeditor/config_js.php?'.api_get_cidreq();
$config['flash_flvPlayer'] = api_get_path(WEB_LIBRARY_JS_PATH).'ckeditor/plugins/flash/swf/player.swf';
if (api_get_configuration_value('enable_uploadimage_editor')) {
$config['imageUploadUrl'] = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath=/';
}
/*filebrowserFlashBrowseUrl
filebrowserFlashUploadUrl
filebrowserImageBrowseLinkUrl

Loading…
Cancel
Save