a4a67e9a00f46ed614e4c923bcc8b5db61601e28
[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 TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Script Class for showing the history module of TYPO3s backend
21 * @see \TYPO3\CMS\Backend\History\RecordHistory
22 */
23 class ElementHistoryController {
24
25 /**
26 * @var string
27 */
28 public $content;
29
30 /**
31 * Document template object
32 *
33 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
34 */
35 public $doc;
36
37 /**
38 * @var array
39 */
40 protected $pageInfo;
41
42 /**
43 * Constructor
44 */
45 public function __construct() {
46 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
47 $GLOBALS['SOBE'] = $this;
48
49 $this->init();
50 }
51
52 /**
53 * Initialize the module output
54 *
55 * @return void
56 */
57 protected function init() {
58 // Create internal template object
59 $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
60 $this->doc->backPath = $GLOBALS['BACK_PATH'];
61 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/show_rechis.html');
62 // Start the page header
63 $this->content .= $this->doc->header($this->getLanguageService()->getLL('title'));
64 }
65
66 /**
67 * Generate module output
68 *
69 * @return void
70 */
71 public function main() {
72 // Start history object
73 $historyObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\History\RecordHistory::class);
74 // Get content:
75 $this->content .= $historyObj->main();
76 // Setting up the buttons and markers for docheader
77 $docHeaderButtons = $this->getButtons();
78 $markers['CONTENT'] = $this->content;
79 $markers['CSH'] = $docHeaderButtons['csh'];
80 // Build the <body> for the module
81 $this->content = $this->doc->startPage($this->getLanguageService()->getLL('title'));
82 $this->content .= $this->doc->moduleBody($this->pageInfo, $docHeaderButtons, $markers);
83 }
84
85 /**
86 * Outputting the accumulated content to screen
87 *
88 * @return void
89 */
90 public function printContent() {
91 $this->content .= $this->doc->endPage();
92 $this->content = $this->doc->insertStylesAndJS($this->content);
93 echo $this->content;
94 }
95
96 /**
97 * Create the panel of buttons for submitting the form or otherwise perform operations.
98 *
99 * @return array All available buttons as an assoc. array
100 */
101 protected function getButtons() {
102 $buttons = array(
103 'csh' => '',
104 'back' => ''
105 );
106 // CSH
107 $buttons['csh'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'history_log');
108 // Start history object
109 $historyObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\History\RecordHistory::class);
110 if ($historyObj->returnUrl) {
111 $buttons['back'] = '<a href="' . htmlspecialchars($historyObj->returnUrl) . '" class="typo3-goBack">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
112 }
113 return $buttons;
114 }
115
116 /**
117 * Returns LanguageService
118 *
119 * @return \TYPO3\CMS\Lang\LanguageService
120 */
121 protected function getLanguageService() {
122 return $GLOBALS['LANG'];
123 }
124
125 }