Index: ext_localconf.php =================================================================== --- ext_localconf.php (revision 26012) +++ ext_localconf.php (working copy) @@ -114,6 +114,6 @@ '.$pluginContent); unset($pluginContent); +$TYPO3_CONF_VARS['BE']['AJAX']['TYPO3_tcefile::process'] = PATH_txdam.'lib/class.tx_dam_tce_file.php:tx_dam_tce_file->processAjaxRequest'; - ?> Index: lib/class.tx_dam_tce_file.php =================================================================== --- lib/class.tx_dam_tce_file.php (revision 26012) +++ lib/class.tx_dam_tce_file.php (working copy) @@ -226,6 +226,32 @@ function getLastError($getFullErrorLogEntry=FALSE) { return $this->fileProcessor->getLastError($getFullErrorLogEntry); } + + /** + * Handles the actual process from within the ajaxExec function + * therefore, it does exactly the same as the real typo3/tce_file.php + * but without calling the "finish" method, thus makes it simpler to deal with the + * actual return value + * + * + * @param string $params always empty. + * @param string $ajaxObj The Ajax object used to return content and set content types + * @return void + */ + public function processAjaxRequest(array $params, TYPO3AJAX $ajaxObj) { + $this->init(); + $this->process(); + $errors = $this->fileProcessor->getErrorMessages(); + if (count($errors)) { + $ajaxObj->setError(implode(',', $errors)); + } else { + $ajaxObj->addContent('result', $this->fileData); + if ($this->redirect) { + $ajaxObj->addContent('redirect', $this->redirect); + } + $ajaxObj->setContentFormat('json'); + } + } } Index: mod_file/index.php =================================================================== --- mod_file/index.php (revision 26012) +++ mod_file/index.php (working copy) @@ -134,6 +134,11 @@ $this->addDocStyles(); $this->addDocJavaScript(); + + // include the initialization for the flash uploader + if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) { + $this->addFlashUploader(); + } $this->extObjHeader(); @@ -205,8 +210,68 @@ $this->content.= $this->doc->spacer(10); } } + + function addFlashUploader() { + $this->doc->JScodeArray['flashUploader'] = ' + if (top.TYPO3.FileUploadWindow.isFlashAvailable()) { + 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: "' . t3lib_div::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]": "' . tx_dam::path_makeAbsolute($this->path) . '", + "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: \'\' + }); + 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(); + }; + }); + } + '; + } + + /** * Prints out the module HTML * Index: modfunc_file_list/class.tx_dam_file_list.php =================================================================== --- modfunc_file_list/class.tx_dam_file_list.php (revision 26012) +++ modfunc_file_list/class.tx_dam_file_list.php (working copy) @@ -393,7 +393,11 @@ $actionCall->initActions(); $actions = $actionCall->renderActionsHorizontal(); $this->pObj->markers['FOLDER'] = $actions[0]; - $this->pObj->markers['UPLOAD'] = 'pObj->doc->backPath, 'gfx/upload.gif') . ' title="'.$GLOBALS['LANG']->sL('LLL:EXT:dam/modfunc_file_upload/locallang.xml:tx_dam_file_upload.title',1).'" alt="" height="16" width="16">'; + if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) { + $this->pObj->markers['UPLOAD'] = 'pObj->doc->backPath, 'gfx/upload.gif') . ' title="'.$GLOBALS['LANG']->sL('LLL:EXT:dam/modfunc_file_upload/locallang.xml:tx_dam_file_upload.title',1).'" alt="" height="16" width="16">'; + } else { + $this->pObj->markers['UPLOAD'] = 'pObj->doc->backPath, 'gfx/upload.gif') . ' title="'.$GLOBALS['LANG']->sL('LLL:EXT:dam/modfunc_file_upload/locallang.xml:tx_dam_file_upload.title',1).'" alt="" height="16" width="16">'; + } $this->pObj->markers['NEW'] = $actions[1]; } return $content;