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