From 0269aa224dc88a7bccb305ab14af1675e705c093 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Sun, 11 Nov 2007 22:30:01 +0000 Subject: [PATCH] #1606 - Check add folder & upload-functionality in tinymce git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@44594 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/CMSMain_upload.js | 5 ++-- javascript/TinyMCEImageEnhancement.js | 35 ++++++++------------------- javascript/Upload.js | 7 +++--- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/javascript/CMSMain_upload.js b/javascript/CMSMain_upload.js index 05622e5a..7f22dc05 100644 --- a/javascript/CMSMain_upload.js +++ b/javascript/CMSMain_upload.js @@ -12,7 +12,8 @@ CMSMain_upload.prototype = { onLoad: function() { this.upload = new Upload({ - fileUploadLimit : '6', + fileUploadLimit : '6', + securityID : $('SecurityID').value, beginUploadOnQueue : false, fileQueued : this.uploadFileQueuedCallback.bind(this), fileProgress : this.uploadProgressCallback.bind(this), @@ -170,4 +171,4 @@ CMSMain_upload.prototype = { eval(this.upload.getUploadMessage().replace('1',this.upload.getFilesUploaded())); } } -window.top.document.CMSMain_upload = CMSMain_upload; \ No newline at end of file +window.top.document.CMSMain_upload = CMSMain_upload; diff --git a/javascript/TinyMCEImageEnhancement.js b/javascript/TinyMCEImageEnhancement.js index bc7dd7f9..4b9a9ea9 100644 --- a/javascript/TinyMCEImageEnhancement.js +++ b/javascript/TinyMCEImageEnhancement.js @@ -10,28 +10,12 @@ TinyMCEImageEnhancement.prototype = { Event.observe(window,'load',this.onWindowLoad.bind(this)); }, - buildUI: function() { - $('Form_EditorToolbarImageForm_FolderID').value = ""; - - divAddFolder = this.addElement('div','group',$('FolderID'),{'id': 'AddFolderGroup'}); - addFolder = this.addElement('a','link',divAddFolder,{'id': 'AddFolder','href' : '#','innerHTML': 'add folder'}); - newFolderName = this.addElement('input', 'addFolder',divAddFolder,{'id': 'NewFolderName','type' : 'text'}); - Element.hide(newFolderName); - var folderOk = this.addElement('a','link',divAddFolder,{'id': 'FolderOk','href' : '#','innerHTML': 'ok'}); - Element.hide(folderOk); - Element.addClassName(folderOk,'addFolder'); - var folderCancel = this.addElement('a','link',divAddFolder,{'id': 'FolderCancel','href' : '#','innerHTML': 'cancel'}); - Element.hide(folderCancel); - Element.addClassName(folderCancel,'addFolder'); - - var divUpload = this.addElement('div','group',$('FolderID'),{'id': 'UploadrGroup'}); - var pipeSeparator = this.addElement('div','',divUpload,{'id' : 'PipeSeparator','innerHTML' : ' | '}); - pipeSeparator.style.display = "inline"; - var uploadFiles = this.addElement('a','link',divUpload,{'id' : 'UploadFiles','href' : '#','innerHTML' : 'upload'}); - - Event.observe(addFolder,'click',this.onAddFolder.bind(this)); - Event.observe(folderOk,'click',this.onFolderOk.bind(this)); - Event.observe(folderCancel,'click',this.onFolderCancel.bind(this)); + addListeners: function() { + $('Form_EditorToolbarImageForm_FolderID').value = ""; + + Event.observe($('AddFolder'),'click',this.onAddFolder.bind(this)); + Event.observe($('FolderOk'),'click',this.onFolderOk.bind(this)); + Event.observe($('FolderCancel'),'click',this.onFolderCancel.bind(this)); Event.observe($('UploadFiles'),'click',this.onUpload.bind(this)); }, @@ -152,9 +136,10 @@ TinyMCEImageEnhancement.prototype = { { fileTypes : '*.jpeg;*.jpg;*.jpe;*.png;*.gif;', fileTypesDescription : 'Image files', - fileUploadLimit : '100', + fileUploadLimit : '100', + securityID : $('SecurityID').value, beginUploadOnQueue : true, - buildUI : this.buildUI.bind(this), + buildUI : this.addListeners.bind(this), fileQueued : this.uploadFileQueuedCallback.bind(this), fileComplete : this.uploadFileCompleteCallback.bind(this), queueComplete : this.uploadQueueCompleteCallback.bind(this) @@ -266,4 +251,4 @@ TinyMCEImageEnhancement.prototype = { return $('Form_EditorToolbarImageForm_FolderID').value == '' ? 'root' : $('Form_EditorToolbarImageForm_FolderID').value; } } -tinyMCEImageEnhancement = new TinyMCEImageEnhancement(); \ No newline at end of file +tinyMCEImageEnhancement = new TinyMCEImageEnhancement(); diff --git a/javascript/Upload.js b/javascript/Upload.js index cccfdd51..d6698847 100644 --- a/javascript/Upload.js +++ b/javascript/Upload.js @@ -29,7 +29,8 @@ Upload.prototype = { if(typeof params.fileCancelled != 'undefined') this.fileCancelled = params.fileCancelled; if(typeof params.fileComplete != 'undefined') this.fileComplete = params.fileComplete ; 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; this.onLoad(); }, @@ -41,7 +42,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_target_url: path + '/assets/index/root?executeForm=UploadForm&PHPSESSID=' + sessId, // Relative to the SWF file + upload_target_url: path + '/assets/index/root?executeForm=UploadForm&SecurityID=' + this.securityID + '&PHPSESSID=' + sessId, // Relative to the SWF file file_post_name: 'Files', file_size_limit : this.fileSizeLimit, file_types : this.fileTypes, @@ -251,4 +252,4 @@ Upload.prototype = { isUploadInProgress: function() { return this.uploadInProgress; } -} \ No newline at end of file +}