[BUGFIX] Flash uploader doesn't work in Filelist clickmenus 11/19211/2
authorLorenz Ulrich <lorenz.ulrich@visol.ch>
Tue, 26 Feb 2013 13:27:08 +0000 (14:27 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 12 Apr 2013 20:10:20 +0000 (22:10 +0200)
The Flash uploader only works in the click menu of the folder tree in
the Filelist module. It doesn't work in
- the click menu of a folder in the "right frame"
- the click menu in a folder (in the right top)
This is because the Flash uploader JS is only observing a click event
to a button but cannot be called directly.

Change-Id: I6da96f76a12d305e198b2db53c6009b6c9c1d13b
Resolves: #21288
Releases: 6.0, 4.7, 4.5
Reviewed-on: https://review.typo3.org/19211
Reviewed-by: Henrik Ziegenhain
Tested-by: Henrik Ziegenhain
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/filelist/Classes/Controller/FileListController.php

index 28784a9..532a9d3 100644 (file)
@@ -175,58 +175,67 @@ class FileListController {
                        if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) {
                                $this->doc->JScodeArray['flashUploader'] = '
                                        if (top.TYPO3.FileUploadWindow.isFlashAvailable()) {
+
+                                               function initFlashUploader(event) {
+
+                                                       var target;
+                                                       if (typeof(event)=="string") {
+                                                               target = decodeURIComponent(event);
+                                                       } else {
+                                                               target = "' . ($this->folderObject ? $this->folderObject->getCombinedIdentifier() : '') . '";
+                                                       }
+
+                                                               // set the page specific options for the flashUploader
+                                                       var flashUploadOptions = {
+                                                               uploadURL:           top.TS.PATH_typo3 + "ajax.php",
+                                                               uploadFileSizeLimit: "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getMaxUploadFileSize() . '",
+                                                               uploadFileTypes: {
+                                                                       allow:  "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
+                                                                       deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
+                                                               },
+                                                               uploadFilePostName:  "upload_1",
+                                                               uploadPostParams: {
+                                                                       "file[upload][1][target]": target,
+                                                                       "file[upload][1][data]": 1,
+                                                                       "file[upload][1][charset]": "utf-8",
+                                                                       "ajaxID": "TYPO3_tcefile::process"
+                                                               }
+                                                       };
+
+                                                               // get the flashUploaderWindow instance from the parent frame
+                                                       var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
+                                                       // add an additional function inside the container to show the checkbox option
+                                                       var infoComponent = new top.Ext.Panel({
+                                                               autoEl: { tag: "div" },
+                                                               height: "auto",
+                                                               bodyBorder: false,
+                                                               border: false,
+                                                               hideBorders: true,
+                                                               cls: "t3-upload-window-infopanel",
+                                                               id: "t3-upload-window-infopanel-addition",
+                                                               html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
+                                                       });
+                                                       flashUploader.add(infoComponent);
+
+                                                               // do a reload of this frame once all uploads are done
+                                                       flashUploader.on("totalcomplete", function() {
+                                                               window.location.reload();
+                                                       });
+
+                                                               // this is the callback function that delivers the additional post parameter to the flash application
+                                                       top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
+                                                               var uploader = top.TYPO3.getInstance("FileUploadWindow");
+                                                               if (uploader.isVisible()) {
+                                                                       uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
+                                                               }
+                                                       };
+
+                                                       event.stop();
+                                               };
+
                                                document.observe("dom:loaded", function() {
                                                                // monitor the button
                                                        $("button-upload").observe("click", initFlashUploader);
-
-                                                       function initFlashUploader(event) {
-                                                                       // set the page specific options for the flashUploader
-                                                               var flashUploadOptions = {
-                                                                       uploadURL:           top.TS.PATH_typo3 + "ajax.php",
-                                                                       uploadFileSizeLimit: "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getMaxUploadFileSize() . '",
-                                                                       uploadFileTypes: {
-                                                                               allow:  "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
-                                                                               deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
-                                                                       },
-                                                                       uploadFilePostName:  "upload_1",
-                                                                       uploadPostParams: {
-                                                                               "file[upload][1][target]": "' . ($this->folderObject ? $this->folderObject->getCombinedIdentifier() : '') . '",
-                                                                               "file[upload][1][data]": 1,
-                                                                               "file[upload][1][charset]": "utf-8",
-                                                                               "ajaxID": "TYPO3_tcefile::process"
-                                                                       }
-                                                               };
-
-                                                                       // get the flashUploaderWindow instance from the parent frame
-                                                               var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
-                                                               // add an additional function inside the container to show the checkbox option
-                                                               var infoComponent = new top.Ext.Panel({
-                                                                       autoEl: { tag: "div" },
-                                                                       height: "auto",
-                                                                       bodyBorder: false,
-                                                                       border: false,
-                                                                       hideBorders: true,
-                                                                       cls: "t3-upload-window-infopanel",
-                                                                       id: "t3-upload-window-infopanel-addition",
-                                                                       html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
-                                                               });
-                                                               flashUploader.add(infoComponent);
-
-                                                                       // do a reload of this frame once all uploads are done
-                                                               flashUploader.on("totalcomplete", function() {
-                                                                       window.location.reload();
-                                                               });
-
-                                                                       // this is the callback function that delivers the additional post parameter to the flash application
-                                                               top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
-                                                                       var uploader = top.TYPO3.getInstance("FileUploadWindow");
-                                                                       if (uploader.isVisible()) {
-                                                                               uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
-                                                                       }
-                                                               };
-
-                                                               event.stop();
-                                                       };
                                                });
                                        }
                                ';