本文整理汇总了PHP中TYPO3\CMS\Core\Resource\FileInterface::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP FileInterface::getType方法的具体用法?PHP FileInterface::getType怎么用?PHP FileInterface::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\FileInterface
的用法示例。
在下文中一共展示了FileInterface::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processImagePreview
/**
* 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 processImagePreview(\TYPO3\CMS\Core\Resource\ProcessedFile $processedFile, \TYPO3\CMS\Core\Resource\FileInterface $file, array $configuration)
{
// Merge custom configuration with default configuration
$configuration = array_merge(array('width' => 64, 'height' => 64), $configuration);
$configuration['width'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
$configuration['height'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($configuration['height'], 1, 1000);
$originalFileName = $file->getForLocalProcessing(FALSE);
// Create a temporary file in typo3temp/
if ($file->getExtension() === 'jpg') {
$targetFileExtension = '.jpg';
} else {
$targetFileExtension = '.png';
}
$targetFolder = $this->storage->getProcessingFolder();
$targetFileName = 'preview_' . $processedFile->calculateChecksum() . $targetFileExtension;
// Do the actual processing
if (!$targetFolder->hasFile($targetFileName)) {
// Create the thumb filename in typo3temp/preview_....jpg
$temporaryFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('preview_') . $targetFileExtension;
// Check file extension
if ($file->getType() != $file::FILETYPE_IMAGE && !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $file->getExtension())) {
// Create a default image
$this->getTemporaryImageWithText($temporaryFileName, 'Not imagefile!', 'No ext!', $file->getName());
} else {
// Create the temporary file
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
$parameters = '-sample ' . $configuration['width'] . 'x' . $configuration['height'] . ' ' . $this->wrapFileName($originalFileName) . '[0] ' . $this->wrapFileName($temporaryFileName);
$cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::imageMagickCommand('convert', $parameters);
\TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd);
if (!file_exists($temporaryFileName)) {
// Create a error gif
$this->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', $file->getName());
}
}
}
// Temporary image could have been created
if (file_exists($temporaryFileName)) {
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($temporaryFileName);
// Copy the temporary file to the processedFolder
// this is done here, as the driver can do this without worrying
// about existing ProcessedFile objects
// or permissions in the storage
// for "remote" storages this means "uploading" the file to the storage again
// for the virtual storage, it is merely a thing of "copying a file from typo3temp/ to typo3temp/_processed_"
$this->driver->addFile($temporaryFileName, $targetFolder, $targetFileName, $processedFile);
// Remove the temporary file as it's not needed anymore
\TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($temporaryFileName);
$processedFile->setProcessed(TRUE);
}
} else {
// the file already exists, nothing to do locally, but still mark the file as processed and save the data
// and update the fields, as they might have not been set
if ($processedFile->getProperty('identifier') == '') {
$identifier = $targetFolder->getIdentifier() . $targetFileName;
$processedFile->updateProperties(array('name' => $targetFileName, 'identifier' => $identifier));
}
$processedFile->setProcessed(TRUE);
}
}