/**
     * Initialize script class
     *
     * @return 	void
     * @todo Define visibility
     */
    public function init()
    {
        // Setting target, which must be a file reference to a file within the mounts.
        $this->target = $this->origTarget = $fileIdentifier = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('target');
        $this->returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl'));
        // create the file object
        if ($fileIdentifier) {
            $this->fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileIdentifier);
        }
        // Cleaning and checking target directory
        if (!$this->fileObject) {
            $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, 1294586841);
        }
        // Setting the title and the icon
        $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-filetree-root');
        $this->title = $icon . htmlspecialchars($this->fileObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->fileObject->getIdentifier());
        // ***************************
        // Setting template object
        // ***************************
        $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
        $this->doc->setModuleTemplate('templates/file_edit.html');
        $this->doc->backPath = $GLOBALS['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">';
    }
Example #2
0
    /**
     * Initialize script class
     *
     * @return void
     * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
     */
    protected function init()
    {
        // Setting target, which must be a file reference to a file within the mounts.
        $this->target = $this->origTarget = $fileIdentifier = GeneralUtility::_GP('target');
        $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
        // create the file object
        if ($fileIdentifier) {
            $this->fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileIdentifier);
        }
        // Cleaning and checking target directory
        if (!$this->fileObject) {
            $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', TRUE);
            $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', TRUE);
            throw new \RuntimeException($title . ': ' . $message, 1294586841);
        }
        if ($this->fileObject->getStorage()->getUid() === 0) {
            throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889832);
        }
        // Setting the title and the icon
        $icon = IconUtility::getSpriteIcon('apps-filetree-root');
        $this->title = $icon . htmlspecialchars($this->fileObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->fileObject->getIdentifier());
        // Setting template object
        $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
        $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/file_edit.html');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        $this->doc->JScode = $this->doc->wrapScriptTags('
			function backToList() {	//
				top.goToModule("file_list");
			}
		');
        $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform">';
    }
    /**
     * Initialize script class
     *
     * @throws InsufficientFileAccessPermissionsException
     * @throws \InvalidArgumentException
     * @throws \RuntimeException
     */
    protected function init()
    {
        // Setting target, which must be a file reference to a file within the mounts.
        $this->target = $this->origTarget = $fileIdentifier = GeneralUtility::_GP('target');
        $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
        // create the file object
        if ($fileIdentifier) {
            $this->fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileIdentifier);
        }
        // Cleaning and checking target directory
        if (!$this->fileObject) {
            $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', true);
            $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', true);
            throw new \RuntimeException($title . ': ' . $message, 1294586841);
        }
        if ($this->fileObject->getStorage()->getUid() === 0) {
            throw new InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889832);
        }
        // Setting the title and the icon
        $icon = $this->iconFactory->getIcon('apps-filetree-root', Icon::SIZE_SMALL)->render();
        $this->title = $icon . htmlspecialchars($this->fileObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->fileObject->getIdentifier());
        // Setting template object
        $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
        $this->moduleTemplate->addJavaScriptCode('FileEditBackToList', 'function backToList() {
				top.goToModule("file_FilelistList");
			}');
    }
 /**
  * Create a flash message for a file that is marked as missing
  *
  * @param AbstractFile $file
  * @return FlashMessage
  */
 public static function getFlashMessageForMissingFile(AbstractFile $file)
 {
     /** @var LanguageService $lang */
     $lang = $GLOBALS['LANG'];
     /** @var FlashMessage $flashMessage */
     $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing_text') . ' <abbr title="' . htmlspecialchars($file->getStorage()->getName() . ' :: ' . $file->getIdentifier()) . '">' . htmlspecialchars($file->getName()) . '</abbr>', $lang->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'), FlashMessage::ERROR);
     return $flashMessage;
 }
 /**
  * Updates the properties of a file object with some that are freshly
  * fetched from the driver.
  *
  * @param \TYPO3\CMS\Core\Resource\AbstractFile $file
  * @param string $identifier The identifier of the file. If set, this will overwrite the file object's identifier (use e.g. after moving a file)
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
  * @return void
  */
 protected function updateFile(\TYPO3\CMS\Core\Resource\AbstractFile $file, $identifier = '', $storage = NULL)
 {
     if ($identifier === '') {
         $identifier = $file->getIdentifier();
     }
     $fileInfo = $this->driver->getFileInfoByIdentifier($identifier);
     // TODO extend mapping
     $newProperties = array('storage' => $fileInfo['storage'], 'identifier' => $fileInfo['identifier'], 'tstamp' => $fileInfo['mtime'], 'crdate' => $fileInfo['ctime'], 'mime_type' => $fileInfo['mimetype'], 'size' => $fileInfo['size'], 'name' => $fileInfo['name']);
     if ($storage !== NULL) {
         $newProperties['storage'] = $storage->getUid();
     }
     $file->updateProperties($newProperties);
     /** @var $fileRepository \TYPO3\CMS\Core\Resource\FileRepository */
     $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
     $fileRepository->update($file);
 }
Example #6
0
 /**
  * Create a flash message for a file that is marked as missing
  *
  * @param \TYPO3\CMS\Core\Resource\AbstractFile $file
  * @return \TYPO3\CMS\Core\Messaging\FlashMessage
  */
 public static function getFlashMessageForMissingFile(\TYPO3\CMS\Core\Resource\AbstractFile $file)
 {
     /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
     $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing_text') . ' <abbr title="' . htmlspecialchars($file->getStorage()->getName() . ' :: ' . $file->getIdentifier()) . '">' . htmlspecialchars($file->getName()) . '</abbr>', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     return $flashMessage;
 }