2 namespace TYPO3\CMS\Func\Controller
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Utility\BackendUtility
;
20 * Script Class for the Web > Functions module
21 * This class creates the framework to which other extensions can connect their sub-modules
23 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
25 class PageFunctionsController
extends \TYPO3\CMS\Backend\Module\BaseScriptClass
{
34 * Document Template Object
36 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
41 * The name of the module
45 protected $moduleName = 'web_func';
50 public function __construct() {
51 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_func.xlf');
53 'name' => $this->moduleName
,
58 * Initialize module header etc and call extObjContent function
62 public function main() {
64 // The page will show only if there is a valid page and if this page may be viewed by the user
65 $this->pageinfo
= BackendUtility
::readPageAccess($this->id
, $this->perms_clause
);
66 $access = is_array($this->pageinfo
);
73 $this->doc
= \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate
::class);
74 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
75 $this->doc
->setModuleTemplate('EXT:func/Resources/Private/Templates/func.html');
77 if ($this->id
&& $access) {
79 $this->doc
->postCode
= $this->doc
->wrapScriptTags('if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id
. ';');
80 // Setting up the context sensitive menu:
81 $this->doc
->getContextMenuCode();
82 $this->doc
->form
= '<form action="' . htmlspecialchars(BackendUtility
::getModuleUrl('web_func')) . '" method="post"><input type="hidden" name="id" value="' . htmlspecialchars($this->id
) . '" />';
83 $vContent = $this->doc
->getVersionSelector($this->id
, TRUE);
85 $this->content
.= $this->doc
->section('', $vContent);
87 $this->extObjContent();
88 // Setting up the buttons and markers for docheader
89 $docHeaderButtons = $this->getButtons();
90 $markers['CSH'] = $docHeaderButtons['csh'];
91 $markers['FUNC_MENU'] = BackendUtility
::getFuncMenu(
94 $this->MOD_SETTINGS
['function'],
95 $this->MOD_MENU
['function']
97 $markers['CONTENT'] = $this->content
;
99 // If no access or if ID == zero
100 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance(
101 \TYPO3\CMS\Core\Messaging\FlashMessage
::class,
102 $this->getLanguageService()->getLL('clickAPage_content'),
103 $this->getLanguageService()->getLL('title'),
104 \TYPO3\CMS\Core\Messaging\FlashMessage
::INFO
106 $this->content
= $flashMessage->render();
107 // Setting up the buttons and markers for docheader
108 $docHeaderButtons = $this->getButtons();
109 $markers['CSH'] = $docHeaderButtons['csh'];
110 $markers['CONTENT'] = $this->content
;
112 // Build the <body> for the module
113 $this->content
= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
114 // Renders the module page
115 $this->content
= $this->doc
->render($this->getLanguageService()->getLL('title'), $this->content
);
119 * Print module content (from $this->content)
123 public function printContent() {
128 * Create the panel of buttons for submitting the form or otherwise perform operations.
130 * @return array All available buttons as an assoc. array
132 protected function getButtons() {
139 $buttons['csh'] = BackendUtility
::cshItem('_MOD_web_func', '');
140 if ($this->id
&& is_array($this->pageinfo
)) {
142 $buttons['view'] = '<a href="#" '
143 . 'onclick="' . htmlspecialchars(BackendUtility
::viewOnClick($this->pageinfo
['uid'], $GLOBALS['BACK_PATH'], BackendUtility
::BEgetRootLine($this->pageinfo
['uid']))) . '" '
144 . 'title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
145 . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-document-view') . '</a>';
147 if ($this->getBackendUser()->mayMakeShortcut()) {
148 $buttons['shortcut'] = $this->doc
->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU
)), $this->moduleName
);
155 * Returns LanguageService
157 * @return \TYPO3\CMS\Lang\LanguageService
159 protected function getLanguageService() {
160 return $GLOBALS['LANG'];
164 * Returns the current BE user.
166 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
168 protected function getBackendUser() {
169 return $GLOBALS['BE_USER'];