/**
     * init the pl uploader which is directly included in the webpage
     *
     * @return integer the uploader id
     */
    protected function initUploader()
    {
        \JS::activate('cx');
        // the uploader needs the framework
        $cx = \Cx\Core\Core\Controller\Cx::instanciate();
        \Env::get('ClassLoader')->loadFile($cx->getCodeBaseCoreModulePath() . '/Upload/Controller/UploadFactory.class.php');
        /**
         * Name of the upload instance
         */
        $uploaderInstanceName = 'exposed_combo_uploader';
        $uploaderWidgetName = 'uploadWidget';
        /**
         * jQuery selector of the HTML-element where the upload folder-widget shall be put in
         */
        $uploaderFolderWidgetContainer = '#uploadFormField_uploadWidget';
        // create an exposedCombo uploader
        $uploader = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo');
        //set instance name so we are able to catch the instance with js
        $uploader->setJsInstanceName($uploaderInstanceName);
        // specifies the function to call when upload is finished. must be a static function
        $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/FileSharing/Controller/FileSharing.class.php', '\\Cx\\Modules\\FileSharing\\Controller\\FileSharing', 'uploadFinished'));
        //insert the uploader into the HTML-template
        $this->objTemplate->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml(), 'EXTENDED_FILE_INPUT_CODE' => <<<CODE
<script type="text/javascript">
cx.include(
[
'core_modules/Upload/js/uploaders/exposedCombo/extendedFileInput.js'
],
function() {
        var ef = new ExtendedFileInput({
                field: \$J('#file_upload'),
                instance: '{$uploaderInstanceName}',
                widget: '{$uploaderWidgetName}'
        });
}
);
cx.jQuery(document).ready(function(\$) {
    \$J('a.toggle').click(function() {
        \$J('div.toggle').toggle();
        return false;
    });
});
</script>
CODE
));
        // optional: initialize the widget displaying the folder contents
        $uploadId = $uploader->getUploadId();
        $tempPaths = self::getTemporaryFilePaths($uploadId);
        if (!is_dir($tempPaths[0] . '/' . $tempPaths[2])) {
            \Cx\Lib\FileSystem\FileSystem::make_folder($tempPaths[0] . '/' . $tempPaths[2]);
            //mkdir($tempPaths[0] . '/' . $tempPaths[2]);
            \Cx\Lib\FileSystem\FileSystem::makeWritable($tempPaths[0] . '/' . $tempPaths[2]);
            //chmod($tempPaths[0] . '/' . $tempPaths[2], 0777);
        }
        $folderWidget = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newFolderWidget($tempPaths[0] . '/' . $tempPaths[2], $uploaderInstanceName);
        $this->objTemplate->setVariable('UPLOAD_WIDGET_CODE', $folderWidget->getXHtml($uploaderFolderWidgetContainer, 'uploadWidget'));
        // return the upload id
        return $uploadId;
    }
Example #2
0
    /**
     * Inits the uploader when displaying a contact form.
     */
    protected function initUploader($fieldId, $restrictUpload2SingleFile = true)
    {
        try {
            //init the uploader
            \JS::activate('cx');
            //the uploader needs the framework
            $f = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance();
            /**
             * Name of the upload instance
             */
            $uploaderInstanceName = 'exposed_combo_uploader_' . $fieldId;
            /**
             * jQuery selector of the HTML-element where the upload folder-widget shall be put in
             */
            $uploaderFolderWidgetContainer = '#contactFormField_uploadWidget_' . $fieldId;
            $uploaderWidgetName = 'uploadWidget' . $fieldId;
            $uploader = $f->newUploader('exposedCombo', 0, $restrictUpload2SingleFile);
            $uploadId = $uploader->getUploadId();
            //set instance name so we are able to catch the instance with js
            $uploader->setJsInstanceName($uploaderInstanceName);
            // specifies the function to call when upload is finished. must be a static function
            $uploader->setFinishedCallback(array(\Env::get('cx')->getCodeBaseCoreModulePath() . '/Contact/Controller/Contact.class.php', '\\Cx\\Core_Modules\\Contact\\Controller\\Contact', 'uploadFinished'));
            $uploader->setData(array('submissionId' => $this->submissionId, 'fieldId' => $fieldId, 'singlefile' => $restrictUpload2SingleFile));
            //retrieve temporary location for uploaded files
            $tup = self::getTemporaryUploadPath($this->submissionId, $fieldId);
            //create the folder
            if (!\Cx\Lib\FileSystem\FileSystem::make_folder($tup[1] . '/' . $tup[2])) {
                throw new \Cx\Core_Modules\Contact\Controller\ContactException("Could not create temporary upload directory '" . $tup[0] . '/' . $tup[2] . "'");
            }
            if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($tup[1] . '/' . $tup[2])) {
                //some hosters have problems with ftp and file system sync.
                //this is a workaround that seems to somehow show php that
                //the directory was created. clearstatcache() sadly doesn't
                //work in those cases.
                @closedir(@opendir($tup[0]));
                if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($tup[1] . '/' . $tup[2])) {
                    throw new \Cx\Core_Modules\Contact\Controller\ContactException("Could not chmod temporary upload directory '" . $tup[0] . '/' . $tup[2] . "'");
                }
            }
            //initialize the widget displaying the folder contents
            $folderWidget = $f->newFolderWidget($tup[0] . '/' . $tup[2], $uploaderInstanceName);
            $strInputfield = $folderWidget->getXHtml($uploaderFolderWidgetContainer, $uploaderWidgetName);
            $strInputfield .= $uploader->getXHtml();
            \JS::registerJS('core_modules/Upload/js/uploaders/exposedCombo/extendedFileInput.js');
            $strInputfield .= <<<CODE
            <script type="text/javascript">
            cx.ready(function() {
                    var ef = new ExtendedFileInput({
                            field:  cx.jQuery('#contactFormFieldId_{$fieldId}'),
                            instance: '{$uploaderInstanceName}',
                            widget: '{$uploaderWidgetName}'
                    });
            });
            </script>
CODE;
            return $strInputfield;
        } catch (Exception $e) {
            return '<!-- failed initializing uploader, exception ' . get_class($e) . ' with message "' . $e->getMessage() . '" -->';
        }
    }
Example #3
0
 /**
  * Shows the upload-form in the filebrowser
  */
 function _setUploadForm()
 {
     global $_ARRAYLANG, $_CONFIG;
     //data we want to remember for handling the uploaded files
     $data = array();
     if (array_key_exists($this->_mediaType, $this->mediaTypePaths)) {
         $data['path'] = $this->mediaTypePaths[$this->_mediaType][0] . $this->_path;
         $data['webPath'] = $this->mediaTypePaths[$this->_mediaType][1] . $this->_path;
     } else {
         $data['path'] = ASCMS_CONTENT_IMAGE_PATH . $this->_path;
         $data['webPath'] = ASCMS_CONTENT_IMAGE_WEB_PATH . $this->_path;
     }
     $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo');
     $comboUp->setFinishedCallback(array(ASCMS_CORE_MODULE_PATH . '/FileBrowser/Controller/FileBrowser.class.php', '\\Cx\\Core_Modules\\FileBrowser\\Controller\\FileBrowser', 'uploadFinished'));
     $comboUp->setData($data);
     //set instance name to combo_uploader so we are able to catch the instance with js
     $comboUp->setJsInstanceName('exposed_combo_uploader');
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE' => $comboUp->getXHtml(true)));
     //end of uploader button handling
     //check if a finished upload caused reloading of the page.
     //if yes, we know the added files and want to highlight them
     if (!empty($_GET['highlightUploadId'])) {
         $key = 'filebrowser_upload_files_' . intval($_GET['highlightUploadId']);
         if (isset($_SESSION[$key])) {
             $sessionHighlightCandidates = $_SESSION[$key];
             //an array with the filenames, set in FileBrowser::uploadFinished
         }
         //clean up session; we do only highlight once
         unset($_SESSION[$key]);
         if (is_array($sessionHighlightCandidates)) {
             //make sure we don't cause any unexpected behaviour if we lost the session data
             $this->highlightedFiles = $sessionHighlightCandidates;
         }
     }
     $objFWSystem = new \FWSystem();
     // cannot upload or mkdir in webpages view
     if ($this->_mediaType == "webpages") {
         return;
     }
     $this->_objTpl->addBlockfile('FILEBROWSER_UPLOAD', 'fileBrowser_upload', 'module_fileBrowser_upload.html');
     $this->_objTpl->setVariable(array('FILEBROWSER_UPLOAD_TYPE' => $this->_mediaType, 'FILEBROWSER_UPLOAD_PATH' => $this->_path, 'FILEBROWSER_MAX_FILE_SIZE' => $objFWSystem->getMaxUploadFileSize(), 'TXT_CREATE_DIRECTORY' => $_ARRAYLANG['TXT_FILEBROWSER_CREATE_DIRECTORY'], 'TXT_UPLOAD_FILE' => $_ARRAYLANG['TXT_FILEBROWSER_UPLOAD_FILE'], 'JAVASCRIPT' => \JS::getCode()));
     $this->_objTpl->parse('fileBrowser_upload');
 }
Example #4
0
 /**
  * Overview Media Data
  *
  * @global     array     $_CONFIG
  * @global     array     $_ARRAYLANG
  * @return    string    parsed content
  */
 function _overviewMedia()
 {
     global $_CONFIG, $_ARRAYLANG;
     switch ($this->getAct) {
         case 'download':
             $this->_downloadMedia();
             break;
         case 'newDir':
             $this->_createDirectory($_POST['media_directory_name']);
             break;
         case 'upload':
             $this->_uploadFiles();
             break;
         case 'rename':
             $this->_renameFiles();
             break;
         case 'delete':
             $this->_deleteFiles();
             break;
         default:
     }
     // tree navigation
     $tmp = $this->arrWebPaths[$this->archive];
     if (substr($this->webPath, 0, strlen($tmp)) == $tmp) {
         $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => "Home /", 'MEDIA_TREE_NAV_MAIN_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->arrWebPaths[$this->archive])));
         if (strlen($this->webPath) != strlen($tmp)) {
             $tmpPath = substr($this->webPath, -(strlen($this->webPath) - strlen($tmp)));
             $tmpPath = explode('/', $tmpPath);
             $tmpLink = '';
             foreach ($tmpPath as $path) {
                 if (!empty($path)) {
                     $tmpLink .= $path . '/';
                     $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_DIR' => $path, 'MEDIA_TREE_NAV_DIR_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->arrWebPaths[$this->archive] . $tmpLink)));
                     $this->_objTpl->parse('mediaTreeNavigation');
                 }
             }
         }
     }
     if (isset($_GET['deletefolder']) && ($_GET['deletefolder'] = "success")) {
         $this->_strOkMessage = $_ARRAYLANG['TXT_MEDIA_FOLDER_DELETED_SUCESSFULLY'];
     }
     if (!empty($_GET['highlightFiles'])) {
         $this->highlightName = array_merge($this->highlightName, array_map('basename', json_decode(contrexx_stripslashes(urldecode($_GET['highlightFiles'])))));
     }
     // media directory tree
     $i = 0;
     $dirTree = $this->_dirTree($this->path);
     $dirTree = $this->_sortDirTree($dirTree);
     foreach (array_keys($dirTree) as $key) {
         if (is_array($dirTree[$key]['icon'])) {
             for ($x = 0; $x < count($dirTree[$key]['icon']); $x++) {
                 if (MediaLibrary::isIllegalFileName($dirTree[$key]['name'][$x])) {
                     continue;
                 }
                 $class = $i % 2 ? 'row2' : 'row1';
                 // highlight
                 if (in_array($dirTree[$key]['name'][$x], $this->highlightName)) {
                     $class .= '" style="background-color: ' . $this->highlightColor . ';';
                 }
                 if (!$this->manageAccessGranted()) {
                     //if the user is not allowed to delete or rename files -- hide those blocks
                     if ($this->_objTpl->blockExists('manage_access_option')) {
                         $this->_objTpl->hideBlock('manage_access_option');
                     }
                 }
                 $this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $dirTree[$key]['name'][$x], 'MEDIA_FILE_SIZE' => $this->_formatSize($dirTree[$key]['size'][$x]), 'MEDIA_FILE_TYPE' => $this->_formatType($dirTree[$key]['type'][$x]), 'MEDIA_FILE_DATE' => $this->_formatDate($dirTree[$key]['date'][$x]), 'MEDIA_RENAME_TITLE' => $_ARRAYLANG['TXT_MEDIA_RENAME'], 'MEDIA_DELETE_TITLE' => $_ARRAYLANG['TXT_MEDIA_DELETE']));
                 $tmpHref = $delHref = '';
                 if ($key == 'dir') {
                     $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/');
                     $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;act=delete&amp;path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/');
                 } elseif ($key == 'file') {
                     $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;act=delete&amp;path=' . rawurlencode($this->webPath) . '&amp;file=' . rawurlencode($dirTree[$key]['name'][$x]);
                     if ($this->_isImage($this->path . $dirTree[$key]['name'][$x])) {
                         $tmpSize = getimagesize($this->path . $dirTree[$key]['name'][$x]);
                         $tmpHref = 'javascript: preview(\'' . $this->webPath . $dirTree[$key]['name'][$x] . '\', ' . $tmpSize[0] . ', ' . $tmpSize[1] . ');';
                     } else {
                         $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . '&amp;act=download&amp;path=' . rawurlencode($this->webPath) . '&amp;file=' . rawurlencode($dirTree[$key]['name'][$x]);
                     }
                 }
                 $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_HREF' => $tmpHref, 'MEDIA_FILE_DELETE_HREF' => $delHref));
                 $this->_objTpl->parse('mediaDirectoryTree');
                 $i++;
             }
         }
     }
     // empty dir or php safe mode restriction
     if ($i == 0 && !@opendir($this->rootPath)) {
         $tmpMessage = !@opendir($this->path) ? 'PHP Safe Mode Restriction or wrong path' : $_ARRAYLANG['TXT_MEDIA_DIR_EMPTY'];
         $this->_objTpl->setVariable(array('TXT_MEDIA_DIR_EMPTY' => $tmpMessage, 'MEDIA_SELECT_STATUS' => ' disabled'));
         $this->_objTpl->parse('mediaEmptyDirectory');
     }
     // parse variables
     $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->webPath);
     $tmpIcon = $this->_sortingIcons();
     if ($this->_objTpl->blockExists('manage_access_header')) {
         if ($this->manageAccessGranted()) {
             $this->_objTpl->touchBlock('manage_access_header');
         } else {
             $this->_objTpl->hideBlock('manage_access_header');
         }
     }
     $this->_objTpl->setVariable(array('MEDIA_NAME_HREF' => $tmpHref . '&amp;sort=name&amp;sort_desc=' . ($this->sortBy == 'name' && !$this->sortDesc), 'MEDIA_SIZE_HREF' => $tmpHref . '&amp;sort=size&amp;sort_desc=' . ($this->sortBy == 'size' && !$this->sortDesc), 'MEDIA_TYPE_HREF' => $tmpHref . '&amp;sort=type&amp;sort_desc=' . ($this->sortBy == 'type' && !$this->sortDesc), 'MEDIA_DATE_HREF' => $tmpHref . '&amp;sort=date&amp;sort_desc=' . ($this->sortBy == 'date' && !$this->sortDesc), 'MEDIA_PERM_HREF' => $tmpHref . '&amp;sort=perm&amp;sort_desc=' . ($this->sortBy == 'perm' && !$this->sortDesc), 'TXT_MEDIA_FILE_NAME' => $_ARRAYLANG['TXT_MEDIA_FILE_NAME'], 'TXT_MEDIA_FILE_SIZE' => $_ARRAYLANG['TXT_MEDIA_FILE_SIZE'], 'TXT_MEDIA_FILE_TYPE' => $_ARRAYLANG['TXT_MEDIA_FILE_TYPE'], 'TXT_MEDIA_FILE_DATE' => $_ARRAYLANG['TXT_MEDIA_FILE_DATE'], 'TXT_MEDIA_FILE_PERM' => $_ARRAYLANG['TXT_MEDIA_FILE_PERM'], 'MEDIA_NAME_ICON' => $tmpIcon['name'], 'MEDIA_SIZE_ICON' => $tmpIcon['size'], 'MEDIA_TYPE_ICON' => $tmpIcon['type'], 'MEDIA_DATE_ICON' => $tmpIcon['date'], 'MEDIA_PERM_ICON' => $tmpIcon['perm'], 'MEDIA_JAVASCRIPT' => $this->_getJavaScriptCodePreview()));
     if (!$this->uploadAccessGranted()) {
         // if user not allowed to upload files and creating folders -- hide that blocks
         if ($this->_objTpl->blockExists('media_simple_file_upload')) {
             $this->_objTpl->hideBlock('media_simple_file_upload');
         }
         if ($this->_objTpl->blockExists('media_advanced_file_upload')) {
             $this->_objTpl->hideBlock('media_advanced_file_upload');
         }
         if ($this->_objTpl->blockExists('media_create_directory')) {
             $this->_objTpl->hideBlock('media_create_directory');
         }
     } else {
         // forms for uploading files and creating folders
         if ($this->_objTpl->blockExists('media_simple_file_upload')) {
             //data we want to remember for handling the uploaded files
             $data = array('path' => $this->path, 'webPath' => $this->webPath);
             $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo');
             $comboUp->setFinishedCallback(array(ASCMS_CORE_MODULE_PATH . '/Media/Controller/MediaLibrary.class.php', '\\Cx\\Core_modules\\Media\\Controller\\MediaLibrary', 'uploadFinished'));
             $comboUp->setData($data);
             //set instance name to combo_uploader so we are able to catch the instance with js
             $comboUp->setJsInstanceName('exposed_combo_uploader');
             $this->_objTpl->setVariable(array('TXT_MEDIA_ADD_NEW_FILE' => $_ARRAYLANG['TXT_MEDIA_ADD_NEW_FILE'], 'COMBO_UPLOADER_CODE' => $comboUp->getXHtml(true), 'REDIRECT_URL' => '?section=' . $_REQUEST['section'] . '&path=' . contrexx_raw2encodedUrl($this->webPath)));
             $this->_objTpl->parse('media_simple_file_upload');
         }
         if ($this->_objTpl->blockExists('media_advanced_file_upload')) {
             $this->_objTpl->hideBlock('media_advanced_file_upload');
         }
         // create directory
         $this->_objTpl->setVariable(array('TXT_MEDIA_CREATE_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_CREATE_DIRECTORY'], 'TXT_MEDIA_CREATE_NEW_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_CREATE_NEW_DIRECTORY'], 'MEDIA_CREATE_DIRECTORY_URL' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;act=newDir&amp;path=' . $this->webPath));
         $this->_objTpl->parse('media_create_directory');
     }
 }
Example #5
0
 private function parseUploadForm($objCategory)
 {
     global $_CONFIG, $_ARRAYLANG;
     if (!$this->objTemplate->blockExists('downloads_simple_file_upload') && !$this->objTemplate->blockExists('downloads_advanced_file_upload')) {
         return;
     }
     // check for upload permissiosn
     if ($objCategory->getAddFilesAccessId() && !\Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) {
         if ($this->objTemplate->blockExists('downloads_simple_file_upload')) {
             $this->objTemplate->hideBlock('downloads_simple_file_upload');
         }
         if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) {
             $this->objTemplate->hideBlock('downloads_advanced_file_upload');
         }
         return;
     }
     if ($this->objTemplate->blockExists('downloads_simple_file_upload')) {
         $objFWSystem = new \FWSystem();
         //Uploader button handling
         \JS::activate('cx');
         \Env::get('ClassLoader')->loadFile(ASCMS_CORE_MODULE_PATH . '/Upload/Controller/UploadFactory.class.php');
         //paths we want to remember for handling the uploaded files
         $data = array('path' => ASCMS_DOWNLOADS_IMAGES_PATH, 'webPath' => ASCMS_DOWNLOADS_IMAGES_WEB_PATH, 'category_id' => $objCategory->getId());
         $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo');
         $comboUp->setFinishedCallback(array(ASCMS_MODULE_PATH . '/Downloads/Controller/Downloads.class.php', '\\Cx\\Modules\\Downloads\\Controller\\Downloads', 'uploadFinished'));
         $comboUp->setData($data);
         //set instance name to combo_uploader so we are able to catch the instance with js
         $comboUp->setJsInstanceName('exposed_combo_uploader');
         $this->objTemplate->setVariable(array('COMBO_UPLOADER_CODE' => $comboUp->getXHtml(true), 'DOWNLOADS_UPLOAD_REDIRECT_URL' => \Env::get('Resolver')->getURL()->toString(), 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_UPLOAD_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE'], 'TXT_DOWNLOADS_MAX_FILE_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_MAX_FILE_SIZE'], 'TXT_DOWNLOADS_ADD_NEW_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_ADD_NEW_FILE'], 'DOWNLOADS_MAX_FILE_SIZE' => $this->getFormatedFileSize($objFWSystem->getMaxUploadFileSize())));
         $this->objTemplate->parse('downloads_simple_file_upload');
         if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) {
             $this->objTemplate->hideBlock('downloads_advanced_file_upload');
         }
     }
 }
Example #6
0
    protected function getUploaderCode($submissionId, $fieldName, $uploadCallBack = "uploadFinished", $allowImageOnly = true)
    {
        try {
            //init the uploader
            \JS::activate('cx');
            //the uploader needs the framework
            $f = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance();
            //retrieve temporary location for uploaded files
            $tup = self::getTemporaryUploadPath($fieldName, $submissionId);
            //create the folder
            if (!\Cx\Lib\FileSystem\FileSystem::make_folder($tup[1] . '/' . $tup[2])) {
                throw new \Exception("Could not create temporary upload directory '" . $tup[0] . '/' . $tup[2] . "'");
            }
            if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($tup[1] . '/' . $tup[2])) {
                //some hosters have problems with ftp and file system sync.
                //this is a workaround that seems to somehow show php that
                //the directory was created. clearstatcache() sadly doesn't
                //work in those cases.
                @closedir(@opendir($tup[0]));
                if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($tup[1] . '/' . $tup[2])) {
                    throw new \Exception("Could not chmod temporary upload directory '" . $tup[0] . '/' . $tup[2] . "'");
                }
            }
            /**
             * Name of the upload instance
             */
            $uploaderInstanceName = "exposed_combo_uploader_{$fieldName}_{$submissionId}";
            //initialize the widget displaying the folder contents
            $folderWidget = $f->newFolderWidget($tup[0] . '/' . $tup[2]);
            $uploader = $f->newUploader('exposedCombo', $submissionId, true);
            $uploader->setJsInstanceName($uploaderInstanceName);
            $uploader->setFinishedCallback(array(ASCMS_MODULE_PATH . '/Calendar/Controller/Calendar.class.php', '\\Cx\\Modules\\Calendar\\Controller\\Calendar', $uploadCallBack));
            $uploader->setData(array('submission_id' => $submissionId, 'field_name' => $fieldName, 'allowImageOnly' => $allowImageOnly));
            $strJs = $uploader->getXHtml();
            $strJs .= $folderWidget->getXHtml("#{$fieldName}_uploadWidget", "uploadWidget" . $submissionId);
            $strJs .= <<<JAVASCRIPT
<script type="text/javascript">
    cx.ready(function() {
            var ef = new ExtendedFileInput({
                    field:  cx.jQuery('#{$fieldName}'),
                    instance: '{$uploaderInstanceName}',
                    widget: 'uploadWidget{$submissionId}'
            });
    });
</script>
JAVASCRIPT;
            return $strJs;
        } catch (Exception $e) {
            \DBG::msg('<!-- failed initializing uploader -->');
            throw new \Exception("failed initializing uploader");
        }
    }