コード例 #1
0
 /**
  * Compresses and minifies a javascript file
  *
  * @param string $filename Source filename, relative to requested page
  * @return string Filename of the compressed file, relative to requested page
  */
 public function compressJsFile($filename)
 {
     // generate the unique name of the file
     $filenameAbsolute = GeneralUtility::resolveBackPath($this->rootPath . $this->getFilenameFromMainDir($filename));
     if (@file_exists($filenameAbsolute)) {
         $fileStatus = stat($filenameAbsolute);
         $unique = $filenameAbsolute . $fileStatus['mtime'] . $fileStatus['size'];
     } else {
         $unique = $filenameAbsolute;
     }
     $pathinfo = PathUtility::pathinfo($filename);
     $targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.js';
     // only create it, if it doesn't exist, yet
     if (!file_exists(PATH_site . $targetFile) || $this->createGzipped && !file_exists(PATH_site . $targetFile . '.gzip')) {
         $contents = file_get_contents($filenameAbsolute);
         try {
             $minifiedContents = Minifier::minify($contents);
         } catch (\Exception $e) {
             // Log error and use un-minified content as fallback
             /** @var $logger Logger */
             $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
             $logger->error($e->getMessage(), ['filename' => $filename]);
             $minifiedContents = $contents;
         }
         $this->writeFileAndCompressed($targetFile, $minifiedContents);
     }
     return $this->relativePath . $this->returnFileReference($targetFile);
 }
コード例 #2
0
ファイル: Gridelement.php プロジェクト: c2po/autoloader
 /**
  * Get all the complex data for the loader.
  * This return value will be cached and stored in the database
  * There is no file monitoring for this cache
  *
  * @param Loader $loader
  * @param int    $type
  *
  * @return array
  */
 public function prepareLoader(Loader $loader, $type)
 {
     $grids = [];
     if (!ExtensionManagementUtility::isLoaded('gridelements')) {
         return $grids;
     }
     $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/Grids/';
     $files = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt');
     foreach ($files as $file) {
         $pathInfo = PathUtility::pathinfo($file);
         $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/Grids/' . $pathInfo['filename'] . '.';
         $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath));
         $translationKey = 'grid.' . $pathInfo['filename'];
         if ($type === LoaderInterface::EXT_TABLES) {
             TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']);
         }
         $path = 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Grids/' . $file;
         $icon = $extension ? $iconPath . $extension : false;
         $label = TranslateUtility::getLllString($translationKey, $loader->getExtensionKey());
         $content = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($path));
         $flexForm = 'EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Grids/' . $pathInfo['filename'] . '.xml';
         $flexFormFile = GeneralUtility::getFileAbsFileName($flexForm);
         $flexFormContent = is_file($flexFormFile) ? GeneralUtility::getUrl($flexFormFile) : false;
         $grids[] = $this->getPageTsConfig($pathInfo['filename'], $label, $content, $icon, $flexFormContent);
     }
     return $grids;
 }
コード例 #3
0
ファイル: Icon.php プロジェクト: Calius/autoloader
 /**
  * Get all the complex data for the loader.
  * This return value will be cached and stored in the database
  * There is no file monitoring for this cache
  *
  * @param Loader $loader
  * @param int    $type
  *
  * @return array
  */
 public function prepareLoader(Loader $loader, $type)
 {
     $icons = [];
     if (!class_exists('TYPO3\\CMS\\Core\\Imaging\\IconRegistry')) {
         return $icons;
     }
     $iconFolder = 'Resources/Public/Icon/';
     $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . $iconFolder;
     $extensionPath = ExtensionManagementUtility::extPath($loader->getExtensionKey());
     $files = GeneralUtility::getAllFilesAndFoldersInPath([], $folder, '', false, true);
     if (!sizeof($files)) {
         return $icons;
     }
     foreach ($files as $path) {
         $provider = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\BitmapIconProvider';
         if (substr(strtolower($path), -3) === 'svg') {
             $provider = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\SvgIconProvider';
         }
         $relativePath = str_replace($extensionPath, '', $path);
         $iconPath = str_replace($iconFolder, '', $relativePath);
         $pathElements = PathUtility::pathinfo(strtolower(str_replace('/', '-', $iconPath)));
         $icons[] = ['provider' => $provider, 'path' => 'EXT:' . $loader->getExtensionKey() . '/' . $relativePath, 'identifier' => str_replace('_', '-', $loader->getExtensionKey()) . '-' . $pathElements['filename']];
     }
     return $icons;
 }
コード例 #4
0
 /**
  * collect all fileinformations of given file and
  * save them to the global fileinformation array
  *
  * @param string $file
  * @return boolean is valid file?
  */
 protected function setFileInformations($file)
 {
     $this->fileInfo = array();
     // reset previously information to have a cleaned object
     $this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
     if (is_string($file) && !empty($file)) {
         $this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
         $this->fileInfo['mtime'] = filemtime($file);
         $this->fileInfo['atime'] = fileatime($file);
         $this->fileInfo['owner'] = fileowner($file);
         $this->fileInfo['group'] = filegroup($file);
         $this->fileInfo['size'] = filesize($file);
         $this->fileInfo['type'] = filetype($file);
         $this->fileInfo['perms'] = fileperms($file);
         $this->fileInfo['is_dir'] = is_dir($file);
         $this->fileInfo['is_file'] = is_file($file);
         $this->fileInfo['is_link'] = is_link($file);
         $this->fileInfo['is_readable'] = is_readable($file);
         $this->fileInfo['is_uploaded'] = is_uploaded_file($file);
         $this->fileInfo['is_writeable'] = is_writeable($file);
     }
     if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
         $pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
         $this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
     }
     return $this->fileInfo !== array();
 }
コード例 #5
0
ファイル: ImageUtility.php プロジェクト: mcmz/focuspoint
 /**
  * Check if the given path or extension is valid for the focuspoint
  *
  * @param $pathOrExtension
  * @return bool
  */
 public static function isValidFileExtension($pathOrExtension)
 {
     $pathOrExtension = strtolower($pathOrExtension);
     $validExtensions = self::getAllowedFileExtensions();
     if (in_array($pathOrExtension, $validExtensions)) {
         return true;
     }
     return in_array(PathUtility::pathinfo($pathOrExtension, PATHINFO_EXTENSION), $validExtensions);
 }
コード例 #6
0
 public static function getL10nPathTo($path, $language, $base = self::RELATIVE_L10N_PATH)
 {
     if (!preg_match('/[a-z]{2}/', $language)) {
         throw new \InvalidArgumentException("Argument language '{$language}' is not a valid language code", 1455831055);
     }
     $typo3Path = static::getTypo3PathTo($path);
     if (strpos($typo3Path, self::EXT_PREFIX) !== 0) {
         throw new InvalidArgumentException("Path '{$path}' doesn't belong to an extension!", 1455832193);
     }
     $extensionPath = substr($typo3Path, strlen(self::EXT_PREFIX));
     $pathParts = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($extensionPath);
     $l10nPath = \TYPO3\CMS\Core\Utility\PathUtility::sanitizeTrailingSeparator($base) . $language . '/' . \TYPO3\CMS\Core\Utility\PathUtility::sanitizeTrailingSeparator($pathParts['dirname']) . $language . '.' . $pathParts['basename'];
     return $l10nPath;
 }
コード例 #7
0
 /**
  * Get all the complex data and information for the loader.
  * This return value will be cached and stored in the core_cache of TYPO3.
  * There is no file monitoring for this cache.
  *
  * @param Loader $loader
  * @param int    $type
  *
  * @return array
  */
 public function prepareLoader(Loader $loader, $type)
 {
     $backendLayouts = array();
     $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/BackendLayouts/';
     $backendLayoutFiles = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt');
     foreach ($backendLayoutFiles as $file) {
         $pathInfo = PathUtility::pathinfo($file);
         $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/BackendLayouts/' . $pathInfo['filename'] . '.';
         $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath));
         $translationKey = 'backendLayout.' . $pathInfo['basename'];
         if ($type === LoaderInterface::EXT_TABLES) {
             TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']);
         }
         $backendLayouts[] = array('path' => 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/BackendLayouts/' . $file, 'filename' => $pathInfo['filename'], 'icon' => $extension ? $iconPath . $extension : FALSE, 'label' => TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()), 'extension' => $loader->getExtensionKey());
     }
     return $backendLayouts;
 }
コード例 #8
0
 /**
  * Set the property mapping configuration for the file upload element.
  * * Add the UploadedFileReferenceConverter to convert an uploaded file to an
  *   FileReference.
  * * Add the MimeTypeValidator to the UploadedFileReferenceConverter to
  *   delete non valid filetypes directly.
  * * Setup the storage:
  *   If the property "saveToFileMount" exist for this element it will be used.
  *   If this file mount or the property "saveToFileMount" does not exist
  *   the folder in which the form definition lies (persistence identifier) will be used.
  *   If the form is generated programmatically and therefore no
  *   persistence identifier exist the default storage "1:/user_upload/" will be used.
  *
  * @return void
  * @internal
  * @todo: could we find a not so ugly solution for that?
  */
 public function onBuildingFinished()
 {
     /** @var \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration */
     $propertyMappingConfiguration = $this->getRootForm()->getProcessingRule($this->getIdentifier())->getPropertyMappingConfiguration();
     $mimeTypeValidator = GeneralUtility::makeInstance(ObjectManager::class)->get(MimeTypeValidator::class, ['allowedMimeTypes' => $this->properties['allowedMimeTypes']]);
     $uploadConfiguration = [UploadedFileReferenceConverter::CONFIGURATION_FILE_VALIDATORS => [$mimeTypeValidator], UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_CONFLICT_MODE => 'rename'];
     $saveToFileMountIdentifier = isset($this->properties['saveToFileMount']) ? $this->properties['saveToFileMount'] : null;
     if ($this->checkSaveFileMountAccess($saveToFileMountIdentifier)) {
         $uploadConfiguration[UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER] = $saveToFileMountIdentifier;
     } else {
         $persistenceIdentifier = $this->getRootForm()->getPersistenceIdentifier();
         if (!empty($persistenceIdentifier)) {
             $pathinfo = PathUtility::pathinfo($persistenceIdentifier);
             $saveToFileMountIdentifier = $pathinfo['dirname'];
             if ($this->checkSaveFileMountAccess($saveToFileMountIdentifier)) {
                 $uploadConfiguration[UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER] = $saveToFileMountIdentifier;
             }
         }
     }
     $propertyMappingConfiguration->setTypeConverterOptions(UploadedFileReferenceConverter::class, $uploadConfiguration);
 }
コード例 #9
0
 /**
  * Remove the static files of the given identifier
  *
  * @param $entryIdentifier
  */
 protected function removeStaticFiles($entryIdentifier)
 {
     $fileName = $this->getCacheFilename($entryIdentifier);
     $files = [$fileName, $fileName . '.gz', PathUtility::pathinfo($fileName, PATHINFO_DIRNAME) . '/.htaccess'];
     foreach ($files as $file) {
         if (is_file($file)) {
             unlink($file);
         }
     }
 }
コード例 #10
0
 /**
  * Returns a temporary path for a given file, including the file extension.
  *
  * @param string $fileIdentifier
  * @return string
  */
 protected function getTemporaryPathForFile($fileIdentifier)
 {
     return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-', '.' . PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
 }
コード例 #11
0
ファイル: FocusCropService.php プロジェクト: mcmz/focuspoint
 /**
  * Create the crop image (GifBuilder)
  *
  * @param $absoluteImageName
  * @param $focusWidth
  * @param $focusHeight
  * @param $sourceX
  * @param $sourceY
  * @param $absoluteTempImageName
  */
 protected function createCropImageGifBuilder($absoluteImageName, $focusWidth, $focusHeight, $sourceX, $sourceY, $absoluteTempImageName)
 {
     $size = getimagesize($absoluteImageName);
     $relativeImagePath = rtrim(PathUtility::getRelativePath(GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'), $absoluteImageName), '/');
     $configuration = ['format' => strtolower(PathUtility::pathinfo($absoluteImageName, PATHINFO_EXTENSION)), 'XY' => $size[0] . ',' . $size[1], 'transparentBackground' => '1', '10' => 'IMAGE', '10.' => ['file' => $relativeImagePath, 'file.' => ['quality' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality'], 'width' => $size[0], 'height' => $size[1]]], '20' => 'CROP', '20.' => ['crop' => $sourceX . ',' . $sourceY . ',' . $focusWidth . ',' . $focusHeight]];
     /** @var \TYPO3\CMS\Frontend\Imaging\GifBuilder $gifBuilder */
     $gifBuilder = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder');
     $gifBuilder->init();
     $gifBuilder->start($configuration, []);
     $gifBuilder->createTempSubDir('focuscrop/');
     $gifBuilder->make();
     $gifBuilder->output($absoluteTempImageName);
     $gifBuilder->destroy();
 }
コード例 #12
0
 /**
  * Returns the destination path/fileName of a unique fileName/foldername in that path.
  * If $theFile exists in $theDest (directory) the file have numbers appended up to $this->maxNumber. Hereafter a unique string will be appended.
  * This function is used by fx. TCEmain when files are attached to records and needs to be uniquely named in the uploads/* folders
  *
  * @param Folder $folder
  * @param string $theFile The input fileName to check
  * @param bool $dontCheckForUnique If set the fileName is returned with the path prepended without checking whether it already existed!
  *
  * @throws \RuntimeException
  * @return string A unique fileName inside $folder, based on $theFile.
  * @see \TYPO3\CMS\Core\Utility\File\BasicFileUtility::getUniqueName()
  */
 protected function getUniqueName(Folder $folder, $theFile, $dontCheckForUnique = false)
 {
     static $maxNumber = 99, $uniqueNamePrefix = '';
     // Fetches info about path, name, extension of $theFile
     $origFileInfo = PathUtility::pathinfo($theFile);
     // Adds prefix
     if ($uniqueNamePrefix) {
         $origFileInfo['basename'] = $uniqueNamePrefix . $origFileInfo['basename'];
         $origFileInfo['filename'] = $uniqueNamePrefix . $origFileInfo['filename'];
     }
     // Check if the file exists and if not - return the fileName...
     // The destinations file
     $theDestFile = $origFileInfo['basename'];
     // If the file does NOT exist we return this fileName
     if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) || $dontCheckForUnique) {
         return $theDestFile;
     }
     // Well the fileName in its pure form existed. Now we try to append
     // numbers / unique-strings and see if we can find an available fileName
     // This removes _xx if appended to the file
     $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filename']);
     $theOrigExt = $origFileInfo['extension'] ? '.' . $origFileInfo['extension'] : '';
     for ($a = 1; $a <= $maxNumber + 1; $a++) {
         // First we try to append numbers
         if ($a <= $maxNumber) {
             $insert = '_' . sprintf('%02d', $a);
         } else {
             $insert = '_' . substr(md5(uniqid('', true)), 0, 6);
         }
         $theTestFile = $theTempFileBody . $insert . $theOrigExt;
         // The destinations file
         $theDestFile = $theTestFile;
         // If the file does NOT exist we return this fileName
         if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier())) {
             return $theDestFile;
         }
     }
     throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
 }
コード例 #13
0
 /**
  * this method creates sprite icon names for all tables in TCA (including their possible type-icons)
  * where there is no "typeicon_classes" of this TCA table ctrl section
  * (moved form \TYPO3\CMS\Backend\Utility\IconUtility)
  *
  * @return array Array as $iconName => $fileName
  */
 protected function collectTcaSpriteIcons()
 {
     $tcaTables = array_keys($GLOBALS['TCA']);
     $resultArray = array();
     // Path (relative from typo3 dir) for skin-Images
     if (isset($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'])) {
         $skinPath = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'];
     } else {
         $skinPath = '';
     }
     // check every table in the TCA, if an icon is needed
     foreach ($tcaTables as $tableName) {
         // This method is only needed for TCA tables where
         // typeicon_classes are not configured
         if (is_array($GLOBALS['TCA'][$tableName]) && !is_array($GLOBALS['TCA'][$tableName]['ctrl']['typeicon_classes'])) {
             $tcaCtrl = $GLOBALS['TCA'][$tableName]['ctrl'];
             // Adding the default Icon (without types)
             if (isset($tcaCtrl['iconfile'])) {
                 // In CSS we need a path relative to the css file
                 // [TCA][ctrl][iconfile] defines icons without path info to reside in gfx/i/
                 if (\TYPO3\CMS\Core\Utility\StringUtility::beginsWith($tcaCtrl['iconfile'], 'EXT:')) {
                     list($extensionKey, $relativePath) = explode('/', substr($tcaCtrl['iconfile'], 4), 2);
                     $pathInfo = PathUtility::pathinfo(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . $relativePath);
                     $path = PathUtility::getRelativePathTo($pathInfo['dirname']);
                     $icon = $path . $pathInfo['basename'];
                 } elseif (strpos($tcaCtrl['iconfile'], '/') !== false) {
                     $icon = $tcaCtrl['iconfile'];
                     $icon = GeneralUtility::resolveBackPath($icon);
                 } else {
                     $icon = $skinPath . 'gfx/i/' . $tcaCtrl['iconfile'];
                     $icon = GeneralUtility::resolveBackPath($icon);
                 }
                 $resultArray['tcarecords-' . $tableName . '-default'] = $icon;
             }
         }
     }
     return $resultArray;
 }
コード例 #14
0
 /**
  * Returns a File object for a given $persistenceIdentifier.
  * If no file for this identifier exists a new object will be
  * created.
  *
  * @param string $persistenceIdentifier
  * @return File
  * @throws PersistenceManagerException
  */
 protected function getOrCreateFile(string $persistenceIdentifier) : File
 {
     list($storageUid, $fileIdentifier) = explode(':', $persistenceIdentifier, 2);
     $storage = $this->getStorageByUid((int) $storageUid);
     $pathinfo = PathUtility::pathinfo($fileIdentifier);
     if (!$storage->hasFolder($pathinfo['dirname'])) {
         throw new PersistenceManagerException(sprintf('Could not create folder "%s".', $pathinfo['dirname']), 1471630579);
     }
     $folder = $storage->getFolder($pathinfo['dirname']);
     if (!$storage->checkFolderActionPermission('write', $folder)) {
         throw new PersistenceManagerException(sprintf('No write access to folder "%s".', $pathinfo['dirname']), 1471630580);
     }
     if (!$storage->hasFile($fileIdentifier)) {
         $file = $folder->createFile($pathinfo['basename']);
     } else {
         $file = $storage->getFile($fileIdentifier);
     }
     return $file;
 }
コード例 #15
0
 /**
  * Get the extension of this file in a lower-case variant
  *
  * @return string The file extension
  */
 public function getExtension()
 {
     $pathinfo = PathUtility::pathinfo($this->getName());
     $extension = strtolower($pathinfo['extension']);
     return $extension;
 }
コード例 #16
0
 /**
  * Import a resource and respect configuration given for properties
  *
  * @param array $uploadInfo
  * @param PropertyMappingConfigurationInterface $configuration
  * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
  * @throws TypeConverterException
  * @throws ExistingTargetFileNameException
  */
 protected function importUploadedResource(array $uploadInfo, PropertyMappingConfigurationInterface $configuration)
 {
     if (!GeneralUtility::verifyFilenameAgainstDenyPattern($uploadInfo['name'])) {
         throw new TypeConverterException('Uploading files with PHP file extensions is not allowed!', 1399312430);
     }
     $allowedFileExtensions = $configuration->getConfigurationValue('Bureauoberhoff\\H5upldr\\Property\\TypeConverter\\UploadedFileReferenceConverter', self::CONFIGURATION_ALLOWED_FILE_EXTENSIONS);
     if ($allowedFileExtensions !== NULL) {
         $filePathInfo = PathUtility::pathinfo($uploadInfo['name']);
         if (!GeneralUtility::inList($allowedFileExtensions, strtolower($filePathInfo['extension']))) {
             throw new TypeConverterException('File extension is not allowed!', 1399312430);
         }
     }
     $uploadFolderId = $configuration->getConfigurationValue('Bureauoberhoff\\H5upldr\\Property\\TypeConverter\\UploadedFileReferenceConverter', self::CONFIGURATION_UPLOAD_FOLDER) ?: $this->defaultUploadFolder;
     $conflictMode = $configuration->getConfigurationValue('Bureauoberhoff\\H5upldr\\Property\\TypeConverter\\UploadedFileReferenceConverter', self::CONFIGURATION_UPLOAD_CONFLICT_MODE) ?: $this->defaultConflictMode;
     $uploadFolder = $this->resourceFactory->retrieveFileOrFolderObject($uploadFolderId);
     $uploadedFile = $uploadFolder->addUploadedFile($uploadInfo, $conflictMode);
     $resourcePointer = isset($uploadInfo['submittedFile']['resourcePointer']) && strpos($uploadInfo['submittedFile']['resourcePointer'], 'file:') === FALSE ? $this->hashService->validateAndStripHmac($uploadInfo['submittedFile']['resourcePointer']) : NULL;
     $fileReferenceModel = $this->createFileReferenceFromFalFileObject($uploadedFile, $resourcePointer);
     return $fileReferenceModel;
 }
コード例 #17
0
 /**
  * Compresses a javascript file
  *
  * @param string $filename Source filename, relative to requested page
  * @return string Filename of the compressed file, relative to requested page
  */
 public function compressJsFile($filename)
 {
     // generate the unique name of the file
     $filenameAbsolute = GeneralUtility::resolveBackPath($this->rootPath . $this->getFilenameFromMainDir($filename));
     if (@file_exists($filenameAbsolute)) {
         $fileStatus = stat($filenameAbsolute);
         $unique = $filenameAbsolute . $fileStatus['mtime'] . $fileStatus['size'];
     } else {
         $unique = $filenameAbsolute;
     }
     $pathinfo = PathUtility::pathinfo($filename);
     $targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.js';
     // only create it, if it doesn't exist, yet
     if (!file_exists(PATH_site . $targetFile) || $this->createGzipped && !file_exists(PATH_site . $targetFile . '.gzip')) {
         $contents = GeneralUtility::getUrl($filenameAbsolute);
         $this->writeFileAndCompressed($targetFile, $contents);
     }
     return $this->relativePath . $this->returnFileReference($targetFile);
 }
コード例 #18
0
ファイル: FileUtility.php プロジェクト: sirdiego/autoloader
 /**
  * Get all base file names in the given directory with the given file extension
  * Check also if the directory exists. If you scan the dir recursively you get
  * also the folder name. The filename is also "basename" only.
  *
  * @param string $dirPath
  * @param string $fileExtensions
  * @param bool $recursively
  *
  * @return array
  */
 public static function getBaseFilesRecursivelyInDir($dirPath, $fileExtensions, $recursively = true)
 {
     if (!is_dir($dirPath)) {
         return [];
     }
     $recursively = $recursively ? 99 : 0;
     $files = GeneralUtility::getAllFilesAndFoldersInPath([], $dirPath, $fileExtensions, false, $recursively);
     foreach ($files as $key => $file) {
         $pathInfo = PathUtility::pathinfo($file);
         $files[$key] = $pathInfo['dirname'] . '/' . $pathInfo['filename'];
     }
     $files = GeneralUtility::removePrefixPathFromList($files, $dirPath);
     return array_values($files);
 }
コード例 #19
0
 /**
  * Collects information about the file
  * @param  string $filename Filename
  * @return array            Array of collected information
  */
 private function getFileInformation($filename, $throwExeptions = TRUE)
 {
     $fileProperties = array();
     $fileProperties['filename'] = $filename;
     if (strlen(trim($filename)) == 0 && $throwExeptions) {
         throw new \Exception(LocalizationUtility::translate('iconFontSelector.exception.missingFilename', 't3kit_extension_tools'), 20);
     }
     $fileProperties['absFileName'] = GeneralUtility::getFileAbsFileName($filename);
     $fileProperties['fileExists'] = file_exists($fileProperties['absFileName']);
     if (!$fileProperties['fileExists'] && $throwExeptions) {
         throw new \Exception(LocalizationUtility::translate('iconFontSelector.exception.fileExists', 't3kit_extension_tools') . ' (' . $filename . ')', 21);
     }
     $pathInfo = PathUtility::pathinfo($fileProperties['absFileName']);
     $fileProperties['dirname'] = $pathInfo['dirname'];
     $fileProperties['basename'] = $pathInfo['basename'];
     $fileProperties['extension'] = $pathInfo['extension'];
     $fileProperties['filename'] = $pathInfo['filename'];
     $fileProperties['isAllowedAbsPath'] = GeneralUtility::isAllowedAbsPath($fileProperties['absFileName']);
     if (!$fileProperties['isAllowedAbsPath'] && $throwExeptions) {
         throw new \Exception(LocalizationUtility::translate('iconFontSelector.exception.isAllowedAbsPath', 't3kit_extension_tools'), 22);
     }
     $fileProperties['relativePath'] = PathUtility::getRelativePathTo($fileProperties['dirname']);
     return $fileProperties;
 }
コード例 #20
0
ファイル: Indexer.php プロジェクト: khanhdeux/typo3test
 /**
  * Collects the information to be cached in sys_file
  *
  * @param string $identifier
  * @return array
  */
 protected function gatherFileInformationArray($identifier)
 {
     $fileInfo = $this->storage->getFileInfoByIdentifier($identifier);
     $fileInfo = $this->transformFromDriverFileInfoArrayToFileObjectFormat($fileInfo);
     $fileInfo['type'] = $this->getFileType($fileInfo['mime_type']);
     $fileInfo['sha1'] = $this->storage->hashFileByIdentifier($identifier, 'sha1');
     $fileInfo['extension'] = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($fileInfo['name'], PATHINFO_EXTENSION);
     $fileInfo['missing'] = 0;
     return $fileInfo;
 }
コード例 #21
0
ファイル: SftpDriver.php プロジェクト: vertexvaar/falsftp
 /**
  * Returns a path to a local copy of a file for processing it. When changing the
  * file, you have to take care of replacing the current version yourself!
  *
  * @param string $fileIdentifier
  * @param bool $writable Set this to FALSE if you only need the file for read
  *                       operations. This might speed up things, e.g. by using
  *                       a cached local version. Never modify the file if you
  *                       have set this flag!
  * @return string The path to the file on the local disk
  */
 public function getFileForLocalProcessing($fileIdentifier, $writable = true)
 {
     $fileIdentifier = $this->canonicalizeAndCheckFileIdentifier($this->rootPath . $fileIdentifier);
     return $this->adapter->downloadFile($fileIdentifier, GeneralUtility::tempnam('fal-tempfile-' . ($writable ? 'w' : ''), '.' . PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION)));
 }