TYPO3 CMS  TYPO3_7-6
ClickMenuController.php
Go to the documentation of this file.
1 <?php
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 
23 
29 {
36 
43  public $content = '';
44 
48  public $doc;
49 
55  public $extClassArray = [];
56 
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 
83  protected function init()
84  {
86  }
87 
94  public function main()
95  {
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 
123  public function printContent()
124  {
126  header('Content-Type: text/xml');
127  echo '<?xml version="1.0"?>' . LF . '<t3ajax>' . $this->content . '</t3ajax>';
128  }
129 
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 
174  protected function getLanguageService()
175  {
176  return $GLOBALS['LANG'];
177  }
178 }
getContextMenuAction(ServerRequestInterface $request, ResponseInterface $response)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']