1010use TYPO3 \CMS \Backend \Utility \BackendUtility ;
1111use TYPO3 \CMS \Core \Authentication \BackendUserAuthentication ;
1212use TYPO3 \CMS \Core \Imaging \Icon ;
13+ use TYPO3 \CMS \Core \Imaging \IconFactory ;
14+ use TYPO3 \CMS \Core \Information \Typo3Version ;
1315use TYPO3 \CMS \Core \Localization \LanguageService ;
1416use TYPO3 \CMS \Core \Messaging \FlashMessage ;
17+ use TYPO3 \CMS \Core \Messaging \FlashMessageQueue ;
1518use TYPO3 \CMS \Core \Page \PageRenderer ;
1619use TYPO3 \CMS \Core \Resource \Exception ;
1720use TYPO3 \CMS \Core \Resource \Exception \ExistingTargetFolderException ;
2225use TYPO3 \CMS \Core \Resource \ResourceStorage ;
2326use TYPO3 \CMS \Core \Utility \GeneralUtility ;
2427use TYPO3 \CMS \Extbase \Mvc \Controller \ActionController ;
25- use TYPO3 \ CMS \ Extbase \ Mvc \View \ViewInterface ;
28+ use TYPO3Fluid \ Fluid \View \ViewInterface ;
2629use WebVision \WvFileCleanup \Domain \Repository \FileRepository ;
2730
2831/**
@@ -42,14 +45,18 @@ class CleanupController extends ActionController
4245
4346 protected FileRepository $ fileRepository ;
4447
48+ protected IconFactory $ iconFactory ;
49+
4550 public function __construct (
4651 FileRepository $ fileRepository ,
4752 PageRenderer $ pageRenderer ,
48- ModuleTemplateFactory $ moduleTemplateFactory
53+ ModuleTemplateFactory $ moduleTemplateFactory ,
54+ IconFactory $ iconFactory
4955 ) {
5056 $ this ->fileRepository = $ fileRepository ;
5157 $ this ->pageRenderer = $ pageRenderer ;
5258 $ this ->moduleTemplateFactory = $ moduleTemplateFactory ;
59+ $ this ->iconFactory = $ iconFactory ;
5360 }
5461
5562 public function initializeAction (): void
@@ -219,7 +226,6 @@ protected function initializeIndexAction(): void
219226 protected function registerDocHeaderButtons (): void
220227 {
221228 $ buttonBar = $ this ->moduleTemplate ->getDocHeaderComponent ()->getButtonBar ();
222- $ iconFactory = $ this ->moduleTemplate ->getIconFactory ();
223229
224230 // Refresh page
225231 $ refreshLink = GeneralUtility::linkThisScript (
@@ -234,7 +240,7 @@ protected function registerDocHeaderButtons(): void
234240 $ refreshButton = $ buttonBar ->makeLinkButton ($ buttonFactory )
235241 ->setHref ($ refreshLink )
236242 ->setTitle ($ buttonTitle )
237- ->setIcon ($ iconFactory ->getIcon ('actions-refresh ' , Icon::SIZE_SMALL ));
243+ ->setIcon ($ this -> iconFactory ->getIcon ('actions-refresh ' , Icon::SIZE_SMALL ));
238244
239245 $ buttonBar ->addButton ($ refreshButton , ButtonBar::BUTTON_POSITION_RIGHT );
240246
@@ -250,10 +256,6 @@ protected function registerDocHeaderButtons(): void
250256 if (!$ levelUpTitle ) {
251257 $ levelUpTitle = 'Up one level ' ;
252258 }
253- $ levelUpClick = 'top.document.getElementsByName("navigation")[0]. ' ;
254- $ levelUpClick .= 'contentWindow.Tree.highlightActiveItem("file","folder ' ;
255- $ levelUpClick .= GeneralUtility::md5int ($ parentFolder ->getCombinedIdentifier ());
256- $ levelUpClick .= '_"+top.fsMod.currentBank) ' ;
257259 $ uriBuilder = GeneralUtility::makeInstance (UriBuilder::class);
258260 $ levelUpButton = $ buttonBar ->makeLinkButton ($ buttonFactory )
259261 ->setHref (
@@ -262,9 +264,15 @@ protected function registerDocHeaderButtons(): void
262264 ['id ' => $ parentFolder ->getCombinedIdentifier ()]
263265 )
264266 )
265- ->setOnClick ($ levelUpClick )
266267 ->setTitle ($ levelUpTitle )
267- ->setIcon ($ iconFactory ->getIcon ('actions-view-go-up ' , Icon::SIZE_SMALL ));
268+ ->setIcon ($ this ->iconFactory ->getIcon ('actions-view-go-up ' , Icon::SIZE_SMALL ));
269+ if ((new Typo3Version ())->getMajorVersion () < 12 ) {
270+ $ levelUpClick = 'top.document.getElementsByName("navigation")[0]. ' ;
271+ $ levelUpClick .= 'contentWindow.Tree.highlightActiveItem("file","folder ' ;
272+ $ levelUpClick .= GeneralUtility::md5int ($ parentFolder ->getCombinedIdentifier ());
273+ $ levelUpClick .= '_"+top.fsMod.currentBank) ' ;
274+ $ levelUpButton ->setOnClick ($ levelUpClick );
275+ }
268276 $ buttonBar ->addButton ($ levelUpButton , ButtonBar::BUTTON_POSITION_LEFT , 1 );
269277 }
270278 } catch (\Exception $ e ) {
@@ -273,7 +281,9 @@ protected function registerDocHeaderButtons(): void
273281
274282 // Shortcut
275283 if ($ this ->getBackendUser ()->mayMakeShortcut ()) {
276- $ shortCutButton = $ buttonBar ->makeShortcutButton ()->setModuleName ('file_WvFileCleanupCleanup ' );
284+ $ shortCutButton = $ buttonBar ->makeShortcutButton ()
285+ ->setRouteIdentifier ('file_WvFileCleanupCleanup ' )
286+ ->setDisplayName ('File cleanup ' );
277287 $ buttonBar ->addButton ($ shortCutButton , ButtonBar::BUTTON_POSITION_RIGHT );
278288 }
279289 }
@@ -283,7 +293,7 @@ protected function registerDocHeaderButtons(): void
283293 */
284294 public function indexAction (): ResponseInterface
285295 {
286- $ this ->view ->assign ('files ' , $ this ->fileRepository ->findUnusedFile ($ this ->folder , $ this ->moduleSettings ['recursive ' ]));
296+ $ this ->view ->assign ('files ' , $ this ->fileRepository ->findUnusedFile ($ this ->folder , $ this ->moduleSettings ['recursive ' ] ?? false ));
287297 $ this ->view ->assign ('folder ' , $ this ->folder );
288298 $ backendUserTsconfig = $ this ->getBackendUserTsconfig ();
289299 $ this ->view ->assign ('checkboxes ' , [
@@ -307,12 +317,12 @@ public function indexAction(): ResponseInterface
307317 'html ' => BackendUtility::getFuncCheck (
308318 $ this ->folder ? $ this ->folder ->getCombinedIdentifier () : '' ,
309319 'SET[recursive] ' ,
310- $ this ->moduleSettings ['recursive ' ],
320+ $ this ->moduleSettings ['recursive ' ] ?? false ,
311321 '' ,
312322 '' ,
313323 'id="checkRecursive" '
314324 ),
315- 'checked ' => $ this ->moduleSettings ['recursive ' ],
325+ 'checked ' => $ this ->moduleSettings ['recursive ' ] ?? false ,
316326 ],
317327 ]);
318328
@@ -328,7 +338,7 @@ public function indexAction(): ResponseInterface
328338 * @throws InsufficientFolderAccessPermissionsException
329339 * @throws \TYPO3\CMS\Core\Exception
330340 */
331- public function cleanupAction (array $ files ): void
341+ public function cleanupAction (array $ files ): ResponseInterface
332342 {
333343 /** @var $resourceFactory ResourceFactory **/
334344 $ resourceFactory = GeneralUtility::makeInstance (ResourceFactory::class);
@@ -371,7 +381,7 @@ public function cleanupAction(array $files): void
371381 );
372382 }
373383
374- $ this ->redirect ('index ' );
384+ return $ this ->redirect ('index ' );
375385 }
376386
377387 /**
@@ -405,7 +415,7 @@ public function addFlashMessage(
405415 $ severity ,
406416 $ storeInSession
407417 );
408- $ this -> controllerContext -> getFlashMessageQueue ( 'core.template.flashMessages ' )->enqueue ($ flashMessage );
418+ GeneralUtility:: makeInstance (FlashMessageQueue::class, 'core.template.flashMessages ' )->enqueue ($ flashMessage );
409419 }
410420
411421 protected function getLanguageService (): LanguageService
0 commit comments