BUGFIX Disabled inline "create folder" and "upload" for anything but Flash Player 9 - versions below have general compatibily issues, versions above (Flash Player 10) have new security restrictions around file dialogues which require an SWFUpload upgrade (see #3023)

ENHANCEMENT Allowing setting of foldername in AssetAdmin->addfolder() to simplify the inline "create folder" logic (doesn't need to send of a fake ajax form-save from CMS into /admin/assets just to save the folder name) (see #3412)
ENHANCEMENT Removed BrowserDetect javascript library which was randomly placed in Security_login.js and just included in AssetAdmin. Reverted to regex-matching for simple browser detection for now
BUGFIX Fixed "cancel" button for inline "create folder" functionality (was not stopping event in IE7)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@70775 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-01-27 01:24:45 +00:00 committed by Sam Minnee
parent aba473608b
commit b423bbe5e0
3 changed files with 16 additions and 40 deletions

View File

@ -80,7 +80,6 @@ class AssetAdmin extends LeftAndMain {
Requirements::javascript(CMS_DIR . "/javascript/CMSMain_upload.js");
Requirements::javascript(CMS_DIR . "/javascript/Upload.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/Security_login.js");
Requirements::javascript(THIRDPARTY_DIR . "/SWFUpload/SWFUpload.js");
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
@ -477,7 +476,8 @@ JS;
* Add a new folder and return its details suitable for ajax.
*/
public function addfolder() {
$parent = ($_REQUEST['ParentID'] && is_numeric($_REQUEST['ParentID'])) ? $_REQUEST['ParentID'] : 0;
$parent = ($_REQUEST['ParentID'] && is_numeric($_REQUEST['ParentID'])) ? (int)$_REQUEST['ParentID'] : 0;
$name = (isset($_REQUEST['Name'])) ? basename($_REQUEST['Name']) : _t('AssetAdmin.NEWFOLDER',"NewFolder");
if($parent) {
$parentObj = DataObject::get_by_id('File', $parent);
@ -486,8 +486,8 @@ JS;
$p = new Folder();
$p->ParentID = $parent;
$p->Title = _t('AssetAdmin.NEWFOLDER',"NewFolder");
$p->Name = _t('AssetAdmin.NEWFOLDER', 'NewFolder');
$p->Title = $name;
$p->Name = $name;
// Get the folder to be created
if(isset($parentObj->ID)) $filename = $parentObj->FullPath . $p->Name;

View File

@ -111,17 +111,7 @@ CMSMain_upload.prototype = {
fileProgress.style.left = '5px';
fileProgress.style.width = '0px';
fileProgress.finished = false;
switch(BrowserDetect.browser) {
case 'Explorer':
fileProgress.style.top = parseInt(fileProgress.style.top) + 6 + 'px';
break;
case 'Safari':
fileProgress.style.top = parseInt(fileProgress.style.top) + 4 + 'px';
break;
case 'Firefox':
fileProgress.style.top = parseInt(fileProgress.style.top) + 8 + 'px';
break;
}
fileProgress.style.top = parseInt(fileProgress.style.top) + 6 + 'px';
fileProgress.style.height = Element.getDimensions(fileName).height + 1 + 'px';
fileToUpload.appendChild(fileProgress);

View File

@ -12,7 +12,6 @@ TinyMCEImageEnhancement.prototype = {
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));
@ -63,7 +62,7 @@ TinyMCEImageEnhancement.prototype = {
var folderName = $('NewFolderName').value;
var options = {
method: 'post',
postBody: 'ParentID=' + this.getParentID() + '&ajax=1&returnID=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
postBody: 'ParentID=' + this.getParentID() + '&ajax=1&returnID=1&Name=' + folderName + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
onSuccess: this.onFolderGetSuccess.bind(this),
onFailure: function(transport) {
errorMessage('Error: Folder not added', transport);
@ -94,30 +93,13 @@ TinyMCEImageEnhancement.prototype = {
this.folderID = folderID;
var options = {
method: 'post',
postBody: 'Created=' + currentDate + '&Name=' + folderName + '&ClassName=Folder&ID=' + folderID + '&ajax=1&action_save=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
onSuccess: this.onFolderAddSuccess.bind(this),
onFailure: function(transport) {
errorMessage('Error: Folder not added', transport);
}
};
new Ajax.Request('admin/assets/EditForm', options);
},
/**
* When folder name has been changed we need to refresh folder list and return to initial state of UI.
*/
onFolderAddSuccess: function(transport) {
statusMessage('Creating new folder');
statusMessage('Creating new folder');
$('TreeDropdownField_Form_EditorToolbarImageForm_FolderID').itemTree = null;
$('TreeDropdownField_Form_EditorToolbarImageForm_FolderID').setValue(this.folderID);
$('NewFolderName').value = '';
Element.show('AddFolder');
Element.hide('NewFolderName','FolderOk','FolderCancel');
this.removeIE6Hack();
this.removeIE6Hack();
},
/**
@ -129,6 +111,8 @@ TinyMCEImageEnhancement.prototype = {
Element.show('AddFolder');
Element.hide('NewFolderName','FolderOk','FolderCancel');
this.removeIE6Hack();
Event.stop(event);
return false;
},
/**
@ -136,10 +120,12 @@ TinyMCEImageEnhancement.prototype = {
*/
onWindowLoad: function() {
// Due to a bug in the flash plugin on Linux and Mac, we need at least version 9.0.64 to use SWFUpload
// Due to a bug in the flash plugin on Linux and Mac,
//we need at least version 9.0.64 to use SWFUpload
// see http://open.silverstripe.com/ticket/3023
if(navigator.appVersion.indexOf("Mac") != -1 || navigator.appVersion.indexOf("X11") != -1 || navigator.appVersion.indexOf("Linux") != -1) {
pv = getFlashPlayerVersion();
if(pv.major < 9 || (pv.major == 9 && pv.minor == 0 && pv.rev < 64)) {
if(pv.major < 9 || pv.major > 9 || (pv.major == 9 && pv.minor == 0 && pv.rev < 64)) {
if($('AddFolderGroup')) $('AddFolderGroup').style.display = 'none';
if($('PipeSeparator')) $('PipeSeparator').style.display = 'none';
if($('UploadGroup')) $('UploadGroup').style.display = 'none';
@ -240,7 +226,7 @@ TinyMCEImageEnhancement.prototype = {
*/
applyIE6Hack: function() {
if(BrowserDetect.browser == 'Explorer') {
if(/msie/i.test(navigator.userAgent)) {
elements = [$('FolderOk'),$('FolderCancel'),$('UploadFiles')];
$A(elements).each(function(element) {
element.style.position = "relative";
@ -250,7 +236,7 @@ TinyMCEImageEnhancement.prototype = {
},
removeIE6Hack: function() {
if(BrowserDetect.browser == 'Explorer') {
if(/msie/i.test(navigator.userAgent)) {
elements = [$('FolderOk'),$('FolderCancel'),$('UploadFiles')];
$A(elements).each(function(element) {
element.style.position = "";