TYPO3 CMS  TYPO3_8-7
ElementHistoryController.php
Go to the documentation of this file.
1 <?php
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 
26 
32 {
36  public $content;
37 
43  public $doc;
44 
48  protected $pageInfo;
49 
53  public function __construct()
54  {
55  parent::__construct();
56  $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_show_rechis.xlf');
57  $GLOBALS['SOBE'] = $this;
58 
59  $this->init();
60  }
61 
70  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
71  {
72  $this->main();
73 
74  $response->getBody()->write($this->moduleTemplate->renderContent());
75  return $response;
76  }
77 
81  protected function init()
82  {
83  // Create internal template object
84  // This is ugly, we need to remove the dependency-wiring via GLOBALS['SOBE']
85  // In this case, RecordHistory.php depends on GLOBALS[SOBE] being set in here
86  $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
87  }
88 
92  public function main()
93  {
94  $this->content = '<h1>' . $this->getLanguageService()->getLL('title') . '</h1>';
95  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
96 
97  // Start history object
98  $historyObj = GeneralUtility::makeInstance(RecordHistory::class);
99 
100  $elementData = GeneralUtility::trimExplode(':', $historyObj->element);
101  $this->setPagePath($elementData[0], $elementData[1]);
102 
103  // Get content:
104  $this->content .= $historyObj->main();
105  // Setting up the buttons and markers for docheader
106  $this->getButtons();
107  // Build the <body> for the module
108  $this->moduleTemplate->setContent($this->content);
109  }
110 
117  protected function setPagePath($table, $uid)
118  {
119  $uid = (int)$uid;
120 
121  if ($table === 'pages') {
122  $pageId = $uid;
123  } else {
124  $record = BackendUtility::getRecord($table, $uid, '*', '', false);
125  $pageId = $record['pid'];
126  }
127 
128  $pageAccess = BackendUtility::readPageAccess($pageId, $this->getBackendUser()->getPagePermsClause(1));
129  if (is_array($pageAccess)) {
130  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pageAccess);
131  }
132  }
133 
139  protected function getButtons()
140  {
141  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
142 
143  $helpButton = $buttonBar->makeHelpButton()
144  ->setModuleName('xMOD_csh_corebe')
145  ->setFieldName('history_log');
146  $buttonBar->addButton($helpButton);
147 
148  // Get returnUrl parameter
149  $returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
150  if ($returnUrl) {
151  $backButton = $buttonBar->makeLinkButton()
152  ->setHref($returnUrl)
153  ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.closeDoc'))
154  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
155  $buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
156  }
157  }
158 
164  protected function getLanguageService()
165  {
166  return $GLOBALS['LANG'];
167  }
168 
174  protected function getBackendUser()
175  {
176  return $GLOBALS['BE_USER'];
177  }
178 }
static readPageAccess($id, $perms_clause)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static makeInstance($className,... $constructorArguments)
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']