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