chore: copy ep_products and ep_theme from EP/website@9593cc8
Copied unchanged from public/typo3conf/ext/ of EP/website at 9593cc8631354f8a363d6609de8b7433f669a9a0 (Git-tracked files only). History stays in the old repository. Only composer.json files are added so the extensions install as path packages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
59afaecea1
commit
a46918de9d
778 files changed
+67000
-2
No files matched your search
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use EP\EpTheme\Exception\ConfigurationMissingException;
|
||||
use EP\EpTheme\Exception\TemplateFileMissingException;
|
||||
use TYPO3\CMS\Backend\View\PageLayoutView;
|
||||
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Resource\FileRepository;
|
||||
use TYPO3\CMS\Core\Service\FlexFormService;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
|
||||
/**
|
||||
* Class AbstractPreviewRenderer
|
||||
*/
|
||||
abstract class AbstractPreviewRenderer implements PageLayoutViewDrawItemHookInterface
|
||||
{
|
||||
/**
|
||||
* @var array tt_content.*
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Define a CType
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cType = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $templatePath = 'EXT:ep_theme/Resources/Private/Templates/PreviewRenderer/';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (empty($this->cType)) {
|
||||
throw new ConfigurationMissingException('Property cType must not be empty', 1586703436);
|
||||
}
|
||||
}
|
||||
|
||||
public function preProcess(
|
||||
PageLayoutView &$parentObject,
|
||||
&$drawItem,
|
||||
&$headerContent,
|
||||
&$itemContent,
|
||||
array &$row
|
||||
) {
|
||||
$this->data = &$row;
|
||||
if ($this->isCtypeMatching() && $this->checkTemplateFile()) {
|
||||
$drawItem = false;
|
||||
$headerContent = $this->getHeaderContent();
|
||||
$itemContent .= $this->getBodytext();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderContent(): string
|
||||
{
|
||||
return '<div id="element-tt_content-' . (int)$this->data['uid']
|
||||
. '" class="t3-ctype-identifier " data-ctype="' . $this->cType . '"></div>';
|
||||
}
|
||||
|
||||
protected function getBodytext(): string
|
||||
{
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$standaloneView = $objectManager->get(StandaloneView::class);
|
||||
$standaloneView->setTemplatePathAndFilename($this->getTemplateFile());
|
||||
$standaloneView->assignMultiple($this->getAssignmentsForTemplate() + [
|
||||
'data' => $this->data,
|
||||
'flexForm' => $this->getFlexForm(),
|
||||
'firstImage' => count($this->getImages()) > 0 ? $this->getImages()[0] : null,
|
||||
'images' => $this->getImages()
|
||||
]);
|
||||
return $standaloneView->render();
|
||||
}
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getFlexForm(): array
|
||||
{
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$flexFormService = $objectManager->get(FlexFormService::class);
|
||||
return $flexFormService->convertFlexFormContentToArray($this->data['pi_flexform']);
|
||||
}
|
||||
|
||||
protected function getImages(int $uid = null, string $tablenames = 'tt_content', string $fieldname = 'image'): array
|
||||
{
|
||||
$uid = $uid ?? $this->data['uid'];
|
||||
$references = [];
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$fileRepository = $objectManager->get(FileRepository::class);
|
||||
/** @var ConnectionPool $connectionPool */
|
||||
$connectionPool = $objectManager->get(ConnectionPool::class);
|
||||
$queryBuilder = $connectionPool->getQueryBuilderForTable('sys_file_reference');
|
||||
$identifiers = (array)$queryBuilder
|
||||
->select('uid')
|
||||
->from('sys_file_reference')
|
||||
->where('uid_foreign=' . $uid . ' and tablenames="' . $tablenames . '" and fieldname="' . $fieldname . '"')
|
||||
->execute()
|
||||
->fetch(\PDO::FETCH_COLUMN);
|
||||
foreach ($identifiers as $identifier) {
|
||||
if ($identifier > 0) {
|
||||
$reference = $fileRepository->findFileReferenceByUid($identifier);
|
||||
if ($reference !== null) {
|
||||
$references[] = $reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isCtypeMatching(): bool
|
||||
{
|
||||
return $this->data['CType'] === $this->cType;
|
||||
}
|
||||
|
||||
protected function checkTemplateFile(): bool
|
||||
{
|
||||
if (is_file($this->getTemplateFile()) === false) {
|
||||
throw new TemplateFileMissingException(
|
||||
'Expected template file for preview rendering for CType ' . $this->cType . ' is missing',
|
||||
1586703260
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getTemplateFile(): string
|
||||
{
|
||||
return GeneralUtility::getFileAbsFileName(
|
||||
$this->templatePath . GeneralUtility::underscoredToUpperCamelCase($this->data['CType']) . '.html'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user