[TASK] Move record-related entrypoints to backend routing
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / ContentElement / ElementHistoryController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller\ContentElement;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Psr\Http\Message\ServerRequestInterface;
18 use Psr\Http\Message\ResponseInterface;
19 use TYPO3\CMS\Core\Http\Response;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * Script Class for showing the history module of TYPO3s backend
24 * @see \TYPO3\CMS\Backend\History\RecordHistory
25 */
26 class ElementHistoryController implements \TYPO3\CMS\Core\Http\ControllerInterface {
27
28 /**
29 * @var string
30 */
31 public $content;
32
33 /**
34 * Document template object
35 *
36 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
37 */
38 public $doc;
39
40 /**
41 * @var array
42 */
43 protected $pageInfo;
44
45 /**
46 * Constructor
47 */
48 public function __construct() {
49 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
50 $GLOBALS['SOBE'] = $this;
51
52 $this->init();
53 }
54
55 /**
56 * Injects the request object for the current request or subrequest
57 * As this controller goes only through the main() method, it is rather simple for now
58 *
59 * @param ServerRequestInterface $request
60 * @return ResponseInterface $response
61 */
62 public function processRequest(ServerRequestInterface $request) {
63 $this->main();
64
65 $this->content .= $this->doc->endPage();
66 $this->content = $this->doc->insertStylesAndJS($this->content);
67
68 /** @var Response $response */
69 $response = GeneralUtility::makeInstance(Response::class);
70 $response->getBody()->write($this->content);
71 return $response;
72 }
73
74 /**
75 * Initialize the module output
76 *
77 * @return void
78 */
79 protected function init() {
80 // Create internal template object
81 $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
82 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/show_rechis.html');
83 // Start the page header
84 $this->content .= $this->doc->header($this->getLanguageService()->getLL('title'));
85 }
86
87 /**
88 * Generate module output
89 *
90 * @return void
91 */
92 public function main() {
93 // Start history object
94 $historyObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\History\RecordHistory::class);
95 // Get content:
96 $this->content .= $historyObj->main();
97 // Setting up the buttons and markers for docheader
98 $docHeaderButtons = $this->getButtons();
99 $markers['CONTENT'] = $this->content;
100 $markers['CSH'] = $docHeaderButtons['csh'];
101 // Build the <body> for the module
102 $this->content = $this->doc->startPage($this->getLanguageService()->getLL('title'));
103 $this->content .= $this->doc->moduleBody($this->pageInfo, $docHeaderButtons, $markers);
104 }
105
106 /**
107 * Outputting the accumulated content to screen
108 *
109 * @return void
110 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use processRequest() instead
111 */
112 public function printContent() {
113 GeneralUtility::logDeprecatedFunction();
114 $this->content .= $this->doc->endPage();
115 $this->content = $this->doc->insertStylesAndJS($this->content);
116 echo $this->content;
117 }
118
119 /**
120 * Create the panel of buttons for submitting the form or otherwise perform operations.
121 *
122 * @return array All available buttons as an assoc. array
123 */
124 protected function getButtons() {
125 $buttons = array(
126 'csh' => '',
127 'back' => ''
128 );
129 // CSH
130 $buttons['csh'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'history_log');
131 // Start history object
132 $historyObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\History\RecordHistory::class);
133 if ($historyObj->returnUrl) {
134 $buttons['back'] = '<a href="' . htmlspecialchars($historyObj->returnUrl) . '" class="typo3-goBack">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
135 }
136 return $buttons;
137 }
138
139 /**
140 * Returns LanguageService
141 *
142 * @return \TYPO3\CMS\Lang\LanguageService
143 */
144 protected function getLanguageService() {
145 return $GLOBALS['LANG'];
146 }
147
148 }