1010use TYPO3 \CMS \Core \Configuration \ExtensionConfiguration ;
1111use TYPO3 \CMS \Core \Core \Bootstrap ;
1212use TYPO3 \CMS \Core \EventDispatcher \EventDispatcher ;
13- use TYPO3 \CMS \Core \Imaging \Icon ;
1413use TYPO3 \CMS \Core \Imaging \IconFactory ;
1514use TYPO3 \CMS \Core \Utility \GeneralUtility ;
1615use Xima \XimaTypo3FrontendEdit \Configuration ;
1716use Xima \XimaTypo3FrontendEdit \Enumerations \ButtonType ;
1817use Xima \XimaTypo3FrontendEdit \Event \FrontendEditDropdownModifyEvent ;
1918use Xima \XimaTypo3FrontendEdit \Template \Component \Button ;
2019use Xima \XimaTypo3FrontendEdit \Utility \ContentUtility ;
20+ use Xima \XimaTypo3FrontendEdit \Utility \IconUtility ;
2121use Xima \XimaTypo3FrontendEdit \Utility \UrlUtility ;
2222
2323final class MenuGenerator
@@ -42,7 +42,7 @@ public function getDropdown(int $pid, string $returnUrl, int $languageUid, array
4242 }
4343 }
4444
45- /* @var $backendUser \TYPO3\CMS\Core\Authentication\ BackendUserAuthentication */
45+ /* @var $backendUser BackendUserAuthentication */
4646 $ backendUser = $ GLOBALS ['BE_USER ' ];
4747 if ($ backendUser ->user === null ) {
4848 Bootstrap::initializeBackendAuthentication ();
@@ -80,7 +80,7 @@ public function getDropdown(int $pid, string $returnUrl, int $languageUid, array
8080 $ contentElementConfig = ContentUtility::getContentElementConfig ($ contentElement ['CType ' ], $ contentElement ['list_type ' ]);
8181 $ returnUrlAnchor = $ returnUrl . '#c ' . $ contentElement ['uid ' ];
8282
83- $ simpleMode = (array_key_exists ('simpleMode ' , $ this ->configuration ) && $ this ->configuration ['simpleMode ' ]) || $ this ->settingsService ->checkSimpleModeMenuStructure ();
83+ $ simpleMode = (array_key_exists ('simpleMode ' , $ this ->configuration ) && ( bool ) $ this ->configuration ['simpleMode ' ]) || $ this ->settingsService ->checkSimpleModeMenuStructure ();
8484
8585 if ($ simpleMode ) {
8686 $ menuButton = new Button (
@@ -98,14 +98,14 @@ public function getDropdown(int $pid, string $returnUrl, int $languageUid, array
9898 'returnUrl ' => $ returnUrlAnchor ,
9999 ]
100100 )->__toString (),
101- icon: $ this ->iconFactory ->getIcon ('actions-open ' , Icon:: SIZE_SMALL ),
102- targetBlank: array_key_exists ('linkTargetBlank ' , $ this ->configuration ) && $ this ->configuration ['linkTargetBlank ' ]
101+ icon: $ this ->iconFactory ->getIcon ('actions-open ' , IconUtility:: getDefaultIconSize () ),
102+ targetBlank: array_key_exists ('linkTargetBlank ' , $ this ->configuration ) && ( bool ) $ this ->configuration ['linkTargetBlank ' ]
103103 );
104104 } else {
105105 $ menuButton = new Button (
106106 'LLL:EXT:xima_typo3_frontend_edit/Resources/Private/Language/locallang.xlf:edit_menu ' ,
107107 ButtonType::Menu,
108- icon: $ this ->iconFactory ->getIcon ('actions-open ' , Icon:: SIZE_SMALL )
108+ icon: $ this ->iconFactory ->getIcon ('actions-open ' , IconUtility:: getDefaultIconSize () )
109109 );
110110
111111 /*
@@ -118,7 +118,7 @@ public function getDropdown(int $pid, string $returnUrl, int $languageUid, array
118118 $ menuButton ,
119119 'header ' ,
120120 ButtonType::Info,
121- label: $ GLOBALS ['LANG ' ]->sL ($ contentElementConfig ['label ' ]) . '<p><small> ' . ($ contentElement ['header ' ] ? ContentUtility::shortenString ($ contentElement ['header ' ]) : '' ) . $ additionalUid . '</small></p> ' ,
121+ label: $ GLOBALS ['LANG ' ]->sL ($ contentElementConfig ['label ' ]) . '<p><small> ' . ($ contentElement ['header ' ] !== null ? ContentUtility::shortenString ($ contentElement ['header ' ]) : '' ) . $ additionalUid . '</small></p> ' ,
122122 icon: $ contentElementConfig ['icon ' ]
123123 );
124124
@@ -254,31 +254,39 @@ private function processNewButton(Button &$button, string $identifier, ButtonTyp
254254 }
255255
256256 $ button ->appendChild (new Button (
257- $ label ? : "LLL:EXT:xima_typo3_frontend_edit/Resources/Private/Language/locallang.xlf: $ identifier " ,
257+ $ label !== null ? $ label : "LLL:EXT:xima_typo3_frontend_edit/Resources/Private/Language/locallang.xlf: $ identifier " ,
258258 $ type ,
259259 $ url ,
260- $ icon ? $ this ->iconFactory ->getIcon ($ icon , Icon:: SIZE_SMALL ) : null ,
260+ $ icon !== null ? $ this ->iconFactory ->getIcon ($ icon , IconUtility:: getDefaultIconSize () ) : null ,
261261 array_key_exists ('linkTargetBlank ' , $ this ->configuration ) && $ this ->configuration ['linkTargetBlank ' ]
262262 ), $ identifier );
263263 }
264264
265265 private function handleAdditionalData (Button $ button , array $ contentElement , array $ contentElementConfig , array $ data , BackendUserAuthentication $ backendUser , int $ languageUid , string $ returnUrlAnchor ): void
266266 {
267- if ((array_key_exists ($ contentElement ['uid ' ], $ data ) && ($ uid = $ contentElement ['uid ' ]) && !empty ($ data [$ uid ])) ||
268- (array_key_exists ('l10n_source ' , $ contentElement ) && array_key_exists ($ contentElement ['l10n_source ' ], $ data ) && ($ uid = $ contentElement ['l10n_source ' ]) && !empty ($ data [$ uid ]))
267+ $ uid = null ;
268+ if (
269+ (array_key_exists ($ contentElement ['uid ' ], $ data ) && $ data [$ contentElement ['uid ' ]] !== []) ||
270+ (
271+ array_key_exists ('l10n_source ' , $ contentElement )
272+ && array_key_exists ($ contentElement ['l10n_source ' ], $ data )
273+ && $ data [$ contentElement ['l10n_source ' ]] !== []
274+ && ($ uid = $ contentElement ['l10n_source ' ]) !== 0
275+ )
269276 ) {
277+ $ uid = $ uid ?? $ contentElement ['uid ' ];
270278 $ button ->appendChild (new Button (
271279 'LLL:EXT:xima_typo3_frontend_edit/Resources/Private/Language/locallang.xlf:div_data ' ,
272280 ButtonType::Divider
273281 ), 'div_data ' );
274282
275283 foreach ($ data [$ uid ] as $ key => $ dataEntry ) {
276- if (!$ dataEntry ['label ' ] || !(($ dataEntry ['table ' ] && $ dataEntry ['uid ' ]) || ($ dataEntry ['url ' ]))) {
284+ if (!$ dataEntry ['label ' ] || !(($ dataEntry ['table ' ] !== null && $ dataEntry ['uid ' ] !== null ) || ($ dataEntry ['url ' ] !== null ))) {
277285 continue ;
278286 }
279287
280288 $ recordUid = null ;
281- if ($ dataEntry ['table ' ] && $ dataEntry ['uid ' ]) {
289+ if ($ dataEntry ['table ' ] !== null && $ dataEntry ['uid ' ] !== null ) {
282290 if (!$ backendUser ->recordEditAccessInternals ($ dataEntry ['table ' ], $ dataEntry )) {
283291 continue ;
284292 }
@@ -288,7 +296,7 @@ private function handleAdditionalData(Button $button, array $contentElement, arr
288296 * Check if the record is translated and if so, get the translation
289297 */
290298 $ record = BackendUtility::getRecord ($ dataEntry ['table ' ], $ recordUid );
291- if ($ record && array_key_exists ('sys_language_uid ' , $ record ) && $ record ['sys_language_uid ' ] !== $ languageUid ) {
299+ if ($ record !== null && array_key_exists ('sys_language_uid ' , $ record ) && $ record ['sys_language_uid ' ] !== $ languageUid ) {
292300 $ record = ContentUtility::getTranslatedRecord ($ dataEntry ['table ' ], $ recordUid , $ languageUid );
293301 if ($ record ) {
294302 $ recordUid = $ record ['uid ' ];
@@ -298,7 +306,7 @@ private function handleAdditionalData(Button $button, array $contentElement, arr
298306 }
299307 }
300308
301- $ url = $ dataEntry ['url ' ] ? : GeneralUtility::makeInstance (UriBuilder::class)->buildUriFromRoute (
309+ $ url = $ dataEntry ['url ' ] !== null ? $ dataEntry [ ' url ' ] : GeneralUtility::makeInstance (UriBuilder::class)->buildUriFromRoute (
302310 'record_edit ' ,
303311 [
304312 'edit ' => [
@@ -310,7 +318,7 @@ private function handleAdditionalData(Button $button, array $contentElement, arr
310318 'returnUrl ' => $ returnUrlAnchor ,
311319 ],
312320 )->__toString ();
313- $ icon = $ dataEntry ['icon ' ] ? $ this ->iconFactory ->getIcon ($ dataEntry ['icon ' ], Icon:: SIZE_SMALL ) : $ this ->iconFactory ->getIcon ($ contentElementConfig ['icon ' ], Icon:: SIZE_SMALL );
321+ $ icon = $ dataEntry ['icon ' ] !== null ? $ this ->iconFactory ->getIcon ($ dataEntry ['icon ' ], IconUtility:: getDefaultIconSize ()) : $ this ->iconFactory ->getIcon ($ contentElementConfig ['icon ' ], IconUtility:: getDefaultIconSize () );
314322
315323 $ button ->appendChild (new Button (
316324 ContentUtility::shortenString ($ dataEntry ['label ' ]),
0 commit comments