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