mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FEATURE: reenabled the ability to upload images from the insert image tab. Still commented out while le a couple of tweaks are made
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@91302 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9c67f3e028
commit
87dfd714b2
BIN
images/swf-upload-button-small.jpg
Normal file
BIN
images/swf-upload-button-small.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -6,15 +6,6 @@
|
|||||||
CMSMain_upload = Class.create();
|
CMSMain_upload = Class.create();
|
||||||
CMSMain_upload.prototype = {
|
CMSMain_upload.prototype = {
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
// This is disabled until we get it working reliably
|
|
||||||
return;
|
|
||||||
|
|
||||||
// We require flash 9
|
|
||||||
pv = getFlashPlayerVersion();
|
|
||||||
if(pv.major < 9) return;
|
|
||||||
|
|
||||||
// Due to a bug in the flash plugin on Linux and Mac, we need at least version 9.0.64 to use SWFUpload
|
|
||||||
if(pv.major == 9 && pv.minor == 0 && pv.rev < 64) return;
|
|
||||||
|
|
||||||
// If those 2 checks pass, we can provide upload capabilities to the user
|
// If those 2 checks pass, we can provide upload capabilities to the user
|
||||||
this.iframe = window.top.document.getElementById('AssetAdmin_upload');
|
this.iframe = window.top.document.getElementById('AssetAdmin_upload');
|
||||||
|
@ -7,21 +7,29 @@ TinyMCEImageEnhancement.prototype = {
|
|||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.filesUploaded = 0;
|
this.filesUploaded = 0;
|
||||||
this.processInProgress = false;
|
this.processInProgress = false;
|
||||||
Event.observe(window,'load',this.onWindowLoad.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
addListeners: function() {
|
|
||||||
$('Form_EditorToolbarImageForm_FolderID').value = "";
|
|
||||||
Event.observe($('AddFolder'),'click',this.onAddFolder.bind(this));
|
Event.observe($('AddFolder'),'click',this.onAddFolder.bind(this));
|
||||||
Event.observe($('FolderOk'),'click',this.onFolderOk.bind(this));
|
Event.observe($('FolderOk'),'click',this.onFolderOk.bind(this));
|
||||||
Event.observe($('FolderCancel'),'click',this.onFolderCancel.bind(this));
|
Event.observe($('FolderCancel'),'click',this.onFolderCancel.bind(this));
|
||||||
Event.observe($('UploadFiles'),'click',this.onUpload.bind(this));
|
|
||||||
|
this.onLoad();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
onLoad: function() {
|
||||||
|
this.upload = new Upload({
|
||||||
|
fileUploadLimit : '6',
|
||||||
|
button_image_url : '../cms/images/swf-upload-button-small.jpg',
|
||||||
|
button_width : 59,
|
||||||
|
button_height: 18,
|
||||||
|
fileQueued: this.uploadFileQueuedCallback.bind(this),
|
||||||
|
fileComplete: this.uploadFileCompleteCallback.bind(this),
|
||||||
|
queueComplete: this.uploadQueueCompleteCallback.bind(this)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
* Method creates HTML element, only reason for this method is DRY.
|
* Method creates HTML element, only reason for this method is DRY.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addElement: function(tag, className, parent, properties) {
|
addElement: function(tag, className, parent, properties) {
|
||||||
var e = document.createElement(tag);
|
var e = document.createElement(tag);
|
||||||
Element.addClassName(e,className);
|
Element.addClassName(e,className);
|
||||||
@ -30,17 +38,6 @@ TinyMCEImageEnhancement.prototype = {
|
|||||||
return e;
|
return e;
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpload: function(event) {
|
|
||||||
Event.stop(event);
|
|
||||||
if(!this.processInProgress) {
|
|
||||||
if(this.getParentID() != 'root') {
|
|
||||||
this.upload.browse();
|
|
||||||
} else {
|
|
||||||
statusMessage("Please choose folder","bad");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when user clicks "add folder" anchor.
|
* Called when user clicks "add folder" anchor.
|
||||||
*/
|
*/
|
||||||
@ -115,51 +112,25 @@ TinyMCEImageEnhancement.prototype = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
uploadFileQueuedCallback: function(file,queueLength) {
|
||||||
* Called on window.onload
|
if(this.getParentID() == "root") {
|
||||||
*/
|
statusMessage("Please choose folder","bad");
|
||||||
|
}
|
||||||
onWindowLoad: function() {
|
else {
|
||||||
// Due to a bug in the flash plugin on Linux and Mac,
|
this.processInProgress = true;
|
||||||
//we need at least version 9.0.64 to use SWFUpload
|
this.upload.setFolderID(this.getParentID());
|
||||||
// see http://open.silverstripe.com/ticket/3023
|
this.upload.addFileParam(file.id,'ID',this.folderID);
|
||||||
pv = getFlashPlayerVersion();
|
this.upload.addFileParam(file.id,'action_doUpload','1');
|
||||||
if(pv.major < 9 || pv.major > 9 || (pv.major == 9 && pv.minor == 0 && pv.rev < 64)) {
|
this.upload.addFileParam(file.id,'Files',file.name);
|
||||||
if($('AddFolderGroup')) $('AddFolderGroup').style.display = 'none';
|
this.upload.addFileParam(file.id,'MAX_FILE_SIZE','31457280');
|
||||||
if($('PipeSeparator')) $('PipeSeparator').style.display = 'none';
|
$('UploadFiles').innerHTML = "Uploading Files...("+ this.filesUploaded +")";
|
||||||
if($('UploadGroup')) $('UploadGroup').style.display = 'none';
|
this.upload.swfu.startUpload(file.id);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($('FolderID') != null) {
|
|
||||||
if($('SecurityID')) var securityid=$('SecurityID').value;
|
|
||||||
else var securityid=null;
|
|
||||||
this.upload = new Upload(
|
|
||||||
{
|
|
||||||
fileTypes : '*.jpeg;*.jpg;*.jpe;*.png;*.gif;',
|
|
||||||
fileTypesDescription : 'Image files',
|
|
||||||
fileUploadLimit : '100',
|
|
||||||
securityID : securityid,
|
|
||||||
beginUploadOnQueue : true,
|
|
||||||
buildUI : this.addListeners.bind(this),
|
|
||||||
fileQueued : this.uploadFileQueuedCallback.bind(this),
|
|
||||||
fileComplete : this.uploadFileCompleteCallback.bind(this),
|
|
||||||
queueComplete : this.uploadQueueCompleteCallback.bind(this)
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadFileQueuedCallback: function(file,queueLength) {
|
|
||||||
this.processInProgress = true;
|
|
||||||
this.upload.setFolderID(this.getParentID());
|
|
||||||
$('UploadFiles').innerHTML = "Uploading ... 1/" + this.upload.getFilesToUpload();
|
|
||||||
this.upload.startUpload();
|
|
||||||
},
|
|
||||||
|
|
||||||
uploadFileCompleteCallback: function(file,serverData) {
|
uploadFileCompleteCallback: function(file,serverData) {
|
||||||
Element.addClassName($('UploadFiles'),'link');//Safari hack
|
this.filesUploaded++;
|
||||||
$('UploadFiles').innerHTML = 'Uploading ... ' + this.upload.getFilesUploaded() + "/" + this.upload.getFilesToUpload();
|
$('UploadFiles').innerHTML = 'Uploading Files..... ('+ this.filesUploaded +")";
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadQueueCompleteCallback: function() {
|
uploadQueueCompleteCallback: function() {
|
||||||
|
@ -14,23 +14,33 @@ Upload.prototype = {
|
|||||||
* @param params object contains all configuration data for upload.
|
* @param params object contains all configuration data for upload.
|
||||||
*/
|
*/
|
||||||
initialize: function(params) {
|
initialize: function(params) {
|
||||||
|
|
||||||
this.filesUploaded = 0;
|
this.filesUploaded = 0;
|
||||||
this.filesToUpload = 0;
|
this.filesToUpload = 0;
|
||||||
this.folderID = 'root';
|
this.folderID = 'root';
|
||||||
this.uploadInProgress = false;
|
this.uploadInProgress = false;
|
||||||
this.uploadMessage = '';
|
this.uploadMessage = '';
|
||||||
|
this.queueComplete = this.uploadQueueCompleteCallback.bind(this);
|
||||||
|
this.fileComplete = this.uploadFileCompleteCallback.bind(this);
|
||||||
|
this.fileQueued = this.uploadFileQueuedCallback;
|
||||||
|
|
||||||
if(typeof params.fileSizeLimit != 'undefined') this.setFileSizeLimit = params.fileSizeLimit; else this.fileSizeLimit = '30720';
|
if(typeof params.fileSizeLimit != 'undefined') this.setFileSizeLimit = params.fileSizeLimit; else this.fileSizeLimit = '30720';
|
||||||
if(typeof params.fileTypes != 'undefined') this.fileTypes = params.fileTypes; else this.fileTypes = '*.*';
|
if(typeof params.fileTypes != 'undefined') this.fileTypes = params.fileTypes; else this.fileTypes = '*.*';
|
||||||
if(typeof params.fileTypesDescription != 'undefined') this.fileTypesDescription = params.fileTypesDescription; else this.fileTypesDescription = 'All Files';
|
if(typeof params.fileTypesDescription != 'undefined') this.fileTypesDescription = params.fileTypesDescription; else this.fileTypesDescription = 'All Files';
|
||||||
if(typeof params.fileUploadLimit != 'undefined') this.fileUploadLimit = params.fileUploadLimit; else this.fileUploadLimit = '6';
|
if(typeof params.fileUploadLimit != 'undefined') this.fileUploadLimit = params.fileUploadLimit; else this.fileUploadLimit = '6';
|
||||||
if(typeof params.beginUploadOnQueue != 'undefined') this.beginUploadOnQueue = params.beginUploadOnQueue; else this.beginUploadOnQueue = false;
|
if(typeof params.beginUploadOnQueue != 'undefined') this.beginUploadOnQueue = params.beginUploadOnQueue; else this.beginUploadOnQueue = true;
|
||||||
if(typeof params.fileQueued != 'undefined') this.fileQueued = params.fileQueued;
|
if(typeof params.fileQueued != 'undefined') this.fileQueued = params.fileQueued;
|
||||||
|
|
||||||
if(typeof params.fileProgress != 'undefined') this.fileProgress = params.fileProgress; else this.fileProgress = Prototype.emptyFunction;
|
if(typeof params.fileProgress != 'undefined') this.fileProgress = params.fileProgress; else this.fileProgress = Prototype.emptyFunction;
|
||||||
if(typeof params.fileCancelled != 'undefined') this.fileCancelled = params.fileCancelled;
|
if(typeof params.fileCancelled != 'undefined') this.fileCancelled = params.fileCancelled;
|
||||||
if(typeof params.fileComplete != 'undefined') this.fileComplete = params.fileComplete ;
|
if(typeof params.fileComplete != 'undefined') this.fileComplete = params.fileComplete;
|
||||||
if(typeof params.queueComplete != 'undefined') this.queueComplete = params.queueComplete;
|
if(typeof params.queueComplete != 'undefined') this.queueComplete = params.queueComplete;
|
||||||
if(typeof params.buildUI != 'undefined') this.customBuildUI = params.buildUI;
|
if(typeof params.buildUI != 'undefined') this.customBuildUI = params.buildUI;
|
||||||
if(typeof params.securityID != 'undefined') this.securityID = params.securityID;
|
if(typeof params.securityID != 'undefined') this.securityID = params.securityID;
|
||||||
|
if(typeof params.button_image_url != 'undefined') this.buttonImageURL = params.button_image_url;
|
||||||
|
if(typeof params.button_width != 'undefined') this.buttonWidth = params.button_width;
|
||||||
|
if(typeof params.button_height != 'undefined') this.buttonHeight = params.button_height;
|
||||||
|
|
||||||
this.onLoad();
|
this.onLoad();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -39,6 +49,7 @@ Upload.prototype = {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
|
|
||||||
path = this.getBasePath();
|
path = this.getBasePath();
|
||||||
sessId = this.getSessionId();//Because flash doesn't send proper cookies, we need to set session id in URL.
|
sessId = this.getSessionId();//Because flash doesn't send proper cookies, we need to set session id in URL.
|
||||||
this.swfu = new SWFUpload({
|
this.swfu = new SWFUpload({
|
||||||
@ -51,19 +62,23 @@ Upload.prototype = {
|
|||||||
begin_upload_on_queue : this.beginUploadOnQueue,
|
begin_upload_on_queue : this.beginUploadOnQueue,
|
||||||
use_server_data_event : true,
|
use_server_data_event : true,
|
||||||
validate_files: false,
|
validate_files: false,
|
||||||
|
button_placeholder_id: "SWFUploadButton",
|
||||||
file_queued_handler : this.uploadFileQueuedCallback.bind(this),
|
file_queued_handler : this.fileQueued,
|
||||||
upload_success_handler : this.uploadFileCompleteCallback.bind(this),
|
upload_success_handler : this.queueComplete,
|
||||||
|
file_dialog_complete_handler : this.fileCompleted,
|
||||||
upload_progress_handler: this.uploadFileProgressCallback.bind(this),
|
upload_progress_handler: this.uploadFileProgressCallback.bind(this),
|
||||||
error_handler : this.uploadErrorCallback.bind(this),
|
error_handler : this.uploadErrorCallback.bind(this),
|
||||||
file_validation_handler : Prototype.emptyFunction,
|
file_validation_handler : Prototype.emptyFunction,
|
||||||
file_cancelled_handler: Prototype.emptyFunction,
|
file_cancelled_handler: Prototype.emptyFunction,
|
||||||
|
button_image_url : this.buttonImageURL,
|
||||||
flash_url : 'jsparty/SWFUpload/swfupload_f9.swf', // Relative to this file
|
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),
|
swfupload_loaded_handler: this.buildUI.bind(this),
|
||||||
debug: false
|
debug: false
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves base path from URL.
|
* Retrieves base path from URL.
|
||||||
@ -95,7 +110,7 @@ Upload.prototype = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
buildUI: function() {
|
buildUI: function() {
|
||||||
this.customBuildUI();
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +122,7 @@ Upload.prototype = {
|
|||||||
|
|
||||||
uploadFileQueuedCallback: function(file,queueLength) {
|
uploadFileQueuedCallback: function(file,queueLength) {
|
||||||
this.filesToUpload++;
|
this.filesToUpload++;
|
||||||
this.fileQueued(file, queueLength);
|
// this.swfu.fileQueued(file, queueLength);
|
||||||
this.addFileParam(file);
|
this.addFileParam(file);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -151,6 +166,10 @@ Upload.prototype = {
|
|||||||
this.fileProgress(file, bytes_complete);
|
this.fileProgress(file, bytes_complete);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
uploadQueueCompleteCallback: function(event) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on error.
|
* Called on error.
|
||||||
* @param error_code int
|
* @param error_code int
|
||||||
|
Loading…
Reference in New Issue
Block a user