2019-01-20 12:55:15 +01:00
|
|
|
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace TYPO3\CMS\Feedit\Modules;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the TYPO3 CMS project.
|
|
|
|
*
|
|
|
|
* It is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, either version 2
|
|
|
|
* of the License, or any later version.
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please read the
|
|
|
|
* LICENSE.txt file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* The TYPO3 project - inspiring people to share!
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule;
|
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\InitializableInterface;
|
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\PageSettingsProviderInterface;
|
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface;
|
2020-01-31 11:25:26 +01:00
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder;
|
2019-01-20 12:55:15 +01:00
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
2020-01-31 11:25:26 +01:00
|
|
|
use TYPO3\CMS\Feedit\Service\EditToolbarService;
|
2019-01-20 12:55:15 +01:00
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView;
|
|
|
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Admin Panel Edit Module
|
|
|
|
*/
|
2020-04-01 11:53:36 +02:00
|
|
|
class EditModule extends AbstractModule implements PageSettingsProviderInterface, RequestEnricherInterface, ResourceProviderInterface
|
2019-01-20 12:55:15 +01:00
|
|
|
{
|
2020-01-31 11:25:26 +01:00
|
|
|
/**
|
|
|
|
* @var UriBuilder
|
|
|
|
*/
|
|
|
|
protected $uriBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param UriBuilder $uriBuilder
|
|
|
|
*/
|
|
|
|
public function __construct(UriBuilder $uriBuilder)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->uriBuilder = $uriBuilder;
|
|
|
|
}
|
|
|
|
|
2019-01-20 12:55:15 +01:00
|
|
|
/**
|
|
|
|
* Creates the content for the "edit" section ("module") of the Admin Panel
|
|
|
|
*
|
|
|
|
* @return string HTML content for the section. Consists of a string with table-rows with four columns.
|
|
|
|
*/
|
|
|
|
public function getPageSettings(): string
|
|
|
|
{
|
|
|
|
$editToolbarService = GeneralUtility::makeInstance(EditToolbarService::class);
|
|
|
|
$toolbar = $editToolbarService->createToolbar();
|
|
|
|
$view = GeneralUtility::makeInstance(StandaloneView::class);
|
|
|
|
$templateNameAndPath = 'EXT:feedit/Resources/Private/Templates/Modules/Settings/Edit.html';
|
|
|
|
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
|
|
|
|
$view->setPartialRootPaths(['EXT:feedit/Resources/Private/Partials']);
|
|
|
|
$view->assignMultiple(
|
|
|
|
[
|
|
|
|
'display' => [
|
|
|
|
'fieldIcons' => $this->configurationService->getConfigurationOption('edit', 'displayFieldIcons'),
|
|
|
|
'displayIcons' => $this->configurationService->getConfigurationOption('edit', 'displayIcons'),
|
|
|
|
],
|
|
|
|
'toolbar' => $toolbar,
|
|
|
|
'script' => [
|
2020-01-31 11:25:26 +01:00
|
|
|
'backendScript' => $this->uriBuilder->buildUriFromRoute(
|
|
|
|
'web_layout',
|
|
|
|
[
|
|
|
|
'id' => (int)$this->getTypoScriptFrontendController()->page['uid'],
|
|
|
|
]
|
|
|
|
),
|
2019-01-20 12:55:15 +01:00
|
|
|
't3BeSitenameMd5' => md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']),
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
return $view->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return TypoScriptFrontendController
|
|
|
|
*/
|
|
|
|
protected function getTypoScriptFrontendController(): TypoScriptFrontendController
|
|
|
|
{
|
|
|
|
return $GLOBALS['TSFE'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getPageModule(): string
|
|
|
|
{
|
|
|
|
$pageModule = trim($this->getBackendUser()->getTSConfig()['options.']['overridePageModule'] ?? '');
|
|
|
|
return BackendUtility::isModuleSetInTBE_MODULES($pageModule) ? $pageModule : 'web_layout';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function getIdentifier(): string
|
|
|
|
{
|
|
|
|
return 'edit';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function getIconIdentifier(): string
|
|
|
|
{
|
|
|
|
return 'actions-open';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function getLabel(): string
|
|
|
|
{
|
|
|
|
$locallangFileAndPath = 'LLL:EXT:feedit/Resources/Private/Language/locallang_edit.xlf:module.label';
|
|
|
|
return $this->getLanguageService()->sL($locallangFileAndPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the edit module
|
|
|
|
* Includes the frontend edit initialization
|
|
|
|
*
|
|
|
|
* @param ServerRequestInterface $request
|
2020-04-01 11:53:36 +02:00
|
|
|
* @return ServerRequestInterface
|
2019-01-20 12:55:15 +01:00
|
|
|
*/
|
2020-04-01 11:53:36 +02:00
|
|
|
public function enrich(ServerRequestInterface $request): ServerRequestInterface
|
2019-01-20 12:55:15 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getJavaScriptFiles(): array
|
|
|
|
{
|
|
|
|
return ['EXT:feedit/Resources/Public/JavaScript/Modules/Edit.js'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string array with css files that will be rendered after the module
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getCssFiles(): array
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|