[TASK] Restructure position of help icons in 'Pagetree overview'
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Controller / PageInformationController.php
1 <?php
2 namespace TYPO3\CMS\Frontend\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 TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Backend\View\PageLayoutView;
19 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * Class for displaying page information (records, page record properties)
24 */
25 class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule
26 {
27 /**
28 * Returns the menu array
29 *
30 * @return array
31 */
32 public function modMenu()
33 {
34 return [
35 'pages' => [
36 0 => $GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:pages_0'),
37 2 => $GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:pages_2'),
38 1 => $GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:pages_1')
39 ],
40 'depth' => [
41 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
42 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
43 2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
44 3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
45 4 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
46 999 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
47 ]
48 ];
49 }
50
51 /**
52 * MAIN function for page information display
53 *
54 * @return string Output HTML for the module.
55 */
56 public function main()
57 {
58 $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title')) . '</h1>';
59 $dblist = GeneralUtility::makeInstance(PageLayoutView::class);
60 $dblist->descrTable = '_MOD_web_info';
61 $dblist->thumbs = 0;
62 $dblist->script = BackendUtility::getModuleUrl('web_info');
63 $dblist->showIcon = 0;
64 $dblist->setLMargin = 0;
65 $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
66 $dblist->pI_showUser = 1;
67
68 switch ((int)$this->pObj->MOD_SETTINGS['pages']) {
69 case 1:
70 $dblist->fieldArray = ['title', 'uid'] + array_keys($this->cleanTableNames());
71 break;
72 case 2:
73 $dblist->fieldArray = [
74 'title',
75 'uid',
76 'lastUpdated',
77 'newUntil',
78 'no_cache',
79 'cache_timeout',
80 'php_tree_stop',
81 'TSconfig',
82 'is_siteroot',
83 'fe_login_mode'
84 ];
85 break;
86 default:
87 $dblist->fieldArray = [
88 'title',
89 'uid',
90 'alias',
91 'starttime',
92 'endtime',
93 'fe_group',
94 'target',
95 'url',
96 'shortcut',
97 'shortcut_mode'
98 ];
99 }
100
101 // PAGES:
102 $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
103 // ONLY for the sake of dblist module which uses this value.
104 $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
105 $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
106 $dblist->start($this->pObj->id, 'pages', 0);
107 $dblist->generateList();
108 // CSH
109 $optionKey = $this->pObj->MOD_SETTINGS['pages'];
110 $cshPagetreeOverview = BackendUtility::cshItem($dblist->descrTable, 'func_' . $optionKey, null, '<span class="btn btn-default btn-sm">|</span>');
111
112 $theOutput .= '<div class="form-inline form-inline-spaced">'
113 . $h_func
114 . '<div class="form-group">' . $cshPagetreeOverview . '</div>'
115 . '</div>'
116 . $dblist->HTMLcode;
117
118 // Additional footer content
119 $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'];
120 if (is_array($footerContentHook)) {
121 foreach ($footerContentHook as $hook) {
122 $params = [];
123 $theOutput .= GeneralUtility::callUserFunction($hook, $params, $this);
124 }
125 }
126 return $theOutput;
127 }
128
129 /**
130 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
131 * which the user has access. Also a set of standard tables (pages, sys_filemounts, etc...)
132 * are filtered out. So what is left is basically all tables which makes sense to list content from.
133 *
134 * @return string[]
135 */
136 protected function cleanTableNames()
137 {
138 // Get all table names:
139 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
140 // Unset common names:
141 unset($tableNames['pages']);
142 unset($tableNames['sys_filemounts']);
143 unset($tableNames['sys_action']);
144 unset($tableNames['sys_workflows']);
145 unset($tableNames['be_users']);
146 unset($tableNames['be_groups']);
147 $allowedTableNames = [];
148 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
149 if (is_array($tableNames)) {
150 foreach ($tableNames as $k => $v) {
151 if (!$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->getBackendUser()->check('tables_select', $k)) {
152 $allowedTableNames['table_' . $k] = $k;
153 }
154 }
155 }
156 return $allowedTableNames;
157 }
158
159 /**
160 * @return BackendUserAuthentication
161 */
162 protected function getBackendUser()
163 {
164 return $GLOBALS['BE_USER'];
165 }
166 }