diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 641a9400ae184c060e995e7b8fb7aa1fe8fac611..bd452c28caad413b1dd4aa05e32dcc6406b34997 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -31,6 +31,7 @@ use SGalinski\SgNews\Utility\BackendNewsUtility; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; +use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\Icon; @@ -80,6 +81,12 @@ class BackendController extends ActionController { */ private $docHeaderComponent; + + /** + * @var ?ModuleTemplate + */ + protected $moduleTemplate = NULL; + /** * Initializes the view before invoking an action method. * @@ -101,7 +108,13 @@ class BackendController extends ActionController { $backendUser = $GLOBALS['BE_USER']; $this->pageInfo = BackendUtility::readPageAccess($this->pageUid, $backendUser->getPagePermsClause(1)); if ($this->pageInfo) { - $this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class); + if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { + $this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class); + } + else { + $this->getDocHeaderComponent(); + + } if ($this->pageUid) { $this->rootPageUid = BackendNewsUtility::getRootUidByPageUid($this->pageUid); } @@ -260,9 +273,31 @@ class BackendController extends ActionController { * @return \Psr\Http\Message\ResponseInterface */ protected function createBackendResponse(): \Psr\Http\Message\ResponseInterface { - $moduleTemplateFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\ModuleTemplateFactory::class); - $moduleTemplate = $moduleTemplateFactory->create($this->request); - $moduleTemplate->setContent($this->view->render()); - return $this->htmlResponse($moduleTemplate->renderContent()); + $this->getModuleTemplate(); + $this->moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($this->moduleTemplate->renderContent()); + } + + /** + * Since we cannot use constructer Injection, we do have to get one Dynamicly. If we want to use + * our ModuleTemplate, call GetModuleTemplate before, which will init one if there is none for some reason + */ + protected function getModuleTemplate() { + if ($this->moduleTemplate === NULL) { + $moduleTemplateFactory = GeneralUtility::makeInstance( + \TYPO3\CMS\Backend\Template\ModuleTemplateFactory::class + ); + $this->moduleTemplate = $moduleTemplateFactory->create($this->request); + } + } + + /** + * Other Helper function, which gets us just the DocHeaderComponent + */ + protected function getDocHeaderComponent() { + if ($this->moduleTemplate === NULL) { + $this->getModuleTemplate(); + } + $this->docHeaderComponent = $this->moduleTemplate->getDocHeaderComponent(); } } diff --git a/Classes/Paginator/QueryBuilderPaginator.php b/Classes/Paginator/QueryBuilderPaginator.php index 5d9dd48b349fab0a66ffed2baf914e2dd7a53694..ac476aac53190a2057107e44bdec9437b3b21797 100644 --- a/Classes/Paginator/QueryBuilderPaginator.php +++ b/Classes/Paginator/QueryBuilderPaginator.php @@ -68,11 +68,20 @@ final class QueryBuilderPaginator extends AbstractPaginator { protected function getTotalAmountOfItems(): int { $countBuilder = clone $this->queryBuilder; - $totalItems = $countBuilder - ->setMaxResults(99999) - ->setFirstResult(0) - ->count('uid') - ->execute()->fetchOne(); + try { + $totalItems = $countBuilder + ->setMaxResults(99999) + ->setFirstResult(0) + ->count('uid') + ->execute()->fetchOne(); + } + catch (\Exception $e){ + $totalItems = $countBuilder + ->setMaxResults(99999) + ->setFirstResult(0) + ->count('p.uid') + ->execute()->fetchOne(); + } $this->setTotalItems($totalItems); return $totalItems; } diff --git a/Resources/Private/Layouts/Backend.html b/Resources/Private/Layouts/Backend.html index 7fedf9d12f6d712ba8859825c746e0dd29185b2a..73ae87a2fdbf1b53bcc8580a0fa8225f38b2ffe5 100644 --- a/Resources/Private/Layouts/Backend.html +++ b/Resources/Private/Layouts/Backend.html @@ -8,6 +8,7 @@ 1: 'TYPO3/CMS/Backend/Tooltip', 2: 'TYPO3/CMS/SgNews/Backend'}" /> + <h1> <f:render section="headline" /> </h1>