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


PHP PathUtility::getRelativePathTo方法代码示例

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


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

示例1: getRelativePath

 /**
  * Return a public path pointing to a resource.
  *
  * @param string $resource
  * @return string
  */
 public static function getRelativePath($resource)
 {
     // If file is not found, resolve the path
     if (!is_file(PATH_site . $resource)) {
         $resource = substr(self::resolvePath($resource), strlen(PATH_site));
     }
     return PathUtility::getRelativePathTo(PathUtility::dirname(PATH_site . $resource)) . PathUtility::basename($resource);
 }
开发者ID:visol,项目名称:media,代码行数:14,代码来源:Path.php

示例2: getUrl

 /**
  * Get url
  *
  * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all.
  * @return string
  */
 public function getUrl($relativeToCurrentScript = false)
 {
     $url = $this->url;
     if ($relativeToCurrentScript && !GeneralUtility::isValidUrl($url)) {
         $absolutePathToContainingFolder = PathUtility::dirname(PATH_site . $url);
         $pathPart = PathUtility::getRelativePathTo($absolutePathToContainingFolder);
         $filePart = substr(PATH_site . $url, strlen($absolutePathToContainingFolder) + 1);
         $url = $pathPart . $filePart;
     }
     return $url;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:17,代码来源:Image.php

示例3: getPublicUrl

 /**
  * @param ResourceStorage $storage
  * @param AbstractDriver $driver
  * @param ResourceInterface $resource
  * @param boolean $relativeToCurrentScript
  * @param array $urlData
  */
 public function getPublicUrl(ResourceStorage $storage, AbstractDriver $driver, ResourceInterface $resource, $relativeToCurrentScript, array $urlData)
 {
     if (!$driver instanceof LocalDriver) {
         // We cannot handle other files than local files yet
         return;
     }
     $publicUrl = $this->resourcePublisher->getResourceWebUri($resource);
     if ($publicUrl !== FALSE) {
         // If requested, make the path relative to the current script in order to make it possible
         // to use the relative file
         if ($relativeToCurrentScript) {
             $publicUrl = PathUtility::getRelativePathTo(PathUtility::dirname(PATH_site . $publicUrl)) . PathUtility::basename($publicUrl);
         }
         // $urlData['publicUrl'] is passed by reference, so we can change that here and the value will be taken into account
         $urlData['publicUrl'] = $publicUrl;
     }
 }
开发者ID:IngoMueller,项目名称:naw_securedl,代码行数:24,代码来源:UrlGenerationInterceptor.php

示例4: getTemplateFromName

 /**
  * @param string $content
  * @param array $conf
  * @return string
  */
 public function getTemplateFromName($content, $conf)
 {
     $basename = $content;
     if ($conf['paths'][0] === '<') {
         $key = trim(substr($conf['paths'], 1));
         $typoScriptParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
         list($name, $conf['paths.']) = $typoScriptParser->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
     }
     $paths = ArrayUtility::sortArrayWithIntegerKeys($conf['paths.']);
     $paths = array_reverse($paths, TRUE);
     foreach ($paths as $path) {
         // why does it have to be relative?
         $test_file = PathUtility::getRelativePathTo(GeneralUtility::getFileAbsFileName($path)) . $basename;
         if (is_file($test_file)) {
             return $test_file;
         }
         if (is_file($test_file . '.html')) {
             return $test_file . '.html';
         }
     }
     return $content;
 }
开发者ID:newenduser,项目名称:bootstrap_package,代码行数:27,代码来源:TemplateFileResolver.php

示例5: getPublicUrl

 /**
  * Returns the public URL to a file.
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource
  * @param bool  $relativeToCurrentScript    Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
  * @return string
  */
 public function getPublicUrl(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $relativeToCurrentScript = false)
 {
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($resource->getIdentifier(), '/_processed_/')) {
         $publicUrl = '../typo3temp/yag' . $resource->getIdentifier();
         // TODO: ....!!!!
     } else {
         $item = $resource->getProperty('yagItem');
         if (!$item instanceof \Tx_Yag_Domain_Model_Item) {
             $pathInfo = new PathInfo($resource->getIdentifier());
             $item = $this->getItem($pathInfo);
         }
         $publicUrl = $this->yagFileSystemDiv->getFileRelFileName($item->getSourceuri());
     }
     if ($relativeToCurrentScript) {
         $publicUrl = PathUtility::getRelativePathTo(PathUtility::dirname(PATH_site . $publicUrl)) . PathUtility::basename($publicUrl);
     }
     return $publicUrl;
 }
开发者ID:kabarakh,项目名称:yag,代码行数:25,代码来源:YagDriver.php

示例6: getPublicUrl

 /**
  * Returns a publicly accessible URL for a file.
  *
  * WARNING: Access to the file may be restricted by further means, e.g.
  * some web-based authentication. You have to take care of this yourself.
  *
  * @param ResourceInterface $resourceObject The file or folder object
  * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
  * @return string
  */
 public function getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript = false)
 {
     $publicUrl = null;
     if ($this->isOnline()) {
         // Pre-process the public URL by an accordant slot
         $this->emitPreGeneratePublicUrlSignal($resourceObject, $relativeToCurrentScript, array('publicUrl' => &$publicUrl));
         if ($publicUrl === null && $resourceObject instanceof File && ($helper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($resourceObject)) !== false) {
             $publicUrl = $helper->getPublicUrl($resourceObject, $relativeToCurrentScript);
         }
         // If slot did not handle the signal, use the default way to determine public URL
         if ($publicUrl === null) {
             if ($this->hasCapability(self::CAPABILITY_PUBLIC)) {
                 $publicUrl = $this->driver->getPublicUrl($resourceObject->getIdentifier());
             }
             if ($publicUrl === null && $resourceObject instanceof FileInterface) {
                 $queryParameterArray = array('eID' => 'dumpFile', 't' => '');
                 if ($resourceObject instanceof File) {
                     $queryParameterArray['f'] = $resourceObject->getUid();
                     $queryParameterArray['t'] = 'f';
                 } elseif ($resourceObject instanceof ProcessedFile) {
                     $queryParameterArray['p'] = $resourceObject->getUid();
                     $queryParameterArray['t'] = 'p';
                 }
                 $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
                 $publicUrl = 'index.php?' . str_replace('+', '%20', http_build_query($queryParameterArray));
             }
             // If requested, make the path relative to the current script in order to make it possible
             // to use the relative file
             if ($publicUrl !== null && $relativeToCurrentScript && !GeneralUtility::isValidUrl($publicUrl)) {
                 $absolutePathToContainingFolder = PathUtility::dirname(PATH_site . $publicUrl);
                 $pathPart = PathUtility::getRelativePathTo($absolutePathToContainingFolder);
                 $filePart = substr(PATH_site . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
                 $publicUrl = $pathPart . $filePart;
             }
         }
     }
     return $publicUrl;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:48,代码来源:ResourceStorage.php

示例7: getPublicUrl

 /**
  * Returns the public URL to a file. For the local driver, this will always
  * return a path relative to PATH_site.
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface  $fileOrFolder
  * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
  * @return string
  */
 public function getPublicUrl(\TYPO3\CMS\Core\Resource\ResourceInterface $fileOrFolder, $relativeToCurrentScript = FALSE)
 {
     if ($this->configuration['pathType'] === 'relative' && rtrim($this->configuration['basePath'], '/') !== '') {
         $publicUrl = rtrim($this->configuration['basePath'], '/') . '/' . ltrim($fileOrFolder->getIdentifier(), '/');
     } elseif (isset($this->baseUri)) {
         $publicUrl = $this->baseUri . ltrim($fileOrFolder->getIdentifier(), '/');
     } else {
         throw new \TYPO3\CMS\Core\Resource\Exception('Public URL of file cannot be determined', 1329765518);
     }
     // If requested, make the path relative to the current script in order to make it possible
     // to use the relative file
     if ($relativeToCurrentScript) {
         $publicUrl = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePathTo(dirname(PATH_site . $publicUrl)) . basename($publicUrl);
     }
     return $publicUrl;
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:24,代码来源:LocalDriver.php

示例8: addStyleSheetDirectory

 /**
  * Add all *.css files of the directory $path to the stylesheets
  *
  * @param string $path directory to add
  * @return void
  */
 public function addStyleSheetDirectory($path)
 {
     $path = GeneralUtility::getFileAbsFileName($path);
     // Read all files in directory and sort them alphabetically
     $cssFiles = GeneralUtility::getFilesInDir($path, 'css');
     foreach ($cssFiles as $cssFile) {
         $this->pageRenderer->addCssFile(PathUtility::getRelativePathTo($path) . $cssFile);
     }
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:15,代码来源:DocumentTemplate.php

示例9: resolvePath

 /**
  * Resolve path
  *
  * @param string $resourcePath
  * @return NULL|string
  */
 protected function resolvePath($resourcePath)
 {
     $absoluteFilePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($resourcePath);
     $absolutePath = dirname($absoluteFilePath);
     $fileName = basename($absoluteFilePath);
     return \TYPO3\CMS\Core\Utility\PathUtility::getRelativePathTo($absolutePath) . $fileName;
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:13,代码来源:AdditionalResourceService.php

示例10: getRelativeFolder

 /**
  * Get relative path from absolute path, but don't touch if it's already a relative path
  *
  * @param string $path
  * @return string
  */
 public static function getRelativeFolder($path)
 {
     if (PathUtility::isAbsolutePath($path)) {
         $path = PathUtility::getRelativePathTo($path);
     }
     return $path;
 }
开发者ID:VladStawizki,项目名称:ipl-logistik.de,代码行数:13,代码来源:BasicFileUtility.php

示例11: getFileInformation

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

示例12: preGeneratePublicUrl

 /**
  * signal slot for public url generation of a file
  * @see \TYPO3\CMS\Core\Resource\ResourceStorage and the function getPublicUrl
  * 
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $t
  * @param \TYPO3\CMS\Core\Resource\Driver\LocalDriver $driver
  * @param object $resourceObject e.g. \TYPO3\CMS\Core\Resource\File, \TYPO3\CMS\Core\Resource\Folder, \TYPO3\CMS\Core\Resource\ProcessedFile
  * @param boolean $relativeToCurrentScript
  * @param array $urlData
  * 
  * @return void
  */
 public function preGeneratePublicUrl($t, $driver, $resourceObject, $relativeToCurrentScript, $urlData)
 {
     $this->emSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
     // check if resource is file
     if (is_a($resourceObject, 'TYPO3\\CMS\\Core\\Resource\\File')) {
         $fileData = $this->getFileData($resourceObject);
         $newPublicUrl = '';
         $enable = true;
         // check if TYPO3 is in frontend mode
         if (TYPO3_MODE === 'FE') {
             if ($this->emSettings['disable_fe']) {
                 $enable = false;
             } else {
                 // check filetypes field
                 if (!empty($this->emSettings['filetypes_fe'])) {
                     $filetypes = explode(',', $this->emSettings['filetypes_fe']);
                     if (in_array($fileData['extension'], $filetypes)) {
                     } else {
                         $enable = false;
                     }
                 }
                 if ($enable) {
                     $newPublicUrl = $driver->getPublicUrl($fileData['identifier']);
                 }
             }
         }
         // check if TYPO3 is in backend mode and make the path relative to the current script
         // in order to make it possible to use the relative file
         if (TYPO3_MODE === 'BE' && $relativeToCurrentScript) {
             //DebuggerUtility::var_dump($this->emSettings);
             if ($this->emSettings['disable_be']) {
                 $enable = false;
             } else {
                 // check filetypes field
                 if (!empty($this->emSettings['filetypes_be'])) {
                     $filetypes = explode(',', $this->emSettings['filetypes_be']);
                     if (in_array($fileData['extension'], $filetypes)) {
                     } else {
                         $enable = false;
                     }
                 }
                 if ($enable) {
                     $publicUrl = $driver->getPublicUrl($fileData['identifier']);
                     $absolutePathToContainingFolder = PathUtility::dirname(PATH_site . $publicUrl);
                     $pathPart = PathUtility::getRelativePathTo($absolutePathToContainingFolder);
                     $filePart = substr(PATH_site . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
                     $newPublicUrl = $pathPart . $filePart;
                 }
             }
         }
         if (!empty($newPublicUrl) && !empty($fileData['modDate']) && $enable) {
             $urlData['publicUrl'] = $newPublicUrl . '?v=' . $fileData['modDate'];
         }
     }
 }
开发者ID:Kephson,项目名称:reint_file_timestamp,代码行数:67,代码来源:PublicFileUri.php

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


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