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