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