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;
		');
    }
 /**
  * Renders the extension PHP code; this was
  *
  * @param    string $k : module name key
  * @param    array $config : module configuration
  * @param    string $extKey : extension key
  * @return    void
  */
 function render_extPart($k, $config, $extKey)
 {
     $WOP = '[ts][' . $k . ']';
     $tsPath = strtolower(t3lib_basicFileFunctions::cleanFileName($config['title']));
     $pathSuffix = 'static/' . $tsPath . '/';
     $this->addFileToFileArray($pathSuffix . 'constants.txt', $config['constants']);
     $this->addFileToFileArray($pathSuffix . 'setup.txt', $config['setup']);
     // add TS definition to ext_tables.php
     $this->wizard->ext_tables[] = $this->sPS($this->WOPcomment('WOP:' . $WOP) . chr(10) . 't3lib_extMgm::addStaticFile($_EXTKEY,\'' . $pathSuffix . '\', \'' . $config['title'] . '\');', 0);
 }
Exemplo n.º 3
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.º 4
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.º 5
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.º 6
0
 /**
  * Returns a unique absolut path of a file or folder.
  *
  * @param string $path
  *        the path of a file or folder relative to the calling extension's
  *        upload directory, must not be empty
  *
  * @return string the unique absolut path of a file or folder
  *
  * @throws InvalidArgumentException
  */
 public function getUniqueFileOrFolderPath($path)
 {
     if (empty($path)) {
         throw new InvalidArgumentException('The first parameter $path must not be empty.', 1334439457);
     }
     if (!self::$fileNameProcessor) {
         self::$fileNameProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
     }
     return self::$fileNameProcessor->getUniqueName(basename($path), $this->uploadFolderPath . t3lib_div::dirname($path));
 }
Exemplo n.º 7
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'), '');
        }
    }
 /**
  * Copies any "RTEmagic" image files found in record with table/id to new names.
  * Usage: After copying a record this function should be called to search for "RTEmagic"-images inside the record. If such are found they should be duplicated to new names so all records have a 1-1 relation to them.
  * Reason for copying RTEmagic files: a) if you remove an RTEmagic image from a record it will remove the file - any other record using it will have a lost reference! b) RTEmagic images keeps an original and a copy. The copy always is re-calculated to have the correct physical measures as the HTML tag inserting it defines. This is calculated from the original. Two records using the same image could have difference HTML-width/heights for the image and the copy could only comply with one of them. If you don't want a 1-1 relation you should NOT use RTEmagic files but just insert it as a normal file reference to a file inside fileadmin/ folder
  *
  * @param	string		Table name
  * @param	integer		Record UID
  * @return	void
  */
 function copyRecord_fixRTEmagicImages($table, $theNewSQLID)
 {
     global $TYPO3_DB;
     // Creating fileFunc object.
     if (!$this->fileFunc) {
         $this->fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
         $this->include_filefunctions = 1;
     }
     // Select all RTEmagic files in the reference table from the table/ID
     /* @var $TYPO3_DB t3lib_DB */
     $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string LIKE ' . $TYPO3_DB->fullQuoteStr('%/RTEmagic%', 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('images', 'sys_refindex') . ' AND tablename=' . $TYPO3_DB->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . intval($theNewSQLID), '', 'sorting DESC');
     // Traverse the files found and copy them:
     if (is_array($recs)) {
         foreach ($recs as $rec) {
             $filename = basename($rec['ref_string']);
             $fileInfo = array();
             if (t3lib_div::isFirstPartOfStr($filename, 'RTEmagicC_')) {
                 $fileInfo['exists'] = @is_file(PATH_site . $rec['ref_string']);
                 $fileInfo['original'] = substr($rec['ref_string'], 0, -strlen($filename)) . 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', substr($filename, 10));
                 $fileInfo['original_exists'] = @is_file(PATH_site . $fileInfo['original']);
                 // CODE from tx_impexp and class.rte_images.php adapted for use here:
                 if ($fileInfo['exists'] && $fileInfo['original_exists']) {
                     // Initialize; Get directory prefix for file and set the original name:
                     $dirPrefix = dirname($rec['ref_string']) . '/';
                     $rteOrigName = basename($fileInfo['original']);
                     // If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
                     if ($rteOrigName && t3lib_div::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) {
                         // RTE:
                         // From the "original" RTE filename, produce a new "original" destination filename which is unused.
                         $origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
                         // Create copy file name:
                         $pI = pathinfo($rec['ref_string']);
                         $copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
                         if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === t3lib_div::getFileAbsFileName($origDestName) && $copyDestName === t3lib_div::getFileAbsFileName($copyDestName)) {
                             // Making copies:
                             t3lib_div::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
                             t3lib_div::upload_copy_move(PATH_site . $rec['ref_string'], $copyDestName);
                             clearstatcache();
                             // Register this:
                             $this->RTEmagic_copyIndex[$rec['tablename']][$rec['recuid']][$rec['field']][$rec['ref_string']] = substr($copyDestName, strlen(PATH_site));
                             // Check and update the record using the t3lib_refindex class:
                             if (@is_file($copyDestName)) {
                                 $sysRefObj = t3lib_div::makeInstance('t3lib_refindex');
                                 $error = $sysRefObj->setReferenceValue($rec['hash'], substr($copyDestName, strlen(PATH_site)), FALSE, TRUE);
                                 if ($error) {
                                     echo $this->newlog('t3lib_refindex::setReferenceValue(): ' . $error, 1);
                                 }
                             } else {
                                 $this->newlog('File "' . $copyDestName . '" was not created!', 1);
                             }
                         } else {
                             $this->newlog('Could not construct new unique names for file!', 1);
                         }
                     } else {
                         $this->newlog('Maybe directory of file was not within "uploads/"?', 1);
                     }
                 } else {
                     $this->newlog('Trying to copy RTEmagic files (' . $rec['ref_string'] . ' / ' . $fileInfo['original'] . ') but one or both were missing', 1);
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
 function _checkFileSize($sFileName, $iMaxFileSize, $sAbsName, $sType = "byte")
 {
     if (!empty($sFileName)) {
         $sFullPath = $this->_getFullServerPath($sAbsName, $sFileName);
         require_once PATH_t3lib . "class.t3lib_basicfilefunc.php";
         $aInfos = t3lib_basicFileFunctions::getTotalFileInfo($sFullPath);
         switch ($sType) {
             case "kilobyte":
                 $iMaxFileSize = $iMaxFileSize * 1024;
                 break;
             case "megabyte":
                 $iMaxFileSize = $iMaxFileSize * 1024 * 1024;
                 break;
         }
         if (intval($aInfos["size"]) <= intval($iMaxFileSize)) {
             return TRUE;
         } else {
             $this->_unlink($sFullPath);
             return FALSE;
         }
     }
     return TRUE;
 }