/**
  * Loads index-data into processedFileObject
  *
  * @param \TYPO3\CMS\Core\Resource\ProcessedFile $processedFileObject
  * @return boolean
  */
 public function populateDataOfProcessedFileObject(\TYPO3\CMS\Core\Resource\ProcessedFile $processedFileObject)
 {
     /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
     $recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->table, 'original=' . intval($processedFileObject->getOriginalFile()->getUid()) . ' AND checksum=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($processedFileObject->calculateChecksum(), $this->table) . ' AND deleted=0');
     // Update the properties if the data was found
     if (is_array($recordData)) {
         $processedFileObject->updateProperties($recordData);
         return TRUE;
     } else {
         return FALSE;
     }
 }
Example #2
0
 /**
  * Sets parameters needed in the checksum. Can be overridden to add additional parameters to the checksum.
  * This should include all parameters that could possibly vary between different task instances, e.g. the
  * TYPO3 image configuration in TYPO3_CONF_VARS[GFX] for graphic processing tasks.
  *
  * @return array
  */
 protected function getChecksumData()
 {
     return array($this->targetFile->getOriginalFile()->getUid(), $this->getType() . '.' . $this->getName(), serialize($this->configuration));
 }
 /**
  * @param ProcessedFile $processedFile
  * @param string $prefix
  * @return string
  */
 protected function getTargetFileName(ProcessedFile $processedFile, $prefix = 'preview_')
 {
     return $prefix . $processedFile->getTask()->getConfigurationChecksum() . '_' . $processedFile->getOriginalFile()->getNameWithoutExtension() . '.jpg';
 }
Example #4
0
 /**
  * Calculates the compatibility values
  * This is duplicate code taken from ContentObjectRenderer::getImgResource()
  * Ideally we should get rid of this code in both places.
  *
  * @param ProcessedFile $processedImage
  * @return array
  */
 protected function getCompatibilityImageResourceValues(ProcessedFile $processedImage)
 {
     $hash = $processedImage->calculateChecksum();
     if (isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) {
         $compatibilityImageResourceValues = $GLOBALS['TSFE']->tmpl->fileCache[$hash];
     } else {
         $compatibilityImageResourceValues = array(0 => $processedImage->getProperty('width'), 1 => $processedImage->getProperty('height'), 2 => $processedImage->getExtension(), 3 => $processedImage->getPublicUrl(), 'origFile' => $processedImage->getOriginalFile()->getPublicUrl(), 'origFile_mtime' => $processedImage->getOriginalFile()->getModificationTime(), 'originalFile' => $processedImage->getOriginalFile(), 'processedFile' => $processedImage, 'fileCacheHash' => $hash);
     }
     return $compatibilityImageResourceValues;
 }
Example #5
0
 /**
  * @param Resource\ProcessedFile $targetFile
  * @param array $configuration
  */
 public function __construct(Resource\ProcessedFile $targetFile, array $configuration)
 {
     $this->targetFile = $targetFile;
     $this->sourceFile = $targetFile->getOriginalFile();
     $this->configuration = $configuration;
 }
Example #6
0
 /**
  * Updates a processed file with a new file from the local filesystem.
  *
  * @param string $localFilePath
  * @param ProcessedFile $processedFile
  * @param Folder $processingFolder
  * @return FileInterface
  * @throws \InvalidArgumentException
  * @internal use only
  */
 public function updateProcessedFile($localFilePath, ProcessedFile $processedFile, Folder $processingFolder = null)
 {
     if (!file_exists($localFilePath)) {
         throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552746);
     }
     if ($processingFolder === null) {
         $processingFolder = $this->getProcessingFolder($processedFile->getOriginalFile());
     }
     $fileIdentifier = $this->driver->addFile($localFilePath, $processingFolder->getIdentifier(), $processedFile->getName());
     // @todo check if we have to update the processed file other then the identifier
     $processedFile->setIdentifier($fileIdentifier);
     return $processedFile;
 }
Example #7
0
	/**
	 * Calculates the compatibility values
	 * This is duplicate code taken from ContentObjectRenderer::getImgResource()
	 * Ideally we should get rid of this code in both places.
	 *
	 * @param ProcessedFile $processedImage
	 * @return array
	 */
	protected function getCompatibilityImageResourceValues(ProcessedFile $processedImage) {
		$hash = $processedImage->calculateChecksum();
		if (isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) {
			$compatibilityImageResourceValues = $GLOBALS['TSFE']->tmpl->fileCache[$hash];
		} else {
			$compatibilityImageResourceValues = array(
				0 => $processedImage->getProperty('width'),
				1 => $processedImage->getProperty('height'),
				2 => $processedImage->getExtension(),
				3 => $processedImage->getPublicUrl(),
				'origFile' => $processedImage->getOriginalFile()->getPublicUrl(),
				'origFile_mtime' => $processedImage->getOriginalFile()->getModificationTime(),
				// This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder,
				// in order for the setup-array to create a unique filename hash.
				'originalFile' => $processedImage->getOriginalFile(),
				'processedFile' => $processedImage,
				'fileCacheHash' => $hash
			);
		}
		return $compatibilityImageResourceValues;
	}
 /**
  * Returns the filename for a cropped/scaled/masked file.
  *
  * @param Resource\ProcessedFile $processedFile
  * @return string
  */
 protected function getFilenameForImageCropScaleMask(Resource\ProcessedFile $processedFile)
 {
     $configuration = $processedFile->getProcessingConfiguration();
     $targetFileExtension = $processedFile->getOriginalFile()->getExtension();
     $processedFileExtension = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] ? 'png' : 'gif';
     if (is_array($configuration['maskImages']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] && $processedFile->getOriginalFile()->getExtension() != $processedFileExtension) {
         $targetFileExtension = 'jpg';
     } elseif ($configuration['fileExtension']) {
         $targetFileExtension = $configuration['fileExtension'];
     }
     return $processedFile->generateProcessedFileNameWithoutExtension() . '.' . ltrim(trim($targetFileExtension), '.');
 }