TYPO3 CMS  TYPO3_7-6
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/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 
83  protected function init()
84  {
85  // Create internal template object
86  // This is ugly, we need to remove the dependency-wiring via GLOBALS['SOBE']
87  // In this case, RecordHistory.php depends on GLOBALS[SOBE] being set in here
88  $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
89  }
90 
96  public function main()
97  {
98  $this->content = '<h1>' . $this->getLanguageService()->getLL('title') . '</h1>';
99  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
100 
101  // Start history object
102  $historyObj = GeneralUtility::makeInstance(RecordHistory::class);
103 
104  $elementData = GeneralUtility::trimExplode(':', $historyObj->element);
105  $this->setPagePath($elementData[0], $elementData[1]);
106 
107  // Get content:
108  $this->content .= $historyObj->main();
109  // Setting up the buttons and markers for docheader
110  $this->getButtons();
111  // Build the <body> for the module
112  $this->moduleTemplate->setContent($this->content);
113  }
114 
121  protected function setPagePath($table, $uid)
122  {
123  $uid = (int)$uid;
124 
125  if ($table === 'pages') {
126  $pageId = $uid;
127  } else {
128  $record = BackendUtility::getRecord($table, $uid, '*', '', false);
129  $pageId = $record['pid'];
130  }
131 
132  $pageAccess = BackendUtility::readPageAccess($pageId, $this->getBackendUser()->getPagePermsClause(1));
133  if (is_array($pageAccess)) {
134  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pageAccess);
135  }
136  }
137 
143  protected function getButtons()
144  {
145  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
146 
147  $helpButton = $buttonBar->makeHelpButton()
148  ->setModuleName('xMOD_csh_corebe')
149  ->setFieldName('history_log');
150  $buttonBar->addButton($helpButton);
151 
152  // Get returnUrl parameter
153  $returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
154  if ($returnUrl) {
155  $backButton = $buttonBar->makeLinkButton()
156  ->setHref($returnUrl)
157  ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc'))
158  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
159  $buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
160  }
161  }
162 
168  protected function getLanguageService()
169  {
170  return $GLOBALS['LANG'];
171  }
172 
178  protected function getBackendUser()
179  {
180  return $GLOBALS['BE_USER'];
181  }
182 }
static readPageAccess($id, $perms_clause)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
$uid
Definition: server.php:38
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']