[TASK] Fix CGL violations against InlineControlStructure
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Context menu
30 *
31 * The script is called in the top frame of the backend typically by a click on an icon for which a context menu should appear.
32 * Either this script displays the context menu horizontally in the top frame or alternatively (default in MSIE, Mozilla) it writes the output to a <div>-layer in the calling document (which then appears as a layer/context sensitive menu)
33 * Writing content back into a <div>-layer is necessary if we want individualized context menus with any specific content for any specific element.
34 * Context menus can appear for either database elements or files
35 * The input to this script is basically the "&init" var which is divided by "|" - each part is a reference to table|uid|listframe-flag.
36 *
37 * If you want to integrate a context menu in your scripts, please see template::getContextMenuCode()
38 *
39 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
40 * XHTML compliant
41 *
42 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
43 */
44
45 require('init.php');
46 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
47
48 /**
49 * Class for generating the click menu
50 *
51 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
52 * @package TYPO3
53 * @subpackage core
54 * @internal
55 */
56 class clickMenu {
57
58 // Internal, static: GPvar:
59 // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
60 var $cmLevel = 0;
61 // Clipboard array (submitted by eg. pressing the paste button)
62 var $CB;
63
64 // Internal, static:
65 // Backpath for scripts/images.
66 var $backPath = '';
67 // BackPath place holder: We need different backPath set whether the clickmenu is written back to a frame which is not in typo3/ dir or if the clickmenu is shown in the top frame (no backpath)
68 var $PH_backPath = '###BACK_PATH###';
69 // If set, the calling document should be in the listframe of a frameset.
70 var $listFrame = 0;
71 // If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
72 var $isDBmenu = 0;
73 // If TRUE, the "content" frame is always used for reference (when condensed mode is enabled)
74 var $alwaysContentFrame = 0;
75 // Stores the parts of the input $item string, splitted by "|":
76 // [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame,
77 // If "2" then "content frame" is forced [3] = ("+" prefix = disable
78 // all by default, enable these. Default is to disable) Items key list
79 var $iParts = array();
80 // Contains list of keywords of items to disable in the menu
81 var $disabledItems = array();
82 // If TRUE, the context sensitive menu will not appear in the top frame, only as a layer.
83 var $dontDisplayTopFrameCM = 0;
84 // If TRUE, Show icons on the left.
85 var $leftIcons = 0;
86 // Array of classes to be used for user processing of the menu content. This is for the API of adding items to the menu from outside.
87 var $extClassArray = array();
88 // Enable/disable ajax behavior
89 var $ajax = 0;
90
91 // Internal, dynamic:
92 // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
93 var $elCount = 0;
94 // Set, when edit icon is drawn.
95 var $editPageIconSet = 0;
96 // Set to TRUE, if editing of the element is OK.
97 var $editOK = 0;
98 var $rec = array();
99
100 /**
101 * Initialize click menu
102 *
103 * @return string The clickmenu HTML content
104 */
105 function init() {
106 // Setting GPvars:
107 $this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
108 $this->CB = t3lib_div::_GP('CB');
109 if (t3lib_div::_GP('ajax')) {
110 $this->ajax = 1;
111 // XML has to be parsed, no parse errors allowed
112 @ini_set('display_errors', 0);
113 }
114
115 // Deal with Drag&Drop context menus
116 if (strcmp(t3lib_div::_GP('dragDrop'), '')) {
117 $CMcontent = $this->printDragDropClickMenu(t3lib_div::_GP('dragDrop'), t3lib_div::_GP('srcId'), t3lib_div::_GP('dstId'));
118 return $CMcontent;
119 }
120
121 // Can be set differently as well
122 $this->iParts[0] = t3lib_div::_GP('table');
123 $this->iParts[1] = t3lib_div::_GP('uid');
124 $this->iParts[2] = t3lib_div::_GP('listFr');
125 $this->iParts[3] = t3lib_div::_GP('enDisItems');
126
127 // Setting flags:
128 if ($this->iParts[2]) {
129 $this->listFrame = 1;
130 }
131 if ($GLOBALS['BE_USER']->uc['condensedMode'] || $this->iParts[2] == 2) {
132 $this->alwaysContentFrame = 1;
133 }
134 if (strcmp($this->iParts[1], '')) {
135 $this->isDBmenu = 1;
136 }
137
138 $TSkey = ($this->isDBmenu? 'page' : 'folder' ) . ($this->listFrame ? 'List' : 'Tree');
139 $this->disabledItems = t3lib_div::trimExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'), 1);
140 $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
141
142 // &cmLevel flag detected (2nd level menu)
143 if (!$this->cmLevel) {
144 // Make 1st level clickmenu:
145 if ($this->isDBmenu) {
146 $CMcontent = $this->printDBClickMenu($this->iParts[0], $this->iParts[1]);
147 } else {
148 $CMcontent = $this->printFileClickMenu($this->iParts[0]);
149 }
150 } else {
151 // Make 2nd level clickmenu (only for DBmenus)
152 if ($this->isDBmenu) {
153 $CMcontent = $this->printNewDBLevel($this->iParts[0], $this->iParts[1]);
154 }
155 }
156
157 // Return clickmenu content:
158 return $CMcontent;
159 }
160
161 /**
162 * Returns TRUE if the menu should (also?) be displayed in topframe, not just <div>-layers
163 *
164 * @return boolean
165 */
166 function doDisplayTopFrameCM() {
167 if ($this->ajax) {
168 return FALSE;
169 } else {
170 return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
171 }
172 }
173
174 /***************************************
175 *
176 * DATABASE
177 *
178 ***************************************/
179
180 /**
181 * Make 1st level clickmenu:
182 *
183 * @param string $table Table name
184 * @param integer $uid UID for the current record.
185 * @return string HTML content
186 */
187 function printDBClickMenu($table, $uid) {
188
189 // Get record:
190 $this->rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
191 $menuItems=array();
192
193 $root=0;
194 $DBmount = FALSE;
195 // Rootlevel
196 if ($table=='pages' && !strcmp($uid, '0')) {
197 $root=1;
198 }
199
200 // DB mount
201 if ($table=='pages' && in_array($uid, $GLOBALS['BE_USER']->returnWebmounts())) {
202 $DBmount = TRUE;
203 }
204 // Used to hide cut,copy icons for l10n-records
205 $l10nOverlay = FALSE;
206 // Should only be performed for overlay-records within the same table
207 if (t3lib_BEfunc::isTableLocalizable($table) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
208 $l10nOverlay = intval($this->rec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]) != 0;
209 }
210
211 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
212 if (is_array($this->rec) || $root) {
213
214 // Get permissions
215 $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', ($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
216
217 // View
218 if (!in_array('view', $this->disabledItems)) {
219 if ($table == 'pages') {
220 $menuItems['view'] = $this->DB_view($uid);
221 }
222 if ($table == $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
223 $ws_rec = t3lib_BEfunc::getRecordWSOL($table, $this->rec['uid']);
224 $menuItems['view'] = $this->DB_view($ws_rec['pid']);
225 }
226 }
227
228 // Edit:
229 if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
230 if (!in_array('edit', $this->disabledItems)) {
231 $menuItems['edit']=$this->DB_edit($table, $uid);
232 }
233 $this->editOK =1 ;
234 }
235
236 // New:
237 if (!in_array('new', $this->disabledItems) && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'new')) {
238 $menuItems['new'] = $this->DB_new($table, $uid);
239 }
240
241 // Info:
242 if (!in_array('info', $this->disabledItems) && !$root) {
243 $menuItems['info'] = $this->DB_info($table, $uid);
244 }
245
246 $menuItems['spacer1'] = 'spacer';
247
248 // Copy:
249 if (!in_array('copy', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) {
250 $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
251 }
252 // Cut:
253 if (!in_array('cut', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) {
254 $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
255 }
256
257 // Paste:
258 $elFromAllTables = count($this->clipObj->elFromTable(''));
259 if (!in_array('paste', $this->disabledItems) && $elFromAllTables) {
260 $selItem = $this->clipObj->getSelectedRecord();
261 $elInfo = array(
262 t3lib_div::fixed_lgd_cs($selItem['_RECORD_TITLE'],
263 $GLOBALS['BE_USER']->uc['titleLen']),
264 ($root
265 ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
266 : t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen'])
267 ),
268 $this->clipObj->currentMode()
269 );
270 if ($table == 'pages' && ($lCP & 8)) {
271 if ($elFromAllTables) {
272 $menuItems['pasteinto'] = $this->DB_paste('', $uid, 'into', $elInfo);
273 }
274 }
275
276 $elFromTable = count($this->clipObj->elFromTable($table));
277 if (!$root && !$DBmount && $elFromTable && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
278 $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo);
279 }
280 }
281
282 // Delete:
283 $elInfo=array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen']));
284 if (!in_array('delete', $this->disabledItems) && !$root && !$DBmount && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'delete')) {
285 $menuItems['spacer2'] = 'spacer';
286 $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo);
287 }
288
289 if (!in_array('history', $this->disabledItems)) {
290 $menuItems['history'] = $this->DB_history($table, $uid, $elInfo);
291 }
292 }
293
294 // Adding external elements to the menuItems array
295 $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
296
297 // Processing by external functions?
298 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
299
300 if (!is_array($this->rec)) {
301 $this->rec = array();
302 }
303
304 // Return the printed elements:
305 return $this->printItems($menuItems,
306 $root?
307 t3lib_iconWorks::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) :
308 t3lib_iconWorks::getSpriteIconForRecord($table, $this->rec, array('title'=> htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec, $table)))) . t3lib_BEfunc::getRecordTitle($table, $this->rec, TRUE)
309 );
310 }
311
312 /**
313 * Make 2nd level clickmenu (only for DBmenus)
314 *
315 * @param string $table Table name
316 * @param integer $uid UID for the current record.
317 * @return string HTML content
318 */
319 function printNewDBLevel($table, $uid) {
320
321 // Setting internal record to the table/uid :
322 $this->rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
323 $menuItems = array();
324 $root = 0;
325 // Rootlevel
326 if ($table == 'pages' && !strcmp($uid, '0')) {
327 $root = 1;
328 }
329
330 // If record was found, check permissions and get menu items.
331 if (is_array($this->rec) || $root) {
332 $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord(
333 'pages',
334 ($table == 'pages' ? $this->rec['uid'] : $this->rec['pid']))
335 );
336 // Edit:
337 if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
338 $this->editOK = 1;
339 }
340
341 $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
342 }
343
344 // Return the printed elements:
345 if (!is_array($menuItems)) {
346 $menuItems = array();
347 }
348 return $this->printItems($menuItems,
349 $root?
350 t3lib_iconWorks::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
351 t3lib_iconWorks::getSpriteIconForRecord($table, $this->rec,
352 array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec, $table)))) .
353 t3lib_BEfunc::getRecordTitle($table, $this->rec, TRUE)
354 );
355 }
356
357 /**
358 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
359 *
360 * @param array $menuItems Array for manipulation.
361 * @return array Processed $menuItems array
362 */
363 function externalProcessingOfDBMenuItems($menuItems) {
364 return $menuItems;
365 }
366
367 /**
368 * Processing the $menuItems array by external classes (typ. adding items)
369 *
370 * @param array $menuItems Array for manipulation.
371 * @param string $table Table name
372 * @param integer $uid UID for the current record.
373 * @return array Processed $menuItems array
374 */
375 function processingByExtClassArray($menuItems, $table, $uid) {
376 if (is_array($this->extClassArray)) {
377 foreach ($this->extClassArray as $conf) {
378 $obj = t3lib_div::makeInstance($conf['name']);
379 $menuItems = $obj->main($this, $menuItems, $table, $uid);
380 }
381 }
382 return $menuItems;
383 }
384
385 /**
386 * Returning JavaScript for the onClick event linking to the input URL.
387 *
388 * @param string $url The URL relative to TYPO3_mainDir
389 * @param string $retUrl The return_url-parameter
390 * @param boolean $hideCM If set, the "hideCM()" will be called
391 * @param string $overrideLoc If set, gives alternative location to load in (for example top frame or somewhere else)
392 * @return string JavaScript for an onClick event.
393 */
394 function urlRefForCM($url, $retUrl = '', $hideCM = 1, $overrideLoc = '') {
395 $loc = 'top.content.list_frame';
396 $editOnClick = ($overrideLoc ? 'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
397 ($retUrl ? "+'&" . $retUrl . "='+top.rawurlencode(" . $this->frameLocation('docRef.document') . '.pathname+' . $this->frameLocation('docRef.document') . '.search)' : '') . ';' .
398 ($hideCM ? 'return hideCM();' : '');
399 return $editOnClick;
400 }
401
402 /**
403 * Adding CM element for Clipboard "copy" and "cut"
404 *
405 * @param string $table Table name
406 * @param integer $uid UID for the current record.
407 * @param string $type Type: "copy" or "cut"
408 * @return array Item array, element in $menuItems
409 * @internal
410 */
411 function DB_copycut($table, $uid, $type) {
412 if ($this->clipObj->current=='normal') {
413 $isSel = $this->clipObj->isSelected($table, $uid);
414 }
415
416 $addParam = array();
417 if ($this->listFrame) {
418 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
419 }
420
421 return $this->linkItem(
422 $this->label($type),
423 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-' . $type . ($isSel === $type ? '-release' : ''))),
424 "top.loadTopMenu('" . $this->clipObj->selUrlDB($table, $uid, ($type == 'copy' ? 1: 0), ($isSel==$type), $addParam) . "');return false;"
425 );
426 }
427
428 /**
429 * Adding CM element for Clipboard "paste into"/"paste after"
430 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
431 *
432 * @param string $table Table name
433 * @param integer $uid UID for the current record. NOTICE: Special syntax!
434 * @param string $type Type: "into" or "after"
435 * @param array $elInfo Contains instructions about whether to copy or cut an element.
436 * @return array Item array, element in $menuItems
437 * @see t3lib_clipboard::pasteUrl()
438 * @internal
439 */
440 function DB_paste($table, $uid, $type, $elInfo) {
441 $editOnClick = '';
442 $loc = 'top.content.list_frame';
443 if ($GLOBALS['BE_USER']->jsConfirmation(2)) {
444 $conf = $loc.' && confirm('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.($elInfo[2]=='copy'?'copy':'move').'_'.$type), $elInfo[0], $elInfo[1])).')';
445 } else {
446 $conf = $loc;
447 }
448 $editOnClick = 'if(' . $conf . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $this->clipObj->pasteUrl($table, $uid, 0) . '&redirect=\'+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search); hideCM();}';
449
450 return $this->linkItem(
451 $this->label('paste'.$type),
452 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-paste-' . $type)),
453 $editOnClick.'return false;'
454 );
455 }
456
457 /**
458 * Adding CM element for Info
459 *
460 * @param string $table Table name
461 * @param integer $uid UID for the current record.
462 * @return array Item array, element in $menuItems
463 * @internal
464 */
465 function DB_info($table, $uid) {
466 return $this->linkItem(
467 $this->label('info'),
468 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-info')),
469 "top.launchView('".$table."', '".$uid."'); return hideCM();"
470 );
471 }
472
473 /**
474 * Adding CM element for History
475 *
476 * @param string $table Table name
477 * @param integer $uid UID for the current record.
478 * @return array Item array, element in $menuItems
479 * @internal
480 */
481 function DB_history($table, $uid) {
482 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
483 return $this->linkItem(
484 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
485 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-history-open')),
486 $this->urlRefForCM($url, 'returnUrl'),
487 0
488 );
489 }
490
491 /**
492 * Adding CM element for Permission setting
493 *
494 * @param string $table Table name
495 * @param integer $uid UID for the current record.
496 * @param array $rec The "pages" record with "perms_*" fields inside.
497 * @return array Item array, element in $menuItems
498 * @internal
499 */
500 function DB_perms($table, $uid, $rec) {
501 if (!t3lib_extMgm::isLoaded('perm')) {
502 return '';
503 }
504 $url = t3lib_extMgm::extRelPath('perm') . 'mod1/index.php?id=' . $uid . ($rec['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin() ? '&return_id=' . $uid . '&edit=1' : '');
505 return $this->linkItem(
506 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
507 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('status-status-locked')),
508 $this->urlRefForCM($url),
509 0
510 );
511 }
512
513 /**
514 * Adding CM element for DBlist
515 *
516 * @param string $table Table name
517 * @param integer $uid UID for the current record.
518 * @param array $rec Record of the element (needs "pid" field if not pages-record)
519 * @return array Item array, element in $menuItems
520 * @internal
521 */
522 function DB_db_list($table, $uid, $rec) {
523 $urlParams = array();
524 $urlParams['id'] = ($table == 'pages') ? $uid : $rec['pid'];
525 $urlParams['table'] = $table == 'pages' ? '' : $table;
526 $url = t3lib_BEfunc::getModuleUrl('web_list', $urlParams, '', TRUE);
527 return $this->linkItem(
528 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
529 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-system-list-open')),
530 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list', 1);",
531 0
532 );
533 }
534
535 /**
536 * Adding CM element for Moving wizard
537 *
538 * @param string $table Table name
539 * @param integer $uid UID for the current record.
540 * @param array $rec Record. Needed for tt-content elements which will have the sys_language_uid sent
541 * @return array Item array, element in $menuItems
542 * @internal
543 */
544 function DB_moveWizard($table, $uid, $rec) {
545 // Hardcoded field for tt_content elements.
546 $url = 'move_el.php?table=' . $table . '&uid=' . $uid .
547 ($table == 'tt_content' ? '&sys_language_uid=' . intval($rec['sys_language_uid']) : '');
548
549 return $this->linkItem(
550 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard' . ($table=='pages' ? '_page' : ''))),
551 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document' ) . '-move')),
552 $this->urlRefForCM($url, 'returnUrl'),
553 0
554 );
555 }
556
557 /**
558 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
559 *
560 * @param string $table Table name
561 * @param integer $uid UID for the current record.
562 * @param array $rec Record.
563 * @return array Item array, element in $menuItems
564 * @internal
565 */
566 function DB_newWizard($table, $uid, $rec) {
567 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
568 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
569 $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
570 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
571
572 $url = ($table == 'pages' || !t3lib_extMgm::isLoaded('cms')) ? 'db_new.php?id='.$uid.'&pagesOnly=1' : $newContentWizScriptPath.'?id='.$rec['pid'].'&sys_language_uid='.intval($rec['sys_language_uid']);
573 return $this->linkItem(
574 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
575 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document' ) . '-new')),
576 $this->urlRefForCM($url, 'returnUrl'),
577 0
578 );
579 }
580
581 /**
582 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
583 *
584 * @param string $table Table name
585 * @param integer $uid UID for the current record.
586 * @return array Item array, element in $menuItems
587 * @internal
588 */
589 function DB_editAccess($table, $uid) {
590 $addParam='&columnsOnly='.rawurlencode(implode(',', $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
591 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
592 return $this->linkItem(
593 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
594 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-edit-access')),
595 $this->urlRefForCM($url, 'returnUrl'),
596 1 // no top frame CM!
597 );
598 }
599
600 /**
601 * Adding CM element for edit page properties
602 *
603 * @param integer $uid page uid to edit (PID)
604 * @return array Item array, element in $menuItems
605 * @internal
606 */
607 function DB_editPageProperties($uid) {
608 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
609 return $this->linkItem(
610 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
611 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-page-open')),
612 $this->urlRefForCM($url, 'returnUrl'),
613 1 // no top frame CM!
614 );
615 }
616
617 /**
618 * Adding CM element for regular editing of the element!
619 *
620 * @param string $table Table name
621 * @param integer $uid UID for the current record.
622 * @return array Item array, element in $menuItems
623 * @internal
624 */
625 function DB_edit($table, $uid) {
626
627 // If another module was specified, replace the default Page module with the new one
628 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
629 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
630
631 $editOnClick = '';
632 $loc = 'top.content.list_frame';
633 $addParam = '';
634 $theIcon = 'actions-document-open';
635 if (
636 $this->iParts[0]=='pages' &&
637 $this->iParts[1] &&
638 $GLOBALS['BE_USER']->check('modules', $pageModule)
639 ) {
640 $theIcon = 'actions-page-open';
641 $this->editPageIconSet=1;
642 if ($GLOBALS['BE_USER']->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
643 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
644 } else {
645 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'&edit[" . $table . '][' . $uid . ']=edit' . $addParam . "';}";
646 }
647 }
648 if (!$editOnClick) {
649 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'&edit[" . $table . '][' . $uid . ']=edit' . $addParam . "';}";
650 }
651
652 return $this->linkItem(
653 $this->label('edit'),
654 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon($theIcon)),
655 $editOnClick.'return hideCM();'
656 );
657 }
658
659 /**
660 * Adding CM element for regular Create new element
661 *
662 * @param string $table Table name
663 * @param integer $uid UID for the current record.
664 * @return array Item array, element in $menuItems
665 * @internal
666 */
667 function DB_new($table, $uid) {
668 $editOnClick = '';
669 $loc = 'top.content.list_frame';
670 $editOnClick = 'if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
671 ($this->listFrame?
672 "alt_doc.php?returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'&edit[" . $table . '][-' . $uid . "]=new'":
673 'db_new.php?id='.intval($uid)."'").
674 ';}';
675
676 return $this->linkItem(
677 $this->label('new'),
678 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document' ) . '-new')),
679 $editOnClick.'return hideCM();'
680 );
681 }
682
683 /**
684 * Adding CM element for Delete
685 *
686 * @param string $table Table name
687 * @param integer $uid UID for the current record.
688 * @param array $elInfo Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
689 * @return array Item array, element in $menuItems
690 * @internal
691 */
692 function DB_delete($table, $uid, $elInfo) {
693 $editOnClick = '';
694 $loc = 'top.content.list_frame';
695 if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
696 $conf = 'confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'), $elInfo[0]) .
697 t3lib_BEfunc::referenceCount($table, $uid, ' (There are %s reference(s) to this record!)') .
698 t3lib_BEfunc::translationCount($table, $uid, ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'))
699 ) . ')';
700 } else {
701 $conf = '1==1';
702 }
703 $editOnClick = 'if(' . $loc . ' && ' . $conf . ' ){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'" .
704 '&cmd[' . $table . '][' . $uid . '][delete]=1&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . t3lib_BEfunc::getUrlToken('tceAction') . "';}hideCM();top.nav.refresh.defer(500, top.nav);";
705
706 return $this->linkItem(
707 $this->label('delete'),
708 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete')),
709 $editOnClick.'return false;'
710 );
711 }
712
713 /**
714 * Adding CM element for View Page
715 *
716 * @param integer $id Page uid (PID)
717 * @param string $anchor Anchor, if any
718 * @return array Item array, element in $menuItems
719 * @internal
720 */
721 function DB_view($id, $anchor = '') {
722 return $this->linkItem(
723 $this->label('view'),
724 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-view')),
725 t3lib_BEfunc::viewOnClick($id, $this->PH_backPath, t3lib_BEfunc::BEgetRootLine($id), $anchor).'return hideCM();'
726 );
727 }
728
729 /**
730 * Adding element for setting temporary mount point.
731 *
732 * @param integer $page_id Page uid (PID)
733 * @return array Item array, element in $menuItems
734 * @internal
735 */
736 function DB_tempMountPoint($page_id) {
737 return $this->linkItem(
738 $this->label('tempMountPoint'),
739 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-mountpoint')),
740 'if (top.content.nav_frame) {
741 var node = top.TYPO3.Backend.NavigationContainer.PageTree.getSelected();
742 if (node === null) {
743 return false;
744 }
745
746 var useNode = {
747 attributes: {
748 nodeData: {
749 id: ' . intval($page_id) . '
750 }
751 }
752 };
753
754 node.ownerTree.commandProvider.mountAsTreeRoot(useNode, node.ownerTree);
755 }
756 return hideCM();
757 '
758 );
759 }
760
761 /**
762 * Adding CM element for hide/unhide of the input record
763 *
764 * @param string $table Table name
765 * @param array $rec Record array
766 * @param string $hideField Name of the hide field
767 * @return array Item array, element in $menuItems
768 * @internal
769 */
770 function DB_hideUnhide($table, $rec, $hideField) {
771 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?'un':'').'hide'), 'hide');
772 }
773
774 /**
775 * Adding CM element for a flag field of the input record
776 *
777 * @param string $table Table name
778 * @param array $rec Record array
779 * @param string $flagField Name of the flag field
780 * @param string $title Menu item Title
781 * @param string $name Name of the item used for icons and labels
782 * @param string $iconRelPath Icon path relative to typo3/ folder
783 * @return array Item array, element in $menuItems
784 */
785 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath = 'gfx/') {
786 $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
787 $editOnClick = '';
788 $loc = 'top.content.list_frame';
789 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='" .
790 '+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'" .
791 '&data[' . $table . '][' . $uid . '][' . $flagField . ']=' .
792 ($rec[$flagField] ? 0 : 1) . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . t3lib_BEfunc::getUrlToken('tceAction') . "';}hideCM();top.nav.refresh.defer(500, top.nav);";
793
794 return $this->linkItem(
795 $title,
796 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-' . ( $rec[$flagField] ? 'un' : '') . 'hide')),
797 $editOnClick.'return false;',
798 1
799 );
800 }
801
802 /***************************************
803 *
804 * FILE
805 *
806 ***************************************/
807
808 /**
809 * Make 1st level clickmenu:
810 *
811 * @param string $combinedIdentifier The combined identifier
812 * @return string HTML content
813 * @see t3lib_file_Factory::retrieveFileOrFolderObject()
814 */
815 function printFileClickMenu($combinedIdentifier) {
816 $menuItems=array();
817 $combinedIdentifier = rawurldecode($combinedIdentifier);
818
819 $fileObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
820
821 if ($fileObject) {
822 $folder = FALSE;
823 $identifier = $fileObject->getCombinedIdentifier();
824 if ($fileObject instanceof t3lib_file_Folder) {
825 $icon = t3lib_iconWorks::getSpriteIconForFile(
826 'folder',
827 array(
828 'class'=>'absmiddle',
829 'title' => htmlspecialchars($fileObject->getName())
830 )
831 );
832 $folder = TRUE;
833 } else {
834 $icon = t3lib_iconWorks::getSpriteIconForFile(
835 $fileObject->getExtension(),
836 array(
837 'class'=>'absmiddle',
838 'title' => htmlspecialchars(
839 $fileObject->getName() .
840 ' (' . t3lib_div::formatSize($fileObject->getSize()) . ')'
841 )
842 )
843 );
844 }
845 // Edit
846 if (!in_array('edit', $this->disabledItems) && !$folder
847 && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension())) {
848 $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit.php', 'edit', 'edit_file.gif');
849 }
850 // Rename
851 if (!in_array('rename', $this->disabledItems)) {
852 $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename.php', 'rename', 'rename.gif');
853 }
854 // Upload
855 if (!in_array('upload', $this->disabledItems) && $folder) {
856 $menuItems['upload'] = $this->FILE_upload($identifier);
857 }
858
859 // New
860 if (!in_array('new', $this->disabledItems) && $folder) {
861 $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder.php', 'new', 'new_file.gif');
862 }
863 // Info
864 if (!in_array('info', $this->disabledItems)) {
865 $menuItems['info'] = $this->DB_info($identifier, '');
866 }
867
868 $menuItems[] = 'spacer';
869
870 // Copy:
871 if (!in_array('copy', $this->disabledItems)) {
872 $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
873 }
874 // Cut:
875 if (!in_array('cut', $this->disabledItems)) {
876 $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
877 }
878
879 // Paste:
880 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
881 if (!in_array('paste', $this->disabledItems) && $elFromAllTables && $folder) {
882 $elArr = $this->clipObj->elFromTable('_FILE');
883 $selItem = reset($elArr);
884 $elInfo=array(
885 basename($selItem),
886 basename($path),
887 $this->clipObj->currentMode()
888 );
889 $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
890 }
891
892 $menuItems[]='spacer';
893
894 // Delete:
895 if (!in_array('delete', $this->disabledItems)) {
896 $menuItems['delete']=$this->FILE_delete($identifier);
897 }
898 }
899
900 // Adding external elements to the menuItems array
901 $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
902
903 // Processing by external functions?
904 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
905
906 // Return the printed elements:
907 return $this->printItems($menuItems, $icon . $fileObject->getName());
908 }
909
910 /**
911 * Processing the $menuItems array (for extension classes) (FILES)
912 *
913 * @param array $menuItems Array for manipulation.
914 * @return array Processed $menuItems array
915 */
916 function externalProcessingOfFileMenuItems($menuItems) {
917 return $menuItems;
918 }
919
920 /**
921 * Multi-function for adding an entry to the $menuItems array
922 *
923 * @param string $path Path to the file/directory (target)
924 * @param string $script Script (eg. file_edit.php) to pass &target= to
925 * @param string $type "type" is the code which fetches the correct label for the element from "cm."
926 * @param string $image icon image-filename from "gfx/" (12x12 icon)
927 * @param boolean $noReturnUrl If set, the return URL parameter will not be set in the link
928 * @return array Item array, element in $menuItems
929 * @internal
930 */
931 function FILE_launch($path, $script, $type, $image, $noReturnUrl = FALSE) {
932 $loc = 'top.content.list_frame';
933
934 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'".$script.'?target=' . rawurlencode($path) . ($noReturnUrl ? "'" : "&returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)') . ';}';
935 return $this->linkItem(
936 $this->label($type),
937 $this->excludeIcon('<img' . t3lib_iconWorks::skinImg($this->PH_backPath, 'gfx/' . $image, 'width="12" height="12"') . ' alt="" />'),
938 $editOnClick . 'top.nav.refresh();return hideCM();'
939 );
940 }
941
942 /**
943 * function for adding an upload entry to the $menuItems array
944 *
945 * @param string $path Path to the file/directory (target)
946 * @return array Item array, element in $menuItems
947 * @internal
948 */
949 function FILE_upload($path) {
950 $script = 'file_upload.php';
951 $type = 'upload';
952 $image = 'upload.gif';
953 if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) {
954 $loc = 'top.content.list_frame';
955
956 $editOnClick = 'if (top.TYPO3.FileUploadWindow.isFlashAvailable()) { initFlashUploader("' . rawurlencode($path) . '"); } else if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'".$script.'?target=' . rawurlencode($path) . "';}";
957
958 return $this->linkItem(
959 $this->label($type),
960 $this->excludeIcon('<img' . t3lib_iconWorks::skinImg($this->PH_backPath, 'gfx/' . $image, 'width="12" height="12"') . ' alt="" />'),
961 $editOnClick . 'return hideCM();'
962 );
963 } else {
964 return $this->FILE_launch($path, $script, $type, $image, TRUE);
965 }
966 }
967
968 /**
969 * Returns element for copy or cut of files.
970 *
971 * @param string $path Path to the file/directory (target)
972 * @param string $type Type: "copy" or "cut"
973 * @return array Item array, element in $menuItems
974 * @internal
975 */
976 function FILE_copycut($path, $type) {
977 // Pseudo table name for use in the clipboard.
978 $table = '_FILE';
979 $uid = t3lib_div::shortmd5($path);
980 if ($this->clipObj->current=='normal') {
981 $isSel = $this->clipObj->isSelected($table, $uid);
982 }
983
984 $addParam = array();
985 if ($this->listFrame) {
986 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
987 }
988
989 return $this->linkItem(
990 $this->label($type),
991 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-' . $type . ($isSel === $type ? '-release' : ''))),
992 "top.loadTopMenu('".$this->clipObj->selUrlFile($path, ($type=='copy'?1:0), ($isSel==$type), $addParam)."');return false;"
993 );
994 }
995
996 /**
997 * Creates element for deleting of target
998 *
999 * @param string $path Path to the file/directory (target)
1000 * @return array Item array, element in $menuItems
1001 * @internal
1002 */
1003 function FILE_delete($path) {
1004 $editOnClick = '';
1005 $loc = 'top.content.list_frame';
1006 if ($GLOBALS['BE_USER']->jsConfirmation(4)) {
1007 $conf = 'confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'), basename($path)).t3lib_BEfunc::referenceCount('_FILE', $path, ' (There are %s reference(s) to this file!)')) . ')';
1008 } else {
1009 $conf = '1==1';
1010 }
1011 $editOnClick = 'if(' . $loc . ' && ' . $conf . ' ){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'" .
1012 '&file[delete][0][data]=' . rawurlencode($path) . '&vC=' . $GLOBALS['BE_USER']->veriCode() . "';}hideCM();";
1013
1014 return $this->linkItem(
1015 $this->label('delete'),
1016 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete')),
1017 $editOnClick.'return false;'
1018 );
1019 }
1020
1021 /**
1022 * Creates element for pasting files.
1023 *
1024 * @param string $path Path to the file/directory (target)
1025 * @param string $target target - NOT USED.
1026 * @param array $elInfo Various values for the labels.
1027 * @return array Item array, element in $menuItems
1028 * @internal
1029 */
1030 function FILE_paste($path, $target, $elInfo) {
1031 $editOnClick = '';
1032 $loc = 'top.content.list_frame';
1033 if ($GLOBALS['BE_USER']->jsConfirmation(2)) {
1034 $conf = $loc . ' && confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.' . ($elInfo[2]=='copy'?'copy':'move') . '_into'), $elInfo[0], $elInfo[1])). ')';
1035 } else {
1036 $conf=$loc;
1037 }
1038
1039 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE', $path, 0).
1040 "&redirect='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search); }hideCM();top.nav.refresh();';
1041
1042 return $this->linkItem(
1043 $this->label('pasteinto'),
1044 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-paste-into')),
1045 $editOnClick.'return false;'
1046 );
1047 }
1048
1049 /***************************************
1050 *
1051 * DRAG AND DROP
1052 *
1053 ***************************************/
1054
1055 /**
1056 * Make 1st level clickmenu:
1057 *
1058 * @param string $table The absolute path
1059 * @param integer $srcId UID for the current record.
1060 * @param integer $dstId Destination ID
1061 * @return string HTML content
1062 */
1063 function printDragDropClickMenu($table, $srcId, $dstId) {
1064 $menuItems=array();
1065
1066 // If the drag and drop menu should apply to PAGES use this set of menu items
1067 if ($table == 'pages') {
1068 // Move Into:
1069 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId, $dstId, 'move', 'into');
1070 // Move After:
1071 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId, $dstId, 'move', 'after');
1072 // Copy Into:
1073 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'into');
1074 // Copy After:
1075 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'after');
1076 }
1077
1078 // If the drag and drop menu should apply to FOLDERS use this set of menu items
1079 if ($table == 'folders') {
1080 // Move Into:
1081 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId, $dstId, 'move');
1082 // Copy Into:
1083 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId, $dstId, 'copy');
1084 }
1085
1086 // Adding external elements to the menuItems array
1087 $menuItems = $this->processingByExtClassArray($menuItems, 'dragDrop_' .$table, $srcId); // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar
1088
1089 // Processing by external functions?
1090 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
1091
1092 // Return the printed elements:
1093 return $this->printItems($menuItems,
1094 t3lib_iconWorks::getSpriteIconForRecord($table, $this->rec, array('title'=> t3lib_BEfunc::getRecordTitle($table, $this->rec, TRUE)))
1095 );
1096 }
1097
1098 /**
1099 * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
1100 *
1101 * @param array $menuItems Array for manipulation.
1102 * @return array Processed $menuItems array
1103 */
1104 function externalProcessingOfDragDropMenuItems($menuItems) {
1105 return $menuItems;
1106 }
1107
1108 /**
1109 * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
1110 *
1111 * @param integer $srcUid source UID code for the record to modify
1112 * @param integer $dstUid destination UID code for the record to modify
1113 * @param string $action Action code: either "move" or "copy"
1114 * @param string $into Parameter code: either "into" or "after"
1115 * @return array Item array, element in $menuItems
1116 * @internal
1117 */
1118 function dragDrop_copymovepage($srcUid, $dstUid, $action, $into) {
1119 $negativeSign = ($into == 'into') ? '' : '-';
1120 $editOnClick = '';
1121 $loc = 'top.content.list_frame';
1122 $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)+"' .
1123 '&cmd[pages][' . $srcUid . '][' . $action . ']=' . $negativeSign . $dstUid . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . t3lib_BEfunc::getUrlToken('tceAction') . '";}hideCM();top.nav.refresh();';
1124
1125 return $this->linkItem(
1126 $this->label($action.'Page_'.$into),
1127 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-paste-' . $into)),
1128 $editOnClick.'return false;',
1129 0
1130 );
1131 }
1132
1133 /**
1134 * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
1135 *
1136 * @param string $srcPath source path for the record to modify
1137 * @param string $dstPath destination path for the records to modify
1138 * @param string $action Action code: either "move" or "copy"
1139 * @return array Item array, element in $menuItems
1140 * @internal
1141 */
1142 function dragDrop_copymovefolder($srcPath, $dstPath, $action) {
1143 $editOnClick = '';
1144 $loc = 'top.content.list_frame';
1145 $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)+"' .
1146 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";}hideCM();top.nav.refresh();';
1147
1148 return $this->linkItem(
1149 $this->label($action.'Folder_into'),
1150 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('apps-pagetree-drag-move-into')),
1151 $editOnClick.'return false;',
1152 0
1153 );
1154 }
1155
1156 /***************************************
1157 *
1158 * COMMON
1159 *
1160 **************************************/
1161
1162 /**
1163 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
1164 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns TRUE
1165 *
1166 * @param array $menuItems Array
1167 * @param string $item HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
1168 * @return string HTML code
1169 */
1170 function printItems($menuItems, $item) {
1171
1172 $out = '';
1173
1174 // Enable/Disable items:
1175 $menuItems = $this->enableDisableItems($menuItems);
1176
1177 // Clean up spacers:
1178 $menuItems = $this->cleanUpSpacers($menuItems);
1179
1180 // Adding topframe part (horizontal clickmenu)
1181 if ($this->doDisplayTopFrameCM()) {
1182 $out .= '
1183
1184 <!--
1185 Table, which contains the click menu when shown in the top frame of the backend:
1186 -->
1187 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
1188 <tr>
1189
1190 <!-- Items: -->
1191 <td class="c-item">' .
1192 implode('</td>
1193 <td><img' . t3lib_iconWorks::skinImg($this->PH_backPath, 'gfx/acm_spacer2.gif', 'width="8" height="12"') . ' alt="" /></td>
1194 <td class="c-item">', $this->menuItemsForTopFrame($menuItems)) .
1195 '</td>
1196
1197 <!-- Close button: -->
1198 <td class="c-closebutton"><a href="#" onclick="hideCM();return false;">' .
1199 t3lib_iconWorks::getSpriteIcon('actions-document-close', array(
1200 'title'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close', 1)
1201 )) . '</a></td>
1202
1203 <!-- The item of the clickmenu: -->
1204 <td class="c-itemicon">'.$item.'</td>
1205 </tr>
1206 </table>
1207 ';
1208
1209 // Set remaining BACK_PATH to blank (if any)
1210 $out = str_replace($this->PH_backPath, '', $out);
1211 }
1212 // Adding JS part:
1213 $out .=$this->printLayerJScode($menuItems);
1214
1215 // Return the content
1216 return $out;
1217 }
1218
1219 /**
1220 * Create the JavaScript section
1221 *
1222 * @param array $menuItems The $menuItems array to print
1223 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1224 */
1225 function printLayerJScode($menuItems) {
1226 $script = '';
1227 // Clipboard must not be submitted - then it's probably a copy/cut situation.
1228 if ($this->isCMlayers()) {
1229 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
1230 if ($this->alwaysContentFrame) {
1231 $frameName = '';
1232 }
1233
1234 // Create the table displayed in the clickmenu layer:
1235 $CMtable = '
1236 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM">
1237 '.implode('', $this->menuItemsForClickMenu($menuItems)).'
1238 </table>';
1239
1240 // Wrap the inner table in another table to create outer border:
1241 $CMtable = $this->wrapColorTableCM($CMtable);
1242
1243 // Set back path place holder to real back path
1244 $CMtable = str_replace($this->PH_backPath, $this->backPath, $CMtable);
1245 if ($this->ajax) {
1246 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
1247 return $innerXML;
1248 } else {
1249 // Create JavaScript section:
1250 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1251
1252 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.Clickmenu) {
1253 top.content'.$frameName.'.Clickmenu.populateData(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
1254 }
1255 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
1256 );
1257 return $script;
1258 }
1259 }
1260 }
1261
1262 /**
1263 * Wrapping the input string in a table with background color 4 and a black border style.
1264 * For the pop-up menu
1265 *
1266 * @param string $str HTML content to wrap in table.
1267 * @return string
1268 */
1269 function wrapColorTableCM($str) {
1270
1271 return '<div class="typo3-CSM-wrapperCM">
1272 ' . $str . '
1273 </div>';
1274 }
1275
1276 /**
1277 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1278 *
1279 * @param array $menuItems Array
1280 * @return array Array of menu items for top frame.
1281 */
1282 function menuItemsForTopFrame($menuItems) {
1283 $out = array();
1284 foreach ($menuItems as $i) {
1285 // IF the topbar is the ONLY means of the click menu, then items normally disabled from
1286 // the top menu will appear anyways IF they are disabled with a "1" (2+ will still disallow
1287 // them in the topbar)
1288 if ($i[4] == 1 && !$GLOBALS['SOBE']->doc->isCMlayers()) {
1289 $i[4] = 0;
1290 }
1291 if (is_array($i) && !$i[4]) {
1292 $out[] = $i[0];
1293 }
1294 }
1295 return $out;
1296 }
1297
1298 /**
1299 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1300 *
1301 * @param array $menuItems Array
1302 * @return array array for implosion in the CM div-layers table.
1303 */
1304 function menuItemsForClickMenu($menuItems) {
1305 $out = array();
1306 foreach ($menuItems as $cc => $i) {
1307 // MAKE horizontal spacer
1308 if (is_string($i) && $i=='spacer') {
1309 $out[] = '
1310 <tr class="bgColor2">
1311 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1312 </tr>';
1313 } else { // Just make normal element:
1314 $onClick = $i[3];
1315 $onClick = preg_replace('/return[[:space:]]+hideCM\(\)[[:space:]]*;/i', '', $onClick);
1316 $onClick = preg_replace('/return[[:space:]]+false[[:space:]]*;/i', '', $onClick);
1317 $onClick = preg_replace('/hideCM\(\);/i', '', $onClick);
1318 if (!$i[5]) {
1319 $onClick.='Clickmenu.hideAll();';
1320 }
1321
1322 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
1323
1324 $out[] = '
1325 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
1326 '.(!$this->leftIcons?'<td class="typo3-CSM-item">'.$i[1].'</td><td align="center">'.$i[2].'</td>' : '<td align="center">'.$i[2].'</td><td class="typo3-CSM-item">'.$i[1].'</td>').'
1327 </tr>';
1328 }
1329 }
1330 return $out;
1331 }
1332
1333 /**
1334 * Adds or inserts a menu item
1335 * Can be used to set the position of new menu entries within the list of existing menu entries. Has this syntax: [cmd]:[menu entry key],[cmd].... cmd can be "after", "before" or "top" (or blank/"bottom" which is default). If "after"/"before" then menu items will be inserted after/before the existing entry with [menu entry key] if found. "after-spacer" and "before-spacer" do the same, but inserts before or after an item and a spacer. If not found, the bottom of list. If "top" the items are inserted in the top of the list.
1336 *
1337 * @param array $menuItems Menu items array
1338 * @param array $newMenuItems Menu items array to insert
1339 * @param string $position Position command string. Has this syntax: [cmd]:[menu entry key],[cmd].... cmd can be "after", "before" or "top" (or blank/"bottom" which is default). If "after"/"before" then menu items will be inserted after/before the existing entry with [menu entry key] if found. "after-spacer" and "before-spacer" do the same, but inserts before or after an item and a spacer. If not found, the bottom of list. If "top" the items are inserted in the top of the list.
1340 * @return array Menu items array, processed.
1341 */
1342 function addMenuItems($menuItems, $newMenuItems, $position = '') {
1343 if (is_array($newMenuItems)) {
1344
1345 if ($position) {
1346
1347 $posArr = t3lib_div::trimExplode(',', $position, 1);
1348 foreach ($posArr as $pos) {
1349 list($place, $menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
1350 list($place, $placeExtra) = t3lib_div::trimExplode('-', $place, 1);
1351
1352 // Bottom
1353 $pointer = count($menuItems);
1354
1355 $found = FALSE;
1356
1357 if ($place) {
1358 switch(strtolower($place)) {
1359 case 'after':
1360 case 'before':
1361 if ($menuEntry) {
1362 $p=1;
1363 reset ($menuItems);
1364 while (TRUE) {
1365 if (!strcmp(key($menuItems), $menuEntry)) {
1366 $pointer = $p;
1367 $found = TRUE;
1368 break;
1369 }
1370 if (!next($menuItems)) {
1371 break;
1372 }
1373 $p++;
1374 }
1375 if (!$found) {
1376 break;
1377 }
1378
1379 if ($place == 'before') {
1380 $pointer--;
1381 if ($placeExtra == 'spacer' AND prev($menuItems) == 'spacer') {
1382 $pointer--;
1383 }
1384 } elseif ($place == 'after') {
1385 if ($placeExtra == 'spacer' AND next($menuItems) == 'spacer') {
1386 $pointer++;
1387 }
1388 }
1389 }
1390 break;
1391 default:
1392 if (strtolower($place) == 'top') {
1393 $pointer = 0;
1394 } else {
1395 $pointer = count($menuItems);
1396 }
1397 $found = TRUE;
1398 break;
1399 }
1400 }
1401 if ($found) {
1402 break;
1403 }
1404 }
1405 }
1406 $pointer = max(0, $pointer);
1407 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?$pointer:0));
1408 $menuItemsAfter = array_slice($menuItems, $pointer);
1409 $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
1410 }
1411 return $menuItems;
1412 }
1413
1414 /**
1415 * Creating an array with various elements for the clickmenu entry
1416 *
1417 * @param string $str The label, htmlspecialchar'ed already
1418 * @param string $icon <img>-tag for the icon
1419 * @param string $onClick JavaScript onclick event for label/icon
1420 * @param boolean $onlyCM ==1 and the element will NOT appear in clickmenus in the topframe (unless clickmenu is totally unavailable)! ==2 and the item will NEVER appear in top frame. (This is mostly for "less important" options since the top frame is not capable of holding so many elements horizontally)
1421 * @param boolean $dontHide If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1422 * @return array $menuItem entry with 6 numerical entries: [0] is the HTML for display of the element with link and icon an mouseover etc., [1]-[5] is simply the input params passed through!
1423 */
1424 function linkItem($str, $icon, $onClick, $onlyCM = 0, $dontHide = 0) {
1425 $this->elCount++;
1426 if ($this->ajax) {
1427 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1428 }
1429
1430 return array(
1431 t3lib_iconWorks::getSpriteIcon('empty-empty', array(
1432 'class' => 'c-roimg',
1433 'id'=> 'roimg_' . $this->elCount
1434 )) .
1435 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
1436 $str.$icon.
1437 '</a>',
1438 $str,
1439 $icon,
1440 $onClick,
1441 $onlyCM,
1442 $dontHide
1443 );
1444 }
1445
1446 /**
1447 * Returns the input string IF not a user setting has disabled display of icons.
1448 *
1449 * @param string $iconCode The icon-image tag
1450 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1451 */
1452 function excludeIcon($iconCode) {
1453 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'], 'icons')) ? '' : ' '.$iconCode;
1454 }
1455
1456 /**
1457 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1458 *
1459 * @param array $menuItems Menu items array
1460 * @return array Menu items array, processed.
1461 */
1462 function enableDisableItems($menuItems) {
1463 if ($this->iParts[3]) {
1464
1465 // Detect "only" mode: (only showing listed items)
1466 if (substr($this->iParts[3], 0, 1)=='+') {
1467 $this->iParts[3] = substr($this->iParts[3], 1);
1468 $only = TRUE;
1469 } else {
1470 $only = FALSE;
1471 }
1472
1473 // Do filtering:
1474 // Transfer ONLY elements which are mentioned (or are spacers)
1475 if ($only) {
1476 $newMenuArray = array();
1477 foreach ($menuItems as $key => $value) {
1478 if (t3lib_div::inList($this->iParts[3], $key) || (is_string($value) && $value=='spacer')) {
1479 $newMenuArray[$key] = $value;
1480 }
1481 }
1482 $menuItems = $newMenuArray;
1483 } else { // Traverse all elements except those listed (just unsetting them):
1484 $elements = t3lib_div::trimExplode(',', $this->iParts[3], 1);
1485 foreach ($elements as $value) {
1486 unset($menuItems[$value]);
1487 }
1488 }
1489 }
1490
1491 // Return processed menu items:
1492 return $menuItems;
1493 }
1494
1495 /**
1496 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1497 *
1498 * @param array $menuItems Menu items array
1499 * @return array Menu items array, processed.
1500 */
1501 function cleanUpSpacers($menuItems) {
1502
1503 // Remove doubles:
1504 $prevItemWasSpacer = FALSE;
1505 foreach ($menuItems as $key => $value) {
1506 if (is_string($value) && $value == 'spacer') {
1507 if ($prevItemWasSpacer) {
1508 unset($menuItems[$key]);
1509 }
1510 $prevItemWasSpacer = TRUE;
1511 } else {
1512 $prevItemWasSpacer = FALSE;
1513 }
1514 }
1515
1516 // Remove first:
1517 reset($menuItems);
1518 $key = key($menuItems);
1519 $value = current($menuItems);
1520 if (is_string($value) && $value == 'spacer') {
1521 unset($menuItems[$key]);
1522 }
1523
1524 // Remove last:
1525 end($menuItems);
1526 $key = key($menuItems);
1527 $value = current($menuItems);
1528 if (is_string($value) && $value == 'spacer') {
1529 unset($menuItems[$key]);
1530 }
1531
1532 // Return processed menu items:
1533 return $menuItems;
1534 }
1535
1536 /**
1537 * Get label from locallang_core.php:cm.*
1538 *
1539 * @param string $label The "cm."-suffix to get.
1540 * @return string
1541 */
1542 function label($label) {
1543 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label, 1));
1544 }
1545
1546 /**
1547 * Returns TRUE if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1548 *
1549 * @return boolean
1550 */
1551 function isCMlayers() {
1552 if ($this->ajax) {
1553 return !$this->CB;
1554 } else {
1555 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
1556 }
1557 }
1558
1559 /**
1560 * Appends ".location" to input string
1561 *
1562 * @param string $str Input string, probably a JavaScript document reference
1563 * @return string
1564 */
1565 function frameLocation($str) {
1566 return $str.'.location';
1567 }
1568 }
1569
1570 /**
1571 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1572 *
1573 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
1574 * @package TYPO3
1575 * @subpackage core
1576 * @see template::getContextMenuCode()
1577 */
1578 class SC_alt_clickmenu {
1579
1580 // Internal, static: GPvar:
1581 // Back path.
1582 var $backPath;
1583 // Definition of which item the click menu should be made for.
1584 var $item;
1585 // Defines the name of the document object for which to reload the URL.
1586 var $reloadListFrame;
1587
1588 // Internal:
1589 // Content accumulation
1590 var $content = '';
1591 // Template object
1592 var $doc;
1593 // Files to include_once() - set in init() function
1594 var $include_once = array();
1595 // Internal array of classes for extending the clickmenu
1596 var $extClassArray = array();
1597 // If set, then the clickmenu will NOT display in the top frame.
1598 var $dontDisplayTopFrameCM = 0;
1599
1600 /**
1601 * Constructor function for script class.
1602 *
1603 * @return void
1604 */
1605 function init() {
1606
1607 // Setting GPvars:
1608 $this->backPath = t3lib_div::_GP('backPath');
1609 $this->item = t3lib_div::_GP('item');
1610 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame');
1611
1612 // Setting pseudo module name
1613 $this->MCONF['name']='xMOD_alt_clickmenu.php';
1614
1615 // 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:
1616 $inputBP = explode('|', $this->backPath);
1617 if (count($inputBP) == 2 && $inputBP[1] == t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1618 $this->backPath = $inputBP[0];
1619 } else {
1620 $this->backPath = $GLOBALS['BACK_PATH'];
1621 }
1622
1623 // Setting internal array of classes for extending the clickmenu:
1624 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1625
1626 // Traversing that array and setting files for inclusion:
1627 if (is_array($this->extClassArray)) {
1628 foreach ($this->extClassArray as $extClassConf) {
1629 if ($extClassConf['path']) {
1630 $this->include_once[]=$extClassConf['path'];
1631 }
1632 }
1633 }
1634
1635 // Initialize template object
1636 if (!$this->ajax) {
1637 $this->doc = t3lib_div::makeInstance('template');
1638 $this->doc->backPath = $GLOBALS['BACK_PATH'];
1639 }
1640
1641 // Setting mode for display and background image in the top frame
1642 $this->dontDisplayTopFrameCM = $this->doc->isCMlayers() && !$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1643 if ($this->dontDisplayTopFrameCM) {
1644 $this->doc->bodyTagId.= '-notop';
1645 }
1646
1647 // Setting clickmenu timeout
1648 $secs = t3lib_utility_Math::forceIntegerInRange($GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'), 1, 100, 5); // default is 5
1649
1650 // Setting the JavaScript controlling the timer on the page
1651 $listFrameDoc = $this->reloadListFrame!=2 ? 'top.content.list_frame' : 'top.content';
1652 $this->doc->JScode.=$this->doc->wrapScriptTags('
1653 var date = new Date();
1654 var mo_timeout = Math.floor(date.getTime()/1000);
1655
1656 roImg = "' . t3lib_iconWorks::getSpriteIconClasses('status-status-current') . '";
1657
1658 routImg = "t3-icon-empty";
1659
1660 function mo(c) { //
1661 var name="roimg_"+c;
1662 document.getElementById(name).className = roImg;
1663 updateTime();
1664 }
1665 function mout(c) { //
1666 var name="roimg_"+c;
1667 document[name].src = routImg;
1668 updateTime();
1669 }
1670 function updateTime() { //
1671 date = new Date();
1672 mo_timeout = Math.floor(date.getTime()/1000);
1673 }
1674 function timeout_func() { //
1675 date = new Date();
1676 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1677 hideCM();
1678 return false;
1679 } else {
1680 window.setTimeout("timeout_func();",1*1000);
1681 }
1682 }
1683 function hideCM() { //
1684 window.location.href="alt_topmenu_dummy.php";
1685 return false;
1686 }
1687
1688 // Start timer
1689 timeout_func();
1690
1691 '.($this->reloadListFrame ? '
1692 // Reload list frame:
1693 if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' :
1694 '').'
1695 ');
1696 }
1697
1698 /**
1699 * Main function - generating the click menu in whatever form it has.
1700 *
1701 * @return void
1702 */
1703 function main() {
1704 $this->ajax = t3lib_div::_GP('ajax') ? TRUE : FALSE;
1705
1706 // Initialize Clipboard object:
1707 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
1708 $clipObj->initializeClipboard();
1709 // This locks the clipboard to the Normal for this request.
1710 $clipObj->lockToNormal();
1711
1712 // Update clipboard if some actions are sent.
1713 $CB = t3lib_div::_GET('CB');
1714 $clipObj->setCmd($CB);
1715 $clipObj->cleanCurrent();
1716 // Saves
1717 $clipObj->endClipboard();
1718
1719 // Create clickmenu object
1720 $clickMenu = t3lib_div::makeInstance('clickMenu');
1721
1722 // Set internal vars in clickmenu object:
1723 $clickMenu->clipObj = $clipObj;
1724 $clickMenu->extClassArray = $this->extClassArray;
1725 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
1726 $clickMenu->backPath = $this->backPath;
1727
1728 // Start page
1729 if (!$this->ajax) {
1730 $this->content.= $this->doc->startPage('Context Sensitive Menu');
1731 }
1732 // Set content of the clickmenu with the incoming var, "item"
1733 $this->content.= $clickMenu->init();
1734 }
1735
1736 /**
1737 * End page and output content.
1738 *
1739 * @return void
1740 */
1741 function printContent() {
1742 if (!$this->ajax) {
1743 $this->content.= $this->doc->endPage();
1744 $this->content = $this->doc->insertStylesAndJS($this->content);
1745 echo $this->content;
1746 } else {
1747 t3lib_ajax::outputXMLreply($this->content);
1748 }
1749 }
1750 }
1751
1752 // Make instance:
1753 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
1754 $SOBE->init();
1755
1756 // Include files?
1757 foreach ($SOBE->include_once as $INC_FILE) {
1758 include_once($INC_FILE);
1759 }
1760
1761 $SOBE->main();
1762 $SOBE->printContent();
1763
1764 ?>