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