/**
  * Import a resource and respect configuration given for properties
  *
  * @param array $uploadInfo
  * @param PropertyMappingConfigurationInterface $configuration
  * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
  * @throws TypeConverterException
  * @throws ExistingTargetFileNameException
  */
 protected function importUploadedResource(array $uploadInfo, PropertyMappingConfigurationInterface $configuration)
 {
     if (!GeneralUtility::verifyFilenameAgainstDenyPattern($uploadInfo['name'])) {
         throw new TypeConverterException('Uploading files with PHP file extensions is not allowed!', 1399312430);
     }
     $allowedFileExtensions = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_ALLOWED_EXTENSIONS);
     if ($allowedFileExtensions !== null) {
         $filePathInfo = PathUtility::pathinfo($uploadInfo['name']);
         if (!GeneralUtility::inList($allowedFileExtensions, strtolower($filePathInfo['extension']))) {
             throw new TypeConverterException('File extension is not allowed!', 1399312430);
         }
     }
     $uploadFolderId = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_UPLOAD_FOLDER) ?: $this->defaultUploadFolder;
     $conflictMode = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_UPLOAD_CONFLICT_MODE) ?: $this->defaultConflictMode;
     $uploadFolder = $this->resourceFactory->retrieveFileOrFolderObject($uploadFolderId);
     $uploadedFile = $uploadFolder->addUploadedFile($uploadInfo, $conflictMode);
     $resourcePointer = null;
     if (isset($uploadInfo['submittedFile']['resourcePointer'])) {
         $submittedResourcePointer = $uploadInfo['submittedFile']['resourcePointer'];
         if (strpos($uploadInfo['submittedFile']['resourcePointer'], 'file:') === false) {
             $resourcePointer = $this->hashService->validateAndStripHmac($submittedResourcePointer);
         }
     }
     $fileReferenceModel = $this->createFileReferenceFromFalFileObject($uploadedFile, $resourcePointer);
     return $fileReferenceModel;
 }
Exemplo n.º 2
0
 /**
  * Import a resource and respect configuration given for properties
  *
  * @param array $uploadInfo
  * @param PropertyMappingConfigurationInterface $configuration
  * @return ExtbaseFileReference
  * @throws TypeConverterException
  */
 protected function importUploadedResource(array $uploadInfo, PropertyMappingConfigurationInterface $configuration) : ExtbaseFileReference
 {
     if (!GeneralUtility::verifyFilenameAgainstDenyPattern($uploadInfo['name'])) {
         throw new TypeConverterException('Uploading files with PHP file extensions is not allowed!', 1471710357);
     }
     $uploadFolderId = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_UPLOAD_FOLDER) ?: $this->defaultUploadFolder;
     $conflictMode = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_UPLOAD_CONFLICT_MODE) ?: $this->defaultConflictMode;
     $uploadFolder = $this->resourceFactory->retrieveFileOrFolderObject($uploadFolderId);
     $uploadedFile = $uploadFolder->addUploadedFile($uploadInfo, $conflictMode);
     $validators = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_FILE_VALIDATORS);
     if (is_array($validators)) {
         foreach ($validators as $validator) {
             if ($validator instanceof AbstractValidator) {
                 $validationResult = $validator->validate($uploadedFile);
                 if ($validationResult->hasErrors()) {
                     $uploadedFile->getStorage()->deleteFile($uploadedFile);
                     throw new TypeConverterException($validationResult->getErrors()[0]->getMessage(), 1471708999);
                 }
             }
         }
     }
     $resourcePointer = isset($uploadInfo['submittedFile']['resourcePointer']) && strpos($uploadInfo['submittedFile']['resourcePointer'], 'file:') === false ? $this->hashService->validateAndStripHmac($uploadInfo['submittedFile']['resourcePointer']) : null;
     $fileReferenceModel = $this->createFileReferenceFromFalFileObject($uploadedFile, $resourcePointer);
     return $fileReferenceModel;
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function retrieveFileOrFolderObjectReturnsFileIfPathIsGiven()
 {
     $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class, array('getFileObjectFromCombinedIdentifier'), array(), '', false);
     $filename = 'typo3temp/4711.txt';
     $this->subject->expects($this->once())->method('getFileObjectFromCombinedIdentifier')->with($filename);
     // Create and prepare test file
     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filename, '42');
     $this->filesCreated[] = PATH_site . $filename;
     $this->subject->retrieveFileOrFolderObject($filename);
 }
Exemplo n.º 4
0
	/**
	 * Get File or FileReference object by src
	 *
	 * @param string $src
	 * @param bool $treatIdAsReference
	 * @return FileInterface|FileReference|\TYPO3\CMS\Core\Resource\Folder
	 */
	protected function getImageFromSourceString($src, $treatIdAsReference) {
		if ($this->environmentService->isEnvironmentInBackendMode() && substr($src, 0, 3) === '../') {
			$src = substr($src, 3);
		}
		if (MathUtility::canBeInterpretedAsInteger($src)) {
			if ($treatIdAsReference) {
				$image = $this->resourceFactory->getFileReferenceObject($src);
			} else {
				$image = $this->resourceFactory->getFileObject($src);
			}
		} else {
			// We have a combined identifier or legacy (storage 0) path
			$image = $this->resourceFactory->retrieveFileOrFolderObject($src);
		}
		return $image;
	}
Exemplo n.º 5
0
 /**
  * @param File $image
  * @return string
  */
 public function showAction(File $image = null)
 {
     if ($this->configurationInvalid) {
         return $this->getErrorMessageForActionName('Show');
     }
     // when this plugin is standalone or no image has been selected in the list view
     if ($image === null) {
         $image = $this->resourceFactory->retrieveFileOrFolderObject($this->settings['default']['image']);
     }
     if ($image instanceof File) {
         $this->view->assign('image', $image);
         $localCopy = $image->getForLocalProcessing();
         if ($this->settings['show']['exif'] && function_exists('exif_read_data') && function_exists('exif_imagetype') && exif_imagetype($localCopy)) {
             $this->view->assign('exifInformation', exif_read_data($localCopy, '', true));
             unlink($localCopy);
         }
     }
 }
 /**
  * Show search form
  *
  * @return void
  */
 public function searchAction()
 {
     // Get $_GET parameters
     $arguments = $this->request->getArguments();
     // Create record management object
     $recordManagement = $this->objectManager->create('Frohland\\Ezqueries\\Domain\\Model\\RecordManagement', $this->recordManagementRepository, 'search');
     // Set Table names
     $recordManagement->setTableNames(explode(',', $this->settings['tables']));
     // Set column types
     $recordManagement->setColumnTypes($this->settings);
     // Set selected columns
     $fullTextSearch = $recordManagement->setSelectedColumns($this->settings, $arguments);
     $this->view->assign('fullTextSearch', $fullTextSearch);
     // Set filter arguments
     if (isset($arguments['filters'])) {
         $filters = $arguments['filters'];
     } else {
         $filters = array();
     }
     $recordManagement->getConditions()->setFilters($filters);
     // Assign record management to view
     $this->view->assign('recordManagement', $recordManagement);
     // Show close link?
     $this->view->assign('showCloseLink', $this->settings['showCloseLinkSearch']);
     // Use custom search template? -> assign template to view
     if ($this->settings['useSearchTemplate']) {
         if ($this->settings['searchTemplateFile']) {
             $template = $this->resourceFactory->retrieveFileOrFolderObject($this->settings['searchTemplateFile'])->getContents();
         } else {
             $template = $this->settings['searchTemplate'];
         }
         $this->view->assign('template', $template);
     }
     $this->view->assign('useTemplate', $this->settings['useSearchTemplate']);
     // Assign headline to view
     $languageUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\LanguageUtility');
     $this->view->assign('headline', $languageUtility->translateValue($this->settings['headlineSearch']));
     // Assign additional text to view
     $this->view->assign('textTop', $languageUtility->translateValue($this->settings['additionalTextTopSearch']));
     $this->view->assign('textBottom', $languageUtility->translateValue($this->settings['additionalTextBottomSearch']));
 }
Exemplo n.º 7
0
 /**
  * Creates the clipboard control pad
  *
  * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
  * @return string HTML-table
  */
 public function makeClip($fileOrFolderObject)
 {
     if (!$fileOrFolderObject->checkActionPermission('read')) {
         return '';
     }
     $cells = array();
     $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
     $fullName = $fileOrFolderObject->getName();
     $md5 = GeneralUtility::shortmd5($fullIdentifier);
     // For normal clipboard, add copy/cut buttons:
     if ($this->clipObj->current == 'normal') {
         $isSel = $this->clipObj->isSelected('_FILE', $md5);
         $cells[] = '<a class="btn btn-default"" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 1, $isSel == 'copy')) . '">' . IconUtility::getSpriteIcon('actions-edit-copy' . ($isSel == 'copy' ? '-release' : ''), array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE))) . '</a>';
         // we can only cut if file can be moved
         if ($fileOrFolderObject->checkActionPermission('move')) {
             $cells[] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 0, $isSel == 'cut')) . '">' . IconUtility::getSpriteIcon('actions-edit-cut' . ($isSel == 'cut' ? '-release' : ''), array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE))) . '</a>';
         } else {
             $cells[] = $this->spaceIcon;
         }
     } else {
         // For numeric pads, add select checkboxes:
         $n = '_FILE|' . $md5;
         $this->CBnames[] = $n;
         $checked = $this->clipObj->isSelected('_FILE', $md5) ? ' checked="checked"' : '';
         $cells[] = '<label class="btn btn-default btn-checkbox"><input type="hidden" name="CBH[' . $n . ']" value="0" /><input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" ' . $checked . ' /><span class="t3-icon fa"></span></label>';
     }
     // Display PASTE button, if directory:
     $elFromTable = $this->clipObj->elFromTable('_FILE');
     if ($fileOrFolderObject instanceof Folder && !empty($elFromTable) && $fileOrFolderObject->checkActionPermission('write')) {
         $addPasteButton = TRUE;
         $elToConfirm = array();
         foreach ($elFromTable as $key => $element) {
             $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element);
             if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $fileOrFolderObject)) {
                 $addPasteButton = FALSE;
             }
             $fileInfo = $clipBoardElement->getStorage()->getFileInfoByIdentifier(substr(strstr($element, ':'), 1));
             $elToConfirm[$key] = $fileInfo['name'];
         }
         if ($addPasteButton) {
             $cells[] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $fullIdentifier)) . '" onclick="return ' . htmlspecialchars($this->clipObj->confirmMsg('_FILE', $fullName, 'into', $elToConfirm)) . '" title="' . $this->getLanguageService()->getLL('clip_pasteInto', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-paste-into') . '</a>';
         }
     }
     // Compile items into a DIV-element:
     return ' <div class="btn-group" role="group">' . implode('', $cells) . '</div>';
 }
Exemplo n.º 8
0
 /**
  * Gets a File or a Folder object from an identifier [storage]:[fileId]
  *
  * @param string $identifier
  * @return \TYPO3\CMS\Core\Resource\Folder|\TYPO3\CMS\Core\Resource\File
  * @throws \TYPO3\CMS\Core\Resource\Exception\InvalidFileException
  */
 protected function getFileObject($identifier)
 {
     $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
     if (!is_object($object)) {
         throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileException('The item ' . $identifier . ' was not a file or directory!!', 1320122453);
     }
     if ($object->getStorage()->getUid() === 0) {
         throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889830);
     }
     return $object;
 }
 /**
  * Gets a File or a Folder object from an identifier [storage]:[fileId]
  *
  * @param string $identifier
  * @return \TYPO3\CMS\Core\Resource\Folder|\TYPO3\CMS\Core\Resource\File
  */
 protected function getFileObject($identifier)
 {
     $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
     if (!is_object($object)) {
         throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileException('The item ' . $identifier . ' was not a file or directory!!', 1320122453);
     }
     return $object;
 }
Exemplo n.º 10
0
    /**
     * Creates the clipboard control pad
     *
     * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
     * @return string HTML-table
     * @todo Define visibility
     */
    public function makeClip($fileOrFolderObject)
    {
        if (!$fileOrFolderObject->checkActionPermission('read')) {
            return '';
        }
        $cells = array();
        $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
        $md5 = GeneralUtility::shortmd5($fullIdentifier);
        // For normal clipboard, add copy/cut buttons:
        if ($this->clipObj->current == 'normal') {
            $isSel = $this->clipObj->isSelected('_FILE', $md5);
            $cells[] = '<a href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 1, $isSel == 'copy')) . '">' . IconUtility::getSpriteIcon('actions-edit-copy' . ($isSel == 'copy' ? '-release' : ''), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE))) . '</a>';
            // we can only cut if file can be moved
            if ($fileOrFolderObject->checkActionPermission('move')) {
                $cells[] = '<a href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 0, $isSel == 'cut')) . '">' . IconUtility::getSpriteIcon('actions-edit-cut' . ($isSel == 'cut' ? '-release' : ''), array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE))) . '</a>';
            } else {
                $cells[] = IconUtility::getSpriteIcon('empty-empty');
            }
        } else {
            // For numeric pads, add select checkboxes:
            $n = '_FILE|' . $md5;
            $this->CBnames[] = $n;
            $checked = $this->clipObj->isSelected('_FILE', $md5) ? ' checked="checked"' : '';
            $cells[] = '<input type="hidden" name="CBH[' . $n . ']" value="0" />' . '<input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" class="smallCheckboxes"' . $checked . ' />';
        }
        // Display PASTE button, if directory:
        $elFromTable = $this->clipObj->elFromTable('_FILE');
        if (is_a($fileOrFolderObject, 'TYPO3\\CMS\\Core\\Resource\\Folder') && count($elFromTable) && $fileOrFolderObject->checkActionPermission('write')) {
            $addPasteButton = TRUE;
            foreach ($elFromTable as $element) {
                $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element);
                if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $fileOrFolderObject)) {
                    $addPasteButton = FALSE;
                }
            }
            if ($addPasteButton) {
                $cells[] = '<a class="btn" href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $fullIdentifier)) . '" onclick="return ' . htmlspecialchars($this->clipObj->confirmMsg('_FILE', $fullIdentifier, 'into', $elFromTable)) . '" title="' . $GLOBALS['LANG']->getLL('clip_pasteInto', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-paste-into') . '</a>';
            }
        }
        // Compile items into a DIV-element:
        return '							<!-- CLIPBOARD PANEL: -->
											<div class="typo3-clipCtrl">
												' . implode('
												', $cells) . '
											</div>';
    }
Exemplo n.º 11
0
 /**
  * Creates the clipboard control pad
  *
  * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
  * @return string HTML-table
  */
 public function makeClip($fileOrFolderObject)
 {
     if (!$fileOrFolderObject->checkActionPermission('read')) {
         return '';
     }
     $cells = [];
     $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
     $fullName = $fileOrFolderObject->getName();
     $md5 = GeneralUtility::shortMD5($fullIdentifier);
     // For normal clipboard, add copy/cut buttons:
     if ($this->clipObj->current === 'normal') {
         $isSel = $this->clipObj->isSelected('_FILE', $md5);
         $copyTitle = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.copy'));
         $cutTitle = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut'));
         $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render();
         $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL)->render();
         if ($isSel === 'copy') {
             $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL)->render();
         } elseif ($isSel === 'cut') {
             $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL)->render();
         }
         $cells[] = '<a class="btn btn-default"" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 1, $isSel === 'copy')) . '" title="' . $copyTitle . '">' . $copyIcon . '</a>';
         // we can only cut if file can be moved
         if ($fileOrFolderObject->checkActionPermission('move')) {
             $cells[] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 0, $isSel === 'cut')) . '" title="' . $cutTitle . '">' . $cutIcon . '</a>';
         } else {
             $cells[] = $this->spaceIcon;
         }
     } else {
         // For numeric pads, add select checkboxes:
         $n = '_FILE|' . $md5;
         $this->CBnames[] = $n;
         $checked = $this->clipObj->isSelected('_FILE', $md5) ? ' checked="checked"' : '';
         $cells[] = '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" ' . $checked . ' /><span class="t3-icon fa"></span></label>';
     }
     // Display PASTE button, if directory:
     $elFromTable = $this->clipObj->elFromTable('_FILE');
     if ($fileOrFolderObject instanceof Folder && !empty($elFromTable) && $fileOrFolderObject->checkActionPermission('write')) {
         $addPasteButton = true;
         $elToConfirm = [];
         foreach ($elFromTable as $key => $element) {
             $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element);
             if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $fileOrFolderObject)) {
                 $addPasteButton = false;
             }
             $elToConfirm[$key] = $clipBoardElement->getName();
         }
         if ($addPasteButton) {
             $cells[] = '<a class="btn btn-default t3js-modal-trigger" ' . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $fullIdentifier)) . '"' . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText('_FILE', $fullName, 'into', $elToConfirm)) . '"' . ' data-severity="warning"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . '>' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
         }
     }
     // Compile items into a DIV-element:
     return ' <div class="btn-group" role="group">' . implode('', $cells) . '</div>';
 }