[BUGFIX] Wrong path generated for icon in NewContentElementController 44/42044/2
authorWouter Wolters <typo3@wouterwolters.nl>
Tue, 28 Jul 2015 15:00:14 +0000 (17:00 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Tue, 28 Jul 2015 17:21:07 +0000 (19:21 +0200)
When using EXT:myext/icon.png in the new content element wizard,
a wrong path is generated. The current solution only works for core
extension. Fix this by creating a correct relative path.
Allow usage of absolute paths too.

Resolves: #68575
Releases: master
Change-Id: Ideccb89da85fc81722e880f386514e56feb88069
Reviewed-on: http://review.typo3.org/42044
Reviewed-by: Georg Tiefenbrunn <georg.tiefenbrunn@gmail.com>
Tested-by: Georg Tiefenbrunn <georg.tiefenbrunn@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php

index 5c98c98..575777b 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\ContentElement;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
 
 /**
  * Script Class for the New Content element wizard
@@ -238,9 +239,11 @@ class NewContentElementController {
                                        }
 
                                        $icon = $wInfo['icon'];
-                                       if (strpos($wInfo['icon'], '..') === FALSE) {
+                                       if (strpos($wInfo['icon'], '..') === FALSE && !GeneralUtility::isAbsPath($icon)) {
                                                $icon = GeneralUtility::getFileAbsFileName($icon, TRUE, TRUE);
-                                               $icon = substr($icon, strlen(PATH_typo3));
+                                               $pathInfo = PathUtility::pathinfo($icon);
+                                               $path = PathUtility::getRelativePathTo($pathInfo['dirname']);
+                                               $icon = $path . $pathInfo['basename'];
                                        }
                                        $menuItems[$key]['content'] .= '
                                                <div class="media">