4c2330d114c105e4b92dd455e00e8a3f83c0149d
[Packages/TYPO3.CMS.git] / typo3 / sysext / version / Classes / Controller / VersionModuleController.php
1 <?php
2 namespace TYPO3\CMS\Version\Controller;
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\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Core\Imaging\Icon;
20 use TYPO3\CMS\Core\Imaging\IconFactory;
21 use TYPO3\CMS\Core\Utility\ArrayUtility;
22 use TYPO3\CMS\Core\Utility\DiffUtility;
23 use TYPO3\CMS\Core\Utility\GeneralUtility;
24 use TYPO3\CMS\Backend\Utility\BackendUtility;
25
26 /**
27 * Versioning module, including workspace management
28 */
29 class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
30 {
31 /**
32 * Module configuration
33 *
34 * @var array
35 */
36 public $MCONF = array();
37
38 /**
39 * Module menu items
40 *
41 * @var array
42 */
43 public $MOD_MENU = array();
44
45 /**
46 * Module session settings
47 *
48 * @var array
49 */
50 public $MOD_SETTINGS = array();
51
52 /**
53 * document template object
54 *
55 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
56 */
57 public $doc;
58
59 /**
60 * @var string
61 */
62 public $content;
63
64 /**
65 * Accumulated content
66 *
67 * @var int
68 */
69 public $showWorkspaceCol = 0;
70
71 /**
72 * @var array
73 */
74 public $formatWorkspace_cache = array();
75
76 /**
77 * @var array
78 */
79 public $formatCount_cache = array();
80
81 /**
82 * @var array
83 */
84 public $targets = array();
85
86 /**
87 * Accumulation of online targets.
88 *
89 * @var string
90 */
91 public $pageModule = '';
92
93 /**
94 * Name of page module
95 *
96 * @var bool
97 */
98 public $publishAccess = false;
99
100 /**
101 * @var array
102 */
103 public $stageIndex = array();
104
105 /**
106 * @var array
107 */
108 public $recIndex = array();
109
110 /**
111 * @var IconFactory
112 */
113 protected $iconFactory;
114
115 /**
116 * The name of the module
117 *
118 * @var string
119 */
120 protected $moduleName = 'web_txversionM1';
121
122 /**
123 * Initialize language files
124 */
125 public function __construct()
126 {
127 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
128 $GLOBALS['SOBE'] = $this;
129 $GLOBALS['LANG']->includeLLFile('EXT:version/Resources/Private/Language/locallang.xlf');
130 }
131
132 /**
133 * Initialize menu configuration
134 *
135 * @return void
136 */
137 public function menuConfig()
138 {
139 // CLEANSE SETTINGS
140 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName, 'ses');
141 }
142
143 /**
144 * Main function of the module. Write the content to $this->content
145 *
146 * @return void
147 */
148 public function main()
149 {
150 // Template markers
151 $markers = array(
152 'CSH' => '',
153 'FUNC_MENU' => '',
154 'WS_MENU' => '',
155 'CONTENT' => ''
156 );
157 // Setting module configuration:
158 $this->MCONF['name'] = $this->moduleName;
159 $this->REQUEST_URI = str_replace('&sendToReview=1', '', GeneralUtility::getIndpEnv('REQUEST_URI'));
160 // Draw the header.
161 $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
162 $this->doc->setModuleTemplate('EXT:version/Resources/Private/Templates/version.html');
163
164 // Setting up the context sensitive menu:
165 $this->doc->getContextMenuCode();
166 // Getting input data:
167 $this->id = (int)GeneralUtility::_GP('id');
168
169 // Record uid. Goes with table name to indicate specific record
170 $this->uid = (int)GeneralUtility::_GP('uid');
171 // // Record table. Goes with uid to indicate specific record
172 $this->table = GeneralUtility::_GP('table');
173
174 $this->details = GeneralUtility::_GP('details');
175 // Page id. If set, indicates activation from Web>Versioning module
176 $this->diffOnly = GeneralUtility::_GP('diffOnly');
177 // Flag. If set, shows only the offline version and with diff-view
178 // Force this setting:
179 $this->MOD_SETTINGS['expandSubElements'] = true;
180 $this->MOD_SETTINGS['diff'] = $this->details || $this->MOD_SETTINGS['diff'] ? 1 : 0;
181 // Reading the record:
182 $record = BackendUtility::getRecord($this->table, $this->uid);
183 if ($record['pid'] == -1) {
184 $record = BackendUtility::getRecord($this->table, $record['t3ver_oid']);
185 }
186 $this->recordFound = is_array($record);
187 $pidValue = $this->table === 'pages' ? $this->uid : $record['pid'];
188 // Checking access etc.
189 if ($this->recordFound && $GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] && !$this->id) {
190 $this->uid = $record['uid'];
191 // Might have changed if new live record was found!
192 // Access check!
193 // The page will show only if there is a valid page and if this page may be viewed by the user
194 $this->pageinfo = BackendUtility::readPageAccess($pidValue, $this->perms_clause);
195 $access = is_array($this->pageinfo) ? 1 : 0;
196 if ($pidValue && $access || $GLOBALS['BE_USER']->user['admin'] && !$pidValue) {
197 // If another page module was specified, replace the default Page module with the new one
198 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
199 $this->pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
200 // Setting publish access permission for workspace:
201 $this->publishAccess = $GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace);
202 $this->versioningMgm();
203 }
204 // Setting up the buttons and markers for docheader
205 $docHeaderButtons = $this->getButtons();
206 $markers['CSH'] = $docHeaderButtons['csh'];
207 $markers['FUNC_MENU'] = BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
208 $markers['CONTENT'] = $this->content;
209 } else {
210 // If no access or id value, create empty document
211 $this->content = $this->doc->section($GLOBALS['LANG']->getLL('clickAPage_header'), $GLOBALS['LANG']->getLL('clickAPage_content'), 0, 1);
212 // Setting up the buttons and markers for docheader
213 $docHeaderButtons = $this->getButtons();
214 $markers['CONTENT'] = $this->content;
215 }
216 // Build the <body> for the module
217 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
218 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
219 $this->content .= $this->doc->endPage();
220 $this->content = $this->doc->insertStylesAndJS($this->content);
221 }
222
223 /**
224 * Outputs accumulated module content to browser.
225 *
226 * @return void
227 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
228 */
229 public function printContent()
230 {
231 GeneralUtility::logDeprecatedFunction();
232 echo $this->content;
233 }
234
235 /**
236 * Create the panel of buttons for submitting the form or otherwise perform operations.
237 *
238 * @return array All available buttons as an assoc. array
239 */
240 protected function getButtons()
241 {
242 $buttons = array(
243 'csh' => '',
244 'view' => '',
245 'record_list' => '',
246 'shortcut' => ''
247 );
248 // CSH
249 if ($this->recordFound && $GLOBALS['TCA'][$this->table]['ctrl']['versioningWS']) {
250 // View page
251 $buttons['view'] = '
252 <a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true) . '">
253 ' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '
254 </a>';
255 // Shortcut
256 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
257 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->moduleName);
258 }
259 // If access to Web>List for user, then link to that module.
260 $buttons['record_list'] = BackendUtility::getListViewLink(array(
261 'id' => $this->pageinfo['uid'],
262 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
263 ), '', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList'));
264 }
265 return $buttons;
266 }
267
268 /******************************
269 *
270 * Versioning management
271 *
272 ******************************/
273 /**
274 * Management of versions for record
275 *
276 * @return void
277 */
278 public function versioningMgm()
279 {
280 // Diffing:
281 $diff_1 = GeneralUtility::_POST('diff_1');
282 $diff_2 = GeneralUtility::_POST('diff_2');
283 if (GeneralUtility::_POST('do_diff')) {
284 $content = '';
285 $content .= '<div class="panel panel-space panel-default">';
286 $content .= '<div class="panel-heading">' . $GLOBALS['LANG']->getLL('diffing') . '</div>';
287 if ($diff_1 && $diff_2) {
288 $diff_1_record = BackendUtility::getRecord($this->table, $diff_1);
289 $diff_2_record = BackendUtility::getRecord($this->table, $diff_2);
290 if (is_array($diff_1_record) && is_array($diff_2_record)) {
291 $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
292 $rows = array();
293 $rows[] = '
294 <tr>
295 <th>' . $GLOBALS['LANG']->getLL('fieldname') . '</th>
296 <th width="98%">' . $GLOBALS['LANG']->getLL('coloredDiffView') . ':</th>
297 </tr>
298 ';
299 foreach ($diff_1_record as $fN => $fV) {
300 if ($GLOBALS['TCA'][$this->table]['columns'][$fN] && $GLOBALS['TCA'][$this->table]['columns'][$fN]['config']['type'] !== 'passthrough' && !GeneralUtility::inList('t3ver_label', $fN)) {
301 if ((string)$diff_1_record[$fN] !== (string)$diff_2_record[$fN]) {
302 $diffres = $diffUtility->makeDiffDisplay(
303 BackendUtility::getProcessedValue($this->table, $fN, $diff_2_record[$fN], 0, 1),
304 BackendUtility::getProcessedValue($this->table, $fN, $diff_1_record[$fN], 0, 1)
305 );
306 $rows[] = '
307 <tr>
308 <td>' . $fN . '</td>
309 <td width="98%">' . $diffres . '</td>
310 </tr>
311 ';
312 }
313 }
314 }
315 if (count($rows) > 1) {
316 $content .= '<div class="table-fit"><table class="table">' . implode('', $rows) . '</table></div>';
317 } else {
318 $content .= '<div class="panel-body">' . $GLOBALS['LANG']->getLL('recordsMatchesCompletely') . '</div>';
319 }
320 } else {
321 $content .= '<div class="panel-body">' . $GLOBALS['LANG']->getLL('errorRecordsNotFound') . '</div>';
322 }
323 } else {
324 $content .= '<div class="panel-body">' . $GLOBALS['LANG']->getLL('errorDiffSources') . '</div>';
325 }
326 $content .= '</div>';
327 }
328 // Element:
329 $record = BackendUtility::getRecord($this->table, $this->uid);
330 $recTitle = BackendUtility::getRecordTitle($this->table, $record, true);
331 // Display versions:
332 $content .= '
333 <form name="theform" action="' . str_replace('&sendToReview=1', '', $this->REQUEST_URI) . '" method="post">
334 <div class="panel panel-space panel-default">
335 <div class="panel-heading">' . $recTitle . '</div>
336 <div class="table-fit">
337 <table class="table">
338 <thead>
339 <tr>
340 <th colspan="2" class="col-icon"></th>
341 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_title') . '">' . $GLOBALS['LANG']->getLL('tblHeader_title') . '</th>
342 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_uid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_uid') . '</i></th>
343 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_oid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_oid') . '</i></th>
344 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_id') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_id') . '</i></th>
345 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_wsid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_wsid') . '</i></th>
346 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_state', true) . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_state') . '</i></th>
347 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_stage') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_stage') . '</i></th>
348 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_count') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_count') . '</i></th>
349 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_pid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_pid') . '</i></th>
350 <th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_label') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</i></th>
351 <th></th>
352 <th colspan="2">
353 <button class="btn btn-default btn-sm" type="submit" name="do_diff" value="true">
354 ' . $GLOBALS['LANG']->getLL('diff') . '
355 </button>
356 </th>
357 </tr>
358 </thead>
359 <tbody>
360 ';
361 $versions = BackendUtility::selectVersionsOfRecord($this->table, $this->uid, '*', $GLOBALS['BE_USER']->workspace);
362 foreach ($versions as $row) {
363 $adminLinks = $this->adminLinks($this->table, $row);
364
365 $editUrl = BackendUtility::getModuleUrl('record_edit', [
366 'edit' => [
367 $this->table => [
368 $row['uid'] => 'edit'
369 ]
370 ],
371 'columnsOnly' => 't3ver_label',
372 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
373 ]);
374 $content .= '
375 <tr' . ($row['uid'] != $this->uid ? '' : ' class="active"') . '>
376 <td class="col-icon">' .
377 ($row['uid'] != $this->uid ?
378 '<a href="' . $this->doc->issueCommand('&cmd[' . $this->table . '][' . $this->uid . '][version][swapWith]=' . $row['uid'] . '&cmd[' . $this->table . '][' . $this->uid . '][version][action]=swap') . '" title="' . $GLOBALS['LANG']->getLL('swapWithCurrent', true) . '">' . $this->iconFactory->getIcon('actions-version-swap-version', Icon::SIZE_SMALL)->render() . '</a>' :
379 '<span title="' . $GLOBALS['LANG']->getLL('currentOnlineVersion', true) . '">' . $this->iconFactory->getIcon('status-status-current', Icon::SIZE_SMALL)->render() . '</span>'
380 ) . '
381 </td>
382 <td class="col-icon">' . $this->iconFactory->getIconForRecord($this->table, $row, Icon::SIZE_SMALL)->render() . '</td>
383 <td>' . htmlspecialchars(BackendUtility::getRecordTitle($this->table, $row, true)) . '</td>
384 <td>' . $row['uid'] . '</td>
385 <td>' . $row['t3ver_oid'] . '</td>
386 <td>' . $row['t3ver_id'] . '</td>
387 <td>' . $row['t3ver_wsid'] . '</td>
388 <td>' . $row['t3ver_state'] . '</td>
389 <td>' . $row['t3ver_stage'] . '</td>
390 <td>' . $row['t3ver_count'] . '</td>
391 <td>' . $row['pid'] . '</td>
392 <td>
393 <a href="' . htmlspecialchars($editUrl) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', true) . '">
394 ' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '
395 </a>' . htmlspecialchars($row['t3ver_label']) . '
396 </td>
397 <td class="col-control">' . $adminLinks . '</td>
398 <td class="text-center success"><input type="radio" name="diff_1" value="' . $row['uid'] . '"' . ($diff_1 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
399 <td class="text-center danger"><input type="radio" name="diff_2" value="' . $row['uid'] . '"' . ($diff_2 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
400 </tr>';
401 // Show sub-content if the table is pages AND it is not the online branch (because that will mostly render the WHOLE tree below - not smart;)
402 if ($this->table === 'pages' && $row['uid'] != $this->uid) {
403 $sub = $this->pageSubContent($row['uid']);
404 if ($sub) {
405 $content .= '
406 <tr>
407 <td colspan="2"></td>
408 <td colspan="11">' . $sub . '</td>
409 <td class="success"></td>
410 <td class="danger"></td>
411 </tr>';
412 }
413 }
414 }
415 $content .= '
416 </tbody>
417 </table>
418 </div>
419 </div>
420 </form>';
421 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
422 // Create new:
423 $content = '
424 <form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db')) . '" method="post">
425 <div class="row">
426 <div class="col-sm-6 col-md-4 col-lg-3">
427 <div class="form-group">
428 <label for="typo3-new-version-label">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</label>
429 <input id="typo3-new-version-label" class="form-control" type="text" name="cmd[' . $this->table . '][' . $this->uid . '][version][label]" />
430 </div>
431 <div class="form-group">
432 <input type="hidden" name="cmd[' . $this->table . '][' . $this->uid . '][version][action]" value="new" />
433 <input type="hidden" name="prErr" value="1" />
434 <input type="hidden" name="redirect" value="' . htmlspecialchars($this->REQUEST_URI) . '" />
435 <input class="btn btn-default" type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('createNewVersion') . '" />
436 </div>
437 </div>
438 </div>
439 </form>
440
441 ';
442 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('createNewVersion'), $content, 0, 1);
443 }
444
445 /**
446 * Recursively look for children for page version with $pid
447 *
448 * @param int $pid UID of page record for which to look up sub-elements following that version
449 * @param int $c Counter, do not set (limits to 100 levels)
450 * @return string Table with content if any
451 */
452 public function pageSubContent($pid, $c = 0)
453 {
454 $tableNames = ArrayUtility::removeArrayEntryByValue(array_keys($GLOBALS['TCA']), 'pages');
455 $tableNames[] = 'pages';
456 $content = '';
457 foreach ($tableNames as $table) {
458 // Basically list ALL tables - not only those being copied might be found!
459 $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . (int)$pid . BackendUtility::deleteClause($table), '', $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? $GLOBALS['TCA'][$table]['ctrl']['sortby'] : '');
460 if ($GLOBALS['TYPO3_DB']->sql_num_rows($mres)) {
461 $content .= '
462 <table class="table">
463 <tr>
464 <th class="col-icon">' . $this->iconFactory->getIconForRecord($table, array(), Icon::SIZE_SMALL)->render() . '</th>
465 <th class="col-title">' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], true) . '</th>
466 <th></th>
467 <th></th>
468 </tr>';
469 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
470 $ownVer = $this->lookForOwnVersions($table, $subrow['uid']);
471 $content .= '
472 <tr>
473 <td class="col-icon">' . $this->iconFactory->getIconForRecord($table, $subrow, Icon::SIZE_SMALL)->render() . '</td>
474 <td class="col-title">' . htmlspecialchars(BackendUtility::getRecordTitle($table, $subrow, true)) . '</td>
475 <td>' . ($ownVer > 1 ? '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_txversionM1', array('table' => $table, 'uid' => $subrow['uid']))) . '">' . ($ownVer - 1) . '</a>' : '') . '</td>
476 <td class="col-control">' . $this->adminLinks($table, $subrow) . '</td>
477 </tr>';
478 if ($table == 'pages' && $c < 100) {
479 $sub = $this->pageSubContent($subrow['uid'], $c + 1);
480 if ($sub) {
481 $content .= '
482 <tr>
483 <td></td>
484 <td></td>
485 <td></td>
486 <td width="98%">' . $sub . '</td>
487 </tr>';
488 }
489 }
490 }
491 $content .= '</table>';
492 }
493 $GLOBALS['TYPO3_DB']->sql_free_result($mres);
494 }
495 return $content;
496 }
497
498 /**
499 * Look for number of versions of a record
500 *
501 * @param string $table Table name
502 * @param int $uid Record uid
503 * @return int Number of versions for record, FALSE if none.
504 */
505 public function lookForOwnVersions($table, $uid)
506 {
507 $versions = BackendUtility::selectVersionsOfRecord($table, $uid, 'uid', null);
508 if (is_array($versions)) {
509 return count($versions);
510 }
511 return false;
512 }
513
514 /**
515 * Administrative links for a table / record
516 *
517 * @param string $table Table name
518 * @param array $row Record for which administrative links are generated.
519 * @return string HTML link tags.
520 */
521 public function adminLinks($table, $row)
522 {
523 // Edit link:
524 $editUrl = BackendUtility::getModuleUrl('record_edit', [
525 'edit' => [
526 $table => [
527 $row['uid'] => 'edit'
528 ]
529 ],
530 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
531 ]);
532 $adminLink = '<a class="btn btn-default" href="' . htmlspecialchars($editUrl) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', true) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
533 // Delete link:
534 $adminLink .= '<a class="btn btn-default" href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][delete]=1')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete', true) . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
535 if ($table === 'pages') {
536 // If another page module was specified, replace the default Page module with the new one
537 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
538 $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
539 // Perform some access checks:
540 $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
541 $a_wp = $GLOBALS['BE_USER']->check('modules', $pageModule);
542 $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'' . $pageModule . '\'); return false;">'
543 . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render()
544 . '</a>';
545 $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'web_list\'); return false;">' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '</a>';
546 // "View page" icon is added:
547 $adminLink .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['uid'], '', BackendUtility::BEgetRootLine($row['uid']))) . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
548 } else {
549 if ($row['pid'] == -1) {
550 $getVars = '&ADMCMD_vPrev[' . rawurlencode(($table . ':' . $row['t3ver_oid'])) . ']=' . $row['uid'];
551 // "View page" icon is added:
552 $adminLink .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['_REAL_PID'], '', BackendUtility::BEgetRootLine($row['_REAL_PID']), '', '', $getVars)) . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
553 }
554 }
555 return '<div class="btn-group btn-group-sm" role="group">' . $adminLink . '</div>';
556 }
557
558
559 /**
560 * Injects the request object for the current request and gathers all data.
561 *
562 * @param ServerRequestInterface $request the current request
563 * @param ResponseInterface $response the prepared response
564 * @return ResponseInterface the response with the content
565 */
566 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
567 {
568 $this->init();
569 $this->main();
570
571 $response->getBody()->write($this->content);
572 return $response;
573 }
574 }