-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/typo3-update/v12'
- Loading branch information
Showing
55 changed files
with
681 additions
and
725 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 |
---|---|---|
|
@@ -2,4 +2,7 @@ | |
.DS_Store | ||
|
||
#IDE | ||
.idea | ||
.idea | ||
|
||
#Build | ||
vendor |
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 |
---|---|---|
@@ -1,54 +1,26 @@ | ||
<?php | ||
|
||
namespace Denkwerk\DwContentElements\Hooks; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2015 Sascha Zander <[email protected]> | ||
* (c) 2016 Johann Derdak <[email protected]> | ||
* | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
declare(strict_types=1); | ||
|
||
namespace Denkwerk\DwContentElements\Backend\EventListener; | ||
|
||
use Denkwerk\DwContentElements\Service\IniProviderService; | ||
use Denkwerk\DwContentElements\Service\IniService; | ||
use Denkwerk\DwContentElements\Service\IrreService; | ||
use Denkwerk\DwContentElements\Service\UrlService; | ||
use TYPO3\CMS\Backend\Form\Exception; | ||
use TYPO3\CMS\Backend\Form\Exception\AccessDeniedTableModifyException; | ||
use TYPO3\CMS\Backend\Form\FormDataCompiler; | ||
use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord; | ||
use TYPO3\CMS\Backend\Form\NodeFactory; | ||
use TYPO3\CMS\Backend\Utility\BackendUtility; | ||
use TYPO3\CMS\Backend\View\PageLayoutView; | ||
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface; | ||
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; | ||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; | ||
|
||
/** | ||
* Class PageLayoutViewDrawItemHook | ||
* @package Denkwerk\DwContentElements\Hooks | ||
*/ | ||
class PageLayoutViewDrawItemHook implements PageLayoutViewDrawItemHookInterface | ||
class PreviewEventListener | ||
{ | ||
|
||
/** | ||
* @var IniService $iniService | ||
*/ | ||
|
@@ -67,25 +39,11 @@ public function __construct() | |
$this->iniService = GeneralUtility::makeInstance(IniService::class); | ||
$this->iniProviderService = GeneralUtility::makeInstance(IniProviderService::class); | ||
} | ||
|
||
/** | ||
* Preprocessed the preview rendering of a content element. | ||
* | ||
* @param PageLayoutView $parentObject : Calling parent object | ||
* @param boolean $drawItem : Whether to draw the item using the default functionalities | ||
* @param string $headerContent : Header content | ||
* @param string $itemContent : Item content | ||
* @param array $row : Record row of tt_content | ||
* @return void | ||
* @throws \TYPO3\CMS\Backend\Form\Exception | ||
*/ | ||
public function preProcess( | ||
PageLayoutView &$parentObject, | ||
&$drawItem, | ||
&$headerContent, | ||
&$itemContent, | ||
array &$row | ||
) { | ||
public function __invoke(PageContentPreviewRenderingEvent $event): void | ||
{ | ||
if ($event->getTable() !== 'tt_content') { | ||
return; | ||
} | ||
|
||
/// Load all provider configurations as array | ||
$providers = $this->iniProviderService->loadProvider(); | ||
|
@@ -102,6 +60,8 @@ public function preProcess( | |
} | ||
} | ||
|
||
$row = $event->getRecord(); | ||
|
||
// If it is an dwc content element | ||
if (isset($row['CType']) && | ||
!is_array($row['CType']) && | ||
|
@@ -136,7 +96,8 @@ public function preProcess( | |
(isset($field['label']) && | ||
empty($field['label']) === false ? | ||
$field['label'] : | ||
$parentObject->itemLabels[$field['name']] | ||
//todo: make sure field exists | ||
$event->getPageLayoutContext()->getItemLabels()[$field['name']] | ||
) | ||
); | ||
|
||
|
@@ -147,6 +108,8 @@ public function preProcess( | |
} | ||
} | ||
$itemContent .= '</div>'; | ||
|
||
$event->setPreviewContent($itemContent); | ||
} | ||
} | ||
|
||
|
@@ -158,7 +121,7 @@ public function preProcess( | |
* @param string $itemLabels | ||
* @param string $fieldTable | ||
* @return string | ||
* @throws \TYPO3\CMS\Backend\Form\Exception | ||
* @throws Exception | ||
*/ | ||
public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTable = 'tt_content') | ||
{ | ||
|
@@ -304,8 +267,8 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab | |
case "selectCheckBox": | ||
$value = explode(',', $fieldValue); | ||
foreach ($items as $item) { | ||
$filedContent .= $item[0] . ' ' . | ||
(in_array($item[1], $value) ? '✔' : '✘') . | ||
$filedContent .= $item['label'] . ' ' . | ||
(in_array($item['value'], $value) ? '✔' : '✘') . | ||
'<br />'; | ||
} | ||
break; | ||
|
@@ -315,16 +278,17 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab | |
$value = explode(',', $fieldValue); | ||
$selectedContent = array(); | ||
foreach ($items as $item) { | ||
if (in_array($item[1], $value)) { | ||
$selectedContent[] = $item[0]; | ||
if (in_array($item['value'], $value)) { | ||
$selectedContent[] = $item['label']; | ||
} | ||
} | ||
$filedContent .= implode("<br />", $selectedContent); | ||
break; | ||
default: | ||
foreach ($items as $item) { | ||
if ($item[1] == $fieldValue) { | ||
$filedContent .= $item[0]; | ||
if ($item['value'] == $fieldValue) { | ||
|
||
$filedContent .= $item['label']; | ||
} | ||
} | ||
} | ||
|
@@ -359,16 +323,12 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab | |
$filedContent .= ($filePreview != '' ? $filePreview : 'No File'); | ||
} else { | ||
if (isset($fieldConfig['foreign_table'])) { | ||
/** @var ContentObjectRenderer $contentObj */ | ||
$contentObj = GeneralUtility::makeInstance( | ||
ContentObjectRenderer::class | ||
); | ||
$contentObj->data = $row; | ||
|
||
$count = 0; | ||
$filedContent .= '<p style="padding-right: 5px;margin:0;">'; | ||
|
||
foreach (IrreService::getRelations( | ||
$contentObj, | ||
$row, | ||
$fieldConfig['foreign_table'] | ||
) as $item) { | ||
$irreItemLabel = $item[$GLOBALS['TCA'][$fieldConfig['foreign_table']]['ctrl']['label']]; | ||
|
@@ -397,7 +357,7 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab | |
$filedContent .= '</div>'; | ||
} | ||
|
||
return $filedContent; | ||
return $filedContent ; | ||
} | ||
|
||
/** | ||
|
@@ -496,8 +456,9 @@ protected function explodeSingleFieldShowItemConfiguration($field) | |
|
||
return array( | ||
'fieldName' => $fieldArray[0], | ||
'fieldLabel' => isset($fieldArray[1]) ?? null, | ||
'paletteName' => isset($fieldArray[2]) ?? null, | ||
'fieldLabel' => (isset($fieldArray[1]) && trim($fieldArray[1]) !== '' ? $fieldArray[1] : null), | ||
'paletteName' => (isset($fieldArray[2]) && trim($fieldArray[2]) !== '' ? $fieldArray[2] : null) | ||
); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.