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