[TASK] Remove conf.php from ext:info
[Packages/TYPO3.CMS.git] / typo3 / sysext / info / Classes / Controller / InfoModuleController.php
1 <?php
2 namespace TYPO3\CMS\Info\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\Module\BaseScriptClass;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Backend\Utility\IconUtility;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * Script Class for the Web > Info module
24 * This class creates the framework to which other extensions can connect their sub-modules
25 *
26 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
27 */
28 class InfoModuleController extends BaseScriptClass {
29
30 /**
31 * @var array
32 */
33 public $pageinfo;
34
35 /**
36 * Document Template Object
37 *
38 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
39 */
40 public $doc;
41
42 /**
43 * @var \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
44 */
45 protected $backendUser;
46
47 /**
48 * @var \TYPO3\CMS\Lang\LanguageService
49 */
50 protected $languageService;
51
52 /**
53 * The name of the module
54 *
55 * @var string
56 */
57 protected $moduleName = 'web_info';
58
59 /**
60 * Constructor
61 */
62 public function __construct() {
63 $this->languageService = $GLOBALS['LANG'];
64 $this->languageService->includeLLFile('EXT:lang/locallang_mod_web_info.xlf');
65
66 $this->backendUser = $GLOBALS['BE_USER'];
67
68 $this->MCONF = array(
69 'name' => $this->moduleName,
70 );
71 }
72
73 /**
74 * Initialize module header etc and call extObjContent function
75 *
76 * @return void
77 */
78 public function main() {
79 // Access check...
80 // The page will show only if there is a valid page and if this page
81 // may be viewed by the user
82 $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
83 $access = is_array($this->pageinfo);
84 if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) {
85 if ($this->backendUser->user['admin'] && !$this->id) {
86 $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
87 }
88 $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
89 $this->doc->backPath = $GLOBALS['BACK_PATH'];
90 $this->doc->setModuleTemplate('EXT:info/Resources/Private/Templates/info.html');
91 $this->doc->tableLayout = array(
92 '0' => array(
93 '0' => array('<td valign="top"><strong>', '</strong></td>'),
94 'defCol' => array('<td><img src="' . $this->doc->backPath .
95 'clear.gif" width="10" height="1" alt="" /></td><td valign="top"><strong>', '</strong></td>')
96 ),
97 'defRow' => array(
98 '0' => array('<td valign="top">', '</td>'),
99 'defCol' => array('<td><img src="' . $this->doc->backPath .
100 'clear.gif" width="10" height="1" alt="" /></td><td valign="top">', '</td>')
101 )
102 );
103 // JavaScript
104 $this->doc->postCode = $this->doc->wrapScriptTags('if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';');
105 // Setting up the context sensitive menu:
106 $this->doc->getContextMenuCode();
107 $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName)) .
108 '" method="post" name="webinfoForm">';
109 $vContent = $this->doc->getVersionSelector($this->id, 1);
110 if ($vContent) {
111 $this->content .= $this->doc->section('', $vContent);
112 }
113 $this->extObjContent();
114 // Setting up the buttons and markers for docheader
115 $docHeaderButtons = $this->getButtons();
116 $markers = array(
117 'CSH' => $docHeaderButtons['csh'],
118 'FUNC_MENU' => BackendUtility::getFuncMenu(
119 $this->id,
120 'SET[function]',
121 $this->MOD_SETTINGS['function'],
122 $this->MOD_MENU['function']
123 ),
124 'CONTENT' => $this->content
125 );
126 // Build the <body> for the module
127 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
128 } else {
129 // If no access or if ID == zero
130 $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
131 $this->doc->backPath = $GLOBALS['BACK_PATH'];
132 $this->content = $this->doc->header($this->languageService->getLL('title'));
133 $this->content .= $this->doc->spacer(5);
134 $this->content .= $this->doc->spacer(10);
135 }
136 // Renders the module page
137 $this->content = $this->doc->render($this->languageService->getLL('title'), $this->content);
138 }
139
140 /**
141 * Print module content (from $this->content)
142 *
143 * @return void
144 */
145 public function printContent() {
146 $this->content = $this->doc->insertStylesAndJS($this->content);
147 echo $this->content;
148 }
149
150 /**
151 * Create the panel of buttons for submitting the form or otherwise perform operations.
152 *
153 * @return array All available buttons as an assoc. array
154 */
155 protected function getButtons() {
156 $buttons = array(
157 'csh' => '',
158 'view' => '',
159 'shortcut' => ''
160 );
161 // CSH
162 $buttons['csh'] = BackendUtility::cshItem('_MOD_web_info', '');
163 // View page
164 $buttons['view'] = '<a href="#" ' .
165 'onclick="' . htmlspecialchars(
166 BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'],
167 BackendUtility::BEgetRootLine($this->pageinfo['uid']))
168 ) . '" ' .
169 'title="' . $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' .
170 IconUtility::getSpriteIcon('actions-document-view') .
171 '</a>';
172 // Shortcut
173 if ($this->backendUser->mayMakeShortcut()) {
174 $buttons['shortcut'] = $this->doc->makeShortcutIcon(
175 'id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit',
176 implode(',', array_keys($this->MOD_MENU)), $this->moduleName);
177 }
178 return $buttons;
179 }
180 }