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