ElementHistoryController.php 4.19 KB
Newer Older
1
2
3
<?php
namespace TYPO3\CMS\Backend\Controller\ContentElement;

4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
8
9
 * 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.
10
 *
11
12
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
15
 * The TYPO3 project - inspiring people to share!
 */
16

17
18
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
19
20
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
Nicole Cordes's avatar
Nicole Cordes committed
21
22
use TYPO3\CMS\Core\Utility\GeneralUtility;

23
24
/**
 * Script Class for showing the history module of TYPO3s backend
Nicole Cordes's avatar
Nicole Cordes committed
25
 * @see \TYPO3\CMS\Backend\History\RecordHistory
26
 */
27
class ElementHistoryController {
28
29

	/**
30
	 * @var string
31
32
33
34
35
36
	 */
	public $content;

	/**
	 * Document template object
	 *
37
	 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
38
39
40
	 */
	public $doc;

41
42
43
44
45
	/**
	 * @var array
	 */
	protected $pageInfo;

46
47
48
49
	/**
	 * Constructor
	 */
	public function __construct() {
50
		$this->getLanguageService()->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
51
52
53
54
55
		$GLOBALS['SOBE'] = $this;

		$this->init();
	}

56
57
58
59
	/**
	 * Injects the request object for the current request or subrequest
	 * As this controller goes only through the main() method, it is rather simple for now
	 *
60
61
62
	 * @param ServerRequestInterface $request the current request
	 * @param ResponseInterface $response
	 * @return ResponseInterface the response with the content
63
	 */
64
	public function mainAction(ServerRequestInterface $request, ResponseInterface $response) {
65
66
67
68
69
70
71
72
73
		$this->main();

		$this->content .= $this->doc->endPage();
		$this->content = $this->doc->insertStylesAndJS($this->content);

		$response->getBody()->write($this->content);
		return $response;
	}

74
75
76
77
78
	/**
	 * Initialize the module output
	 *
	 * @return void
	 */
79
80
	protected function init() {
		// 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
89
90
91
92
93
	}

	/**
	 * Generate module output
	 *
	 * @return void
	 */
	public function main() {
		// Start history object
94
		$historyObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\History\RecordHistory::class);
95
96
97
98
99
100
101
		// Get content:
		$this->content .= $historyObj->main();
		// Setting up the buttons and markers for docheader
		$docHeaderButtons = $this->getButtons();
		$markers['CONTENT'] = $this->content;
		$markers['CSH'] = $docHeaderButtons['csh'];
		// Build the <body> for the module
102
103
		$this->content = $this->doc->startPage($this->getLanguageService()->getLL('title'));
		$this->content .= $this->doc->moduleBody($this->pageInfo, $docHeaderButtons, $markers);
104
105
106
107
108
109
	}

	/**
	 * Outputting the accumulated content to screen
	 *
	 * @return void
110
	 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use mainAction() instead
111
112
	 */
	public function printContent() {
113
		GeneralUtility::logDeprecatedFunction();
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
		$this->content .= $this->doc->endPage();
		$this->content = $this->doc->insertStylesAndJS($this->content);
		echo $this->content;
	}

	/**
	 * Create the panel of buttons for submitting the form or otherwise perform operations.
	 *
	 * @return array All available buttons as an assoc. array
	 */
	protected function getButtons() {
		$buttons = array(
			'csh' => '',
			'back' => ''
		);
		// CSH
Benni Mack's avatar
Benni Mack committed
130
		$buttons['csh'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'history_log');
131
132
133
		// Get returnUrl parameter
		$returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
		if ($returnUrl) {
134
			$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
135
			$buttons['back'] = '<a href="' . htmlspecialchars($returnUrl) . '" class="typo3-goBack">' . $iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . '</a>';
136
137
138
139
		}
		return $buttons;
	}

140
141
142
143
144
145
146
147
148
	/**
	 * Returns LanguageService
	 *
	 * @return \TYPO3\CMS\Lang\LanguageService
	 */
	protected function getLanguageService() {
		return $GLOBALS['LANG'];
	}

149
}