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