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