17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
48 'MCONF' =>
'Using TaskModuleController::$MCONF is deprecated and will not be possible anymore in TYPO3 v10.0.',
49 'id' =>
'Using TaskModuleController::$id is deprecated and will not be possible anymore in TYPO3 v10.0.',
50 'MOD_MENU' =>
'Using TaskModuleController::$MOD_MENU is deprecated and will not be possible anymore in TYPO3 v10.0.',
51 'modMenu_type' =>
'Using TaskModuleController::$modMenu_type is deprecated and will not be possible anymore in TYPO3 v10.0.',
52 'modMenu_setDefaultList' =>
'Using TaskModuleController::$$modMenu_setDefaultList is deprecated and will not be possible anymore in TYPO3 v10.0.',
53 'modMenu_dontValidateList' =>
'Using TaskModuleController::$modMenu_dontValidateList is deprecated and will not be possible anymore in TYPO3 v10.0.',
54 'content' =>
'Using TaskModuleController::$content is deprecated and will not be possible anymore in TYPO3 v10.0.',
55 'perms_clause' =>
'Using TaskModuleController::$perms_clause is deprecated, the property will be removed in TYPO3 v10.0.',
56 'CMD' =>
'Using TaskModuleController::$CMD is deprecated, the property will be removed in TYPO3 v10.0.',
57 'extClassConf' =>
'Using TaskModuleController::$extClassConf is deprecated, the property will be removed in TYPO3 v10.0.',
58 'extObj' =>
'Using TaskModuleController::$extObj is deprecated, the property will be removed in TYPO3 v10.0.',
65 'menuConfig' =>
'Using TaskModuleController::menuConfig() is deprecated and will not be possible anymore in TYPO3 v10.0.',
66 'mergeExternalItems' =>
'Using TaskModuleController::mergeExternalItems() is deprecated and will not be possible anymore in TYPO3 v10.0.',
67 'handleExternalFunctionValue' =>
'Using TaskModuleController::handleExternalFunctionValue() is deprecated and will not be possible anymore in TYPO3 v10.0.',
68 'getExternalItemConfig' =>
'Using TaskModuleController::getExternalItemConfig() is deprecated and will not be possible anymore in TYPO3 v10.0.',
69 'main' =>
'Using TaskModuleController::main() is deprecated and will not be possible anymore in TYPO3 v10.0.',
70 'urlInIframe' =>
'Using TaskModuleController::urlInIframe() is deprecated. The method will be removed in TYPO3 v10.0.',
71 'extObjHeader' =>
'Using TaskModuleController::extObjHeader() is deprecated. The method will be removed in TYPO3 v10.0.',
72 'checkSubExtObj' =>
'Using TaskModuleController::checkSubExtObj() is deprecated. The method will be removed in TYPO3 v10.0.',
73 'checkExtObj' =>
'Using TaskModuleController::checkExtObj() is deprecated. The method will be removed in TYPO3 v10.0.',
74 'extObjContent' =>
'Using TaskModuleController::extObjContent() is deprecated. The method will be removed in TYPO3 v10.0.',
75 'getExtObjContent' =>
'Using TaskModuleController::getExtObjContent() is deprecated. The method will be removed in TYPO3 v10.0.',
216 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
222 if (!$this->MCONF[
'name']) {
225 $this->
id = (int)GeneralUtility::_GP(
'id');
227 $this->CMD = GeneralUtility::_GP(
'CMD');
239 $this->MOD_MENU = [
'mode' => []];
241 $this->MOD_MENU[
'mode'][
'information'] = $languageService->sL(
'LLL:EXT:taskcenter/Resources/Private/Language/locallang.xlf:task_overview');
242 $this->MOD_MENU[
'mode'][
'tasks'] = $languageService->sL(
'LLL:EXT:taskcenter/Resources/Private/Language/locallang.xlf:task_tasks');
247 $this->MOD_MENU[
'mode'] = $this->
mergeExternalItems($this->MCONF[
'name'],
'mode', $this->MOD_MENU[
'mode']);
248 $blindActions = $this->modTSconfig[
'properties'][
'menu.'][
'mode.'] ?? [];
249 foreach ($blindActions as $key => $value) {
250 if (!$value && array_key_exists($key, $this->MOD_MENU[
'mode'])) {
251 unset($this->MOD_MENU[
'mode'][$key]);
257 $this->MOD_MENU[
'function'] = $this->
mergeExternalItems($this->MCONF[
'name'],
'function', $this->MOD_MENU[
'function']);
258 $blindActions = $this->modTSconfig[
'properties'][
'menu.'][
'function.'] ?? [];
259 foreach ($blindActions as $key => $value) {
260 if (!$value && array_key_exists($key, $this->MOD_MENU[
'function'])) {
261 unset($this->MOD_MENU[
'function'][$key]);
264 $this->MOD_SETTINGS =
BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP(
'SET'), $this->MCONF[
'name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
274 $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
275 $menu->setIdentifier(
'WebFuncJumpMenu');
277 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
278 foreach ($this->MOD_MENU[
'mode'] as $controller => $title) {
282 (
string)$uriBuilder->buildUriFromRoute(
287 'mode' => $controller
293 if ($controller === $this->MOD_SETTINGS[
'mode']) {
294 $item->setActive(
true);
296 $menu->addMenuItem($item);
298 $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
308 public function mainAction(ServerRequestInterface $request): ResponseInterface
314 $this->moduleTemplate->setContent($this->content);
315 return new HtmlResponse($this->moduleTemplate->renderContent());
322 protected function main()
326 $this->moduleTemplate->addJavaScriptCode(
327 'TaskCenterInlineJavascript',
328 'if (top.fsMod) { top.fsMod.recentIds["web"] = 0; }'
332 $mode = (string)$this->MOD_SETTINGS[
'mode'];
333 if ($mode ===
'information') {
348 $chosenTask = (string)$this->MOD_SETTINGS[
'function'];
350 if (empty($chosenTask) || $chosenTask ===
'index') {
351 $chosenTask =
'taskcenter.tasks';
355 $flashMessage =
null;
356 list($extKey, $taskClass) = explode(
'.', $chosenTask, 2);
357 if (class_exists($taskClass)) {
358 $taskInstance = GeneralUtility::makeInstance($taskClass, $this);
359 if ($taskInstance instanceof TaskInterface) {
362 $actionContent .= $taskInstance->getTask();
364 $flashMessage = GeneralUtility::makeInstance(
366 $languageService->getLL(
'error-access'),
367 $languageService->getLL(
'error_header'),
373 $flashMessage = GeneralUtility::makeInstance(
375 sprintf($languageService->getLL(
'error_no-instance'), $taskClass, TaskInterface::class),
376 $languageService->getLL(
'error_header'),
381 $flashMessage = GeneralUtility::makeInstance(
383 $languageService->sL(
'LLL:EXT:taskcenter/Resources/Private/Language/locallang_mod.xlf:mlang_labels_tabdescr'),
384 $languageService->sL(
'LLL:EXT:taskcenter/Resources/Private/Language/locallang_mod.xlf:mlang_tabs_tab'),
391 $flashMessageService = GeneralUtility::makeInstance(\
TYPO3\CMS\Core\Messaging\FlashMessageService::class);
393 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
394 $defaultFlashMessageQueue->enqueue($flashMessage);
399 $assigns[
'taskClass'] = strtolower(str_replace(
'\\',
'-', htmlspecialchars($extKey .
'-' . $taskClass)));
400 $assigns[
'actionContent'] = $actionContent;
403 $view = GeneralUtility::makeInstance(StandaloneView::class);
404 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
405 'EXT:taskcenter/Resources/Private/Templates/ModuleContent.html'
407 $view->assignMultiple($assigns);
408 $this->content .= $view->render();
417 $assigns[
'LLPrefix'] =
'LLL:EXT:taskcenter/Resources/Private/Language/locallang.xlf:';
418 $assigns[
'LLPrefixMod'] =
'LLL:EXT:taskcenter/Resources/Private/Language/locallang_mod.xlf:';
419 $assigns[
'LLPrefixTask'] =
'LLL:EXT:taskcenter/Resources/Private/Language/locallang_task.xlf:';
423 $view = GeneralUtility::makeInstance(StandaloneView::class);
424 $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName(
'EXT:taskcenter/Resources/Private/Templates')]);
425 $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName(
'EXT:taskcenter/Resources/Private/Partials')]);
426 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
427 'EXT:taskcenter/Resources/Private/Templates/InformationContent.html'
429 $view->assignMultiple($assigns);
430 $this->content .= $view->render();
443 $descriptionView = GeneralUtility::makeInstance(StandaloneView::class);
444 $descriptionView->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
445 'EXT:taskcenter/Resources/Private/Partials/Description.html'
447 $descriptionView->assign(
'title', $title);
448 $descriptionView->assign(
'description', $description);
449 return $descriptionView->render();
469 $assigns[
'mainMenu'] = $mainMenu;
473 $userSorting = unserialize($this->
getBackendUser()->uc[
'taskcenter'][
'sorting'], [
'allowed_classes' =>
false]);
474 if (is_array($userSorting)) {
476 foreach ($userSorting as $item) {
477 if (isset($items[$item])) {
478 $newSorting[] = $items[$item];
479 unset($items[$item]);
482 $items = $newSorting + $items;
485 if (is_array($items) && !empty($items)) {
486 foreach ($items as $itemKey => &$item) {
488 if (!empty($item[
'icon'])) {
489 if (strpos($item[
'icon'],
'<img ') ===
false) {
490 $iconFile = GeneralUtility::getFileAbsFileName($item[
'icon']);
491 if (@is_file($iconFile)) {
497 $contentId = strtolower(str_replace(
'\\',
'-',
$id));
498 $item[
'uniqueKey'] =
$id;
499 $item[
'contentId'] = $contentId;
502 $item[
'ariaExpanded'] =
'true';
503 $item[
'collapseIcon'] =
'actions-view-list-expand';
504 $item[
'collapsed'] =
'';
506 $item[
'ariaExpanded'] =
'false';
507 $item[
'collapseIcon'] =
'actions-view-list-collapse';
508 $item[
'collapsed'] =
'in';
511 $panelState = (string)$this->MOD_SETTINGS[
'function'] == $item[
'uid'] ?
'panel-active' :
'panel-default';
512 $item[
'panelState'] = $panelState;
515 $assigns[
'items'] = $items;
518 $view = GeneralUtility::makeInstance(StandaloneView::class);
519 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
520 'EXT:taskcenter/Resources/Private/Templates/ListMenu.html'
522 $view->assignMultiple($assigns);
523 return $view->render();
536 $defaultIcon =
'EXT:taskcenter/Resources/Public/Icons/module-taskcenter.svg';
538 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
540 if (count(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'taskcenter'] ?? [])) {
541 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'taskcenter'] as $extKey => $extensionReports) {
542 foreach ($extensionReports as $taskClass => $task) {
546 $link = (string)$uriBuilder->buildUriFromRoute(
'user_task') .
'&SET[function]=' . $extKey .
'.' . $taskClass;
547 $taskTitle = $languageService->sL($task[
'title']);
548 $taskDescriptionHtml =
'';
550 if (class_exists($taskClass)) {
551 $taskInstance = GeneralUtility::makeInstance($taskClass, $this);
552 if ($taskInstance instanceof TaskInterface) {
553 $taskDescriptionHtml = $taskInstance->getOverview();
557 $uniqueKey = $this->
getUniqueKey($extKey .
'.' . $taskClass);
558 $tasks[$uniqueKey] = [
559 'title' => $taskTitle,
560 'descriptionHtml' => $taskDescriptionHtml,
561 'description' => $languageService->sL($task[
'description']),
562 'icon' => !empty($task[
'icon']) ? $task[
'icon'] : $defaultIcon,
564 'uid' => $extKey .
'.' . $taskClass
570 $flashMessage = GeneralUtility::makeInstance(
572 $languageService->getLL(
'no-tasks'),
577 $flashMessageService = GeneralUtility::makeInstance(\
TYPO3\CMS\Core\Messaging\FlashMessageService::class);
579 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
580 $defaultFlashMessageQueue->enqueue($flashMessage);
591 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
594 $shortcutButton = $buttonBar->makeShortcutButton()
595 ->setModuleName($this->moduleName)
596 ->setSetVariables([
'function']);
597 $buttonBar->addButton($shortcutButton);
610 protected function checkAccess($extKey, $taskClass): bool
614 if ($backendUser->isAdmin()) {
618 if ((
int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'taskcenter'][$extKey][$taskClass][
'admin'] === 1) {
622 return (
bool)($backendUser->getTSConfig()[
'taskcenter.'][$extKey .
'.'][$taskClass] ??
true);
634 $urlView = GeneralUtility::makeInstance(StandaloneView::class);
635 $urlView->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
636 'EXT:taskcenter/Resources/Private/Partials/UrlInIframe.html'
638 $urlView->assign(
'url', $url);
639 return $urlView->render();
651 $search = [
'.',
'_'];
652 $replace = [
'-',
''];
653 return str_replace($search, $replace, $string);
698 $mergeArray =
$GLOBALS[
'TBE_MODULES_EXT'][$modName][
'MOD_MENU'][$menuKey];
699 if (is_array($mergeArray)) {
700 foreach ($mergeArray as $k => $v) {
701 if (((
string)$v[
'ws'] ===
'' || $this->
getBackendUser()->workspace === 0 && GeneralUtility::inList($v[
'ws'],
'online')) || $this->
getBackendUser()->workspace === -1 && GeneralUtility::inList($v[
'ws'],
'offline') || $this->
getBackendUser()->workspace > 0 && GeneralUtility::inList($v[
'ws'],
'custom')) {
718 if ($MS_value ===
null) {
719 $MS_value = $this->MOD_SETTINGS[$MM_key];
736 if (isset(
$GLOBALS[
'TBE_MODULES_EXT'][$modName])) {
737 return (
string)$value !==
'' ?
$GLOBALS[
'TBE_MODULES_EXT'][$modName][
'MOD_MENU'][$menuKey][$value] :
$GLOBALS[
'TBE_MODULES_EXT'][$modName][
'MOD_MENU'][$menuKey];
753 if (is_array($this->extClassConf) && $this->extClassConf[
'name']) {
754 $this->extObj = GeneralUtility::makeInstance($this->extClassConf[
'name']);
755 $this->extObj->init($this, $this->extClassConf);
757 $this->MOD_SETTINGS =
BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP(
'SET'), $this->MCONF[
'name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
768 if (is_object($this->extObj)) {
769 $this->extObj->checkExtObj();
781 if (is_callable([$this->extObj,
'head'])) {
782 $this->extObj->head();
792 if ($this->extObj ===
null) {
793 $flashMessage = GeneralUtility::makeInstance(
795 $this->
getLanguageService()->sL(
'LLL:EXT:backend/Resources/Private/Language/locallang.xlf:no_modules_registered'),
800 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
802 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
803 $defaultFlashMessageQueue->enqueue($flashMessage);
805 $this->extObj->pObj = $this;
806 if (is_callable([$this->extObj,
'main'])) {
807 $this->content .= $this->extObj->main();
824 $this->content = $savedContent;
834 return GeneralUtility::makeInstance(PageRenderer::class);