4223a7998f0e80d9c1c46e501e4323be98aa7a81
[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 // Internal, dynamic:
39 /**
40 * @todo Define visibility
41 */
42 public $be_user_Array;
43
44 /**
45 * @todo Define visibility
46 */
47 public $CALC_PERMS;
48
49 /**
50 * @todo Define visibility
51 */
52 public $pageinfo;
53
54 /**
55 * Document Template Object
56 *
57 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
58 * @todo Define visibility
59 */
60 public $doc;
61
62 /**
63 * Initialize module header etc and call extObjContent function
64 *
65 * @return void
66 * @todo Define visibility
67 */
68 public function main() {
69 // Access check...
70 // The page will show only if there is a valid page and if this page may be viewed by the user
71 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
72 $access = is_array($this->pageinfo) ? 1 : 0;
73 if ($this->id && $access || $GLOBALS['BE_USER']->user['admin'] && !$this->id) {
74 $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
75 if ($GLOBALS['BE_USER']->user['admin'] && !$this->id) {
76 $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
77 }
78 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
79 $this->doc->backPath = $GLOBALS['BACK_PATH'];
80 $this->doc->setModuleTemplate('EXT:info/Resources/Private/Templates/info.html');
81 $this->doc->tableLayout = array(
82 '0' => array(
83 '0' => array('<td valign="top"><strong>', '</strong></td>'),
84 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top"><strong>', '</strong></td>')
85 ),
86 'defRow' => array(
87 '0' => array('<td valign="top">', '</td>'),
88 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top">', '</td>')
89 )
90 );
91 // JavaScript
92 $this->doc->JScode = $this->doc->wrapScriptTags('
93 script_ended = 0;
94 function jumpToUrl(URL) { //
95 window.location.href = URL;
96 }
97 ');
98 $this->doc->postCode = $this->doc->wrapScriptTags('
99 script_ended = 1;
100 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
101 ');
102 // Setting up the context sensitive menu:
103 $this->doc->getContextMenuCode();
104 $this->doc->form = '<form action="index.php" method="post" name="webinfoForm">';
105 $vContent = $this->doc->getVersionSelector($this->id, 1);
106 if ($vContent) {
107 $this->content .= $this->doc->section('', $vContent);
108 }
109 $this->extObjContent();
110 // Setting up the buttons and markers for docheader
111 $docHeaderButtons = $this->getButtons();
112 $markers = array(
113 'CSH' => $docHeaderButtons['csh'],
114 'FUNC_MENU' => \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
115 'CONTENT' => $this->content
116 );
117 // Build the <body> for the module
118 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
119 } else {
120 // If no access or if ID == zero
121 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
122 $this->doc->backPath = $GLOBALS['BACK_PATH'];
123 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('title'));
124 $this->content .= $this->doc->spacer(5);
125 $this->content .= $this->doc->spacer(10);
126 }
127 // Renders the module page
128 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
129 }
130
131 /**
132 * Print module content (from $this->content)
133 *
134 * @return void
135 * @todo Define visibility
136 */
137 public function printContent() {
138 $this->content = $this->doc->insertStylesAndJS($this->content);
139 echo $this->content;
140 }
141
142 /**
143 * Create the panel of buttons for submitting the form or otherwise perform operations.
144 *
145 * @return array All available buttons as an assoc. array
146 */
147 protected function getButtons() {
148 $buttons = array(
149 'csh' => '',
150 'view' => '',
151 'shortcut' => ''
152 );
153 // CSH
154 $buttons['csh'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_web_info', '', $GLOBALS['BACK_PATH'], '', TRUE);
155 // View page
156 $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>';
157 // Shortcut
158 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
159 $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']);
160 }
161 return $buttons;
162 }
163
164 }
165
166
167 ?>