/** * Remove the file if it is located within its album path. * That means, it does not remove files located in an other directory (like files imported by the directory importer) * * @param Tx_Yag_Domain_Model_Item $item */ public function removeImageFileFromAlbumDirectory(Tx_Yag_Domain_Model_Item $item) { $albumPath = $this->getOrigFileDirectoryPathForAlbum($item->getAlbum()); $imageFilePath = Tx_Yag_Domain_FileSystem_Div::makePathAbsolute($item->getSourceuri()); if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($imageFilePath, $albumPath) && file_exists($imageFilePath)) { unlink($imageFilePath); } }
/** * Wrapper for cObj->getImageResource in FE and BE * * @param Tx_Yag_Domain_Model_Item $origFile The original image * @param string $sourcePathAndFileName Must be used to access the file, as it may be overwritten if the original file was not found * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @return TYPO3\CMS\Core\Resource\ProcessedFile */ protected function getImageResource(Tx_Yag_Domain_Model_Item $origFile, $sourcePathAndFileName, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $typoScriptSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($resolutionConfiguration->getSettings()); $contentObject = $this->configurationManager->getContentObject(); /** @var $contentObject \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */ if ($resolutionConfiguration->getMode() == 'GIFBUILDER') { $gifBuilderData = ['yagImage' => $sourcePathAndFileName, 'yagImageTitle' => $origFile->getTitle(), 'yagImageHref' => $origFile->getHref(), 'yagImageUid' => $origFile->getUid(), 'yagAlbumUid' => $origFile->getAlbum()->getUid(), 'yagAlbumTitle' => $origFile->getAlbum()->getName(), 'yagGalleryUid' => $origFile->getAlbum()->getGallery()->getUid(), 'yagGalleryTitle' => $origFile->getAlbum()->getGallery()->getName()]; $contentObject->start($gifBuilderData); $imageResource = $contentObject->getImgResource('GIFBUILDER', $typoScriptSettings); } else { $fileObject = $this->getResourceFactory()->retrieveFileOrFolderObject($sourcePathAndFileName); $imageResource = $contentObject->getImgResource($fileObject, $typoScriptSettings); } // $this->typo3CleanUp($imageResource); return $imageResource['processedFile']; }
/** * Wrapper for cObj->getImageResource in FE and BE * * @param Tx_Yag_Domain_Model_Item $origFile The original image * @param string $sourcePathAndFileName Must be used to access the file, as it may be overwritten if the original file was not found * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @return array $imageData */ protected function getImageResource(Tx_Yag_Domain_Model_Item $origFile, $sourcePathAndFileName, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $typoScriptSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($resolutionConfiguration->getSettings()); $contentObject = $this->configurationManager->getContentObject(); /** @var $contentObject tslib_cObj */ if ($resolutionConfiguration->getMode() == 'GIFBUILDER') { $gifBuilderData = array('yagImage' => $sourcePathAndFileName, 'yagImageTitle' => $origFile->getTitle(), 'yagImageUid' => $origFile->getUid(), 'yagAlbumUid' => $origFile->getAlbum()->getUid(), 'yagAlbumTitle' => $origFile->getAlbum()->getName(), 'yagGalleryUid' => $origFile->getAlbum()->getGallery()->getUid(), 'yagGalleryTitle' => $origFile->getAlbum()->getGallery()->getName()); $contentObject->start($gifBuilderData); $imageResource = $contentObject->getImgResource('GIFBUILDER', $typoScriptSettings); } else { $imageResource = $contentObject->getImgResource($sourcePathAndFileName, $typoScriptSettings); } $this->typo3CleanUp($imageResource, $sourcePathAndFileName); return $imageResource; }