本文整理汇总了PHP中TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceFactory::retrieveFileOrFolderObject方法的具体用法?PHP ResourceFactory::retrieveFileOrFolderObject怎么用?PHP ResourceFactory::retrieveFileOrFolderObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\ResourceFactory
的用法示例。
在下文中一共展示了ResourceFactory::retrieveFileOrFolderObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importUploadedResource
/**
* 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;
}
示例2: retrieveFileOrFolderObjectReturnsFileIfPathIsGiven
/**
* @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);
}
示例3: showAction
/**
* @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);
}
}
}
示例4: searchAction
/**
* 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']));
}
示例5: makeClip
/**
* 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>';
}
示例6: getFileObject
/**
* 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;
}
示例7: getFileObject
/**
* 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;
}
示例8: makeClip
/**
* 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>';
}