[TASK] Add tool-function to strip PATH_site-part of paths 51/25851/3
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 8 Dec 2013 15:42:02 +0000 (16:42 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Wed, 18 Dec 2013 22:29:19 +0000 (23:29 +0100)
Avoid having to use the substr/strlen-magic.
Also strlen(PATH_site) can be statically cached.

Change-Id: I0ef942e331e2039e2ece9a55dd740db2a3896e2c
Resolves: #54126
Releases: 6.2
Reviewed-on: https://review.typo3.org/25851
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Markus Klein
Tested-by: Markus Klein
41 files changed:
typo3/sysext/aboutmodules/Classes/Controller/ModulesController.php
typo3/sysext/backend/Classes/Controller/NoDocumentsOpenController.php
typo3/sysext/backend/Classes/Controller/ShortcutFrameController.php
typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Module/ModuleLoader.php
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/ModuleMenuView.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Database/ReferenceIndex.php
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Classes/Localization/Parser/LocallangArrayParser.php
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
typo3/sysext/core/Classes/Resource/ResourceFactory.php
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Classes/Utility/DebugUtility.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Classes/Utility/PathUtility.php
typo3/sysext/cshmanual/Classes/Controller/HelpModuleController.php
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php
typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ResourceViewHelper.php
typo3/sysext/impexp/Classes/Controller/ImportExportController.php
typo3/sysext/impexp/Classes/ImportExport.php
typo3/sysext/indexed_search/Classes/Controller/IndexedPagesController.php
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
typo3/sysext/indexed_search/Classes/Controller/SearchFormController.php
typo3/sysext/indexed_search/Classes/Hook/CrawlerHook.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php
typo3/sysext/install/Classes/ViewHelpers/File/RelativePathViewHelper.php
typo3/sysext/lowlevel/Classes/DoubleFilesCommand.php
typo3/sysext/lowlevel/Classes/RteImagesCommand.php
typo3/sysext/lowlevel/Classes/View/DatabaseIntegrityView.php
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
typo3/sysext/rtehtmlarea/Classes/Controller/CustomAttributeController.php
typo3/sysext/rtehtmlarea/Classes/SelectImage.php

index 5cb1278..0a42376 100644 (file)
@@ -116,7 +116,7 @@ class ModulesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControll
                        $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
                        $subModuleData = array();
                        $subModuleData['name'] = $subModuleName;
-                       $subModuleData['icon'] = substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$subModuleKey], strlen(PATH_site));
+                       $subModuleData['icon'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($GLOBALS['LANG']->moduleLabels['tabs_images'][$subModuleKey]);
                        $subModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$subModuleKey];
                        $subModuleData['shortDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'label'];
                        $subModuleData['longDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'descr'];
index abfbd62..6fc7181 100644 (file)
@@ -120,11 +120,11 @@ class NoDocumentsOpenController {
                // Finding module images: PAGE
                $imgFile = $GLOBALS['LANG']->moduleLabels['tabs_images']['web_layout_tab'];
                $imgInfo = @getimagesize($imgFile);
-               $img_web_layout = is_array($imgInfo) ? '<img src="../' . substr($imgFile, strlen(PATH_site)) . '" ' . $imgInfo[3] . ' alt="" />' : '';
+               $img_web_layout = is_array($imgInfo) ? '<img src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($imgFile) . '" ' . $imgInfo[3] . ' alt="" />' : '';
                // Finding module images: LIST
                $imgFile = $GLOBALS['LANG']->moduleLabels['tabs_images']['web_list_tab'];
                $imgInfo = @getimagesize($imgFile);
-               $img_web_list = is_array($imgInfo) ? '<img src="../' . substr($imgFile, strlen(PATH_site)) . '" ' . $imgInfo[3] . ' alt="" />' : '';
+               $img_web_list = is_array($imgInfo) ? '<img src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($imgFile) . '" ' . $imgInfo[3] . ' alt="" />' : '';
                // If either the Web>List OR Web>Page module are active, show the little message with links to those modules:
                if ($a_wl || $a_wp) {
                        $msg_2 = array();
index 0abfb80..01e5387 100644 (file)
@@ -749,7 +749,7 @@ class ShortcutFrameController {
                // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
                $Ifilename = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $Ifilename);
                if (GeneralUtility::isAbsPath($Ifilename)) {
-                       $Ifilename = '../' . substr($Ifilename, strlen(PATH_site));
+                       $Ifilename = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($Ifilename);
                }
                return $backPath . $Ifilename;
        }
index d665a13..c14739e 100644 (file)
@@ -371,7 +371,7 @@ class ColorpickerController {
                                }
                                $pickerFormImage = '
                                <p class="c-head">' . $GLOBALS['LANG']->getLL('colorpicker_fromImage', TRUE) . '</p>
-                               <input type="image" src="../' . substr($this->pickerImage, strlen(PATH_site)) . '" name="coords" style="cursor:crosshair;" /><br />';
+                               <input type="image" src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->pickerImage) . '" name="coords" style="cursor:crosshair;" /><br />';
                        } else {
                                $pickerFormImage = '';
                        }
index b3d68fb..defbe81 100644 (file)
@@ -4130,7 +4130,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                                if (!strcmp(substr($wConf['script'], 0, 4), 'EXT:')) {
                                                                        $wScript = GeneralUtility::getFileAbsFileName($wConf['script']);
                                                                        if ($wScript) {
-                                                                               $wScript = '../' . substr($wScript, strlen(PATH_site));
+                                                                               $wScript = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($wScript);
                                                                        } else {
                                                                                break;
                                                                        }
@@ -4289,7 +4289,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                if (substr($icon, 0, 4) == 'EXT:') {
                        $file = GeneralUtility::getFileAbsFileName($icon);
                        if ($file) {
-                               $file = substr($file, strlen(PATH_site));
+                               $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($file);
                                $selIconFile = $this->backPath . '../' . $file;
                                $selIconInfo = @getimagesize((PATH_site . $file));
                        }
@@ -4785,7 +4785,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                $fileArr = GeneralUtility::removePrefixPathFromList($fileArr, $fileFolder);
                                foreach ($fileArr as $fileRef) {
                                        $fI = pathinfo($fileRef);
-                                       $icon = GeneralUtility::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../' . substr($fileFolder, strlen(PATH_site)) . $fileRef : '';
+                                       $icon = GeneralUtility::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fileFolder) . $fileRef : '';
                                        $items[] = array(
                                                $fileRef,
                                                $fileRef,
@@ -4945,7 +4945,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                        // Icon:
                                                        $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$theMod . '_tab'];
                                                        if ($icon) {
-                                                               $icon = '../' . substr($icon, strlen(PATH_site));
+                                                               $icon = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($icon);
                                                        }
                                                        // Add help text
                                                        $helpText = array(
index 9fa43e3..d27c1f9 100644 (file)
@@ -215,7 +215,7 @@ class ModuleLoader {
         */
        public function checkExtensionModule($name) {
                if (isset($this->absPathArray[$name])) {
-                       return rtrim(substr($this->absPathArray[$name], strlen(PATH_site)), '/');
+                       return rtrim(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->absPathArray[$name]), '/');
                }
        }
 
index 0228042..b5aeba9 100644 (file)
@@ -349,7 +349,7 @@ class DocumentTemplate {
                if (($temp_M = (string) GeneralUtility::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
                        $this->scriptID = preg_replace('/^.*\\/(sysext|ext)\\//', 'ext/', $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M] . 'index.php');
                } else {
-                       $this->scriptID = preg_replace('/^.*\\/(sysext|ext)\\//', 'ext/', substr(PATH_thisScript, strlen(PATH_site)));
+                       $this->scriptID = preg_replace('/^.*\\/(sysext|ext)\\//', 'ext/', \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(PATH_thisScript));
                }
                if (TYPO3_mainDir != 'typo3/' && substr($this->scriptID, 0, strlen(TYPO3_mainDir)) == TYPO3_mainDir) {
                        // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
index 3bf09eb..a9dac9d 100644 (file)
@@ -622,7 +622,7 @@ class ShortcutToolbarItem implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookI
                                        // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
                                        $icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon);
                                        if (GeneralUtility::isAbsPath($icon)) {
-                                               $icon = '../' . substr($icon, strlen(PATH_site));
+                                               $icon = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($icon);
                                        }
                                } else {
                                        $icon = 'gfx/dummy_module.gif';
index 12685e9..1ce3280 100644 (file)
@@ -3531,7 +3531,7 @@ class BackendUtility {
                        // Look up the path:
                        if ($table == '_FILE') {
                                if (GeneralUtility::isFirstPartOfStr($ref, PATH_site)) {
-                                       $ref = substr($ref, strlen(PATH_site));
+                                       $ref = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($ref);
                                        $condition = 'ref_string=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($ref, 'sys_refindex');
                                } else {
                                        return '';
index 18ebcb3..2f46de4 100644 (file)
@@ -314,7 +314,7 @@ class ModuleMenuView {
         */
        protected function getModuleIconRelative($iconFilename) {
                if (GeneralUtility::isAbsPath($iconFilename)) {
-                       $iconFilename = '../' . substr($iconFilename, strlen(PATH_site));
+                       $iconFilename = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($iconFilename);
                }
                return $this->backPath . $iconFilename;
        }
index 7ca3451..83d297a 100644 (file)
@@ -2122,7 +2122,7 @@ class DataHandler {
                                                }
                                                $theFile = GeneralUtility::fixWindowsFilePath($theFile);
                                                if (GeneralUtility::isFirstPartOfStr($theFile, PATH_site)) {
-                                                       $theFile = substr($theFile, strlen(PATH_site));
+                                                       $theFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($theFile);
                                                }
                                        }
                                        unset($theFile);
@@ -3506,11 +3506,11 @@ class DataHandler {
                                                                GeneralUtility::upload_copy_move(PATH_site . $rec['ref_string'], $copyDestName);
                                                                clearstatcache();
                                                                // Register this:
-                                                               $this->RTEmagic_copyIndex[$rec['tablename']][$rec['recuid']][$rec['field']][$rec['ref_string']] = substr($copyDestName, strlen(PATH_site));
+                                                               $this->RTEmagic_copyIndex[$rec['tablename']][$rec['recuid']][$rec['field']][$rec['ref_string']] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($copyDestName);
                                                                // Check and update the record using \TYPO3\CMS\Core\Database\ReferenceIndex
                                                                if (@is_file($copyDestName)) {
                                                                        $sysRefObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                                                                       $error = $sysRefObj->setReferenceValue($rec['hash'], substr($copyDestName, strlen(PATH_site)), FALSE, TRUE);
+                                                                       $error = $sysRefObj->setReferenceValue($rec['hash'], \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($copyDestName), FALSE, TRUE);
                                                                        if ($error) {
                                                                                echo $this->newlog('TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error, 1);
                                                                        }
index e91a8f1..6966c9c 100644 (file)
@@ -282,7 +282,7 @@ class ReferenceIndex {
                foreach ($items as $sort => $i) {
                        $filePath = $i['ID_absFile'];
                        if (GeneralUtility::isFirstPartOfStr($filePath, PATH_site)) {
-                               $filePath = substr($filePath, strlen(PATH_site));
+                               $filePath = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                        }
                        $this->relations[] = $this->createEntryData($table, $uid, $fieldname, $flexpointer, $deleted, '_FILE', 0, $filePath, $sort);
                }
@@ -730,7 +730,7 @@ class ReferenceIndex {
         * @todo Define visibility
         */
        public function setReferenceValue_fileRels($refRec, $itemArray, $newValue, &$dataArray, $flexpointer = '') {
-               if (!strcmp(substr($itemArray[$refRec['sorting']]['ID_absFile'], strlen(PATH_site)), $refRec['ref_string']) && !strcmp('_FILE', $refRec['ref_table'])) {
+               if (!strcmp(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($itemArray[$refRec['sorting']]['ID_absFile']), $refRec['ref_string']) && !strcmp('_FILE', $refRec['ref_table'])) {
                        // Setting or removing value:
                        // Remove value:
                        if ($newValue === NULL) {
index 4afb4ba..cc0dd8e 100644 (file)
@@ -402,7 +402,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
                                                                        $attribArray['width'] = $imageInfo[0];
                                                                        $attribArray['height'] = $imageInfo[1];
                                                                        $attribArray['data-htmlarea-file-uid'] = $fileObject->getUid();
-                                                                       $absRef = $siteUrl . substr($filePath, strlen(PATH_site));
+                                                                       $absRef = $siteUrl . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                                                                }
                                                                $attribArray['src'] = $absRef;
                                                                $params = GeneralUtility::implodeAttributes($attribArray, 1);
@@ -464,7 +464,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
                                                                                        $attribArray['style'] = preg_replace('/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
                                                                                        $attribArray['width'] = $imageInfo[0];
                                                                                        $attribArray['height'] = $imageInfo[1];
-                                                                                       $attribArray['src'] = $this->siteURL() . substr($filePath, strlen(PATH_site));
+                                                                                       $attribArray['src'] = $this->siteURL() . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                                                                                        $params = GeneralUtility::implodeAttributes($attribArray, 1);
                                                                                        $imgSplit[$k] = '<img ' . $params . ' />';
                                                                                }
@@ -562,7 +562,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
                                        if ($attribArray['data-htmlarea-file-uid'] && !$isMagicImage) {
                                                $fileObject = $fileFactory->getFileObject($attribArray['data-htmlarea-file-uid']);
                                                $filePath = $fileObject->getForLocalProcessing(FALSE);
-                                               $attribArray['src'] = $siteUrl . substr($filePath, strlen(PATH_site));
+                                               $attribArray['src'] = $siteUrl . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                                        } else {
                                                $attribArray['src'] = substr($attribArray['src'], strlen($this->relBackPath));
                                                // if site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl
index ab484d9..60aaee7 100644 (file)
@@ -138,7 +138,7 @@ class LocallangArrayParser implements \TYPO3\CMS\Core\Localization\Parser\Locali
                // Get PHP data
                include $sourcePath;
                if (!is_array($LOCAL_LANG)) {
-                       $fileName = substr($sourcePath, strlen(PATH_site));
+                       $fileName = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($sourcePath);
                        throw new \RuntimeException('TYPO3 Fatal Error: "' . $fileName . '" is no TYPO3 language file!', 1308898491);
                }
                // Converting the default language (English)
@@ -176,7 +176,7 @@ class LocallangArrayParser implements \TYPO3\CMS\Core\Localization\Parser\Locali
         * @return void
         */
        protected function generateCacheFileName($sourcePath, $languageKey) {
-               $this->hashSource = substr($sourcePath, strlen(PATH_site)) . '|' . date('d-m-Y H:i:s', filemtime($sourcePath)) . '|version=2.3';
+               $this->hashSource = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($sourcePath) . '|' . date('d-m-Y H:i:s', filemtime($sourcePath)) . '|version=2.3';
                $this->cacheFileName = PATH_site . 'typo3temp/llxml/' . substr(basename($sourcePath), 10, 15) . '_' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($this->hashSource) . '.' . $languageKey . '.' . $this->targetCharset . '.cache';
        }
 
index cd4053d..ab378aa 100644 (file)
@@ -119,7 +119,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver {
                if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, PATH_site)) {
                        // use site-relative URLs
                        // TODO add unit test
-                       $this->baseUri = substr($this->absoluteBasePath, strlen(PATH_site));
+                       $this->baseUri = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->absoluteBasePath);
                } elseif (isset($this->configuration['baseUri']) && GeneralUtility::isValidUrl($this->configuration['baseUri'])) {
                        $this->baseUri = rtrim($this->configuration['baseUri'], '/') . '/';
                } else {
index 986c6d3..72a46d1 100644 (file)
@@ -470,7 +470,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        $folderIdentifier = $parts[0];
                        // make sure to not use an absolute path, and remove PATH_site if it is prepended
                        if (GeneralUtility::isFirstPartOfStr($folderIdentifier, PATH_site)) {
-                               $folderIdentifier = substr($parts[0], strlen(PATH_site));
+                               $folderIdentifier = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($parts[0]);
                        }
                }
                return $this->getStorageObject($storageUid, array(), $folderIdentifier)->getFolder($folderIdentifier);
index ba510c2..bdd15ec 100644 (file)
@@ -1079,7 +1079,7 @@ class ExtendedTemplateService extends \TYPO3\CMS\Core\TypoScript\TemplateService
                } elseif (substr($imgConf, 0, 4) == 'EXT:') {
                        $iFile = GeneralUtility::getFileAbsFileName($imgConf);
                        if ($iFile) {
-                               $f = substr($iFile, strlen(PATH_site));
+                               $f = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($iFile);
                                $tFile = $GLOBALS['BACK_PATH'] . '../' . $f;
                        }
                }
index 7d3c1ca..f8d4524 100644 (file)
@@ -1245,7 +1245,7 @@ class TemplateService {
                        list($extKey, $script) = explode('/', substr($file, 4), 2);
                        if ($extKey && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) {
                                $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey);
-                               $newFile = substr($extPath, strlen(PATH_site)) . $script;
+                               $newFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($extPath) . $script;
                        }
                        if (!@is_file((PATH_site . $newFile))) {
                                if ($this->tt_track) {
index 53c9ed8..6b15a22 100644 (file)
@@ -210,7 +210,7 @@ class DebugUtility {
                        $pathFragment = $dat['class'] . $dat['type'] . $dat['function'];
                        // add the path of the included file
                        if (in_array($dat['function'], array('require', 'include', 'require_once', 'include_once'))) {
-                               $pathFragment .= '(' . substr($dat['args'][0], strlen(PATH_site)) . '),' . substr($dat['file'], strlen(PATH_site));
+                               $pathFragment .= '(' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($dat['args'][0]) . '),' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($dat['file']);
                        }
                        $path[] = $pathFragment . '#' . $dat['line'];
                }
index a860db6..9b2de5e 100644 (file)
@@ -136,7 +136,7 @@ class ExtensionManagementUtility {
         * @return string
         */
        static public function siteRelPath($key) {
-               return substr(self::extPath($key), strlen(PATH_site));
+               return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(self::extPath($key));
        }
 
        /**
index 77f7070..d1509ae 100644 (file)
@@ -3312,7 +3312,7 @@ Connection: close
                                break;
                        case 'TYPO3_SITE_URL':
                                if (defined('PATH_thisScript') && defined('PATH_site')) {
-                                       $lPath = substr(dirname(PATH_thisScript), strlen(PATH_site)) . '/';
+                                       $lPath = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(dirname(PATH_thisScript)) . '/';
                                        $url = self::getIndpEnv('TYPO3_REQUEST_DIR');
                                        $siteUrl = substr($url, 0, -strlen($lPath));
                                        if (substr($siteUrl, -1) != '/') {
@@ -4939,7 +4939,7 @@ Connection: close
                        // 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 .= ' (' . substr($function->getFileName(), strlen(PATH_site)) . '#' . $function->getStartLine() . ')';
+               $logMsg .= ' (' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($function->getFileName()) . '#' . $function->getStartLine() . ')';
                self::deprecationLog($logMsg);
        }
 
index add0b5f..6144a54 100644 (file)
@@ -308,6 +308,22 @@ class PathUtility {
                return $protocol . $absolutePathPrefix . implode('/', $theDirParts);
        }
 
+       /**
+        * Strip first part of a path, equal to the length of PATH_site
+        *
+        * @param string $path
+        * @return array
+        */
+       static public function stripPathSitePrefix($path) {
+               static $pathSiteLength = NULL;
+
+               // calculate length when first needed
+               if (!isset($pathSiteLength)) {
+                       $pathSiteLength = strlen(PATH_site);
+               }
+               return substr($path, $pathSiteLength);
+       }
+
        /*********************
         *
         * Helper methods
index 4cce3f8..a49b395 100644 (file)
@@ -456,7 +456,7 @@ class HelpModuleController {
                                } elseif (substr($iPUrl[1], 0, 5) == 'FILE:') {
                                        $fileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName(substr($iPUrl[1], 5), 1, 1);
                                        if ($fileName && @is_file($fileName)) {
-                                               $fileName = '../' . substr($fileName, strlen(PATH_site));
+                                               $fileName = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fileName);
                                                $lines[] = '<a href="' . htmlspecialchars($fileName) . '" target="_blank"><em>' . htmlspecialchars($iPUrl[0]) . '</em></a>';
                                        }
                                } else {
@@ -494,7 +494,7 @@ class HelpModuleController {
                                $descr = $descrArray[$k];
                                $absImagePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($image, 1, 1);
                                if ($absImagePath && @is_file($absImagePath)) {
-                                       $imgFile = substr($absImagePath, strlen(PATH_site));
+                                       $imgFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($absImagePath);
                                        $imgInfo = @getimagesize($absImagePath);
                                        if (is_array($imgInfo)) {
                                                $imgFile = '../' . $imgFile;
index f8a78de..0db6d1a 100644 (file)
@@ -3520,7 +3520,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
         */
        public function debugHandler($function, $execTime, $inData) {
                // we don't want to log our own log/debug SQL
-               $script = substr(PATH_thisScript, strlen(PATH_site));
+               $script = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(PATH_thisScript);
                if (substr($script, -strlen('dbal/mod1/index.php')) != 'dbal/mod1/index.php' && !strstr($inData['args'][0], 'tx_dbal_debuglog')) {
                        $data = array();
                        $errorFlag = 0;
index 3c93514..90b2c34 100644 (file)
@@ -293,7 +293,7 @@ class FileHandlingUtility implements \TYPO3\CMS\Core\SingletonInterface {
         * @return string
         */
        protected function getRelativePath($absolutePath) {
-               return substr($absolutePath, strlen(PATH_site));
+               return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($absolutePath);
        }
 
        /**
index 904744e..785f7a1 100644 (file)
@@ -43,7 +43,7 @@ class ResourceViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHe
                }
                $uri = 'EXT:' . \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName) . '/Resources/Public/' . $path;
                $uri = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($uri);
-               $uri = substr($uri, strlen(PATH_site));
+               $uri = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($uri);
                if (TYPO3_MODE === 'BE' && $absolute === FALSE && $uri !== FALSE) {
                        $uri = '../' . $uri;
                }
index 50b8eb7..3b41ff3 100644 (file)
@@ -312,7 +312,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                $fullName = $savePath . $dlFile;
                                if (GeneralUtility::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && GeneralUtility::isAllowedAbsPath($fullName)) {
                                        GeneralUtility::writeFile($fullName, $out);
-                                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('exportdata_savedFile'), sprintf($GLOBALS['LANG']->getLL('exportdata_savedInSBytes', TRUE), substr($savePath . $dlFile, strlen(PATH_site)), GeneralUtility::formatSize(strlen($out))), 0, 1);
+                                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('exportdata_savedFile'), sprintf($GLOBALS['LANG']->getLL('exportdata_savedInSBytes', TRUE), \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($savePath . $dlFile), GeneralUtility::formatSize(strlen($out))), 0, 1);
                                } else {
                                        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('exportdata_problemsSavingFile'), sprintf($GLOBALS['LANG']->getLL('exportdata_badPathS', TRUE), $fullName), 0, 1, 2);
                                }
@@ -681,7 +681,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                                        ' . (is_array($thumbnails) ? '
                                                        ' . $LANG->getLL('makesavefo_thumbnail', TRUE) . '<br/>
                                                        ' . $this->renderSelectBox('tx_impexp[meta][thumbnail]', $inData['meta']['thumbnail'], $thumbnails) . '<br/>
-                                                       ' . ($inData['meta']['thumbnail'] ? '<img src="' . $this->doc->backPath . '../' . substr($tempDir, strlen(PATH_site)) . $thumbnails[$inData['meta']['thumbnail']] . '" vspace="5" style="border: solid black 1px;" alt="" /><br/>' : '') . '
+                                                       ' . ($inData['meta']['thumbnail'] ? '<img src="' . $this->doc->backPath . '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($tempDir) . $thumbnails[$inData['meta']['thumbnail']] . '" vspace="5" style="border: solid black 1px;" alt="" /><br/>' : '') . '
                                                        ' . $LANG->getLL('makesavefo_uploadThumbnail', TRUE) . '<br/>
                                                        <input type="file" name="upload_1" ' . $this->doc->formWidth(30) . ' size="30" /><br/>
                                                                <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempDir) . '" />
@@ -703,7 +703,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                        <td>' . $this->renderSelectBox('tx_impexp[filetype]', $inData['filetype'], $opt) . '<br/>
                                                ' . $LANG->getLL('makesavefo_maxSizeOfFiles', TRUE) . '<br/>
                                                <input type="text" name="tx_impexp[maxFileSize]" value="' . htmlspecialchars($inData['maxFileSize']) . '"' . $this->doc->formWidth(10) . ' /><br/>
-                                               ' . ($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS', TRUE), substr($savePath, strlen(PATH_site))) . '<br/>
+                                               ' . ($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS', TRUE), \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($savePath)) . '<br/>
                                                <input type="text" name="tx_impexp[filename]" value="' . htmlspecialchars($inData['filename']) . '"' . $this->doc->formWidth(30) . ' /><br/>' : '') . '
                                        </td>
                                </tr>';
@@ -769,7 +769,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                        $row = array();
                        $opt = array('');
                        foreach ($filesInDir as $file) {
-                               $opt[$file] = substr($file, strlen(PATH_site));
+                               $opt[$file] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($file);
                        }
                        $row[] = '<tr class="bgColor5">
                                        <td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', TRUE) . '</strong></td>
@@ -853,7 +853,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                if (GeneralUtility::_POST('_upload')) {
                                        $row[] = '<tr class="bgColor4">
                                                        <td>' . $LANG->getLL('importdata_uploadStatus', TRUE) . '</td>
-                                                       <td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', TRUE) . ' ' . substr($this->fileProcessor->internalUploadMap[1], strlen(PATH_site)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', TRUE) . '</span>') . '</td>
+                                                       <td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', TRUE) . ' ' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileProcessor->internalUploadMap[1]) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', TRUE) . '</span>') . '</td>
                                                </tr>';
                                }
                                $menuItems[] = array(
@@ -908,7 +908,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                        </tr>';
                                $opt = array('');
                                foreach ($filesInDir as $file) {
-                                       $opt[$file] = substr($file, strlen(PATH_site));
+                                       $opt[$file] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($file);
                                }
                                $trow[] = '<tr class="bgColor4">
                                        <td><strong>' . $LANG->getLL('importdata_title', TRUE) . '</strong></td>
@@ -937,7 +937,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                                // Check that the image really is an image and not a malicious PHP script...
                                                if (getimagesize($fileName)) {
                                                        // Create icon tag:
-                                                       $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
+                                                       $iconTag = '<img src="' . $this->doc->backPath . '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fileName) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
                                                        $trow[] = '<tr class="bgColor4">
                                                                <td><strong>' . $LANG->getLL('importdata_icon', TRUE) . '</strong></td>
                                                                <td>' . $iconTag . '</td>
index b94363e..0e6199d 100644 (file)
@@ -802,7 +802,7 @@ class ImportExport {
                                $fileRec['filename'] = basename($fI['ID_absFile']);
                                $fileRec['filemtime'] = filemtime($fI['ID_absFile']);
                                //for internal type file_reference
-                               $fileRec['relFileRef'] = substr($fI['ID_absFile'], strlen(PATH_site));
+                               $fileRec['relFileRef'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fI['ID_absFile']);
                                if ($recordRef) {
                                        $fileRec['record_ref'] = $recordRef . '/' . $fieldname;
                                }
@@ -843,7 +843,7 @@ class ImportExport {
                                                        $fileRec['content_md5'] = md5($fileRec['content']);
                                                        $this->dat['files'][$RTEoriginal_ID] = $fileRec;
                                                } else {
-                                                       $this->error('RTE original file "' . substr($RTEoriginal_absPath, strlen(PATH_site)) . '" was not found!');
+                                                       $this->error('RTE original file "' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($RTEoriginal_absPath) . '" was not found!');
                                                }
                                        }
                                        // Files with external media?
@@ -1902,7 +1902,7 @@ class ImportExport {
                                                        $this->writeFileVerify($copyDestName, $cfg['file_ID'], TRUE);
                                                        $this->writeFileVerify($origDestName, $fileHeaderInfo['RTE_ORIG_ID'], TRUE);
                                                        // Return the relative path of the copy file name:
-                                                       return substr($copyDestName, strlen(PATH_site));
+                                                       return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($copyDestName);
                                                } else {
                                                        $this->error('ERROR: Could not find original file ID');
                                                }
@@ -1945,7 +1945,7 @@ class ImportExport {
        public function processSoftReferences_saveFile_createRelFile($origDirPrefix, $fileName, $fileID, $table, $uid) {
                // If the fileID map contains an entry for this fileID then just return the relative filename of that entry; we don't want to write another unique filename for this one!
                if ($this->fileIDMap[$fileID]) {
-                       return substr($this->fileIDMap[$fileID], strlen(PATH_site));
+                       return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$fileID]);
                }
                // Verify FileMount access to dir-prefix. Returns the best alternative relative path if any
                $dirPrefix = $this->verifyFolderAccess($origDirPrefix);
@@ -1976,7 +1976,7 @@ class ImportExport {
                                                                $absResourceFileName = GeneralUtility::resolveBackPath(PATH_site . $origDirPrefix . $relResourceFileName);
                                                                $absResourceFileName = GeneralUtility::getFileAbsFileName($absResourceFileName);
                                                                if ($absResourceFileName && GeneralUtility::isFirstPartOfStr($absResourceFileName, PATH_site . $this->fileadminFolderName . '/')) {
-                                                                       $destDir = substr(dirname($absResourceFileName) . '/', strlen(PATH_site));
+                                                                       $destDir = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(dirname($absResourceFileName) . '/');
                                                                        if ($this->verifyFolderAccess($destDir, TRUE) && $this->checkOrCreateDir($destDir)) {
                                                                                $this->writeFileVerify($absResourceFileName, $res_fileID);
                                                                        } else {
@@ -2009,7 +2009,7 @@ class ImportExport {
                                                GeneralUtility::writeFile($newName, $tokenizedContent);
                                        }
                                }
-                               return substr($newName, strlen(PATH_site));
+                               return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($newName);
                        }
                }
        }
@@ -2113,7 +2113,7 @@ class ImportExport {
                                if (GeneralUtility::isFirstPartOfStr($dirPrefix, $this->fileadminFolderName . '/')) {
                                        $dirPrefix = substr($dirPrefix, strlen($this->fileadminFolderName . '/'));
                                }
-                               return substr($fileProcObj->mounts[$result]['path'] . $dirPrefix, strlen(PATH_site));
+                               return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fileProcObj->mounts[$result]['path'] . $dirPrefix);
                        }
                } else {
                        return $dirPrefix;
@@ -2768,7 +2768,7 @@ class ImportExport {
                                        $pInfo['msg'] = 'You user profile does not allow you to create files on the server!';
                                }
                        }
-                       $pInfo['showDiffContent'] = substr($this->fileIDMap[$ID], strlen(PATH_site));
+                       $pInfo['showDiffContent'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]);
                        $lines[] = $pInfo;
                        unset($this->remainHeader['files'][$ID]);
                        // RTE originals:
@@ -2780,7 +2780,7 @@ class ImportExport {
                                        $pInfo['msg'] = 'MISSING RTE original FILE: ' . $ID;
                                        $this->error('MISSING RTE original FILE: ' . $ID, 1);
                                }
-                               $pInfo['showDiffContent'] = substr($this->fileIDMap[$ID], strlen(PATH_site));
+                               $pInfo['showDiffContent'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]);
                                $pInfo['preCode'] = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-reference-file');
                                $pInfo['title'] = htmlspecialchars($fI['filename']) . ' <em>(Original)</em>';
                                $pInfo['ref'] = 'FILE';
@@ -2801,7 +2801,7 @@ class ImportExport {
                                        } else {
                                                $pInfo['updatePath'] = $fI['parentRelFileName'];
                                        }
-                                       $pInfo['showDiffContent'] = substr($this->fileIDMap[$ID], strlen(PATH_site));
+                                       $pInfo['showDiffContent'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]);
                                        $pInfo['preCode'] = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-insert-reference');
                                        $pInfo['title'] = htmlspecialchars($fI['filename']) . ' <em>(Resource)</em>';
                                        $pInfo['ref'] = 'FILE';
index 4c99aa9..03a3508 100644 (file)
@@ -871,7 +871,7 @@ class IndexedPagesController extends \TYPO3\CMS\Backend\Module\AbstractFunctionM
                        $fullPath = GeneralUtility::getFileAbsFileName($icon);
                        if ($fullPath) {
                                $info = @getimagesize($fullPath);
-                               $iconPath = $GLOBALS['BACK_PATH'] . '../' . substr($fullPath, strlen(PATH_site));
+                               $iconPath = $GLOBALS['BACK_PATH'] . '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fullPath);
                                $this->iconFileNameCache[$it] = is_array($info) ? '<img src="' . $iconPath . '" ' . $info[3] . ' title="###TITLE_ATTRIBUTE###" alt="" />' : '';
                        }
                }
index 758f0d1..d0e4dc2 100644 (file)
@@ -513,7 +513,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                if ($flag) {
                                        // FIXME not all flags from typo3/gfx/flags
                                        // are available in media/flags/
-                                       $file = substr(PATH_tslib, strlen(PATH_site)) . 'media/flags/flag_' . $flag;
+                                       $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(PATH_tslib) . 'media/flags/flag_' . $flag;
                                        $imgInfo = @getimagesize((PATH_site . $file));
                                        if (is_array($imgInfo)) {
                                                $output = '<img src="' . $file . '" ' . $imgInfo[3] . ' title="' . htmlspecialchars($languageRow['title']) . '" alt="' . htmlspecialchars($languageRow['title']) . '" />';
@@ -561,7 +561,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                        $fullPath = GeneralUtility::getFileAbsFileName($icon);
                                        if ($fullPath) {
                                                $info = @getimagesize($fullPath);
-                                               $iconPath = substr($fullPath, strlen(PATH_site));
+                                               $iconPath = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fullPath);
                                                $this->iconFileNameCache[$imageType] = is_array($info) ? '<img src="' . $iconPath . '" ' . $info[3] . ' title="' . htmlspecialchars($alt) . '" alt="" />' : '';
                                        }
                                }
index 323bf44..6fc1383 100644 (file)
@@ -1816,7 +1816,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
                                        $fullPath = GeneralUtility::getFileAbsFileName($icon);
                                        if ($fullPath) {
                                                $info = @getimagesize($fullPath);
-                                               $iconPath = substr($fullPath, strlen(PATH_site));
+                                               $iconPath = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fullPath);
                                                $this->iconFileNameCache[$it] = is_array($info) ? '<img src="' . $iconPath . '" ' . $info[3] . ' title="' . htmlspecialchars($alt) . '" alt="" />' : '';
                                        }
                                }
@@ -2082,7 +2082,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
                                $flag = $rowDat['flag'];
                                if ($flag) {
                                        // FIXME not all flags from typo3/gfx/flags are available in media/flags/
-                                       $file = substr(PATH_tslib, strlen(PATH_site)) . 'media/flags/flag_' . $flag;
+                                       $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(PATH_tslib) . 'media/flags/flag_' . $flag;
                                        $imgInfo = @getimagesize((PATH_site . $file));
                                        if (is_array($imgInfo)) {
                                                $output = '<img src="' . $file . '" ' . $imgInfo[3] . ' title="' . htmlspecialchars($rowDat['title']) . '" alt="' . htmlspecialchars($rowDat['title']) . '" />';
index 57a71cb..f5f29fe 100644 (file)
@@ -300,7 +300,7 @@ class CrawlerHook {
                                $indexerObj->hash['phash'] = -1;
                                // EXPERIMENT - but to avoid phash_t3 being written to file sections (otherwise they are removed when page is reindexed!!!)
                                // Index document:
-                               $indexerObj->indexRegularDocument(substr($readpath, strlen(PATH_site)), TRUE);
+                               $indexerObj->indexRegularDocument(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($readpath), TRUE);
                        } elseif (@is_dir($readpath)) {
                                // If dir, read content and create new pending items for log:
                                // Select files and directories in path:
index 09e4d5f..b4f47d4 100644 (file)
@@ -257,7 +257,7 @@ class CoreUpdateService {
                        $success = FALSE;
                        /** @var $message \TYPO3\CMS\Install\Status\StatusInterface */
                        $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
-                       $message->setTitle('Core download exists in download location: ' . substr($this->downloadTargetPath, strlen(PATH_site)));
+                       $message->setTitle('Core download exists in download location: ' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->downloadTargetPath));
                        $messages[] = $message;
                } else {
                        $fileContent = GeneralUtility::getUrl($downloadUri);
@@ -343,7 +343,7 @@ class CoreUpdateService {
                        $success = FALSE;
                        /** @var $message \TYPO3\CMS\Install\Status\StatusInterface */
                        $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
-                       $message->setTitle('Unpacked core exists in download location: ' . substr($this->downloadTargetPath, strlen(PATH_site)));
+                       $message->setTitle('Unpacked core exists in download location: ' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->downloadTargetPath));
                        $messages[] = $message;
                } else {
                        $unpackCommand = 'tar xf ' . escapeshellarg($fileLocation) . ' -C ' . escapeshellarg($this->downloadTargetPath) . ' 2>&1';
index 7f3a6fe..4e19586 100644 (file)
@@ -45,6 +45,6 @@ class RelativePathViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractVi
         */
        public function render() {
                $absolutePath = $this->renderChildren();
-               return substr($absolutePath, strlen(PATH_site));
+               return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($absolutePath);
        }
 }
index 48eba27..7566163 100644 (file)
@@ -161,7 +161,7 @@ This will check the system for double files relations.';
                                                // Create unique name for file:
                                                $fileFunc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
                                                $newName = $fileFunc->getUniqueName(basename($key), dirname($absFileName));
-                                               echo '  Copying ' . $key . ' to ' . substr($newName, strlen(PATH_site)) . ' for record "' . $recReference . '": ';
+                                               echo '  Copying ' . $key . ' to ' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($newName) . ' for record "' . $recReference . '": ';
                                                if ($bypass = $this->cli_noExecutionCheck($recReference)) {
                                                        echo $bypass;
                                                } else {
index accb5a7..4c44b43 100644 (file)
@@ -194,7 +194,7 @@ Reports problems with RTE images';
                                                                                        clearstatcache();
                                                                                        if (@is_file($copyDestName)) {
                                                                                                $sysRefObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                                                                                               $error = $sysRefObj->setReferenceValue($hash, substr($copyDestName, strlen(PATH_site)));
+                                                                                               $error = $sysRefObj->setReferenceValue($hash, \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($copyDestName));
                                                                                                if ($error) {
                                                                                                        echo '  - ERROR:        TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error . LF;
                                                                                                        die;
index 1d5b28d..1e52055 100644 (file)
@@ -608,7 +608,7 @@ class DatabaseIntegrityView {
                        $regExpPattern = str_replace('/', '\\/', $pattern);
                        foreach ($files as $value) {
                                if (preg_match('/' . $regExpPattern . '/i', basename($value))) {
-                                       $matching_files[] = substr($value, strlen(PATH_site));
+                                       $matching_files[] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($value);
                                }
                        }
                }
index f585e0f..27ce173 100644 (file)
@@ -307,7 +307,7 @@ class ElementBrowser {
                                        $currentLinkParts[0] = rawurldecode(substr($this->curUrlArray['href'], 5));
                                } elseif (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
                                        if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
-                                               $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(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'], '@')) {
index 78e47e3..a81cd09 100644 (file)
@@ -252,7 +252,7 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         */
        protected function getDeprecationLogFileLink() {
                $logFile = GeneralUtility::getDeprecationLogFileName();
-               $relativePath = GeneralUtility::resolveBackPath($this->backPath . substr($logFile, strlen(PATH_site)));
+               $relativePath = GeneralUtility::resolveBackPath($this->backPath . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($logFile));
                $link = '<a href="' . $relativePath . '">' . $logFile . '</a>';
                return $link;
        }
index 3e5fc3f..dcbaa48 100644 (file)
@@ -86,7 +86,7 @@ class CustomAttributeController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugi
                if ($fileUid) {
                        $fileObject = $fileFactory->getFileObject($fileUid);
                        $filePath = $fileObject->getForLocalProcessing(FALSE);
-                       $file = substr($filePath, strlen(PATH_site));
+                       $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                } else {
                        // Pre-FAL backward compatibility
                        $path = $this->cObj->parameters['src'];
index 01c2ce3..b4dcf09 100644 (file)
@@ -243,7 +243,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        if ($magicImage instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
                                $filePath = $magicImage->getForLocalProcessing(FALSE);
                                $imageInfo = @getimagesize($filePath);
-                               $imageUrl = $this->siteURL . substr($filePath, strlen(PATH_site));
+                               $imageUrl = $this->siteURL . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                                $this->imageInsertJS($imageUrl, $imageInfo[0], $imageInfo[1], $altText, $titleText, $additionalParams);
                        }
                } else {
@@ -263,7 +263,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
        public function insertPlainImage(\TYPO3\CMS\Core\Resource\FileInterface $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
                $filePath = $fileObject->getForLocalProcessing(FALSE);
                $imageInfo = @getimagesize($filePath);
-               $imageUrl = $this->siteURL . substr($filePath, strlen(PATH_site));
+               $imageUrl = $this->siteURL . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
                $this->imageInsertJS($imageUrl, $imageInfo[0], $imageInfo[1], $altText, $titleText, $additionalParams);
        }