[TASK] Remove usage of property $new_unique_uid
[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 * @var array
29 * @internal
30 */
31 public $pageinfo;
32
33 /**
34 * Document Template Object
35 *
36 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
37 */
38 public $doc;
39
40 /**
41 * The name of the module
42 *
43 * @var string
44 */
45 protected $moduleName = 'web_func';
46
47 /**
48 * Constructor
49 */
50 public function __construct() {
51 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_func.xlf');
52 $this->MCONF = array(
53 'name' => $this->moduleName,
54 );
55 }
56
57 /**
58 * Initialize module header etc and call extObjContent function
59 *
60 * @return void
61 */
62 public function main() {
63 // Access check...
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);
67 // Template markers
68 $markers = array(
69 'CSH' => '',
70 'FUNC_MENU' => '',
71 'CONTENT' => ''
72 );
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');
76 // Main
77 if ($this->id && $access) {
78 // JavaScript
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);
84 if ($vContent) {
85 $this->content .= $this->doc->section('', $vContent);
86 }
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(
92 $this->id,
93 'SET[function]',
94 $this->MOD_SETTINGS['function'],
95 $this->MOD_MENU['function']
96 );
97 $markers['CONTENT'] = $this->content;
98 } else {
99 // If no access or if ID == zero
100 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
101 \TYPO3\CMS\Core\Messaging\FlashMessage::class,
102 $GLOBALS['LANG']->getLL('clickAPage_content'),
103 $GLOBALS['LANG']->getLL('title'),
104 \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
105 );
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;
111 }
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($GLOBALS['LANG']->getLL('title'), $this->content);
116 }
117
118 /**
119 * Print module content (from $this->content)
120 *
121 * @return void
122 */
123 public function printContent() {
124 echo $this->content;
125 }
126
127 /**
128 * Create the panel of buttons for submitting the form or otherwise perform operations.
129 *
130 * @return array All available buttons as an assoc. array
131 */
132 protected function getButtons() {
133 $buttons = array(
134 'csh' => '',
135 'view' => '',
136 'shortcut' => ''
137 );
138 // CSH
139 $buttons['csh'] = BackendUtility::cshItem('_MOD_web_func', '');
140 if ($this->id && is_array($this->pageinfo)) {
141 // View page
142 $buttons['view'] = '<a href="#" '
143 . 'onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" '
144 . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
145 . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
146 // Shortcut
147 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
148 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->moduleName);
149 }
150 }
151 return $buttons;
152 }
153
154 }