当前位置: 首页>>代码示例>>PHP>>正文


PHP PathUtility::pathinfo方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\PathUtility::pathinfo方法的典型用法代码示例。如果您正苦于以下问题:PHP PathUtility::pathinfo方法的具体用法?PHP PathUtility::pathinfo怎么用?PHP PathUtility::pathinfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Utility\PathUtility的用法示例。


在下文中一共展示了PathUtility::pathinfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compressJsFile

 /**
  * 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);
 }
开发者ID:maximilian-walter,项目名称:typo3-jshrink,代码行数:34,代码来源:ResourceCompressor.php

示例2: prepareLoader

 /**
  * 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;
 }
开发者ID:c2po,项目名称:autoloader,代码行数:37,代码来源:Gridelement.php

示例3: prepareLoader

 /**
  * 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;
 }
开发者ID:Calius,项目名称:autoloader,代码行数:35,代码来源:Icon.php

示例4: setFileInformations

 /**
  * 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();
 }
开发者ID:mneuhaus,项目名称:ke_search,代码行数:34,代码来源:class.tx_kesearch_lib_fileinfo.php

示例5: isValidFileExtension

 /**
  * 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);
 }
开发者ID:mcmz,项目名称:focuspoint,代码行数:15,代码来源:ImageUtility.php

示例6: getL10nPathTo

 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;
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.locallang_tools,代码行数:14,代码来源:PathUtility.php

示例7: removeStaticFiles

 /**
  * 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);
         }
     }
 }
开发者ID:qbus-agentur,项目名称:nc_staticfilecache,代码行数:15,代码来源:StaticFileBackend.php

示例8: getTemporaryPathForFile

 /**
  * 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));
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:10,代码来源:AbstractDriver.php

示例9: createCropImageGifBuilder

 /**
  * 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();
 }
开发者ID:mcmz,项目名称:focuspoint,代码行数:24,代码来源:FocusCropService.php

示例10: getUniqueName

 /**
  * 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);
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:52,代码来源:ResourceStorage.php

示例11: collectTcaSpriteIcons

 /**
  * 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;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:45,代码来源:AbstractSpriteHandler.php

示例12: getExtension

 /**
  * 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;
 }
开发者ID:rob-ot-dot-be,项目名称:ggallkeysecurity,代码行数:11,代码来源:AbstractFile.php

示例13: importUploadedResource

 /**
  * 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;
 }
开发者ID:philippjbauer,项目名称:h5upldr,代码行数:29,代码来源:UploadedFileReferenceConverter.php

示例14: compressJsFile

 /**
  * 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);
 }
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:25,代码来源:ResourceCompressor.php

示例15: getBaseFilesRecursivelyInDir

 /**
  * 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);
 }
开发者ID:sirdiego,项目名称:autoloader,代码行数:25,代码来源:FileUtility.php


注:本文中的TYPO3\CMS\Core\Utility\PathUtility::pathinfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。