-tags linking them to proper functions. */ public function createToolbar(): string { /** @var LanguageAspect $languageAspect */ $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $tsfe = $this->getTypoScriptFrontendController(); // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead: $moduleName = BackendUtility::getPagesTSconfig($tsfe->page['uid'])['mod.']['newContentElementWizard.']['override'] ?? 'new_content_element'; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $perms = $this->getBackendUser()->calcPerms($tsfe->page); $langAllowed = $this->getBackendUser()->checkLanguageAccess($languageAspect->getId()); $id = $tsfe->id; $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI'); $classes = 'typo3-adminPanel-btn typo3-adminPanel-btn-default typo3-feedit-btn-openBackend'; $output = []; $output[] = '
'; $output[] = '
'; $t3BeSitenameMd5 = md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); // History $link = (string)$uriBuilder->buildUriFromRoute( 'record_history', [ 'element' => 'pages:' . $id, 'returnUrl' => $returnUrl, ] ); $title = $this->getLabel('edit_recordHistory'); $output[] = ''; $output[] = ' ' . $iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render(); $output[] = ''; // New Content if ($perms & Permission::CONTENT_EDIT && $langAllowed) { $linkParameters = [ 'id' => $id, 'returnUrl' => $returnUrl, ]; if (!empty($languageAspect->getId())) { $linkParameters['sys_language_uid'] = $languageAspect->getId(); } $link = (string)$uriBuilder->buildUriFromRoute($moduleName, $linkParameters); $icon = $iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render(); $title = $this->getLabel('edit_newContentElement'); $output[] = ''; $output[] = ' ' . $icon; $output[] = ''; } // Move Page if ($perms & Permission::PAGE_EDIT) { $link = (string)$uriBuilder->buildUriFromRoute( 'move_element', [ 'table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl, ] ); $icon = $iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)->render(); $title = $this->getLabel('edit_move_page'); $output[] = ''; $output[] = ' ' . $icon; $output[] = ''; } // New Page if ($perms & Permission::PAGE_NEW) { $link = (string)$uriBuilder->buildUriFromRoute( 'db_new', [ 'id' => $id, 'pagesOnly' => 1, 'returnUrl' => $returnUrl, ] ); $icon = $iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render(); $title = $this->getLabel('edit_newPage'); $output[] = ''; $output[] = ' ' . $icon; $output[] = ''; } // Edit Page if ($perms & Permission::PAGE_EDIT) { $link = (string)$uriBuilder->buildUriFromRoute( 'record_edit', [ 'edit[pages][' . $id . ']' => 'edit', 'noView' => 1, 'returnUrl' => $returnUrl, ] ); $icon = $iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render(); $title = $this->getLabel('edit_editPageProperties'); $output[] = ''; $output[] = ' ' . $icon; $output[] = ''; } // Edit Page Overlay if ($perms & Permission::PAGE_EDIT && $languageAspect->getId() > 0 && $langAllowed) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('pages'); $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); $row = $queryBuilder ->select('uid', 'pid', 't3ver_state') ->from('pages') ->where( $queryBuilder->expr()->eq( $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT) ), $queryBuilder->expr()->eq( $GLOBALS['TCA']['pages']['ctrl']['languageField'], $queryBuilder->createNamedParameter($languageAspect->getId(), \PDO::PARAM_INT) ) ) ->setMaxResults(1) ->execute() ->fetch(); // @extensionScannerIgnoreLine At least in v10 this is a false positive $tsfe->sys_page->versionOL('pages', $row); if (is_array($row)) { $link = (string)$uriBuilder->buildUriFromRoute( 'record_edit', [ 'edit[pages][' . $row['uid'] . ']' => 'edit', 'noView' => 1, 'returnUrl' => $returnUrl, ] ); $icon = $iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL) ->render(); $title = $this->getLabel('edit_editPageOverlay'); $output[] = ''; $output[] = ' ' . $icon; $output[] = ''; } } // Open list view if ($this->getBackendUser()->check('modules', 'web_list')) { $link = (string)$uriBuilder->buildUriFromRoute( 'web_list', [ 'id' => $id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ] ); $icon = $iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render(); $title = $this->getLabel('edit_db_list'); $output[] = ''; $output[] = ' ' . $icon; $output[] = ''; } $output[] = '
'; $output[] = '
'; return implode('', $output); } /** * Translate given key * * @param string $key Key for a label in the $LOCAL_LANG array of "sysext/core/Resources/Private/Language/locallang_tsfe.xlf * @return string The value for the $key */ protected function getLabel($key): ?string { return htmlspecialchars( $this->getLanguageService()->sL('LLL:EXT:feedit/Resources/Private/Language/locallang_edit.xlf:' . $key), ENT_QUOTES | ENT_HTML5 ); } /** * @return FrontendBackendUserAuthentication */ protected function getBackendUser(): FrontendBackendUserAuthentication { return $GLOBALS['BE_USER']; } /** * @return LanguageService */ protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } /** * @return TypoScriptFrontendController */ protected function getTypoScriptFrontendController(): TypoScriptFrontendController { return $GLOBALS['TSFE']; } }