From db2d551484fa69ae7b35ccdbbe63006882bf894d Mon Sep 17 00:00:00 2001 From: Sascha Marcel Schmidt Date: Thu, 9 Feb 2017 14:06:41 +0100 Subject: [PATCH 1/2] ensures GLOB_BRACE is actually available before using it, also implements fallback for none GNU systems that do not support GLOB_BRACE --- Classes/Utility/MiscellaneousUtility.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Classes/Utility/MiscellaneousUtility.php b/Classes/Utility/MiscellaneousUtility.php index d3ec5e58e..5f9a9edc9 100644 --- a/Classes/Utility/MiscellaneousUtility.php +++ b/Classes/Utility/MiscellaneousUtility.php @@ -99,15 +99,24 @@ public static function getIconForTemplate(Form $form) $templatePathParts = explode('/', $fullTemplatePathAndName); $templateName = pathinfo(array_pop($templatePathParts), PATHINFO_FILENAME); $controllerName = array_pop($templatePathParts); - $allowedExtensions = implode(',', self::$allowedIconTypes); $iconFolder = ExtensionManagementUtility::extPath( $extensionKey, 'Resources/Public/Icons/' . $controllerName . '/' ); $iconAbsoluteUrl = '/' . str_replace(PATH_site, '', $iconFolder); $iconPathAndName = $iconFolder . $templateName; - $iconMatchPattern = $iconPathAndName . '.{' . $allowedExtensions . '}'; - $filesInFolder = (true === is_dir($iconFolder) ? glob($iconMatchPattern, GLOB_BRACE) : []); + $filesInFolder = array(); + if (true === is_dir($iconFolder)) { + if (true === defined(GLOB_BRACE)) { + $allowedExtensions = implode(',', self::$allowedIconTypes); + $iconMatchPattern = $iconPathAndName . '.{' . $allowedExtensions . '}'; + $filesInFolder = glob($iconMatchPattern, GLOB_BRACE); + } else { + foreach (self::$allowedIconTypes as $allowedIconType) { + $filesInFolder = array_merge($filesInFolder, glob($iconPathAndName . '.' . $allowedIconType)); + } + } + } $iconFile = (is_array($filesInFolder) && 0 < count($filesInFolder) ? reset($filesInFolder) : null); $iconRelPathAndFilename = $iconFile ? $iconAbsoluteUrl . str_replace($iconFolder, '', $iconFile) : null; return $iconRelPathAndFilename; From 9b2fdac272ca0d544d31200cb4c657ff4b1dda6d Mon Sep 17 00:00:00 2001 From: Sascha Marcel Schmidt Date: Tue, 28 Feb 2017 15:46:33 +0100 Subject: [PATCH 2/2] ensures to use the default record uid, fixes #1347 --- Classes/Service/ContentService.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Classes/Service/ContentService.php b/Classes/Service/ContentService.php index 6ac906a8b..a4d03cfe7 100644 --- a/Classes/Service/ContentService.php +++ b/Classes/Service/ContentService.php @@ -423,27 +423,32 @@ public function getTargetAreaStoredInSession($relativeTo) } /** - * @param integer $uid uid of record in default language + * @param integer $uid uid of record in chosen source language * @param integer $languageUid sys_language_uid of language for the localized record - * @param array $defaultLanguageRecord record in default language (from table tt_content) + * @param array $sourceRecord record in chosen source language (from table tt_content) * @param DataHandler $reference */ - public function fixPositionInLocalization($uid, $languageUid, &$defaultLanguageRecord, DataHandler $reference) + public function fixPositionInLocalization($uid, $languageUid, &$sourceRecord, DataHandler $reference) { $previousLocalizedRecordUid = $this->getPreviousLocalizedRecordUid($uid, $languageUid, $reference); - $localizedRecord = BackendUtility::getRecordLocalization('tt_content', $uid, $languageUid); + if (!empty($sourceRecord['l18n_parent'])) { + $defaultRecordUid = $sourceRecord['l18n_parent']; + } else { + $defaultRecordUid = $uid; + } + $localizedRecord = BackendUtility::getRecordLocalization('tt_content', $defaultRecordUid, $languageUid); $sortingRow = $GLOBALS['TCA']['tt_content']['ctrl']['sortby']; if (null === $previousLocalizedRecordUid) { // moving to first position in tx_flux_column $localizedRecord[0][$sortingRow] = $reference->getSortNumber( 'tt_content', 0, - $defaultLanguageRecord['pid'] + $sourceRecord['pid'] ); } else { $localizedRecord[0][$sortingRow] = $reference->resorting( 'tt_content', - $defaultLanguageRecord['pid'], + $sourceRecord['pid'], $sortingRow, $previousLocalizedRecordUid );