2019-12-13 12:09:08 +01:00
|
|
|
<?php
|
|
|
|
|
2020-01-08 19:15:08 +01:00
|
|
|
namespace DanielSiepmann\DsSite\Hooks\Backend;
|
2019-12-13 12:09:08 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
|
|
*
|
|
|
|
* This program 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 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2020-01-08 19:15:08 +01:00
|
|
|
use TYPO3\CMS\Backend\Controller\PageLayoutController;
|
2019-12-13 12:09:08 +01:00
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView;
|
2019-12-13 13:36:02 +01:00
|
|
|
use TYPO3\CMS\Frontend\Resource\FileCollector;
|
2019-12-13 12:09:08 +01:00
|
|
|
|
2020-01-08 19:15:08 +01:00
|
|
|
class PageLayoutHeader
|
2019-12-13 12:09:08 +01:00
|
|
|
{
|
|
|
|
/**
|
2020-01-08 19:15:08 +01:00
|
|
|
* @var PageLayoutController
|
2019-12-13 12:09:08 +01:00
|
|
|
*/
|
2020-01-08 19:15:08 +01:00
|
|
|
private $pageLayoutController;
|
2019-12-13 12:09:08 +01:00
|
|
|
|
2020-01-08 19:15:08 +01:00
|
|
|
public function render(
|
|
|
|
array $params,
|
|
|
|
PageLayoutController $pageLayoutController
|
2019-12-13 12:09:08 +01:00
|
|
|
): string {
|
2020-01-08 19:15:08 +01:00
|
|
|
$this->pageLayoutController = $pageLayoutController;
|
2019-12-13 12:09:08 +01:00
|
|
|
|
|
|
|
$view = $this->getView();
|
|
|
|
$view->assignMultiple([
|
2020-01-08 19:15:08 +01:00
|
|
|
'record' => $this->pageLayoutController->pageinfo,
|
2019-12-13 12:09:08 +01:00
|
|
|
'metaInfo' => [
|
|
|
|
[
|
|
|
|
'label' => 'introduction',
|
2020-01-08 19:15:08 +01:00
|
|
|
'value' => $this->pageLayoutController->pageinfo['abstract'],
|
2019-12-13 12:09:08 +01:00
|
|
|
'field' => 'abstract',
|
|
|
|
'type' => 'string',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => 'published',
|
2020-01-08 19:15:08 +01:00
|
|
|
'value' => $this->pageLayoutController->pageinfo['lastUpdated'],
|
2019-12-13 12:09:08 +01:00
|
|
|
'field' => 'lastUpdated',
|
|
|
|
'type' => 'date',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => 'updated',
|
2020-01-08 19:15:08 +01:00
|
|
|
'value' => $this->pageLayoutController->pageinfo['SYS_LASTCHANGED'],
|
2019-12-13 12:09:08 +01:00
|
|
|
'type' => 'date',
|
|
|
|
],
|
2019-12-13 13:36:02 +01:00
|
|
|
[
|
|
|
|
'label' => 'media',
|
|
|
|
'value' => $this->resolvePageMedia(),
|
|
|
|
'field' => 'media',
|
|
|
|
'type' => 'files',
|
|
|
|
],
|
2019-12-13 12:09:08 +01:00
|
|
|
],
|
|
|
|
]);
|
|
|
|
$view->setTemplatePathAndFilename('EXT:ds_site/Resources/Private/Templates/Backend/Page/MetaInfo.html');
|
|
|
|
|
|
|
|
return $view->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getView(): StandaloneView
|
|
|
|
{
|
|
|
|
return GeneralUtility::makeInstance(StandaloneView::class);
|
|
|
|
}
|
2019-12-13 13:36:02 +01:00
|
|
|
|
|
|
|
private function resolvePageMedia(): array
|
|
|
|
{
|
2020-01-08 19:15:08 +01:00
|
|
|
$page = ['uid' => $this->pageLayoutController->pageinfo['uid']];
|
2019-12-13 13:36:02 +01:00
|
|
|
$files = new FileCollector();
|
|
|
|
$files->addFilesFromRelation('pages', 'media', $page);
|
|
|
|
|
|
|
|
return $files->getFiles();
|
|
|
|
}
|
2019-12-13 12:09:08 +01:00
|
|
|
}
|