[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / func / Classes / Controller / PageFunctionsController.php
1 <?php
2 namespace TYPO3\CMS\Func\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 > Functions 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 PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
26
27 /**
28 * @Internal
29 * @todo Define visibility
30 */
31 public $pageinfo;
32
33 /**
34 * @todo Define visibility
35 */
36 public $fileProcessor;
37
38 /**
39 * Document Template Object
40 *
41 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
42 * @todo Define visibility
43 */
44 public $doc;
45
46 /**
47 * Constructor
48 */
49 public function __construct() {
50 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_func.xlf');
51 $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], TRUE);
52 }
53
54 /**
55 * Initialize module header etc and call extObjContent function
56 *
57 * @return void
58 */
59 public function main() {
60 // Access check...
61 // The page will show only if there is a valid page and if this page may be viewed by the user
62 $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
63 $access = is_array($this->pageinfo);
64 // Template markers
65 $markers = array(
66 'CSH' => '',
67 'FUNC_MENU' => '',
68 'CONTENT' => ''
69 );
70 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
71 $this->doc->backPath = $GLOBALS['BACK_PATH'];
72 $this->doc->setModuleTemplate('EXT:func/Resources/Private/Templates/func.html');
73 // Main
74 if ($this->id && $access) {
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_func')) . '" method="post"><input type="hidden" name="id" value="' . htmlspecialchars($this->id) . '" />';
80 $vContent = $this->doc->getVersionSelector($this->id, TRUE);
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['CSH'] = $docHeaderButtons['csh'];
88 $markers['FUNC_MENU'] = BackendUtility::getFuncMenu(
89 $this->id,
90 'SET[function]',
91 $this->MOD_SETTINGS['function'],
92 $this->MOD_MENU['function']
93 );
94 $markers['CONTENT'] = $this->content;
95 } else {
96 // If no access or if ID == zero
97 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
98 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
99 $GLOBALS['LANG']->getLL('clickAPage_content'),
100 $GLOBALS['LANG']->getLL('title'),
101 \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
102 );
103 $this->content = $flashMessage->render();
104 // Setting up the buttons and markers for docheader
105 $docHeaderButtons = $this->getButtons();
106 $markers['CSH'] = $docHeaderButtons['csh'];
107 $markers['CONTENT'] = $this->content;
108 }
109 // Build the <body> for the module
110 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
111 // Renders the module page
112 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
113 }
114
115 /**
116 * Print module content (from $this->content)
117 *
118 * @return void
119 */
120 public function printContent() {
121 echo $this->content;
122 }
123
124 /**
125 * Create the panel of buttons for submitting the form or otherwise perform operations.
126 *
127 * @return array All available buttons as an assoc. array
128 */
129 protected function getButtons() {
130 $buttons = array(
131 'csh' => '',
132 'view' => '',
133 'shortcut' => ''
134 );
135 // CSH
136 $buttons['csh'] = BackendUtility::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH'], '', TRUE);
137 if ($this->id && is_array($this->pageinfo)) {
138 // View page
139 $buttons['view'] = '<a href="#" '
140 . 'onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" '
141 . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
142 . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
143 // Shortcut
144 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
145 $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']);
146 }
147 }
148 return $buttons;
149 }
150
151 }