本文整理汇总了PHP中TYPO3\CMS\Core\Resource\File类的典型用法代码示例。如果您正苦于以下问题:PHP File类的具体用法?PHP File怎么用?PHP File使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* renders <f:then> child if the current logged in FE user has access to the given asset
* otherwise renders <f:else> child.
*
* @param Folder $folder
* @param File $file
* @return bool|string
*/
public function render(Folder $folder, File $file = NULL)
{
/** @var $checkPermissionsService \BeechIt\FalSecuredownload\Security\CheckPermissions */
$checkPermissionsService = GeneralUtility::makeInstance('BeechIt\\FalSecuredownload\\Security\\CheckPermissions');
$userFeGroups = $this->getFeUserGroups();
$access = FALSE;
// check folder access
if ($checkPermissionsService->checkFolderRootLineAccess($folder, $userFeGroups)) {
if ($file === NULL) {
$access = TRUE;
} else {
$feGroups = $file->getProperty('fe_groups');
if ($feGroups !== '') {
$access = $checkPermissionsService->matchFeGroupsWithFeUser($feGroups, $userFeGroups);
} else {
$access = TRUE;
}
}
}
if ($access) {
return $this->renderThenChild();
} else {
return $this->renderElseChild();
}
}
示例2: getUri
/**
* @param File $file
* @return string
*/
protected function getUri(File $file)
{
$metadataProperties = $file->_getMetaData();
$parameterName = sprintf('edit[sys_file_metadata][%s]', $metadataProperties['uid']);
$uri = BackendUtility::getModuleUrl('record_edit', array($parameterName => 'edit', 'returnUrl' => BackendUtility::getModuleUrl(GeneralUtility::_GP('M'), $this->getAdditionalParameters())));
return $uri;
}
示例3: renderFileInformationContent
/**
* Renders a HTML Block with file information
*
* @param File $file
* @return string
*/
protected function renderFileInformationContent(File $file = null)
{
/** @var LanguageService $lang */
$lang = $GLOBALS['LANG'];
if ($file !== null) {
$processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 150, 'height' => 150));
$previewImage = $processedFile->getPublicUrl(true);
$content = '';
if ($file->isMissing()) {
$flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($file);
$content .= $flashMessage->render();
}
if ($previewImage) {
$content .= '<img src="' . htmlspecialchars($previewImage) . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="" class="t3-tceforms-sysfile-imagepreview" />';
}
$content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
$content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
$content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
$content .= $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', true) . ': ';
$content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
$content .= '<br />';
} else {
$content = '<h2>' . $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', true) . '</h2>';
}
return $content;
}
示例4: canProcess
/**
* Checks if the given file can be processed by this Extractor
*
* @param Resource\File $file
* @return boolean
*/
public function canProcess(Resource\File $file)
{
// TODO use MIME type instead of extension
// tika.jar --list-supported-types -> cache supported types
// compare to file's MIME type
return in_array($file->getProperty('extension'), $this->supportedFileTypes);
}
示例5: storageIsNotAskedForMimeTypeForPersistedRecord
/**
* This test accounts for an inconsistency in the Storage–Driver interface of FAL: The driver returns the MIME
* type in a field "mimetype", while the file object and the database table use mime_type.
* The test is placed in the test case for AbstractFile because the broken functionality resides there, though
* it is only triggered when constructing a File instance with an index record.
*
* @test
*/
public function storageIsNotAskedForMimeTypeForPersistedRecord()
{
$mockedStorage = $this->getMockBuilder('TYPO3\\CMS\\Core\\Resource\\ResourceStorage')->disableOriginalConstructor()->getMock();
$mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
$subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
$this->assertEquals('my/mime-type', $subject->getMimeType());
}
示例6: getOnlineMediaId
/**
* Get Online Media item id
*
* @param File $file
* @return string
*/
public function getOnlineMediaId(File $file)
{
if (!isset($this->onlineMediaIdCache[$file->getUid()])) {
// By definition these files only contain the ID of the remote media source
$this->onlineMediaIdCache[$file->getUid()] = trim($file->getContents());
}
return $this->onlineMediaIdCache[$file->getUid()];
}
示例7: getOnlineMediaHelper
/**
* Get helper class for given File
*
* @param File $file
* @return bool|OnlineMediaHelperInterface
*/
public function getOnlineMediaHelper(File $file)
{
$registeredHelpers = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers'];
if (isset($registeredHelpers[$file->getExtension()])) {
return GeneralUtility::makeInstance($registeredHelpers[$file->getExtension()], $file->getExtension());
}
return false;
}
示例8: storageIsNotAskedForMimeTypeForPersistedRecord
/**
* This test accounts for an inconsistency in the Storage–Driver interface of FAL: The driver returns the MIME
* type in a field "mimetype", while the file object and the database table use mime_type.
* The test is placed in the test case for AbstractFile because the broken functionality resides there, though
* it is only triggered when constructing a File instance with an index record.
*
* @test
*/
public function storageIsNotAskedForMimeTypeForPersistedRecord()
{
/** @var ResourceStorage|\PHPUnit_Framework_MockObject_MockObject $mockedStorage */
$mockedStorage = $this->getMockBuilder(ResourceStorage::class)->disableOriginalConstructor()->getMock();
$mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
$subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
$this->assertEquals('my/mime-type', $subject->getMimeType());
}
示例9: getDefaultTemplate
/**
* Returns a default template.
*
* @param File $file
* @return string
*/
protected function getDefaultTemplate(File $file)
{
$template = '%size Ko';
if ($file->getType() == File::FILETYPE_IMAGE) {
$template = '%width x %height - ' . $template;
}
return $template;
}
示例10: setUp
/**
* Sets up this test case.
*/
protected function setUp()
{
$this->fileResourceMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array('toArray', 'getModificationTime', 'getExtension'), array(), '', FALSE);
$this->folderResourceMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array('getIdentifier'), array(), '', FALSE);
$this->mockFileProcessor = $this->getMock('TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtility', array('getErrorMessages'), array(), '', FALSE);
$this->fileResourceMock->expects($this->any())->method('toArray')->will($this->returnValue(array('id' => 'foo')));
$this->fileResourceMock->expects($this->any())->method('getModificationTime')->will($this->returnValue(123456789));
$this->fileResourceMock->expects($this->any())->method('getExtension')->will($this->returnValue('html'));
}
示例11: setUp
/**
* Sets up this test case.
*/
protected function setUp()
{
$this->fileResourceMock = $this->getMock(\TYPO3\CMS\Core\Resource\File::class, array('toArray', 'getModificationTime', 'getExtension'), array(), '', false);
$this->folderResourceMock = $this->getMock(\TYPO3\CMS\Core\Resource\Folder::class, array('getIdentifier'), array(), '', false);
$this->mockFileProcessor = $this->getMock(\TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::class, array('getErrorMessages'), array(), '', false);
$this->fileResourceMock->expects($this->any())->method('toArray')->will($this->returnValue(array('id' => 'foo')));
$this->fileResourceMock->expects($this->any())->method('getModificationTime')->will($this->returnValue(123456789));
$this->fileResourceMock->expects($this->any())->method('getExtension')->will($this->returnValue('html'));
$this->request = new ServerRequest();
$this->response = new Response();
}
示例12: extractMetaData
/**
* Takes a file reference and extracts its meta data.
*
* @param \TYPO3\CMS\Core\Resource\File $file
* @return array
*/
public function extractMetaData(File $file)
{
$localTempFilePath = $file->getForLocalProcessing(FALSE);
$query = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Tika\\Service\\Tika\\SolrCellQuery', $localTempFilePath);
$query->setExtractOnly();
$response = $this->solr->extract($query);
$metaData = $this->solrResponseToArray($response[1]);
$this->cleanupTempFile($localTempFilePath, $file);
$this->log('Meta Data Extraction using Solr', array('file' => $file, 'solr connection' => (array) $this->solr, 'query' => (array) $query, 'response' => $response, 'meta data' => $metaData));
return $metaData;
}
示例13: getFileArray
/**
* Fixes a bug in TYPO3 6.2.0 that the properties metadata is not overlayed on localization.
*
* @param File $file
* @return array
*/
public static function getFileArray(File $file)
{
$properties = $file->getProperties();
$stat = $file->getStorage()->getFileInfo($file);
$array = $file->toArray();
foreach ($properties as $key => $value) {
$array[$key] = $value;
}
foreach ($stat as $key => $value) {
$array[$key] = $value;
}
return $array;
}
示例14: createProcessedThumbnail
/**
* Resize image and garantees a minimum size for each dimension
* @param File $file
* @return File|ProcessedFile
*/
public function createProcessedThumbnail(File $file)
{
$minSize = 84;
$width = (int) $file->getProperty('width');
$height = (int) $file->getProperty('height');
$ratio = $width / $height;
if ($width > $height) {
$configuration = ['maxWidth' => ceil($minSize * $ratio), 'height' => $minSize];
} else {
$configuration = ['width' => $minSize, 'maxHeight' => ceil($minSize / $ratio)];
}
$file = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $configuration);
return $file;
}
示例15: createMagicImage
/**
* Creates a magic image
*
* @param Resource\File $imageFileObject: the original image file
* @param array $fileConfiguration (width, height)
* @return Resource\ProcessedFile
*/
public function createMagicImage(Resource\File $imageFileObject, array $fileConfiguration)
{
// Process dimensions
$maxWidth = MathUtility::forceIntegerInRange($fileConfiguration['width'], 0, $this->magicImageMaximumWidth);
$maxHeight = MathUtility::forceIntegerInRange($fileConfiguration['height'], 0, $this->magicImageMaximumHeight);
if (!$maxWidth) {
$maxWidth = $this->magicImageMaximumWidth;
}
if (!$maxHeight) {
$maxHeight = $this->magicImageMaximumHeight;
}
// Create the magic image
$magicImage = $imageFileObject->process(Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, array('width' => $maxWidth . 'm', 'height' => $maxHeight . 'm'));
return $magicImage;
}