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