mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX: fixed doUpload ajax submission to correctly handle files submitted via the content editor submission.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@91480 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
87e7599ff0
commit
cd1a08d6a6
@ -165,15 +165,29 @@ JS
|
||||
* It will save the uploaded files to /assets/ and create new File objects as required.
|
||||
*/
|
||||
function doUpload($data, $form) {
|
||||
$processedFiles = array();
|
||||
|
||||
if(!isset($data['Files'])) return Director::set_status_code("404");
|
||||
|
||||
if(is_array($data['Files'])) {
|
||||
foreach($data['Files'] as $param => $files) {
|
||||
if(!is_array($files)) $files = array($files);
|
||||
foreach($files as $key => $value) {
|
||||
$processedFiles[$key][$param] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$proccessedFiles[] = $data['Files'];
|
||||
}
|
||||
|
||||
if($data['ID'] && $data['ID'] != 'root') $folder = DataObject::get_by_id("Folder", $data['ID']);
|
||||
else $folder = singleton('Folder');
|
||||
// get the folder to upload to.
|
||||
if(isset($data['FolderID']) && $data['FolderID'] != "root") {
|
||||
$folder = DataObject::get_by_id('Folder', $data['FolderID']);
|
||||
}
|
||||
else {
|
||||
$folder = DataObject::get_one('Folder');
|
||||
}
|
||||
|
||||
$newFiles = array();
|
||||
$fileSizeWarnings = '';
|
||||
|
@ -18,7 +18,7 @@ TinyMCEImageEnhancement.prototype = {
|
||||
onLoad: function() {
|
||||
this.upload = new Upload({
|
||||
fileUploadLimit : '6',
|
||||
button_image_url : '../cms/images/swf-upload-button-small.jpg',
|
||||
button_image_url : 'cms/images/swf-upload-button-small.jpg',
|
||||
button_width : 59,
|
||||
button_height: 18,
|
||||
fileQueued: this.uploadFileQueuedCallback.bind(this),
|
||||
@ -118,11 +118,9 @@ TinyMCEImageEnhancement.prototype = {
|
||||
}
|
||||
else {
|
||||
this.processInProgress = true;
|
||||
this.upload.setFolderID(this.getParentID());
|
||||
this.upload.addFileParam(file.id,'ID',this.folderID);
|
||||
this.upload.addFileParam(file.id,'action_doUpload','1');
|
||||
this.upload.addFileParam(file.id,'Files',file.name);
|
||||
this.upload.addFileParam(file.id,'MAX_FILE_SIZE','31457280');
|
||||
this.upload.swfu.addPostParam('FolderID', this.getParentID());
|
||||
this.upload.swfu.addFileParam(file.id,'ID',this.folderID);
|
||||
this.upload.swfu.addFileParam(file.id,'Files',file.name);
|
||||
$('UploadFiles').innerHTML = "Uploading Files...("+ this.filesUploaded +")";
|
||||
this.upload.swfu.startUpload(file.id);
|
||||
}
|
||||
@ -133,13 +131,12 @@ TinyMCEImageEnhancement.prototype = {
|
||||
$('UploadFiles').innerHTML = 'Uploading Files..... ('+ this.filesUploaded +")";
|
||||
},
|
||||
|
||||
uploadQueueCompleteCallback: function() {
|
||||
uploadQueueCompleteCallback: function(serverData) {
|
||||
this.filesUploaded = this.upload.getFilesUploaded();
|
||||
$('UploadFiles').innerHTML = "upload";
|
||||
statusMessage('Uploaded ' + this.upload.getFilesUploaded() + ' files','good');
|
||||
if(this.getParentID() != 'root') {
|
||||
$('Image').ajaxGetFiles(this.getParentID(), null, this.insertImages.bind(this));
|
||||
}
|
||||
$('UploadFiles').innerHTML = "";
|
||||
statusMessage('Uploaded Files Successfully','good');
|
||||
|
||||
$('FolderImages').ajaxGetFiles(this.getParentID(), null);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -158,7 +155,6 @@ TinyMCEImageEnhancement.prototype = {
|
||||
$('Image').reapplyBehaviour();
|
||||
|
||||
this.addToTinyMCE = this.addToTinyMCE.bind(this);
|
||||
|
||||
this.processInProgress = false;
|
||||
},
|
||||
|
||||
|
@ -53,7 +53,7 @@ Upload.prototype = {
|
||||
path = this.getBasePath();
|
||||
sessId = this.getSessionId();//Because flash doesn't send proper cookies, we need to set session id in URL.
|
||||
this.swfu = new SWFUpload({
|
||||
upload_url: path + 'admin/assets/UploadForm?SecurityID=' + this.securityID + '&PHPSESSID=' + sessId, // Relative to the SWF file
|
||||
upload_url: path + 'admin/assets/UploadForm?action_doUpload=1&PHPSESSID=' + sessId, // Relative to the SWF file
|
||||
file_post_name: 'Files',
|
||||
file_size_limit : this.fileSizeLimit,
|
||||
file_types : this.fileTypes,
|
||||
@ -71,11 +71,13 @@ Upload.prototype = {
|
||||
file_validation_handler : Prototype.emptyFunction,
|
||||
file_cancelled_handler: Prototype.emptyFunction,
|
||||
button_image_url : this.buttonImageURL,
|
||||
button_window_mode : "transparent",
|
||||
button_width : this.buttonWidth,
|
||||
button_height : this.buttonHeight,
|
||||
flash_url : 'jsparty/SWFUpload/swfupload.swf', // Relative to this file
|
||||
swfupload_loaded_handler: this.buildUI.bind(this),
|
||||
debug: false
|
||||
debug: false,
|
||||
preserve_relative_urls: true
|
||||
});
|
||||
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user