[TASK] Cleanup ext:info and ext:info_pagetsconfig
[Packages/TYPO3.CMS.git] / typo3 / sysext / info / Classes / Controller / InfoModuleController.php
1 <?php
2 namespace TYPO3\CMS\Info\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Script Class for the Web > Info module
32 * This class creates the framework to which other extensions can connect their sub-modules
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36 class InfoModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
37
38 /**
39 * @todo Define visibility
40 */
41 public $be_user_Array;
42
43 /**
44 * @todo Define visibility
45 */
46 public $CALC_PERMS;
47
48 /**
49 * @todo Define visibility
50 */
51 public $pageinfo;
52
53 /**
54 * Document Template Object
55 *
56 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
57 * @todo Define visibility
58 */
59 public $doc;
60
61 /**
62 * Constructor
63 */
64 public function __construct() {
65 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_info.xlf');
66 $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], TRUE);
67 }
68
69 /**
70 * Initialize module header etc and call extObjContent function
71 *
72 * @return void
73 */
74 public function main() {
75 // Access check...
76 // The page will show only if there is a valid page and if this page may be viewed by the user
77 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
78 $access = is_array($this->pageinfo);
79 if ($this->id && $access || $GLOBALS['BE_USER']->user['admin'] && !$this->id) {
80 $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
81 if ($GLOBALS['BE_USER']->user['admin'] && !$this->id) {
82 $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
83 }
84 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
85 $this->doc->backPath = $GLOBALS['BACK_PATH'];
86 $this->doc->setModuleTemplate('EXT:info/Resources/Private/Templates/info.html');
87 $this->doc->tableLayout = array(
88 '0' => array(
89 '0' => array('<td valign="top"><strong>', '</strong></td>'),
90 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top"><strong>', '</strong></td>')
91 ),
92 'defRow' => array(
93 '0' => array('<td valign="top">', '</td>'),
94 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top">', '</td>')
95 )
96 );
97 // JavaScript
98 $this->doc->JScode = $this->doc->wrapScriptTags('
99 script_ended = 0;
100 function jumpToUrl(URL) { //
101 window.location.href = URL;
102 }
103 ');
104 $this->doc->postCode = $this->doc->wrapScriptTags('
105 script_ended = 1;
106 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
107 ');
108 // Setting up the context sensitive menu:
109 $this->doc->getContextMenuCode();
110 $this->doc->form = '<form action="index.php" method="post" name="webinfoForm">';
111 $vContent = $this->doc->getVersionSelector($this->id, 1);
112 if ($vContent) {
113 $this->content .= $this->doc->section('', $vContent);
114 }
115 $this->extObjContent();
116 // Setting up the buttons and markers for docheader
117 $docHeaderButtons = $this->getButtons();
118 $markers = array(
119 'CSH' => $docHeaderButtons['csh'],
120 'FUNC_MENU' => \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(
121 $this->id,
122 'SET[function]',
123 $this->MOD_SETTINGS['function'],
124 $this->MOD_MENU['function']
125 ),
126 'CONTENT' => $this->content
127 );
128 // Build the <body> for the module
129 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
130 } else {
131 // If no access or if ID == zero
132 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
133 $this->doc->backPath = $GLOBALS['BACK_PATH'];
134 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('title'));
135 $this->content .= $this->doc->spacer(5);
136 $this->content .= $this->doc->spacer(10);
137 }
138 // Renders the module page
139 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
140 }
141
142 /**
143 * Print module content (from $this->content)
144 *
145 * @return void
146 */
147 public function printContent() {
148 $this->content = $this->doc->insertStylesAndJS($this->content);
149 echo $this->content;
150 }
151
152 /**
153 * Create the panel of buttons for submitting the form or otherwise perform operations.
154 *
155 * @return array All available buttons as an assoc. array
156 */
157 protected function getButtons() {
158 $buttons = array(
159 'csh' => '',
160 'view' => '',
161 'shortcut' => ''
162 );
163 // CSH
164 $buttons['csh'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_web_info', '', $GLOBALS['BACK_PATH'], '', TRUE);
165 // View page
166 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', 1) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
167 // Shortcut
168 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
169 $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']);
170 }
171 return $buttons;
172 }
173
174 }
175
176 ?>