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