本文整理汇总了PHP中TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP PathUtility::stripPathSitePrefix方法的具体用法?PHP PathUtility::stripPathSitePrefix怎么用?PHP PathUtility::stripPathSitePrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\PathUtility
的用法示例。
在下文中一共展示了PathUtility::stripPathSitePrefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadByCorePageRender
/**
* @param array $asset
* @return void
*/
protected function loadByCorePageRender(array $asset)
{
$file = $this->resolveFileForApplicationContext($asset);
$fileNameAndPath = GeneralUtility::getFileAbsFileName($file);
$fileNameAndPath = PathUtility::stripPathSitePrefix($fileNameAndPath);
if ($asset['type'] === 'js') {
$this->getPageRenderer()->addJsFooterFile($fileNameAndPath);
} elseif ($asset['type'] === 'css') {
$this->getPageRenderer()->addCssFile($fileNameAndPath);
}
}
示例2: render_clickenlarge
/**
* Rendering the "data-htmlarea-clickenlarge" custom attribute, called from TypoScript
*
* @param string Content input. Not used, ignore.
* @param array TypoScript configuration
* @return string HTML output.
* @access private
* @todo Define visibility
*/
public function render_clickenlarge($content, $conf)
{
$clickenlarge = isset($this->cObj->parameters['data-htmlarea-clickenlarge']) ? $this->cObj->parameters['data-htmlarea-clickenlarge'] : 0;
if (!$clickenlarge) {
// Backward compatibility
$clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
}
$fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
$fileTable = $this->cObj->parameters['data-htmlarea-file-table'];
$fileUid = $this->cObj->parameters['data-htmlarea-file-uid'];
if ($fileUid) {
$fileObject = $fileFactory->getFileObject($fileUid);
$filePath = $fileObject->getForLocalProcessing(FALSE);
$file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
} else {
// Pre-FAL backward compatibility
$path = $this->cObj->parameters['src'];
$magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
if ($magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
$magicFolderPath = $magicFolder->getPublicUrl();
$pathPre = $magicFolderPath . 'RTEmagicC_';
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($path, $pathPre)) {
// Find original file:
$pI = pathinfo(substr($path, strlen($pathPre)));
$filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
$file = $magicFolderPath . 'RTEmagicP_' . $filename;
} else {
$file = $this->cObj->parameters['src'];
}
}
}
// Unset clickenlarge custom attribute
unset($this->cObj->parameters['data-htmlarea-clickenlarge']);
// Backward compatibility
unset($this->cObj->parameters['clickenlarge']);
unset($this->cObj->parameters['allParams']);
$content = '<img ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
$theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
if ($theImage) {
$this->cObj->parameters['origFile'] = $theImage;
if ($this->cObj->parameters['title']) {
$conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
}
if ($this->cObj->parameters['alt']) {
$conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
}
$content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']);
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
}
}
return $content;
}
示例3: render
/**
* Render the URI to the resource. The filename is used from child content.
*
* @param string $path The path and filename of the resource (relative to Public resource directory of the extension).
* @param string $extensionName Target extension name. If not set, the current extension name will be used
* @param boolean $absolute If set, an absolute URI is rendered
* @return string The URI to the resource
* @api
*/
public function render($path, $extensionName = NULL, $absolute = FALSE)
{
if ($extensionName === NULL) {
$extensionName = $this->controllerContext->getRequest()->getControllerExtensionName();
}
$uri = 'EXT:' . \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName) . '/Resources/Public/' . $path;
$uri = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($uri);
$uri = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($uri);
if (TYPO3_MODE === 'BE' && $absolute === FALSE && $uri !== FALSE) {
$uri = '../' . $uri;
}
if ($absolute === TRUE) {
$uri = $this->controllerContext->getRequest()->getBaseURI() . $uri;
}
return $uri;
}
示例4: renderStatic
/**
* @param array $arguments
* @param callable $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$path = $arguments['path'];
$extensionName = $arguments['extensionName'];
$absolute = $arguments['absolute'];
if ($extensionName === NULL) {
$extensionName = $renderingContext->getControllerContext()->getRequest()->getControllerExtensionName();
}
$uri = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName) . '/Resources/Public/' . $path;
$uri = GeneralUtility::getFileAbsFileName($uri);
$uri = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($uri);
if (TYPO3_MODE === 'BE' && $absolute === FALSE && $uri !== FALSE) {
$uri = '../' . $uri;
}
if ($absolute === TRUE) {
$uri = $renderingContext->getControllerContext()->getRequest()->getBaseUri() . $uri;
}
return $uri;
}
示例5: renderStatic
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$absolutePath = $renderChildrenClosure();
return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($absolutePath);
}
示例6: setReferenceValue_fileRels
/**
* Setting a value for a reference for a FILE field:
*
* @param array $refRec sys_refindex record
* @param array $itemArray Array of references from that field
* @param string $newValue Value to substitute current value with (or NULL to unset it)
* @param array $dataArray Data array in which the new value is set (passed by reference)
* @param string $flexpointer Flexform pointer, if in a flex form field.
* @return string Error message if any, otherwise FALSE = OK
* @todo Define visibility
*/
public function setReferenceValue_fileRels($refRec, $itemArray, $newValue, &$dataArray, $flexpointer = '')
{
$ID_absFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($itemArray[$refRec['sorting']]['ID_absFile']);
if ($ID_absFile === (string) $refRec['ref_string'] && $refRec['ref_table'] === '_FILE') {
// Setting or removing value:
// Remove value:
if ($newValue === NULL) {
unset($itemArray[$refRec['sorting']]);
} else {
$itemArray[$refRec['sorting']]['filename'] = $newValue;
}
// Traverse and compile new list of records:
$saveValue = array();
foreach ($itemArray as $fileInfo) {
$saveValue[] = $fileInfo['filename'];
}
// Set in data array:
if ($flexpointer) {
$flexToolObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
$dataArray[$refRec['tablename']][$refRec['recuid']][$refRec['field']]['data'] = array();
$flexToolObj->setArrayValueByPath(substr($flexpointer, 0, -1), $dataArray[$refRec['tablename']][$refRec['recuid']][$refRec['field']]['data'], implode(',', $saveValue));
} else {
$dataArray[$refRec['tablename']][$refRec['recuid']][$refRec['field']] = implode(',', $saveValue);
}
} else {
return 'ERROR: either "' . $refRec['ref_table'] . '" was not "_FILE" or file PATH_site+"' . $refRec['ref_string'] . '" did not match that of the record ("' . $itemArray[$refRec['sorting']]['ID_absFile'] . '") in sorting index "' . $refRec['sorting'] . '"';
}
}
示例7: initCurrentUrl
/**
* Initialize $this->curUrlArray and $this->curUrlInfo based on script parameters
*
* @return void
*/
protected function initCurrentUrl()
{
// CurrentUrl - the current link url must be passed around if it exists
if ($this->mode == 'wizard') {
$currentValues = GeneralUtility::trimExplode(LF, trim($this->P['currentValue']));
if (count($currentValues) > 0) {
$currentValue = array_pop($currentValues);
} else {
$currentValue = '';
}
$currentLinkParts = GeneralUtility::unQuoteFilenames($currentValue, TRUE);
$initialCurUrlArray = array('href' => $currentLinkParts[0], 'target' => $currentLinkParts[1], 'class' => $currentLinkParts[2], 'title' => $currentLinkParts[3], 'params' => $currentLinkParts[4]);
$this->curUrlArray = is_array(GeneralUtility::_GP('curUrl')) ? array_merge($initialCurUrlArray, GeneralUtility::_GP('curUrl')) : $initialCurUrlArray;
// Additional fields for page links
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])) {
$conf = array();
$_params = array('conf' => &$conf, 'linkParts' => $currentLinkParts);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'] as $objRef) {
$processor =& GeneralUtility::getUserObj($objRef);
$processor->extendUrlArray($_params, $this);
}
}
$this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
// pageid == 0 means that this is not an internal (page) link
if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) {
// Check if there is the FAL API
if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'file:')) {
$this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
// Remove the "file:" prefix
$currentLinkParts[0] = rawurldecode(substr($this->curUrlArray['href'], 5));
} elseif (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
$currentLinkParts[0] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->curUrlArray['href']);
}
$this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
} elseif (strstr($this->curUrlArray['href'], '@')) {
// check for email link
if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
$currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
}
$this->curUrlInfo = $this->parseCurUrl('mailto:' . $this->curUrlArray['href'], $this->siteURL);
} else {
// nothing of the above. this is an external link
if (strpos($this->curUrlArray['href'], '://') === FALSE) {
$currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
}
$this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
}
} elseif (!$this->curUrlArray['href']) {
$this->curUrlInfo = array();
$this->act = 'page';
} else {
$this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
}
} else {
$this->curUrlArray = GeneralUtility::_GP('curUrl');
if ($this->curUrlArray['all']) {
$this->curUrlArray = GeneralUtility::get_tag_attributes($this->curUrlArray['all']);
}
$this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
}
}
示例8: getIconHtml
/**
* Renders the $icon, supports a filename for skinImg or sprite-icon-name
*
* @param string $icon The icon passed, could be a file-reference or a sprite Icon name
* @param string $alt Alt attribute of the icon returned
* @param string $title Title attribute of the icon return
* @return string A tag representing to show the asked icon
* @internal
*/
public static function getIconHtml($icon, $alt = '', $title = '')
{
$icon = (string) $icon;
$iconFile = '';
$iconInfo = false;
if (StringUtility::beginsWith($icon, 'EXT:')) {
$absoluteFilePath = GeneralUtility::getFileAbsFileName($icon);
if (!empty($absoluteFilePath)) {
$iconFile = '../' . PathUtility::stripPathSitePrefix($absoluteFilePath);
$iconInfo = StringUtility::endsWith($absoluteFilePath, '.svg') ? true : getimagesize($absoluteFilePath);
}
} elseif (StringUtility::beginsWith($icon, '../')) {
// @TODO: this is special modList, files from folders and selicon
$iconFile = GeneralUtility::resolveBackPath($icon);
if (is_file(PATH_site . GeneralUtility::resolveBackPath(substr($icon, 3)))) {
$iconInfo = StringUtility::endsWith($icon, '.svg') ? true : getimagesize(PATH_site . GeneralUtility::resolveBackPath(substr($icon, 3)));
}
}
if ($iconInfo !== false && is_file(GeneralUtility::resolveBackPath(PATH_typo3 . $iconFile))) {
return '<img' . ' src="' . htmlspecialchars($iconFile) . '"' . ' alt="' . htmlspecialchars($alt) . '" ' . ($title ? 'title="' . htmlspecialchars($title) . '"' : '') . ' />';
}
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
return '<span alt="' . htmlspecialchars($alt) . '" title="' . htmlspecialchars($title) . '">' . $iconFactory->getIcon($icon, Icon::SIZE_SMALL)->render() . '</span>';
}
示例9: getRelativePath
/**
* Returns relative path
*
* @param string $absolutePath
* @return string
*/
protected function getRelativePath($absolutePath)
{
return PathUtility::stripPathSitePrefix($absolutePath);
}
示例10: ext_getTSCE_config_image
/**
* [Describe function...]
*
* @param [type] $imgConf: ...
* @return [type] ...
* @todo Define visibility
*/
public function ext_getTSCE_config_image($imgConf)
{
if (substr($imgConf, 0, 4) == 'gfx/') {
$iFile = $this->ext_localGfxPrefix . $imgConf;
$tFile = $this->ext_localWebGfxPrefix . $imgConf;
} elseif (substr($imgConf, 0, 4) == 'EXT:') {
$iFile = GeneralUtility::getFileAbsFileName($imgConf);
if ($iFile) {
$f = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($iFile);
$tFile = $GLOBALS['BACK_PATH'] . '../' . $f;
}
}
$imageInfo = @getImagesize($iFile);
return '<img src="' . $tFile . '" ' . $imageInfo[3] . '>';
}
示例11: determineBaseUrl
/**
* Determines the base URL for this driver, from the configuration or
* the TypoScript frontend object
*
* @return void
*/
protected function determineBaseUrl()
{
// only calculate baseURI if the storage does not enforce jumpUrl Script
if ($this->hasCapability(ResourceStorage::CAPABILITY_PUBLIC)) {
if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, PATH_site)) {
// use site-relative URLs
$temporaryBaseUri = rtrim(PathUtility::stripPathSitePrefix($this->absoluteBasePath), '/');
if ($temporaryBaseUri !== '') {
$uriParts = explode('/', $temporaryBaseUri);
$uriParts = array_map('rawurlencode', $uriParts);
$temporaryBaseUri = implode('/', $uriParts) . '/';
}
$this->baseUri = $temporaryBaseUri;
} elseif (isset($this->configuration['baseUri']) && GeneralUtility::isValidUrl($this->configuration['baseUri'])) {
$this->baseUri = rtrim($this->configuration['baseUri'], '/') . '/';
}
}
}
示例12: getFileName
/**
* Returns the reference used for the frontend inclusion, checks against allowed paths for inclusion.
*
* @param string $fileFromSetup TypoScript "resource" data type value.
* @return string|NULL Resulting filename, is either a full absolute URL or a relative path. Returns NULL if invalid filename or a directory is given
*/
public function getFileName($fileFromSetup)
{
$file = trim($fileFromSetup);
if (!$file) {
return NULL;
} elseif (strpos($file, '../') !== FALSE) {
if ($this->tt_track) {
$this->getTimeTracker()->setTSlogMessage('File path "' . $file . '" contained illegal string "../"!', 3);
}
return NULL;
}
// Cache
$hash = md5($file);
if (isset($this->fileCache[$hash])) {
return $this->fileCache[$hash];
}
// if this is an URL, it can be returned directly
$urlScheme = parse_url($file, PHP_URL_SCHEME);
if ($urlScheme === 'https' || $urlScheme === 'http' || is_file(PATH_site . $file)) {
return $file;
}
// this call also resolves EXT:myext/ files
$file = GeneralUtility::getFileAbsFileName($file);
if (!$file) {
if ($this->tt_track) {
$this->getTimeTracker()->setTSlogMessage('File "' . $fileFromSetup . '" was not found!', 3);
}
return NULL;
}
$file = PathUtility::stripPathSitePrefix($file);
// Check if the found file is in the allowed paths
foreach ($this->allowedPaths as $val) {
if (GeneralUtility::isFirstPartOfStr($file, $val)) {
$this->fileCache[$hash] = $file;
return $file;
}
}
if ($this->tt_track) {
$this->getTimeTracker()->setTSlogMessage('"' . $file . '" was not located in the allowed paths: (' . implode(',', $this->allowedPaths) . ')', 3);
}
return NULL;
}
示例13: logDeprecatedFunction
/**
* Logs a call to a deprecated function.
* The log message will be taken from the annotation.
*
* @return void
*/
public static function logDeprecatedFunction()
{
if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
return;
}
// This require_once is needed for deprecation calls
// thrown early during bootstrap, if the autoloader is
// not instantiated yet. This can happen for example if
// ext_localconf triggers a deprecation.
require_once 'DebugUtility.php';
$trail = debug_backtrace();
if ($trail[1]['type']) {
$function = new \ReflectionMethod($trail[1]['class'], $trail[1]['function']);
} else {
$function = new \ReflectionFunction($trail[1]['function']);
}
$msg = '';
if (preg_match('/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
$msg = $match[1];
}
// Write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
$logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
$logMsg .= '() - ' . $msg . ' - ' . \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
$logMsg .= ' (' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($function->getFileName()) . '#' . $function->getStartLine() . ')';
self::deprecationLog($logMsg);
}
示例14: checkExtensionModule
/**
* If the module name ($name) is a module from an extension (has path in $this->absPathArray)
* then that path is returned relative to PATH_site
*
* @param string $name Module name
* @return string If found, the relative path from PATH_site
*/
public function checkExtensionModule($name)
{
if (isset($this->absPathArray[$name])) {
return rtrim(PathUtility::stripPathSitePrefix($this->absPathArray[$name]), '/');
}
return '';
}
示例15: colorImage
/**
* Creates a color image selector
*
* @return string
*/
public function colorImage()
{
// Handling color-picker image if any:
if (!$this->imageError) {
if ($this->pickerImage) {
if (GeneralUtility::_POST('coords_x')) {
/** @var $image \TYPO3\CMS\Core\Imaging\GraphicalFunctions */
$image = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\GraphicalFunctions::class);
$this->colorValue = '#' . $this->getIndex($image->imageCreateFromFile($this->pickerImage), GeneralUtility::_POST('coords_x'), GeneralUtility::_POST('coords_y'));
}
$pickerFormImage = '
<p class="c-head">' . $this->getLanguageService()->getLL('colorpicker_fromImage', true) . '</p>
<input type="image" src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->pickerImage) . '" name="coords" style="cursor:crosshair;" /><br />';
} else {
$pickerFormImage = '';
}
} else {
$pickerFormImage = '
<p class="c-head">' . htmlspecialchars($this->imageError) . '</p>';
}
return $pickerFormImage;
}