diff --git a/Classes/ViewHelpers/ExtendPartialViewHelper.php b/Classes/ViewHelpers/ExtendPartialViewHelper.php new file mode 100644 index 0000000..82d469c --- /dev/null +++ b/Classes/ViewHelpers/ExtendPartialViewHelper.php @@ -0,0 +1,32 @@ +getTemplatePaths()->getPartialRootPaths(); + $newPartialPaths = array_filter($partialPaths, function ($path) use ($packagePath) { + return strpos($path, $packagePath) === false; + }); + $renderingContext->getTemplatePaths()->setPartialRootPaths($newPartialPaths); + $content = $renderChildrenClosure(); + $renderingContext->getTemplatePaths()->setPartialRootPaths($partialPaths); + + return $content; + } +} diff --git a/Classes/ViewHelpers/MaxitemsViewHelper.php b/Classes/ViewHelpers/MaxitemsViewHelper.php new file mode 100644 index 0000000..51114f6 --- /dev/null +++ b/Classes/ViewHelpers/MaxitemsViewHelper.php @@ -0,0 +1,53 @@ +registerArgument('column', 'TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn', 'Current column object', true); + } + + public static function renderStatic( + array $arguments, + \Closure $renderChildrenClosure, + RenderingContextInterface $renderingContext + ) { + $maxitems = -1; + + /** @var GridColumn $column */ + $column = $arguments['column']; + $pageId = $column->getContext()->getPageId(); + $colPos = $column->getColumnNumber(); + $language = $column->getContext()->getSiteLanguage()->getLanguageId(); + + $identifier = implode('_', [$pageId, $language, $colPos]); + + $viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer(); + if ($viewHelperVariableContainer->exists(self::class, $identifier)) { + return $viewHelperVariableContainer->get(self::class, $identifier); + } + + $backendLayoutConfiguration = BackendLayoutConfiguration::createFromPageId($pageId); + $columnConfiguration = $backendLayoutConfiguration->getConfigurationByColPos($colPos); + + if (!empty($columnConfiguration['maxitems'])) { + $maxitems = $columnConfiguration['maxitems'] - count($column->getItems()); + } + + $viewHelperVariableContainer->add(self::class, $identifier, $maxitems); + + return $maxitems; + } +} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index bbea232..3060320 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -4,6 +4,9 @@ services: autoconfigure: true public: false + IchHabRecht\ContentDefender\: + resource: '../Classes/*' + IchHabRecht\ContentDefender\Hooks\WizardItemsHook: tags: - name: event.listener diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php new file mode 100644 index 0000000..ae69825 --- /dev/null +++ b/Configuration/TCA/Overrides/pages.php @@ -0,0 +1,9 @@ + + + + + + +
+ + + + {maxitems} + + + {maxitems} + + + {maxitems} + + + +
+
+
+ + diff --git a/Resources/Private/Partials/Backend/PageLayout/Record.html b/Resources/Private/Partials/Backend/PageLayout/Record.html new file mode 100644 index 0000000..fb58f21 --- /dev/null +++ b/Resources/Private/Partials/Backend/PageLayout/Record.html @@ -0,0 +1,11 @@ + + + +
+ +
+
+
+ diff --git a/Resources/Public/Css/backend.css b/Resources/Public/Css/backend.css new file mode 100644 index 0000000..f0582c5 --- /dev/null +++ b/Resources/Public/Css/backend.css @@ -0,0 +1,34 @@ +@charset "UTF-8"; + +.t3-cd-badge-container { + position: relative; +} + +.t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3js-page-new-ce, +.t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3-page-ce-dropzone { + display: none; +} + +.t3-cd-badge { + position: absolute; + left: 0; + top: 0; + transform: translate(-50%, 0); + background-color: #ff0000; + z-index: 100; +} + +.t3-cd-badge.text-bg-success { + background-color: #107c10; + color: #ffffff; +} + +.t3-cd-badge.text-bg-warning { + background-color: #e8a33d; + color: #ffffff; +} + +.t3-cd-badge.text-bg-danger { + background-color: #ff0000; + color: #ffffff; +}