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


PHP PathUtility::getRelativePath方法代码示例

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


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

示例1: render

 /**
  * @param array|NULL $backendUser
  * @param int $size
  * @param bool $showIcon
  * @return string
  */
 public function render(array $backendUser = NULL, $size = 32, $showIcon = FALSE)
 {
     $size = (int) $size;
     if (!is_array($backendUser)) {
         $backendUser = $this->getBackendUser()->user;
     }
     $image = parent::render($backendUser, $size, $showIcon);
     if (!StringUtility::beginsWith($image, '<span class="avatar"><span class="avatar-image"></span>') || empty($backendUser['email'])) {
         return $image;
     }
     $cachedFilePath = PATH_site . 'typo3temp/t3gravatar/';
     $cachedFileName = sha1($backendUser['email'] . $size) . '.jpg';
     if (!file_exists($cachedFilePath . $cachedFileName)) {
         $gravatar = 'https://www.gravatar.com/avatar/' . md5(strtolower($backendUser['email'])) . '?s=' . $size . '&d=404';
         $gravatarImage = GeneralUtility::getUrl($gravatar);
         if (empty($gravatarImage)) {
             return $image;
         }
         GeneralUtility::writeFileToTypo3tempDir($cachedFileName, $gravatarImage);
     }
     // Icon
     $icon = '';
     if ($showIcon) {
         $icon = '<span class="avatar-icon">' . IconUtility::getSpriteIconForRecord('be_users', $backendUser) . '</span>';
     }
     $relativeFilePath = PathUtility::getRelativePath(PATH_typo3, $cachedFilePath);
     return '<span class="avatar"><span class="avatar-image">' . '<img src="' . $relativeFilePath . $cachedFileName . '" width="' . $size . '" height="' . $size . '" /></span>' . $icon . '</span>';
 }
开发者ID:smichaelsen,项目名称:t3gravatar,代码行数:34,代码来源:Avatar.php

示例2: getExistingFiles

 /**
  * Handles the existing files of a Fine Uploader form.
  * The values are stored in the GET/POST var at the index "fieldValue".
  *
  * @return string
  */
 public function getExistingFiles()
 {
     $files = array();
     $fieldValue = GeneralUtility::_GP('fieldValue');
     if ($fieldValue != '') {
         $imagePath = GeneralUtility::getFileAbsFileName($fieldValue);
         $imageName = PathUtility::basename($imagePath);
         $imageDirectoryPath = PathUtility::dirname($imagePath);
         $imageDirectoryPath = PathUtility::getRelativePath(PATH_site, $imageDirectoryPath);
         $imageUrl = GeneralUtility::locationHeaderUrl('/' . $imageDirectoryPath . $imageName);
         if (file_exists($imagePath)) {
             $files[] = array('name' => $imageName, 'uuid' => $imageUrl, 'thumbnailUrl' => $imageUrl);
         }
     }
     return json_encode($files);
 }
开发者ID:AgenceStratis,项目名称:TYPO3-Site-Factory,代码行数:22,代码来源:FileUtility.php

示例3: getExistingFiles

 /**
  * Handles the existing files of a Fine Uploader form.
  * The values are stored in the GET/POST var at the index "fieldValue".
  *
  * @return string
  */
 public function getExistingFiles()
 {
     $files = [];
     $fieldValue = GeneralUtility::_GP('fieldValue');
     if ($fieldValue != '') {
         //            $imagePath = GeneralUtility::getFileAbsFileName($fieldValue);
         $imagePath = str_replace('new:', '', $fieldValue);
         $imageName = PathUtility::basename($imagePath);
         $imageDirectoryPath = PathUtility::dirname($imagePath);
         $imageDirectoryPath = PathUtility::getRelativePath(PATH_site, $imageDirectoryPath);
         $imageUrl = GeneralUtility::locationHeaderUrl('/' . $imageDirectoryPath . $imageName);
         if (file_exists($imagePath)) {
             $files[] = ['name' => $imageName, 'uuid' => $imageUrl, 'thumbnailUrl' => $imageUrl];
         }
     }
     return $files;
 }
开发者ID:romaincanon,项目名称:TYPO3-Site-Factory,代码行数:23,代码来源:FileUtility.php

示例4: loadRequireJs

 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     // load all paths to map to package names / namespaces
     if (count($this->requireJsConfig) === 0) {
         // first, load all paths for the namespaces, and configure contrib libs.
         $this->requireJsConfig['paths'] = array('jquery-ui' => 'contrib/jqueryui', 'jquery' => 'contrib/jquery');
         // get all extensions that are loaded
         $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
         foreach ($loadedExtensions as $packageName) {
             $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
             $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
             $fullJsPath = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePath(PATH_typo3, $fullJsPath);
             $fullJsPath = rtrim($fullJsPath, '/');
             if ($fullJsPath) {
                 $this->requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $this->backPath . $fullJsPath;
             }
         }
         // check if additional AMD modules need to be loaded if a single AMD module is initialized
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
             $this->addInlineSettingArray('RequireJS.PostInitializationModules', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']);
         }
     }
     $this->addRequireJs = TRUE;
 }
开发者ID:samuweiss,项目名称:TYPO3-Site,代码行数:32,代码来源:PageRenderer.php

示例5: loadRequireJs

 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     // load all paths to map to package names / namespaces
     if (empty($this->requireJsConfig)) {
         // In order to avoid browser caching of JS files, adding a GET parameter to the files loaded via requireJS
         if (GeneralUtility::getApplicationContext()->isDevelopment()) {
             $this->requireJsConfig['urlArgs'] = 'bust=' . $GLOBALS['EXEC_TIME'];
         } else {
             $this->requireJsConfig['urlArgs'] = 'bust=' . GeneralUtility::hmac(TYPO3_version . PATH_site);
         }
         // first, load all paths for the namespaces, and configure contrib libs.
         $this->requireJsConfig['paths'] = array('jquery-ui' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery-ui', 'datatables' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.dataTables', 'nprogress' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/nprogress', 'moment' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/moment', 'cropper' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/cropper.min', 'imagesloaded' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/imagesloaded.pkgd.min', 'bootstrap' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap', 'twbs/bootstrap-datetimepicker' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-datetimepicker', 'autosize' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/autosize', 'taboverride' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/taboverride.min', 'twbs/bootstrap-slider' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-slider.min', 'jquery/autocomplete' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.autocomplete');
         // get all extensions that are loaded
         $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
         foreach ($loadedExtensions as $packageName) {
             $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
             $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
             $fullJsPath = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePath(PATH_typo3, $fullJsPath);
             $fullJsPath = rtrim($fullJsPath, '/');
             if ($fullJsPath) {
                 $this->requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $this->backPath . $fullJsPath;
             }
         }
         // check if additional AMD modules need to be loaded if a single AMD module is initialized
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
             $this->addInlineSettingArray('RequireJS.PostInitializationModules', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']);
         }
     }
     $this->addRequireJs = true;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:38,代码来源:PageRenderer.php

示例6: isRelativePathResolvedCorrectly

 /**
  * @param string $source
  * @param string $target
  * @param string $expected
  * @dataProvider isRelativePathResolvedCorrectlyDataProvider
  * @test
  */
 public function isRelativePathResolvedCorrectly($source, $target, $expected)
 {
     $relativePath = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePath($source, $target);
     $this->assertEquals($expected, $relativePath);
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:12,代码来源:PathUtilityTest.php

示例7: attachAssets

 /**
  * @return void
  */
 protected function attachAssets()
 {
     if (FALSE === self::$assetsIncluded) {
         $doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
         $doc->backPath = $GLOBALS['BACK_PATH'];
         /** @var PageRenderer $pageRenderer */
         $pageRenderer = $doc->getPageRenderer();
         $pageRenderer->addCssFile($doc->backPath . ExtensionManagementUtility::extRelPath('flux') . 'Resources/Public/css/grid.css');
         // /typo3/sysext/backend/Resources/Public/JavaScript/LayoutModule/DragDrop.js
         // is not the perfect solution for Flux Grids!
         // an adapted version of DragDrop.js is used - Resources/Public/js/VersionSevenPointTwo/DragDrop.js
         // Also fluxCollapse.js is updated.
         $fullJsPath = PathUtility::getRelativePath(PATH_typo3, GeneralUtility::getFileAbsFileName('EXT:flux/Resources/Public/js/'));
         // requirejs
         $pageRenderer->addRequireJsConfiguration(array('paths' => array('FluidTypo3/Flux/DragDrop' => $fullJsPath . 'DragDrop')));
         $pageRenderer->loadRequireJsModule('FluidTypo3/Flux/DragDrop');
         // This is necessary for fluxCollapse.js
         $pageRenderer->loadExtJS();
         $pageRenderer->addJsFile($doc->backPath . ExtensionManagementUtility::extRelPath('flux') . 'Resources/Public/js/fluxCollapse.js');
         self::$assetsIncluded = TRUE;
     }
 }
开发者ID:busynoggin,项目名称:flux,代码行数:25,代码来源:Preview.php

示例8: retrieveFileOrFolderObject

 /**
  * Bulk function, can be used for anything to get a file or folder
  *
  * 1. It's a UID
  * 2. It's a combined identifier
  * 3. It's just a path/filename (coming from the oldstyle/backwards compatibility)
  *
  * Files, previously laid on fileadmin/ or something, will be "mapped" to the storage the file is
  * in now. Files like typo3temp/ or typo3conf/ will be moved to the first writable storage
  * in its processing folder
  *
  * $input could be
  * - "2:myfolder/myfile.jpg" (combined identifier)
  * - "23" (file UID)
  * - "uploads/myfile.png" (backwards-compatibility, storage "0")
  * - "file:23"
  *
  * @param string $input
  * @return FileInterface|Folder
  */
 public function retrieveFileOrFolderObject($input)
 {
     // Remove PATH_site because absolute paths under Windows systems contain ':'
     // This is done in all considered sub functions anyway
     $input = str_replace(PATH_site, '', $input);
     if (GeneralUtility::isFirstPartOfStr($input, 'file:')) {
         $input = substr($input, 5);
         return $this->retrieveFileOrFolderObject($input);
     } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($input)) {
         return $this->getFileObject($input);
     } elseif (strpos($input, ':') > 0) {
         list($prefix, $folderIdentifier) = explode(':', $input);
         if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($prefix)) {
             // path or folder in a valid storageUID
             return $this->getObjectFromCombinedIdentifier($input);
         } elseif ($prefix == 'EXT') {
             $input = GeneralUtility::getFileAbsFileName($input);
             if (empty($input)) {
                 return NULL;
             }
             $input = PathUtility::getRelativePath(PATH_site, dirname($input)) . basename($input);
             return $this->getFileObjectFromCombinedIdentifier($input);
         } else {
             return NULL;
         }
     } else {
         // this is a backwards-compatible way to access "0-storage" files or folders
         // eliminate double slashes, /./ and /../
         $input = \TYPO3\CMS\Core\Utility\PathUtility::getCanonicalPath(ltrim($input, '/'));
         if (@is_file(PATH_site . $input)) {
             // only the local file
             return $this->getFileObjectFromCombinedIdentifier($input);
         } else {
             // only the local path
             return $this->getFolderObjectFromCombinedIdentifier($input);
         }
     }
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:58,代码来源:ResourceFactory.php

示例9: returnFileReference

 /**
  * Decides whether a client can deal with gzipped content or not and returns the according file name,
  * based on HTTP_ACCEPT_ENCODING
  *
  * @param string $filename File name
  * @return string $filename suffixed with '.gzip' or not - dependent on HTTP_ACCEPT_ENCODING
  */
 protected function returnFileReference($filename)
 {
     // if the client accepts gzip and we can create gzipped files, we give him compressed versions
     if ($this->createGzipped && strpos(GeneralUtility::getIndpEnv('HTTP_ACCEPT_ENCODING'), 'gzip') !== false) {
         $filename .= '.gzip';
     }
     return PathUtility::getRelativePath($this->rootPath, PATH_site) . $filename;
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:15,代码来源:ResourceCompressor.php

示例10: 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


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