[TASK] Remove unneeded parenthesis on array-access
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / ClickMenuController.php
1 <?php
2 namespace TYPO3\CMS\Backend\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 Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Backend\Template\DocumentTemplate;
21 use TYPO3\CMS\Backend\Clipboard\Clipboard;
22 use TYPO3\CMS\Backend\ClickMenu\ClickMenu;
23
24 /**
25 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
26 * @see \TYPO3\CMS\Backend\Template\DocumentTemplate::getContextMenuCode()
27 */
28 class ClickMenuController
29 {
30 /**
31 * Defines the name of the document object for which to reload the URL.
32 *
33 * @var int
34 */
35 public $reloadListFrame;
36
37 /**
38 * Content accumulation
39 *
40 * @var string
41 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
42 */
43 public $content = '';
44
45 /**
46 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
47 */
48 public $doc;
49
50 /**
51 * Internal array of classes for extending the clickmenu
52 *
53 * @var array
54 */
55 public $extClassArray = array();
56
57 /**
58 * Constructor
59 */
60 public function __construct()
61 {
62 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_misc.xlf');
63 $GLOBALS['SOBE'] = $this;
64
65 // Setting GPvars:
66 $this->reloadListFrame = GeneralUtility::_GP('reloadListFrame');
67 // Setting pseudo module name
68 $this->MCONF['name'] = 'xMOD_alt_clickmenu.php';
69
70 // Setting internal array of classes for extending the clickmenu:
71 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
72
73 // Initialize template object
74 $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
75 }
76
77 /**
78 * Constructor function for script class.
79 *
80 * @return void
81 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, all done in the constructor now
82 */
83 protected function init()
84 {
85 GeneralUtility::logDeprecatedFunction();
86 }
87
88 /**
89 * Main function - generating the click menu in whatever form it has.
90 *
91 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, as an AJAX Route is now the main entry point
92 * @return void
93 */
94 public function main()
95 {
96 GeneralUtility::logDeprecatedFunction();
97 // Initialize Clipboard object:
98 $clipObj = GeneralUtility::makeInstance(Clipboard::class);
99 $clipObj->initializeClipboard();
100 // This locks the clipboard to the Normal for this request.
101 $clipObj->lockToNormal();
102 // Update clipboard if some actions are sent.
103 $CB = GeneralUtility::_GET('CB');
104 $clipObj->setCmd($CB);
105 $clipObj->cleanCurrent();
106 // Saves
107 $clipObj->endClipboard();
108 // Create clickmenu object
109 $clickMenu = GeneralUtility::makeInstance(ClickMenu::class);
110 // Set internal vars in clickmenu object:
111 $clickMenu->clipObj = $clipObj;
112 $clickMenu->extClassArray = $this->extClassArray;
113 // Set content of the clickmenu with the incoming var, "item"
114 $this->content .= $clickMenu->init();
115 }
116
117 /**
118 * End page and output content.
119 *
120 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, as an AJAX Route is now the main entry point
121 * @return void
122 */
123 public function printContent()
124 {
125 GeneralUtility::logDeprecatedFunction();
126 header('Content-Type: text/xml');
127 echo '<?xml version="1.0"?>' . LF . '<t3ajax>' . $this->content . '</t3ajax>';
128 }
129
130 /**
131 * this is an intermediate clickmenu handler
132 *
133 * @param ServerRequestInterface $request
134 * @param ResponseInterface $response
135 * @return ResponseInterface
136 */
137 public function getContextMenuAction(ServerRequestInterface $request, ResponseInterface $response)
138 {
139
140 // XML has to be parsed, no parse errors allowed
141 @ini_set('display_errors', 0);
142
143 $clipObj = GeneralUtility::makeInstance(Clipboard::class);
144 $clipObj->initializeClipboard();
145 // This locks the clipboard to the Normal for this request.
146 $clipObj->lockToNormal();
147 // Update clipboard if some actions are sent.
148 $CB = GeneralUtility::_GET('CB');
149 $clipObj->setCmd($CB);
150 $clipObj->cleanCurrent();
151 // Saves
152 $clipObj->endClipboard();
153 // Create clickmenu object
154 $clickMenu = GeneralUtility::makeInstance(ClickMenu::class);
155 // Set internal vars in clickmenu object:
156 $clickMenu->clipObj = $clipObj;
157 $clickMenu->extClassArray = $this->extClassArray;
158
159 // Set content of the clickmenu with the incoming var, "item"
160 $ajaxContent = $clickMenu->init();
161
162 // send the data
163 $ajaxContent = '<?xml version="1.0"?><t3ajax>' . $ajaxContent . '</t3ajax>';
164 $response->getBody()->write($ajaxContent);
165 $response = $response->withHeader('Content-Type', 'text/xml; charset=utf-8');
166 return $response;
167 }
168
169 /**
170 * Returns LanguageService
171 *
172 * @return \TYPO3\CMS\Lang\LanguageService
173 */
174 protected function getLanguageService()
175 {
176 return $GLOBALS['LANG'];
177 }
178 }