/** * @override */ public function getXHtml($backend = false) { global $objInit; $uploadPath = $this->getUploadPath('jump'); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('jump.html'); $basePath = 'index.php?'; $basePath .= $this->isBackendRequest ? 'cmd=Upload&act' : 'section=Upload&cmd'; //act and cmd vary $appletPath = $basePath . '=jumpUploaderApplet'; $l10nPath = $basePath . '=jumpUploaderL10n'; $langId; if (!$this->isBackendRequest) { $langId = $objInit->getFrontendLangId(); } else { //backend $langId = $objInit->getBackendLangId(); } $langCode = \FWLanguage::getLanguageCodeById($langId); if (!file_exists(ASCMS_CORE_MODULE_PATH . '/Upload/ressources/uploaders/jump/messages_' . $langCode . '.zip')) { $langCode = 'en'; } $l10nPath .= '&lang=' . $langCode; $tpl->setVariable('UPLOAD_CHUNK_LENGTH', \FWSystem::getMaxUploadFileSize() - 1000); $tpl->setVariable('UPLOAD_APPLET_URL', $appletPath); $tpl->setVariable('UPLOAD_LANG_URL', $l10nPath); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('UPLOAD_ID', $this->uploadId); return $tpl->get(); }
/** * @override */ public function getXHtml() { global $_CORELANG; // CSS dependencies \JS::activate('cx'); $uploadPath = $this->getUploadPath('pl'); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('pl.html'); $tpl->setVariable('UPLOAD_FLASH_URL', ASCMS_CORE_MODULE_WEB_PATH . '/Upload/ressources/uploaders/pl/plupload.flash.swf'); $tpl->setVariable('UPLOAD_CHUNK_LENGTH', \FWSystem::getLiteralSizeFormat(\FWSystem::getMaxUploadFileSize() - 1000)); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('UPLOAD_ID', $this->uploadId); //I18N $tpl->setVariable(array('UPLOAD' => $_CORELANG['UPLOAD'], 'OTHER_UPLOADERS' => $_CORELANG['OTHER_UPLOADERS'], 'FORM_UPLOADER' => $_CORELANG['FORM_UPLOADER'], 'PL_UPLOADER' => $_CORELANG['PL_UPLOADER'], 'JUMP_UPLOADER' => $_CORELANG['JUMP_UPLOADER'], 'SELECT_FILES' => $_CORELANG['SELECT_FILES'], 'ADD_INSTRUCTIONS' => $_CORELANG['ADD_INSTRUCTIONS'], 'FILENAME' => $_CORELANG['FILENAME'], 'STATUS' => $_CORELANG['STATUS'], 'SIZE' => $_CORELANG['SIZE'], 'ADD_FILES' => $_CORELANG['ADD_FILES'], 'STOP_CURRENT_UPLOAD' => $_CORELANG['STOP_CURRENT_UPLOAD'], 'DRAG_FILES_HERE' => $_CORELANG['DRAG_FILES_HERE'])); return $tpl->get(); }
public function preFinalize(\Cx\Core\Html\Sigma $template) { if (count($this->uploaderInstances) == 0) { return; } global $_ARRAYLANG; \Env::get('init')->loadLanguageData('Uploader'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/UPLOADER(_[A-Za-z0-9]+)?/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $appendix = ""; foreach ($this->uploaderInstances as $uploader) { if ($uploader->getType() == Uploader::UPLOADER_TYPE_MODAL) { $appendix .= $uploader->getContainer(); } } $template->_blocks["__global__"] = preg_replace("/<\\/body>/", $appendix . '</body>', $template->_blocks["__global__"]); \ContrexxJavascript::getInstance()->setVariable('chunk_size', min(floor((\FWSystem::getMaxUploadFileSize() - 1000000) / 1000000), 20) . 'mb', 'uploader'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/Uploader/View/Script/Uploader.js'); }
/** * Upload submitted files * * Move all files that are allowed to be uploaded in the folder that * has been specified in the configuration option "File upload deposition path" * @access private * @global array * @param array Files that have been submited * @see getSettings(), _cleanFileName(), errorMsg, FWSystem::getMaxUploadFileSize() * @return array A list of files that have been stored successfully in the system */ function _uploadFilesLegacy($arrFields) { global $_ARRAYLANG; $arrSettings = $this->getSettings(); $arrFiles = array(); if (isset($_FILES) && is_array($_FILES)) { foreach (array_keys($_FILES) as $file) { $fileName = !empty($_FILES[$file]['name']) ? $this->_cleanFileName($_FILES[$file]['name']) : ''; $fileTmpName = !empty($_FILES[$file]['tmp_name']) ? $_FILES[$file]['tmp_name'] : ''; switch ($_FILES[$file]['error']) { case UPLOAD_ERR_INI_SIZE: //Die hochgeladene Datei überschreitet die in der Anweisung upload_max_filesize in php.ini festgelegte Grösse. $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_SIZE_EXCEEDS_LIMIT'], $fileName, \FWSystem::getMaxUploadFileSize()) . '<br />'; break; case UPLOAD_ERR_FORM_SIZE: //Die hochgeladene Datei überschreitet die in dem HTML Formular mittels der Anweisung MAX_FILE_SIZE angegebene maximale Dateigrösse. $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_TOO_LARGE'], $fileName) . '<br />'; break; case UPLOAD_ERR_PARTIAL: //Die Datei wurde nur teilweise hochgeladen. $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_CORRUPT'], $fileName) . '<br />'; break; case UPLOAD_ERR_NO_FILE: //Es wurde keine Datei hochgeladen. continue; break; default: if (!empty($fileTmpName)) { $arrFile = pathinfo($fileName); $i = ''; $suffix = ''; $documentRootPath = \Env::get('cx')->getWebsiteDocumentRootPath(); $filePath = $arrSettings['fileUploadDepositionPath'] . '/' . $arrFile['filename'] . $suffix . '.' . $arrFile['extension']; while (file_exists($documentRootPath . $filePath)) { $suffix = '-' . ++$i; $filePath = $arrSettings['fileUploadDepositionPath'] . '/' . $arrFile['filename'] . $suffix . '.' . $arrFile['extension']; } $arrMatch = array(); if (\FWValidator::is_file_ending_harmless($fileName)) { if (@move_uploaded_file($fileTmpName, $documentRootPath . $filePath)) { $id = intval(substr($file, 17)); $arrFiles[$id] = array('path' => $filePath, 'name' => $fileName); } else { $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_UPLOAD_FAILED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)) . '<br />'; } } else { $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_EXTENSION_NOT_ALLOWED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)) . '<br />'; } } break; } } } return $arrFiles; }
/** * 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'); }
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 $cx = \Cx\Core\Core\Controller\Cx::instanciate(); //paths we want to remember for handling the uploaded files $data = array('path' => $cx->getWebsiteImagesDownloadsPath(), 'webPath' => $cx->getWebsiteImagesDownloadsWebPath(), 'category_id' => $objCategory->getId()); $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Downloads/Controller/Downloads.class.php', '\\Cx\\Modules\\Downloads\\Controller\\Downloads', 'uploadFinished')); $uploader->setCallback('uploadFinishedCallbackJs'); $uploader->setData($data); $this->objTemplate->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE']), 'DOWNLOADS_UPLOAD_REDIRECT_URL' => \Env::get('Resolver')->getURL(), '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'); } } }
public function getFrameXHtml() { global $_CORELANG; if (!empty($_SESSION['upload']['handlers'][$this->uploadId]['singleFileMode'])) { \ContrexxJavascript::getInstance()->setVariable('restrictUpload2SingleFile', true, "upload/widget_{$this->uploadId}"); } //JS / CSS dependencies \JS::activate('cx'); \JS::registerCSS('core_modules/Upload/css/uploaders/form/formUploader.css'); \JS::registerJS('core_modules/Upload/js/uploaders/form/formUploader.js'); $uploadPath = $this->getUploadPath('form'); $redirectUrl = ''; if ($this->isBackendRequest) { $redirectUrl = ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=Upload&act=formUploaderFrameFinished&uploadId=' . $this->uploadId; } else { $url = clone \Env::get('cx')->getRequest()->getUrl(); $url->removeAllParams(); $url->setParams(array('section' => 'Upload', 'cmd' => 'formUploaderFrameFinished', 'uploadId' => $this->uploadId)); $redirectUrl = (string) $url; } $this->setRedirectUrl($redirectUrl); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('formFrame.html'); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('INCLUDES', \JS::getCode()); $tpl->setVariable('CXJS_INIT_JS', \ContrexxJavascript::getInstance()->initJs()); $tpl->setVariable('UPLOAD_FORM_ADD', $_CORELANG['UPLOAD_FORM_ADD']); $tpl->setVariable('UPLOAD', $_CORELANG['UPLOAD']); $tpl->setVariable('UPLOAD_ID', $this->uploadId); $tpl->setVariable('MAX_FILE_SIZE', \FWSystem::getMaxUploadFileSize() - 1000); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $ls = new \LinkSanitizer($cx, $cx->getCodeBaseOffsetPath(), $tpl->get()); return $ls->replace(); }
/** * @param Sigma $template */ public function preFinalize(Sigma $template) { if (count($this->mediaBrowserInstances) == 0) { return; } global $_ARRAYLANG; /** * @var $init \InitCMS */ $init = \Env::get('init'); $init->loadLanguageData('MediaBrowser'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $thumbnailsTemplate = new Sigma(); $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html'); $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE'])); foreach ($this->cx->getMediaSourceManager()->getThumbnailGenerator()->getThumbnails() as $thumbnail) { $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size'])); $thumbnailsTemplate->parse('thumbnails'); } \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('chunk_size', min(floor((\FWSystem::getMaxUploadFileSize() - 1000000) / 1000000), 20) . 'mb', 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('languages', \FWLanguage::getActiveFrontendLanguages(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('language', \FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId()), 'mediabrowser'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/MediaBrowser/View/Script/MediaBrowser.js'); }
/** * Process upload form * * @global array $_ARRAYLANG * @return boolean true if file uplod successfully and false if it failed */ private function processFormUpload() { global $_ARRAYLANG; $inputField = 'media_upload_file'; if (!isset($_FILES[$inputField]) || !is_array($_FILES[$inputField])) { return false; } $fileName = !empty($_FILES[$inputField]['name']) ? contrexx_stripslashes($_FILES[$inputField]['name']) : ''; $fileTmpName = !empty($_FILES[$inputField]['tmp_name']) ? $_FILES[$inputField]['tmp_name'] : ''; if (MediaLibrary::isIllegalFileName($fileName)) { $this->_strErrorMessage = $_ARRAYLANG['TXT_MEDIA_FILE_DONT_CREATE']; return false; } switch ($_FILES[$inputField]['error']) { case UPLOAD_ERR_INI_SIZE: $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_SIZE_EXCEEDS_LIMIT'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET), $this->getFormatedFileSize(\FWSystem::getMaxUploadFileSize())); break; case UPLOAD_ERR_FORM_SIZE: $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_TOO_LARGE'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); break; case UPLOAD_ERR_PARTIAL: $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_CORRUPT'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); break; case UPLOAD_ERR_NO_FILE: $this->_strErrorMessage = $_ARRAYLANG['TXT_MEDIA_NO_FILE']; continue; break; default: if (!empty($fileTmpName)) { $suffix = ''; $file = $this->path . $fileName; $arrFile = pathinfo($file); $i = 0; while (file_exists($file)) { $suffix = '-' . (time() + ++$i); $file = $this->path . $arrFile['filename'] . $suffix . '.' . $arrFile['extension']; } if (\FWValidator::is_file_ending_harmless($fileName)) { $fileExtension = $arrFile['extension']; if (@move_uploaded_file($fileTmpName, $file)) { $fileName = $arrFile['filename']; $obj_file = new \File(); $obj_file->setChmod($this->path, $this->webPath, $fileName); $this->_strOkMessage = $_ARRAYLANG['TXT_MEDIA_FILE_UPLOADED_SUCESSFULLY']; return true; } else { $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_UPLOAD_FAILED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); } } else { $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_EXTENSION_NOT_ALLOWED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); } } break; } return false; }
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'); } } }