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