本文整理匯總了PHP中TYPO3\CMS\Core\Resource\FileInterface::getExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileInterface::getExtension方法的具體用法?PHP FileInterface::getExtension怎麽用?PHP FileInterface::getExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Core\Resource\FileInterface
的用法示例。
在下文中一共展示了FileInterface::getExtension方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCroppedImageSrcByFile
/**
* Get the cropped image by File Object
*
* @param FileInterface $file
* @param string $ratio
*
* @return string The new filename
*/
public function getCroppedImageSrcByFile(FileInterface $file, $ratio)
{
$absoluteImageName = GeneralUtility::getFileAbsFileName($file->getPublicUrl());
$focusPointX = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_x'), -100, 100, 0);
$focusPointY = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_y'), -100, 100, 0);
$tempImageFolder = 'typo3temp/focuscrop/';
$tempImageName = $tempImageFolder . $file->getSha1() . '-' . str_replace(':', '-', $ratio) . '-' . $focusPointX . '-' . $focusPointY . '.' . $file->getExtension();
$absoluteTempImageName = GeneralUtility::getFileAbsFileName($tempImageName);
if (is_file($absoluteTempImageName)) {
return $tempImageName;
}
$absoluteTempImageFolder = GeneralUtility::getFileAbsFileName($tempImageFolder);
if (!is_dir($absoluteTempImageFolder)) {
GeneralUtility::mkdir_deep($absoluteTempImageFolder);
}
$this->graphicalFunctions = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
$imageSizeInformation = getimagesize($absoluteImageName);
$width = $imageSizeInformation[0];
$height = $imageSizeInformation[1];
// dimensions
/** @var \HDNET\Focuspoint\Service\DimensionService $service */
$dimensionService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\DimensionService');
list($focusWidth, $focusHeight) = $dimensionService->getFocusWidthAndHeight($width, $height, $ratio);
$cropMode = $dimensionService->getCropMode($width, $height, $ratio);
list($sourceX, $sourceY) = $dimensionService->calculateSourcePosition($cropMode, $width, $height, $focusWidth, $focusHeight, $focusPointX, $focusPointY);
// generate image
$sourceImage = $this->graphicalFunctions->imageCreateFromFile($absoluteImageName);
$destinationImage = imagecreatetruecolor($focusWidth, $focusHeight);
$this->graphicalFunctions->imagecopyresized($destinationImage, $sourceImage, 0, 0, $sourceX, $sourceY, $focusWidth, $focusHeight, $focusWidth, $focusHeight);
$this->graphicalFunctions->ImageWrite($destinationImage, $absoluteTempImageName, $GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality']);
return $tempImageName;
}
示例2: fileIsSelectableInFileList
/**
* Checks if the given file is selectable in the filelist.
*
* In "plain" RTE mode only image files with a maximum width and height are selectable.
*
* @param FileInterface $file
* @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
* @return bool TRUE if file is selectable.
*/
protected function fileIsSelectableInFileList(FileInterface $file, array $imgInfo)
{
return $this->mode !== 'plain' || GeneralUtility::inList(SelectImageController::PLAIN_MODE_IMAGE_FILE_EXTENSIONS, strtolower($file->getExtension())) && $imgInfo[0] <= $this->plainMaxWidth && $imgInfo[1] <= $this->plainMaxHeight;
}
示例3: canExtractText
/**
* Checks if the given file can be processed by this Extractor
*
* @param FileInterface $file
* @return bool
*/
public function canExtractText(FileInterface $file)
{
return in_array($file->getExtension(), $this->supportedFileTypes);
}
示例4: assureFileDeletePermissions
/**
* Assures delete permission for given file.
*
* @param FileInterface $file
* @return void
* @throws Exception\IllegalFileExtensionException
* @throws Exception\InsufficientFileWritePermissionsException
* @throws Exception\InsufficientFolderWritePermissionsException
*/
protected function assureFileDeletePermissions(FileInterface $file)
{
// Check for disallowed file extensions
if (!$this->checkFileExtensionPermission($file->getName())) {
throw new Exception\IllegalFileExtensionException('You are not allowed to delete a file with extension "' . $file->getExtension() . '"', 1377778916);
}
// Check further permissions if file is not a processed file
if (!$file instanceof ProcessedFile) {
// Check if user is allowed to delete the file and $file is writable
if (!$this->checkFileActionPermission('delete', $file)) {
throw new Exception\InsufficientFileWritePermissionsException('You are not allowed to delete the file "' . $file->getIdentifier() . '"', 1319550425);
}
// Check if the user has write permissions to folders
// Would be good if we could check for actual write permissions in the containig folder
// but we cannot since we have no access to the containing folder of this file.
if (!$this->checkUserActionPermission('write', 'Folder')) {
throw new Exception\InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377778702);
}
}
}
示例5: canRender
/**
* Check if given File(Reference) can be rendered
*
* @param FileInterface $file File of FileReference to render
* @return bool
*/
public function canRender(FileInterface $file)
{
return ($file->getMimeType() === 'video/vimeo' || $file->getExtension() === 'vimeo') && $this->getOnlineMediaHelper($file) !== false;
}
示例6: getTemporaryPathForFile
/**
* Returns a temporary path for a given file, including the file extension.
*
* @param \TYPO3\CMS\Core\Resource\FileInterface $file
* @return string
*/
protected function getTemporaryPathForFile(\TYPO3\CMS\Core\Resource\FileInterface $file)
{
return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-') . '.' . $file->getExtension();
}
示例7: getExtension
/**
* @return string
*/
public function getExtension()
{
return strtoupper($this->resource->getExtension());
}
示例8: fileIsSelectableInFileList
/**
* Checks if the given file is selectable in the file list.
*
* In "plain" RTE mode only image files with a maximum width and height are selectable.
*
* @param \TYPO3\CMS\Core\Resource\FileInterface $file
* @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
* @return bool TRUE if file is selectable.
*/
protected function fileIsSelectableInFileList(\TYPO3\CMS\Core\Resource\FileInterface $file, array $imgInfo)
{
return $this->act !== 'plain' || GeneralUtility::inList(self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS, strtolower($file->getExtension())) && $imgInfo[0] <= $this->plainMaxWidth && $imgInfo[1] <= $this->plainMaxHeight;
}
示例9: processImageCropResizeMask
/**
* This method actually does the processing of files locally
*
* takes the original file (on remote storages this will be fetched from the remote server)
* does the IM magic on the local server by creating a temporary typo3temp/ file
* copies the typo3temp/ file to the processingfolder of the target storage
* removes the typo3temp/ file
*
* @param \TYPO3\CMS\Core\Resource\ProcessedFile $processedFile
* @param \TYPO3\CMS\Core\Resource\FileInterface $file
* @param array $configuration
* @return void
*/
protected function processImageCropResizeMask(\TYPO3\CMS\Core\Resource\ProcessedFile $processedFile, \TYPO3\CMS\Core\Resource\FileInterface $file, array $configuration)
{
// checks to see if m (the mask array) is defined
$doMasking = is_array($configuration['maskImages']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'];
// @todo: is it ok that we use tslib (=FE) here?
/** @var $gifBuilder tslib_gifbuilder */
$gifBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_gifbuilder');
$gifBuilder->init();
// @todo: this is not clean yet
if (!trim($configuration['fileExtension'])) {
$configuration['fileExtension'] = 'web';
$targetFileExtension = $file->getExtension();
} elseif ($doMasking) {
$targetFileExtension = $file->getExtension() == $gifBuilder->gifExtension ? $gifBuilder->gifExtension : 'jpg';
} else {
$targetFileExtension = $configuration['fileExtension'];
}
$originalFileName = $file->getForLocalProcessing(FALSE);
$targetFolder = $this->storage->getProcessingFolder();
$targetFileName = 'previewcrm_' . $processedFile->calculateChecksum() . '.' . $targetFileExtension;
// @todo: implement meaningful TempFileIndex
if ($configuration['useSample']) {
$gifBuilder->scalecmd = '-sample';
}
$options = array();
if ($configuration['maxWidth']) {
$options['maxW'] = $configuration['maxWidth'];
}
if ($configuration['maxHeight']) {
$options['maxH'] = $configuration['maxHeight'];
}
if ($configuration['minWidth']) {
$options['minW'] = $configuration['minWidth'];
}
if ($configuration['minHeight']) {
$options['minH'] = $configuration['minHeight'];
}
$options['noScale'] = $configuration['noScale'];
$configuration['additionalParameters'] = $this->modifyImageMagickStripProfileParameters($configuration['additionalParameters'], $configuration);
// Do the actual processing
if (!$targetFolder->hasFile($targetFileName)) {
if (!$doMasking) {
// Normal situation (no masking)
// the result info is an array with 0=width,1=height,2=extension,3=filename
list($targetWidth, $targetHeight, $targetExtension, $temporaryFileName) = $gifBuilder->imageMagickConvert($originalFileName, $configuration['fileExtension'], $configuration['width'], $configuration['height'], $configuration['additionalParameters'], $configuration['frame'], $options);
} else {
$temporaryFileName = $gifBuilder->tempPath . $targetFileName;
$maskImage = $configuration['maskImages']['maskImage'];
$maskBackgroundImage = $configuration['maskImages']['backgroundImage'];
if ($maskImage instanceof \TYPO3\CMS\Core\Resource\FileInterface && $maskBackgroundImage instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
$negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : '';
$temporaryExtension = 'png';
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif']) {
// If ImageMagick version 5+
$temporaryExtension = $gifBuilder->gifExtension;
}
$tempFileInfo = $gifBuilder->imageMagickConvert($originalFileName, $temporaryExtension, $configuration['width'], $configuration['height'], $configuration['additionalParameters'], $configuration['frame'], $options);
if (is_array($tempFileInfo)) {
$maskBottomImage = $configuration['maskImages']['maskBottomImage'];
if ($maskBottomImage instanceof $maskBottomImage) {
$maskBottomImageMask = $configuration['maskImages']['maskBottomImageMask'];
}
// Scaling: ****
$tempScale = array();
$command = '-geometry ' . $tempFileInfo[0] . 'x' . $tempFileInfo[1] . '!';
$command = $this->modifyImageMagickStripProfileParameters($command, $configuration);
$tmpStr = $gifBuilder->randomName();
// m_mask
$tempScale['m_mask'] = $tmpStr . '_mask.' . $temporaryExtension;
$gifBuilder->imageMagickExec($maskImage->getForLocalProcessing(TRUE), $tempScale['m_mask'], $command . $negate);
// m_bgImg
$tempScale['m_bgImg'] = $tmpStr . '_bgImg.' . trim($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_noloss']);
$gifBuilder->imageMagickExec($maskBackgroundImage->getForLocalProcessing(), $tempScale['m_bgImg'], $command);
// m_bottomImg / m_bottomImg_mask
if ($maskBottomImage instanceof \TYPO3\CMS\Core\Resource\FileInterface && $maskBottomImageMask instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
$tempScale['m_bottomImg'] = $tmpStr . '_bottomImg.' . $temporaryExtension;
$gifBuilder->imageMagickExec($maskBottomImage->getForLocalProcessing(), $tempScale['m_bottomImg'], $command);
$tempScale['m_bottomImg_mask'] = $tmpStr . '_bottomImg_mask.' . $temporaryExtension;
$gifBuilder->imageMagickExec($maskBottomImageMask->getForLocalProcessing(), $tempScale['m_bottomImg_mask'], $command . $negate);
// BEGIN combining:
// The image onto the background
$gifBuilder->combineExec($tempScale['m_bgImg'], $tempScale['m_bottomImg'], $tempScale['m_bottomImg_mask'], $tempScale['m_bgImg']);
}
// The image onto the background
$gifBuilder->combineExec($tempScale['m_bgImg'], $tempFileInfo[3], $tempScale['m_mask'], $temporaryFileName);
// Unlink the temp-images...
foreach ($tempScale as $file) {
//.........這裏部分代碼省略.........
示例10: isAllowed
/**
* Checks whether a file is allowed according to the criteria defined in the class variables ($this->allowedFileExtensions etc.)
*
* @param \TYPO3\CMS\Core\Resource\FileInterface $file
* @return boolean
*/
protected function isAllowed(\TYPO3\CMS\Core\Resource\FileInterface $file)
{
$result = TRUE;
$fileExt = $file->getExtension();
// Check allowed file extensions
if ($this->allowedFileExtensions !== NULL && count($this->allowedFileExtensions) > 0 && !in_array($fileExt, $this->allowedFileExtensions)) {
$result = FALSE;
}
// Check disallowed file extensions
if ($this->disallowedFileExtensions !== NULL && count($this->disallowedFileExtensions) > 0 && in_array($fileExt, $this->disallowedFileExtensions)) {
$result = FALSE;
}
return $result;
}