TYPO3 CMS  TYPO3_6-2
ClickMenuController.php
Go to the documentation of this file.
1 <?php
3 
18 
26 
27  // Internal, static: GPvar:
28  // Back path.
32  public $backPath;
33 
34  // Definition of which item the click menu should be made for.
38  public $item;
39 
40  // Defines the name of the document object for which to reload the URL.
45 
46  // Internal:
47  // Content accumulation
51  public $content = '';
52 
53  // Template object
57  public $doc;
58 
64  public $include_once = array();
65 
66  // Internal array of classes for extending the clickmenu
70  public $extClassArray = array();
71 
75  public function __construct() {
76  $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
77  $GLOBALS['SOBE'] = $this;
78 
79  $this->init();
80  }
81 
87  protected function init() {
88  // Setting GPvars:
89  $this->backPath = GeneralUtility::_GP('backPath');
90  $this->item = GeneralUtility::_GP('item');
91  $this->reloadListFrame = GeneralUtility::_GP('reloadListFrame');
92  // Setting pseudo module name
93  $this->MCONF['name'] = 'xMOD_alt_clickmenu.php';
94  // Takes the backPath as a parameter BUT since we are worried about someone forging a backPath (XSS security hole) we will check with sent md5 hash:
95  $inputBP = explode('|', $this->backPath);
96  if (count($inputBP) == 2 && $inputBP[1] == GeneralUtility::shortMD5($inputBP[0] . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
97  $this->backPath = $inputBP[0];
98  } else {
99  $this->backPath = $GLOBALS['BACK_PATH'];
100  }
101  // Setting internal array of classes for extending the clickmenu:
102  $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
103  // Traversing that array and setting files for inclusion:
104  // @deprecated since 6.1, will be removed 2 versions later
105  if (is_array($this->extClassArray)) {
106  foreach ($this->extClassArray as $extClassConf) {
107  if (isset($extClassConf['path'])) {
109  '$GLOBALS[\'TBE_MODULES_EXT\'][\'xMOD_alt_clickmenu\'][\'extendCMclasses\'][\'path\'] option is not needed anymore. The autoloader takes care of loading the class.'
110  );
111  $this->include_once[] = $extClassConf['path'];
112  }
113  }
114  }
115  // Initialize template object
116  if (!$this->ajax) {
117  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
118  $this->doc->backPath = $GLOBALS['BACK_PATH'];
119  }
120  // Setting mode for display and background image in the top frame
121 
122  // Setting clickmenu timeout
123  $secs = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'), 1, 100, 5);
124  // default is 5
125  // Setting the JavaScript controlling the timer on the page
126  $listFrameDoc = $this->reloadListFrame != 2 ? 'top.content.list_frame' : 'top.content';
127  $this->doc->JScode .= $this->doc->wrapScriptTags('
128  var date = new Date();
129  var mo_timeout = Math.floor(date.getTime()/1000);
130 
131  roImg = "' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('status-status-current') . '";
132 
133  routImg = "t3-icon-empty";
134 
135  function mo(c) { //
136  var name="roimg_"+c;
137  document.getElementById(name).className = roImg;
138  updateTime();
139  }
140  function mout(c) { //
141  var name="roimg_"+c;
142  document[name].src = routImg;
143  updateTime();
144  }
145  function updateTime() { //
146  date = new Date();
147  mo_timeout = Math.floor(date.getTime()/1000);
148  }
149  function timeout_func() { //
150  date = new Date();
151  if (Math.floor(date.getTime()/1000)-mo_timeout > ' . $secs . ') {
152  hideCM();
153  return false;
154  } else {
155  window.setTimeout("timeout_func();",1*1000);
156  }
157  }
158  function hideCM() { //
159  window.location.href="alt_topmenu_dummy.php";
160  return false;
161  }
162 
163  // Start timer
164  timeout_func();
165 
166  ' . ($this->reloadListFrame ? '
167  // Reload list frame:
168  if(' . $listFrameDoc . '){' . $listFrameDoc . '.location.href=' . $listFrameDoc . '.location.href;}' : '') . '
169  ');
170  }
171 
177  public function main() {
178  $this->ajax = GeneralUtility::_GP('ajax') ? TRUE : FALSE;
179  // Initialize Clipboard object:
180  $clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
181  $clipObj->initializeClipboard();
182  // This locks the clipboard to the Normal for this request.
183  $clipObj->lockToNormal();
184  // Update clipboard if some actions are sent.
185  $CB = GeneralUtility::_GET('CB');
186  $clipObj->setCmd($CB);
187  $clipObj->cleanCurrent();
188  // Saves
189  $clipObj->endClipboard();
190  // Create clickmenu object
191  $clickMenu = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\ClickMenu\\ClickMenu');
192  // Set internal vars in clickmenu object:
193  $clickMenu->clipObj = $clipObj;
194  $clickMenu->extClassArray = $this->extClassArray;
195  $clickMenu->backPath = $this->backPath;
196  // Start page
197  if (!$this->ajax) {
198  $this->content .= $this->doc->startPage('Context Sensitive Menu');
199  }
200  // Set content of the clickmenu with the incoming var, "item"
201  $this->content .= $clickMenu->init();
202  }
203 
209  public function printContent() {
210  if (!$this->ajax) {
211  $this->content .= $this->doc->endPage();
212  $this->content = $this->doc->insertStylesAndJS($this->content);
213  echo $this->content;
214  } else {
215  header('Content-Type: text/xml');
216  echo '<?xml version="1.0"?>' . LF . '<t3ajax>' . $this->content . '</t3ajax>';
217  }
218  }
219 
220 }
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]