/** * Overview Media Data * * @global array $_ARRAYLANG * @global array $_CONFIG * @global array $_CORELANG * @return string parsed content */ function _overviewMedia() { global $_ARRAYLANG, $_CONFIG, $_CORELANG, $objDatabase; \JS::activate('shadowbox'); $this->_objTpl->loadTemplateFile('module_media.html', true, true); switch ($this->archive) { case 'themes': $this->pageTitle = $_ARRAYLANG['TXT_MEDIA_LAYOUT']; break; case 'content': $this->pageTitle = $_ARRAYLANG['TXT_IMAGE_ADMINISTRATION']; break; case 'Contact': $this->pageTitle = $_ARRAYLANG['TXT_FILE_UPLOADS']; break; case 'attach': case 'Access': case 'Blog': case 'Calendar': case 'Downloads': case 'Gallery': case 'MediaDir': case 'Podcast': case 'Shop': $archives = array('attach' => 'TXT_FILE_UPLOADS', 'Shop' => 'TXT_IMAGE_SHOP', 'Gallery' => 'TXT_GALLERY_TITLE', 'Access' => 'TXT_USER_ADMINISTRATION', 'MediaDir' => 'TXT_MEDIADIR_MODULE', 'Downloads' => 'TXT_DOWNLOADS', 'Calendar' => 'TXT_CALENDAR', 'Podcast' => 'TXT_PODCAST', 'Blog' => 'TXT_BLOG_MODULE'); $moduleMatchTable = array('attach' => 'core'); $subnavigation = ' <div id="subnavbar_level2"> <ul>'; $license = \Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase); $license->check(); foreach ($archives as $archive => $txtKey) { $moduleName = $archive; if (isset($moduleMatchTable[$archive])) { $moduleName = $moduleMatchTable[$archive]; } if (!$license->isInLegalComponents($moduleName)) { \DBG::msg('Module "' . $archive . '" is deactivated'); continue; } $subnavigation .= ' <li><a href="index.php?cmd=Media&archive=' . $archive . '" class="' . ($this->archive == $archive ? 'active' : '') . '">' . $_ARRAYLANG[$txtKey] . '</a></li>'; } $subnavigation .= ' </ul> </div>'; $this->_objTpl->setVariable('CONTENT_SUBNAVIGATION', $subnavigation); default: $this->pageTitle = $_ARRAYLANG['TXT_MEDIA_OVERVIEW']; if ($this->archive == "FileSharing") { \Cx\Modules\FileSharing\Controller\FileSharingLib::cleanUp(); } break; } // cut, copy and paste session if (isset($_SESSION['mediaCutFile'])) { $tmpArray = array(); foreach ($_SESSION['mediaCutFile'][2] as $tmp) { if (file_exists($_SESSION['mediaCutFile'][0] . $tmp)) { $tmpArray[] = $tmp; } } if (count($tmpArray) > 0) { $_SESSION['mediaCutFile'][0] = $_SESSION['mediaCutFile'][0]; $_SESSION['mediaCutFile'][1] = $_SESSION['mediaCutFile'][1]; $_SESSION['mediaCutFile'][2] = $tmpArray; } else { unset($_SESSION['mediaCutFile']); } } if (isset($_SESSION['mediaCopyFile'])) { $tmpArray = array(); foreach ($_SESSION['mediaCopyFile'][2] as $tmp) { if (file_exists($_SESSION['mediaCopyFile'][0] . $tmp)) { $tmpArray[] = $tmp; } } if (count($tmpArray) > 0) { $_SESSION['mediaCopyFile'][0] = $_SESSION['mediaCopyFile'][0]; $_SESSION['mediaCopyFile'][1] = $_SESSION['mediaCopyFile'][1]; $_SESSION['mediaCopyFile'][2] = $tmpArray; } else { unset($_SESSION['mediaCopyFile']); } } // tree navigation $tmp = $this->arrWebPaths[$this->archive]; if (substr($this->webPath, 0, strlen($tmp)) == $tmp) { $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => 'http://' . $_SERVER['HTTP_HOST'] . $this->arrWebPaths[$this->archive], 'MEDIA_TREE_NAV_MAIN_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $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' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->arrWebPaths[$this->archive] . $tmpLink)); $this->_objTpl->parse('mediaTreeNavigation'); } } } } //data we want to remember for handling the uploaded files $data = array('path' => $this->path, 'webPath' => $this->webPath); $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setCallback('mediaCallbackJs'); $uploader->setFinishedCallback(array(ASCMS_CORE_MODULE_PATH . '/Media/Controller/MediaLibrary.class.php', '\\Cx\\Core_modules\\Media\\Controller\\MediaLibrary', 'uploadFinished')); $uploader->setOptions(array('id' => 'media_browse_button', 'type' => 'button')); $uploader->setData($data); $this->_objTpl->setVariable('MEDIA_UPLOADER_BUTTON', $uploader->getXHtml($_ARRAYLANG['TXT_MEDIA_UPLOAD_FILES'])); //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 = 'media_upload_files_' . $_GET['highlightUploadId']; if (isset($_SESSION[$key])) { $sessionHighlightCandidates = $_SESSION[$key]->toArray(); //an array with the filenames, set in mediaLib::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->highlightName = $sessionHighlightCandidates; } } // Check if an image has been edited. // If yes, we know the edited file and want to highlight them. if (!empty($_GET['editedImage'])) { \Cx\Core\Core\Controller\Cx::instanciate()->getMediaSourceManager()->getThumbnailGenerator()->createThumbnailFromPath($this->path . $_GET['editedImage'], true); $this->highlightName[] = $_GET['editedImage']; } // media directory tree $i = 0; $dirTree = $this->_dirTree($this->path); $dirTree = $this->_sortDirTree($dirTree); foreach (array_keys($dirTree) as $key) { if (isset($dirTree[$key]['icon']) && is_array($dirTree[$key]['icon'])) { for ($x = 0; $x < count($dirTree[$key]['icon']); $x++) { $fileName = $dirTree[$key]['name'][$x]; if (MediaLibrary::isIllegalFileName($fileName)) { continue; } // colors $class = $i % 2 ? 'row2' : 'row1'; if (in_array($fileName, $this->highlightName)) { $class .= '" style="background-color: ' . $this->highlightColor . ';'; } if (isset($_SESSION['mediaCutFile']) && !empty($_SESSION['mediaCutFile'])) { if ($this->webPath == $_SESSION['mediaCutFile'][1] && in_array($fileName, $_SESSION['mediaCutFile'][2])) { $class .= '" style="background-color: ' . $this->highlightCCColor . ';'; } } if (isset($_SESSION['mediaCopyFile']) && !empty($_SESSION['mediaCopyFile'])) { if ($this->webPath == $_SESSION['mediaCopyFile'][1] && in_array($fileName, $_SESSION['mediaCopyFile'][2])) { $class .= '" style="background-color: ' . $this->highlightCCColor . ';'; } } $this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $fileName, '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_FILE_PERM' => $this->_formatPerm($dirTree[$key]['perm'][$x], $key))); // creates link if ($key == 'dir') { $tmpHref = 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath . $fileName . '/'; } elseif ($key == 'file') { if ($this->_isImage($this->path . $fileName)) { $tmpHref = 'javascript:expandcontent(\'preview_' . $fileName . '\');'; } else { $tmpHref = 'index.php?cmd=Media&archive=' . $this->archive . '&act=download&path=' . $this->webPath . '&file=' . $fileName; } } $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_HREF' => $tmpHref)); // show thumbnail if ($this->_isImage($this->path . $fileName)) { // make thumbnail if it doesn't exist $tmpSize = @getimagesize($this->path . $fileName); $thumbnails = \Cx\Core\Core\Controller\Cx::instanciate()->getMediaSourceManager()->getThumbnailGenerator()->createThumbnailFromPath($this->path . $fileName); $thumb = $this->webPath . $thumbnails[0]; if (in_array($fileName, $this->highlightName)) { $thumb .= '?lastAccess=' . fileatime($this->path . $fileName); } $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_SIZE' => $tmpSize[0] . ' x ' . $tmpSize[1], 'MEDIA_FILE_NAME_PRE' => 'preview_' . $fileName, 'MEDIA_FILE_NAME_IMG_HREF' => $this->webPath . $fileName, 'MEDIA_FILE_NAME_IMG_SRC' => $thumb, 'MEDIA_FILE_NAME_IMG_SIZE' => $thumbnails[0]['size'])); $this->_objTpl->parse('mediaShowThumbnail'); $this->_objTpl->setVariable(array('MEDIA_FILE_EDIT_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=edit&path=' . $this->webPath . '&file=' . $fileName, 'MEDIA_EDIT' => $_ARRAYLANG['TXT_MEDIA_EDIT'])); $this->_objTpl->parse('mediaImageEdit'); } $this->_objTpl->setVariable(array('MEDIA_FILE_RENAME_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=rename&path=' . $this->webPath . '&file=' . $fileName, 'MEDIA_RENAME' => $_ARRAYLANG['TXT_MEDIA_RENAME'], 'MEDIA_FILE_DELETE_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=delete&path=' . $this->webPath . '&file=' . $fileName, 'MEDIA_DELETE' => $_ARRAYLANG['TXT_MEDIA_DELETE'], 'MEDIA_FILE_FILESHARING_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=filesharing&path=' . $this->webPath . '&file=' . $fileName, 'MEDIA_FILESHARING' => $_ARRAYLANG['TXT_FILESHARING_MODULE'], 'MEDIA_FILESHARING_STATE' => \Cx\Modules\FileSharing\Controller\FileSharingLib::isShared(null, (isset($_GET['path']) ? $_GET['path'] : ASCMS_FILESHARING_WEB_PATH . '/') . $fileName) ? '_green' : '_red')); if ($this->archive == "FileSharing" && !is_dir($this->path . $fileName)) { $this->_objTpl->parse('mediaFilesharing'); } else { $this->_objTpl->hideBlock('mediaFilesharing'); } $this->_objTpl->parse('mediaDirectoryTree'); $i++; } } } // empty dir or php safe mode restriction if ($i == 0 || !@opendir($this->path)) { $tmpMessage = $_ARRAYLANG['TXT_MEDIA_DIR_EMPTY']; if (!@opendir($this->path)) { $tmpMessage = 'PHP Safe Mode Restriction!'; } $this->_objTpl->setVariable(array('TXT_MEDIA_DIR_EMPTY' => $tmpMessage, 'MEDIA_SELECT_STATUS' => ' disabled')); $this->_objTpl->parse('mediaEmptyDirectory'); } else { // not empty dir (select action) $this->_objTpl->setVariable(array('TXT_SELECT_ALL' => $_CORELANG['TXT_SELECT_ALL'], 'TXT_DESELECT_ALL' => $_CORELANG['TXT_DESELECT_ALL'], 'TXT_MEDIA_SELECT_ACTION' => $_ARRAYLANG['TXT_MEDIA_SELECT_ACTION'], 'TXT_MEDIA_CUT' => $_ARRAYLANG['TXT_MEDIA_CUT'], 'TXT_MEDIA_COPY' => $_ARRAYLANG['TXT_MEDIA_COPY'], 'TXT_MEDIA_DELETE' => $_ARRAYLANG['TXT_MEDIA_DELETE'])); $this->_objTpl->parse('mediaSelectAction'); $this->_objTpl->setVariable('MEDIA_ARCHIVE', $this->archive); } // paste media if (isset($_SESSION['mediaCutFile']) or isset($_SESSION['mediaCopyFile'])) { $this->_objTpl->setVariable(array('MEDIDA_PASTE_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=paste&path=' . $this->webPath, 'TXT_MEDIA_PASTE' => $_ARRAYLANG['TXT_MEDIA_PASTE'])); $this->_objTpl->parse('mediaActionPaste'); } // parse variables $tmpHref = 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath; $tmpIcon = $this->_sortingIcons(); $tmpClass = $this->_sortingClass(); $this->_objTpl->setVariable(array('TXT_MEDIA_CHECK_NAME' => $_ARRAYLANG['TXT_MEDIA_CHECK_NAME'], 'TXT_MEDIA_CONFIRM_DELETE_2' => $_ARRAYLANG['TXT_MEDIA_CONFIRM_DELETE_2'], 'MEDIA_DO_ACTION_PATH' => $this->webPath, 'TXT_MEDIA_MAKE_SELECTION' => $_ARRAYLANG['TXT_MEDIA_MAKE_SELECTION'], 'TXT_MEDIA_SELECT_UPLOAD_FILE' => $_ARRAYLANG['TXT_MEDIA_SELECT_UPLOAD_FILE'], 'MEDIA_JAVA_SCRIPT_PREVIEW' => $this->_getJavaScriptCodePreview())); $this->_objTpl->setVariable(array('TXT_MEDIA_NEW_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_NEW_DIRECTORY'], 'MEDIA_CREATE_DIR_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=newDir&path=' . $this->webPath, 'TXT_MEDIA_NAME' => $_ARRAYLANG['TXT_MEDIA_NAME'], 'TXT_MEDIA_CREATE' => $_ARRAYLANG['TXT_MEDIA_CREATE'])); $this->_objTpl->setVariable(array('TXT_MEDIA_UPLOAD_FILES' => $_ARRAYLANG['TXT_MEDIA_UPLOAD_FILES'], 'MEDIA_UPLOAD_FILES_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=upload&path=' . $this->webPath, 'TXT_MEDIA_UPLOAD' => $_ARRAYLANG['TXT_MEDIA_UPLOAD'], 'TXT_MEDIA_FORCE_OVERWRITE' => $_ARRAYLANG['TXT_MEDIA_FORCE_OVERWRITE'])); $this->_objTpl->setVariable(array('MEDIA_NAME_HREF' => $tmpHref . '&sort=name&sort_desc=' . ($this->sortBy == 'name' && !$this->sortDesc), 'MEDIA_SIZE_HREF' => $tmpHref . '&sort=size&sort_desc=' . ($this->sortBy == 'size' && !$this->sortDesc), 'MEDIA_TYPE_HREF' => $tmpHref . '&sort=type&sort_desc=' . ($this->sortBy == 'type' && !$this->sortDesc), 'MEDIA_DATE_HREF' => $tmpHref . '&sort=date&sort_desc=' . ($this->sortBy == 'date' && !$this->sortDesc), 'MEDIA_PERM_HREF' => $tmpHref . '&sort=perm&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'], 'TXT_MEDIA_FILE_FUNCTIONS' => $_ARRAYLANG['TXT_FUNCTIONS'], 'MEDIA_NAME_ICON' => isset($tmpIcon['name']) ? $tmpIcon['name'] : '', 'MEDIA_SIZE_ICON' => isset($tmpIcon['size']) ? $tmpIcon['size'] : '', 'MEDIA_TYPE_ICON' => isset($tmpIcon['type']) ? $tmpIcon['type'] : '', 'MEDIA_DATE_ICON' => isset($tmpIcon['date']) ? $tmpIcon['date'] : '', 'MEDIA_PERM_ICON' => isset($tmpIcon['perm']) ? $tmpIcon['perm'] : '', 'MEDIA_NAME_CLASS' => isset($tmpClass['name']) ? $tmpIcon['name'] : '', 'MEDIA_SIZE_CLASS' => isset($tmpClass['size']) ? $tmpIcon['size'] : '', 'MEDIA_TYPE_CLASS' => isset($tmpClass['type']) ? $tmpIcon['type'] : '', 'MEDIA_DATE_CLASS' => isset($tmpClass['date']) ? $tmpIcon['date'] : '', 'MEDIA_PERM_CLASS' => isset($tmpClass['perm']) ? $tmpIcon['perm'] : '', 'CSRF' => \Cx\Core\Csrf\Controller\Csrf::param())); }
/** * Inits the uploader when displaying a contact form. * * @param string $callBackFun * @param string $callBackJs * @param array $data * @param string $buttonText * @param array $options * * @return null */ function initUploader($callBackFun, $callBackJs, $data, $buttonText, $options = array()) { global $_ARRAYLANG; try { //init the uploader $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); if (!empty($callBackJs)) { $uploader->setCallback($callBackJs); } if (!empty($callBackFun)) { $uploader->setFinishedCallback(array(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Crm/Controller/CrmManager.class.php', '\\Cx\\Modules\\Crm\\Controller\\CrmManager', $callBackFun)); } $uploader->setOptions($options); $uploader->setData($data); if (empty($buttonText)) { $buttonText = $_ARRAYLANG['TXT_MEDIA_UPLOAD_FILES']; } return $uploader->getXHtml($buttonText); } catch (Exception $e) { return '<!-- failed initializing uploader, exception ' . get_class($e) . ' with message "' . $e->getMessage() . '" -->'; } }
/** * Initialize the uploader * * @return null */ public function initForumUploader() { $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setCallback('forumFileUploaderCallback'); $options = array('id' => 'forum-attachment-uploader', 'allowed-extensions' => explode(',', $this->_arrSettings['allowed_extensions']), 'style' => 'display:none', 'data-upload-limit' => 1); $uploader->setOptions($options); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Forum/Controller/Forum.class.php', '\\Cx\\Modules\\Forum\\Controller\\Forum', 'uploadFinished')); $this->_objTpl->setVariable(array('FORUM_UPLOADER' => $uploader->getXhtml(), 'FORUM_UPLOADER_ID' => $uploader->getId())); }
/** * Get uploader code * * @param string $fieldKey uploadFieldKey * @param string $fieldName uploadFieldName * @param string $uploadCallBack upload callback function * @param boolean $allowImageOnly allow only images files * * @return string uploaderCode * @throws \Exception */ protected function getUploaderCode($fieldKey, $fieldName, $uploadCallBack = "uploadFinished", $allowImageOnly = true) { \cmsSession::getInstance(); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); try { $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploaderId = $uploader->getId(); $uploadOptions = array('id' => 'calendarUploader_' . $uploaderId, 'style' => 'display: none'); if ($allowImageOnly) { $uploadOptions['allowed-extensions'] = array('gif', 'jpg', 'png', 'jpeg'); } $uploader->setCallback($fieldName . 'JsCallback'); $uploader->setUploadLimit(1); $uploader->setOptions($uploadOptions); $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Calendar/Controller/Calendar.class.php', '\\Cx\\Modules\\Calendar\\Controller\\Calendar', $uploadCallBack)); $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploaderId); $this->_objTpl->setVariable(array(strtoupper($fieldName) . '_WIDGET_CODE' => $folderWidget->getXHtml(), "{$this->moduleLangVar}_" . strtoupper($fieldKey) => $uploaderId)); $strJs = <<<JAVASCRIPT {$uploader->getXHtml()} <script type="text/javascript"> cx.ready(function() { //called if user clicks on the field jQuery('#{$fieldName}').bind('click', function() { jQuery('#calendarUploader_{$uploaderId}').trigger('click'); return false; }); }); //uploader javascript callback function function {$fieldName}JsCallback(callback) { angular.element('#mediaBrowserfolderWidget_{$folderWidget->getId()}').scope().refreshBrowser(); } </script> JAVASCRIPT; return $strJs; } catch (\Exception $e) { \DBG::msg('<!-- failed initializing uploader -->'); throw new \Exception("failed initializing uploader"); } }
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'); } } }
/** * Inits the uploader when displaying a contact form. */ protected function initUploader($fieldId, $restrictUpload2SingleFile = true) { try { $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $sessionObj = $cx->getComponent('Session')->getSession(); $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); //set instance name so we are able to catch the instance with js $uploader->setCallback('contactFormUploader_' . $fieldId); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); // specifies the function to call when upload is finished. must be a static function $uploader->setFinishedCallback(array($cx->getCodeBaseCoreModulePath() . '/Contact/Controller/Contact.class.php', '\\Cx\\Core_Modules\\Contact\\Controller\\Contact', 'uploadFinished')); if ($restrictUpload2SingleFile) { $uploader->setData(array('singleFile' => $restrictUpload2SingleFile)); $uploader->setUploadLimit(1); } $uploaderId = $uploader->getId(); $uploader->setOptions(array('id' => 'contactUploader_' . $uploaderId, 'style' => 'display: none')); //initialize the widget displaying the folder contents $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploaderId); $this->objTemplate->setVariable(array('CONTACT_UPLOADER_FOLDER_WIDGET_' . $fieldId => $folderWidget->getXhtml(), 'CONTACT_UPLOADER_ID_' . $fieldId => $uploaderId)); $folderWidgetId = $folderWidget->getId(); $strInputfield = $uploader->getXHtml(); $strInputfield .= <<<CODE <script type="text/javascript"> cx.ready(function() { jQuery('#contactFormFieldId_{$fieldId}').bind('click', function() { jQuery('#contactUploader_{$uploaderId}').trigger('click'); return false; }).removeAttr('disabled'); }); //uploader javascript callback function function contactFormUploader_{$fieldId}(callback) { angular.element('#mediaBrowserfolderWidget_{$folderWidgetId}').scope().refreshBrowser(); } </script> CODE; return $strInputfield; } catch (Exception $e) { return '<!-- failed initializing uploader, exception ' . get_class($e) . ' with message "' . $e->getMessage() . '" -->'; } }
/** * 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 . '&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 . '&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 . '&path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/'); $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&act=delete&path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/'); } elseif ($key == 'file') { $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&act=delete&path=' . rawurlencode($this->webPath) . '&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 . '&act=download&path=' . rawurlencode($this->webPath) . '&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 . '&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 . '&sort=name&sort_desc=' . ($this->sortBy == 'name' && !$this->sortDesc), 'MEDIA_SIZE_HREF' => $tmpHref . '&sort=size&sort_desc=' . ($this->sortBy == 'size' && !$this->sortDesc), 'MEDIA_TYPE_HREF' => $tmpHref . '&sort=type&sort_desc=' . ($this->sortBy == 'type' && !$this->sortDesc), 'MEDIA_DATE_HREF' => $tmpHref . '&sort=date&sort_desc=' . ($this->sortBy == 'date' && !$this->sortDesc), 'MEDIA_PERM_HREF' => $tmpHref . '&sort=perm&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); //new uploader $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setData($data); $uploader->setCallback('mediaCallbackJs'); $uploader->setFinishedCallback(array(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/Media/Controller/MediaLibrary.class.php', '\\Cx\\Core_modules\\Media\\Controller\\MediaLibrary', 'uploadFinished')); $this->_objTpl->setVariable(array('TXT_MEDIA_ADD_NEW_FILE' => $_ARRAYLANG['TXT_MEDIA_ADD_NEW_FILE'], 'MEDIA_UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_MEDIA_BROWSE']), '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 . '&act=newDir&path=' . $this->webPath)); $this->_objTpl->parse('media_create_directory'); //custom uploader \JS::activate('cx'); // the uploader needs the framework $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); //create an uploader $uploadId = $uploader->getId(); $uploader->setCallback('customUploader'); $uploader->setOptions(array('id' => 'custom_' . $uploadId)); $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploadId, true); $folderWidgetId = $folderWidget->getId(); $extendedFileInputCode = <<<CODE <script type="text/javascript"> //uploader javascript callback function function customUploader(callback) { angular.element('#mediaBrowserfolderWidget_{$folderWidgetId}').scope().refreshBrowser(); } </script> CODE; $this->_objTpl->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml(), 'UPLOADER_ID' => $uploadId, 'FILE_INPUT_CODE' => $extendedFileInputCode, 'FOLDER_WIDGET_CODE' => $folderWidget->getXHtml())); } }
/** * Sets the template for the file selection * * Sets the template and all neede variables * for the file selection. * @param object $tpl The template object (by reference) */ function initFileSelectTemplate(&$tpl) { global $_ARRAYLANG; $template = file_get_contents(ASCMS_LIBRARY_PATH . "/importexport/template/import.fileselect.html"); $tpl->setTemplate($template, true, true); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); // init uploader to upload csv $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setCallback('importUploaderCallback'); $uploader->setOptions(array('id' => 'importCsvUploader', 'allowed-extensions' => array('csv'), 'data-upload-limit' => 1)); $uploader->setFinishedCallback(array($cx->getCodeBaseLibraryPath() . '/importexport/import.class.php', '\\Import', 'uploadFinished')); $tpl->setVariable(array("TXT_IMPORT" => $_ARRAYLANG['TXT_IMPORT'], "IMPORT_TYPELIST" => $this->getTypeSelectList(), "TXT_FILETYPE" => $_ARRAYLANG['TXT_FILETYPE'], "TXT_CHOOSE_FILE" => $_ARRAYLANG['TXT_CHOOSE_FILE'], "TXT_SEPARATOR" => $_ARRAYLANG['TXT_SEPARATOR'], "TXT_ENCLOSURE" => $_ARRAYLANG['TXT_ENCLOSURE'], "TXT_DESC_DELIMITER" => $_ARRAYLANG['TXT_DESC_DELIMITER'], "TXT_DESC_ENCLOSURE" => $_ARRAYLANG['TXT_DESC_ENCLOSURE'], "TXT_HELP" => $_ARRAYLANG['TXT_HELP'], 'IMPORT_UPLOADER_BUTTON' => $uploader->getXHtml($_ARRAYLANG['TXT_BROWSE']), 'IMPORT_UPLOADER_ID' => $uploader->getId())); }
/** * set up Import page * call specific function depending on $_GET * @access private */ private function import() { global $_ARRAYLANG, $objTemplate; \Permission::checkAccess(102, 'static'); $objTemplate->addBlockfile('ADMIN_CONTENT', 'skins_import', 'skins_import.html'); $this->pageTitle = $_ARRAYLANG['TXT_THEME_IMPORT']; if (!empty($_GET['import'])) { $this->importFile(); } // init uploader to import of themes $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setCallback('themesZipFileUploaderCallback'); $uploader->setOptions(array('id' => 'local-archive-uploader', 'allowed-extensions' => array('zip'), 'style' => 'display:none', 'data-upload-limit' => 1)); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $uploader->setFinishedCallback(array($cx->getCodeBaseCorePath() . '/ViewManager/Controller/ViewManager.class.php', '\\Cx\\Core\\ViewManager\\Controller\\ViewManager', 'uploadFinished')); $objTemplate->setVariable(array('TXT_THEMES_EDIT' => $_ARRAYLANG['TXT_SETTINGS_MODFIY'], 'TXT_THEMES_CREATE' => $_ARRAYLANG['TXT_CREATE'], 'TXT_THEME_IMPORT' => $_ARRAYLANG['TXT_THEME_IMPORT'], 'TXT_THEME_LOCAL_FILE' => $_ARRAYLANG['TXT_THEME_LOCAL_FILE'], 'TXT_THEME_SPECIFY_URL' => $_ARRAYLANG['TXT_THEME_SPECIFY_URL'], 'TXT_THEME_IMPORT_INFO' => $_ARRAYLANG['TXT_THEME_IMPORT_INFO'], 'TXT_THEME_NO_URL_SPECIFIED' => $_ARRAYLANG['TXT_THEME_NO_URL_SPECIFIED'], 'TXT_THEME_NO_FILE_SPECIFIED' => $_ARRAYLANG['TXT_THEME_NO_FILE_SPECIFIED'], 'TXT_THEME_FILESYSTEM' => sprintf($_ARRAYLANG['TXT_THEME_FILESYSTEM'], \Cx\Core\Core\Controller\Cx::instanciate()->getThemesFolderName()), 'THEMES_MENU' => $this->getDropdownNotInDb(), 'TXT_THEME_DO_IMPORT' => $_ARRAYLANG['TXT_THEME_DO_IMPORT'], 'TXT_THEME_IMPORT_THEME' => $_ARRAYLANG['TXT_THEME_IMPORT_THEME'], 'TXT_VIEWMANAGER_THEME_SELECTION_TXT' => $_ARRAYLANG['TXT_VIEWMANAGER_THEME_SELECTION_TXT'], 'TXT_VIEWMANAGER_THEME' => $_ARRAYLANG['TXT_VIEWMANAGER_THEME'], 'TXT_VIEWMANAGER_SOURCE' => $_ARRAYLANG['TXT_VIEWMANAGER_SOURCE'], 'TXT_SELECT_FILE' => $_ARRAYLANG['TXT_SELECT_FILE'], 'THEMES_UPLOADER_CODE' => $uploader->getXHtml(), 'THEMES_UPLOADER_ID' => $uploader->getId())); }