Exemplo n.º 1
0
    /**
     * Constructor function for class
     *
     * @return	void
     */
    function init()
    {
        global $LANG, $BACK_PATH, $TYPO3_CONF_VARS;
        // Initialize GPvars:
        $this->number = t3lib_div::_GP('number');
        $this->target = t3lib_div::_GP('target');
        $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
        // Init basic-file-functions object:
        $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->basicff->init($GLOBALS['FILEMOUNTS'], $TYPO3_CONF_VARS['BE']['fileExtensions']);
        // Init basic-charset-functions object:
        $this->charsetConversion = t3lib_div::makeInstance('t3lib_cs');
        // Cleaning and checking target
        $this->target = $this->charsetConversion->conv($this->target, 'utf-8', $GLOBALS['LANG']->charSet);
        $this->target = $this->basicff->is_directory($this->target);
        $key = $this->basicff->checkPathAgainstMounts($this->target . '/');
        if (!$this->target || !$key) {
            $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
            $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
            throw new RuntimeException($title . ': ' . $message);
        }
        // Finding the icon
        switch ($GLOBALS['FILEMOUNTS'][$key]['type']) {
            case 'user':
                $this->icon = 'gfx/i/_icon_ftp_user.gif';
                break;
            case 'group':
                $this->icon = 'gfx/i/_icon_ftp_group.gif';
                break;
            default:
                $this->icon = 'gfx/i/_icon_ftp.gif';
                break;
        }
        $this->icon = '<img' . t3lib_iconWorks::skinImg($this->backPath, $this->icon, 'width="18" height="16"') . ' title="" alt="" />';
        // Relative path to filemount, $key:
        $this->shortPath = substr($this->target, strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
        // Setting title:
        $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
        // Setting template object
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->setModuleTemplate('templates/file_newfolder.html');
        $this->doc->backPath = $BACK_PATH;
        $this->doc->JScode = $this->doc->wrapScriptTags('
			var path = "' . $this->target . '";

			function reload(a)	{	//
				if (!changed || (changed && confirm(' . $LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')) . ')))	{
					var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . urlencode($this->charsetConversion->conv($this->returnUrl, $GLOBALS['LANG']->charSet, 'utf-8')) . '";
					window.location.href = "file_newfolder.php?"+params;
				}
			}
			function backToList()	{	//
				top.goToModule("file_list");
			}

			var changed = 0;
		');
    }
Exemplo n.º 2
0
    /**
     * Initialize script class
     *
     * @return	void
     */
    function init()
    {
        //TODO remove global
        global $BACK_PATH, $TYPO3_CONF_VARS;
        // Setting target, which must be a file reference to a file within the mounts.
        $this->target = $this->origTarget = t3lib_div::_GP('target');
        $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
        // Creating file management object:
        $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->basicff->init($GLOBALS['FILEMOUNTS'], $TYPO3_CONF_VARS['BE']['fileExtensions']);
        if (file_exists($this->target)) {
            $this->target = $this->basicff->cleanDirectoryName($this->target);
            // Cleaning and checking target (file or dir)
        } else {
            $this->target = '';
        }
        $key = $this->basicff->checkPathAgainstMounts($this->target . '/');
        if (!$this->target || !$key) {
            $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
            $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
            throw new RuntimeException($title . ': ' . $message);
        }
        // Finding the icon
        switch ($GLOBALS['FILEMOUNTS'][$key]['type']) {
            case 'user':
                $this->icon = 'gfx/i/_icon_ftp_user.gif';
                break;
            case 'group':
                $this->icon = 'gfx/i/_icon_ftp_group.gif';
                break;
            default:
                $this->icon = 'gfx/i/_icon_ftp.gif';
                break;
        }
        $this->icon = '<img' . t3lib_iconWorks::skinImg($this->backPath, $this->icon, 'width="18" height="16"') . ' title="" alt="" />';
        // Relative path to filemount, $key:
        $this->shortPath = substr($this->target, strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
        // Setting title:
        $this->title = $this->icon . $GLOBALS['FILEMOUNTS'][$key]['name'] . ': ' . $this->shortPath;
        // ***************************
        // Setting template object
        // ***************************
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->setModuleTemplate('templates/file_edit.html');
        $this->doc->backPath = $BACK_PATH;
        $this->doc->JScode = $this->doc->wrapScriptTags('
			function backToList()	{	//
				top.goToModule("file_list");
			}
		');
        $this->doc->form = '<form action="tce_file.php" method="post" name="editform">';
    }
Exemplo n.º 3
0
    /**
     * Constructor function for class
     *
     * @return	void
     */
    function init()
    {
        //TODO remove global
        global $LANG, $BACK_PATH, $TYPO3_CONF_VARS;
        // Initialize GPvars:
        $this->target = t3lib_div::_GP('target');
        $this->returnUrl = t3lib_div::_GP('returnUrl');
        // Init basic-file-functions object:
        $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->basicff->init($GLOBALS['FILEMOUNTS'], $TYPO3_CONF_VARS['BE']['fileExtensions']);
        // Cleaning and checking target
        if (file_exists($this->target)) {
            $this->target = $this->basicff->cleanDirectoryName($this->target);
            // Cleaning and checking target (file or dir)
        } else {
            $this->target = '';
        }
        $key = $this->basicff->checkPathAgainstMounts($this->target . '/');
        if (!$this->target || !$key) {
            t3lib_BEfunc::typo3PrintError($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', true), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', true), '');
            exit;
        }
        // Finding the icon
        switch ($GLOBALS['FILEMOUNTS'][$key]['type']) {
            case 'user':
                $this->icon = 'gfx/i/_icon_ftp_user.gif';
                break;
            case 'group':
                $this->icon = 'gfx/i/_icon_ftp_group.gif';
                break;
            default:
                $this->icon = 'gfx/i/_icon_ftp.gif';
                break;
        }
        $this->icon = '<img' . t3lib_iconWorks::skinImg($this->backPath, $this->icon, 'width="18" height="16"') . ' title="" alt="" />';
        // Relative path to filemount, $key:
        $this->shortPath = substr($this->target, strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
        // Setting title:
        $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
        // Setting template object
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->setModuleTemplate('templates/file_rename.html');
        $this->doc->backPath = $BACK_PATH;
        $this->doc->JScode = $this->doc->wrapScriptTags('
			function backToList()	{	//
				top.goToModule("file_list");
			}
		');
    }
Exemplo n.º 4
0
    /**
     * Constructor for initializing the class
     *
     * @return	void
     */
    function init()
    {
        // Initialize GPvars:
        $this->number = t3lib_div::_GP('number');
        $this->target = t3lib_div::_GP('target');
        $this->returnUrl = t3lib_div::_GP('returnUrl');
        $this->returnUrl = $this->returnUrl ? $this->returnUrl : t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'file_list.php?id=' . rawurlencode($this->target);
        // set the number of input fields
        if (empty($this->number)) {
            $this->number = $GLOBALS['BE_USER']->getTSConfigVal('options.defaultFileUploads');
        }
        $this->number = t3lib_div::intInRange($this->number, 1, $this->uploadNumber);
        // Init basic-file-functions object:
        $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->basicff->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
        // Init basic-charset-functions object:
        $this->charsetConversion = t3lib_div::makeInstance('t3lib_cs');
        // Cleaning and checking target
        $this->target = $this->charsetConversion->conv($this->target, 'utf-8', $GLOBALS['LANG']->charSet);
        $this->target = $this->basicff->is_directory($this->target);
        $key = $this->basicff->checkPathAgainstMounts($this->target . '/');
        if (!$this->target || !$key) {
            t3lib_BEfunc::typo3PrintError($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', true), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', true), '');
            exit;
        }
        // Finding the icon
        switch ($GLOBALS['FILEMOUNTS'][$key]['type']) {
            case 'user':
                $this->icon = 'gfx/i/_icon_ftp_user.gif';
                break;
            case 'group':
                $this->icon = 'gfx/i/_icon_ftp_group.gif';
                break;
            default:
                $this->icon = 'gfx/i/_icon_ftp.gif';
                break;
        }
        $this->icon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], $this->icon, 'width="18" height="16"') . ' title="" alt="" />';
        // Relative path to filemount, $key:
        $this->shortPath = substr($this->target, strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
        // Setting title:
        $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
        // Setting template object
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->setModuleTemplate('templates/file_upload.html');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        $this->doc->form = '<form action="tce_file.php" method="post" name="editform" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">';
        if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
            $confirm = ' && confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')) . ')';
        } else {
            $confirm = '';
        }
        $this->doc->JScode = $this->doc->wrapScriptTags('
			var path = "' . $this->target . '";

			function reload(a) {	//
				if (!changed || (changed ' . $confirm . ')) {
					var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . urlencode($this->charsetConversion->conv($this->returnUrl, $GLOBALS['LANG']->charSet, 'utf-8')) . '";
					window.location.href = "file_upload.php?"+params;
				}
			}
			function backToList() {	//
				top.goToModule("file_list");
			}
			var changed = 0;
		');
    }
Exemplo n.º 5
0
    /**
     * Main function, creating the listing
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $FILEMOUNTS;
        // Initialize the template object
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->backPath = $BACK_PATH;
        $this->doc->setModuleTemplate('templates/file_list.html');
        $this->doc->getPageRenderer()->loadPrototype();
        // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
        $this->id = $this->basicFF->is_directory($this->id);
        $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id . '/');
        // There there was access to this file path, continue, make the list
        if ($access) {
            // include the initialization for the flash uploader
            if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) {
                $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]": "' . $this->id . '",
										"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();
							};
						});
					}
				';
            }
            // Create filelisting object
            $this->filelist = t3lib_div::makeInstance('fileList');
            $this->filelist->backPath = $BACK_PATH;
            // Apply predefined values for hidden checkboxes
            // Set predefined value for DisplayBigControlPanel:
            if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'activated') {
                $this->MOD_SETTINGS['bigControlPanel'] = TRUE;
            } elseif ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'deactivated') {
                $this->MOD_SETTINGS['bigControlPanel'] = FALSE;
            }
            // Set predefined value for DisplayThumbnails:
            if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'activated') {
                $this->MOD_SETTINGS['displayThumbs'] = TRUE;
            } elseif ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'deactivated') {
                $this->MOD_SETTINGS['displayThumbs'] = FALSE;
            }
            // Set predefined value for Clipboard:
            if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableClipBoard') === 'activated') {
                $this->MOD_SETTINGS['clipBoard'] = TRUE;
            } elseif ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableClipBoard') === 'deactivated') {
                $this->MOD_SETTINGS['clipBoard'] = FALSE;
            }
            // if user never opened the list module, set the value for displayThumbs
            if (!isset($this->MOD_SETTINGS['displayThumbs'])) {
                $this->MOD_SETTINGS['displayThumbs'] = $BE_USER->uc['thumbnailsByDefault'];
            }
            $this->filelist->thumbs = $this->MOD_SETTINGS['displayThumbs'];
            // Create clipboard object and initialize that
            $this->filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
            $this->filelist->clipObj->fileMode = 1;
            $this->filelist->clipObj->initializeClipboard();
            $CB = t3lib_div::_GET('CB');
            if ($this->cmd == 'setCB') {
                $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'), t3lib_div::_POST('CBC')), '_FILE');
            }
            if (!$this->MOD_SETTINGS['clipBoard']) {
                $CB['setP'] = 'normal';
            }
            $this->filelist->clipObj->setCmd($CB);
            $this->filelist->clipObj->cleanCurrent();
            $this->filelist->clipObj->endClipboard();
            // Saves
            // If the "cmd" was to delete files from the list (clipboard thing), do that:
            if ($this->cmd == 'delete') {
                $items = $this->filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'), '_FILE', 1);
                if (count($items)) {
                    // Make command array:
                    $FILE = array();
                    foreach ($items as $v) {
                        $FILE['delete'][] = array('data' => $v);
                    }
                    // Init file processing object for deleting and pass the cmd array.
                    $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
                    $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
                    $fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
                    $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
                    $fileProcessor->start($FILE);
                    $fileProcessor->processData();
                    $fileProcessor->printLogErrorMessages();
                }
            }
            if (!isset($this->MOD_SETTINGS['sort'])) {
                // Set default sorting
                $this->MOD_SETTINGS['sort'] = 'file';
                $this->MOD_SETTINGS['reverse'] = 0;
            }
            // Start up filelisting object, include settings.
            $this->pointer = t3lib_div::intInRange($this->pointer, 0, 100000);
            $this->filelist->start($this->id, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']);
            // Generate the list
            $this->filelist->generateList();
            // Write the footer
            $this->filelist->writeBottom();
            // Set top JavaScript:
            $this->doc->JScode = $this->doc->wrapScriptTags('

			if (top.fsMod) top.fsMod.recentIds["file"] = unescape("' . rawurlencode($this->id) . '");
			function jumpToUrl(URL)	{	//
				window.location.href = URL;
			}

			' . $this->filelist->CBfunctions());
            // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
            $this->doc->getContextMenuCode();
            // Setting up the buttons and markers for docheader
            list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->id);
            // add the folder info to the marker array
            $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo();
            $docHeaderButtons = array_merge($this->getButtons(), $buttons);
            // Build the <body> for the module
            // Create output
            $pageContent = '';
            $pageContent .= '<form action="' . htmlspecialchars($this->filelist->listURL()) . '" method="post" name="dblistForm">';
            $pageContent .= $this->filelist->HTMLcode;
            $pageContent .= '<input type="hidden" name="cmd" /></form>';
            if ($this->filelist->HTMLcode) {
                // Making listing options:
                $pageContent .= '

					<!--
						Listing options for extended view, clipboard and thumbnails
					-->
					<div id="typo3-listOptions">
				';
                // Add "display bigControlPanel" checkbox:
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'selectable') {
                    $pageContent .= t3lib_BEfunc::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], 'file_list.php', '', 'id="bigControlPanel"') . '<label for="bigControlPanel"> ' . $GLOBALS['LANG']->getLL('bigControlPanel', TRUE) . '</label><br />';
                }
                // Add "display thumbnails" checkbox:
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'selectable') {
                    $pageContent .= t3lib_BEfunc::getFuncCheck($this->id, 'SET[displayThumbs]', $this->MOD_SETTINGS['displayThumbs'], 'file_list.php', '', 'id="checkDisplayThumbs"') . ' <label for="checkDisplayThumbs">' . $GLOBALS['LANG']->getLL('displayThumbs', TRUE) . '</label><br />';
                }
                // Add "clipboard" checkbox:
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableClipBoard') === 'selectable') {
                    $pageContent .= t3lib_BEfunc::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], 'file_list.php', '', 'id="checkClipBoard"') . ' <label for="checkClipBoard">' . $GLOBALS['LANG']->getLL('clipBoard', TRUE) . '</label>';
                }
                $pageContent .= '
					</div>
				';
                // Set clipboard:
                if ($this->MOD_SETTINGS['clipBoard']) {
                    $pageContent .= $this->filelist->clipObj->printClipboard();
                    $pageContent .= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
                }
            }
            $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'CONTENT' => $pageContent);
            $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers));
            // Renders the module page
            $this->content = $this->doc->render($LANG->getLL('files'), $this->content);
        } else {
            // Create output - no access (no warning though)
            $this->content = $this->doc->render($LANG->getLL('files'), '');
        }
    }