-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Show remaining maxitems in page module
- Loading branch information
1 parent
d83c159
commit 807a66e
Showing
11 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace IchHabRecht\ContentDefender\ViewHelpers; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; | ||
|
||
class ExtendPartialViewHelper extends AbstractViewHelper | ||
{ | ||
use CompileWithRenderStatic; | ||
|
||
protected $escapeOutput = false; | ||
|
||
public static function renderStatic( | ||
array $arguments, | ||
\Closure $renderChildrenClosure, | ||
RenderingContextInterface $renderingContext | ||
) { | ||
$packagePath = GeneralUtility::getFileAbsFileName('EXT:content_defender/Resources/Private/'); | ||
$partialPaths = $renderingContext->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace IchHabRecht\ContentDefender\ViewHelpers; | ||
|
||
use IchHabRecht\ContentDefender\BackendLayout\BackendLayoutConfiguration; | ||
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn; | ||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; | ||
|
||
class MaxitemsViewHelper extends AbstractViewHelper | ||
{ | ||
use CompileWithRenderStatic; | ||
|
||
public function initializeArguments() | ||
{ | ||
parent::initializeArguments(); | ||
|
||
$this->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
defined('TYPO3') || die('Access denied.'); | ||
|
||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile( | ||
'content_defender', | ||
'Configuration/TSconfig/Page/maxitems.tsconfig', | ||
'EXT:content_defender :: Enable maxitems view in page module' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
defined('TYPO3') || die('Access denied.'); | ||
|
||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( | ||
'content_defender', | ||
'Configuration/TypoScript', | ||
'EXT:content_defender :: Enable maxitems view in page module' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
templates.typo3/cms-backend.100 = ichhabrecht/content-defender:Resources/Private/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.tx_contentdefender { | ||
view { | ||
# cat=plugin.tx_contentdefender/file; type=string; label=Path to template root | ||
templateRootPath = EXT:content_defender/Resources/Private/Templates/Backend/ | ||
# cat=plugin.tx_contentdefender/file; type=string; label=Path to template partials | ||
partialRootPath = EXT:content_defender/Resources/Private/Partials/Backend/ | ||
# cat=plugin.tx_contentdefender/file; type=string; label=Path to template layouts | ||
layoutRootPath = EXT:content_defender/Resources/Private/Layouts/Backend/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
module.tx_backend.view.partialRootPaths.100 = {$module.tx_contentdefender.view.partialRootPath} |
27 changes: 27 additions & 0 deletions
27
Resources/Private/Partials/Backend/PageLayout/Grid/ColumnHeader.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
xmlns:cd="http://typo3.org/ns/IchHabRecht/ContentDefender/ViewHelpers" | ||
data-namespace-typo3-fluid="true"> | ||
|
||
<f:be.pageRenderer includeCssFiles="{0: 'EXT:content_defender/Resources/Public/Css/backend.css'}" /> | ||
|
||
<cd:extendPartial> | ||
<f:alias map="{maxitems: '{cd:maxitems(column: column)}'}"> | ||
<div class="t3-cd-badge-container" data-maxitems="{maxitems}"> | ||
<f:switch expression="{maxitems}"> | ||
<f:case value="-1"></f:case> | ||
<f:case value="1"> | ||
<span class="badge text-bg-warning t3-cd-badge">{maxitems}</span> | ||
</f:case> | ||
<f:case value="0"> | ||
<span class="badge text-bg-danger t3-cd-badge">{maxitems}</span> | ||
</f:case> | ||
<f:defaultCase> | ||
<span class="badge text-bg-success t3-cd-badge">{maxitems}</span> | ||
</f:defaultCase> | ||
</f:switch> | ||
<f:render partial="PageLayout/Grid/ColumnHeader" arguments="{_all}" /> | ||
</div> | ||
</f:alias> | ||
</cd:extendPartial> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
xmlns:cd="http://typo3.org/ns/IchHabRecht/ContentDefender/ViewHelpers" | ||
data-namespace-typo3-fluid="true"> | ||
<cd:extendPartial> | ||
<f:alias map="{maxitems: '{cd:maxitems(column: column)}'}"> | ||
<div class="t3-cd-badge-container" data-maxitems="{maxitems}"> | ||
<f:render partial="PageLayout/Record" arguments="{_all}" /> | ||
</div> | ||
</f:alias> | ||
</cd:extendPartial> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |