Fixed bug 5269: wsol_preview.php does not scroll to content element
[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');
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 * @return array Item array, element in $menuItems
904 * @internal
905 */
906 function FILE_launch($path,$script,$type,$image) {
907 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
908
909 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
910
911 return $this->linkItem(
912 $this->label($type),
913 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
914 $editOnClick.'return hideCM();'
915 );
916 }
917
918 /**
919 * Returns element for copy or cut of files.
920 *
921 * @param string Path to the file/directory (target)
922 * @param string Type: "copy" or "cut"
923 * @return array Item array, element in $menuItems
924 * @internal
925 */
926 function FILE_copycut($path,$type) {
927 $table = '_FILE'; // Pseudo table name for use in the clipboard.
928 $uid = t3lib_div::shortmd5($path);
929 if ($this->clipObj->current=='normal') {
930 $isSel = $this->clipObj->isSelected($table,$uid);
931 }
932
933 $addParam = array();
934 if ($this->listFrame) {
935 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
936 }
937
938 return $this->linkItem(
939 $this->label($type),
940 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
941 "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
942 );
943 }
944
945 /**
946 * Creates element for deleting of target
947 *
948 * @param string Path to the file/directory (target)
949 * @return array Item array, element in $menuItems
950 * @internal
951 */
952 function FILE_delete($path) {
953 $editOnClick='';
954 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
955 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
956 $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!)')).")";
957 } else {
958 $conf = '1==1';
959 }
960 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
961 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
962
963 return $this->linkItem(
964 $this->label('delete'),
965 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
966 $editOnClick.'return false;'
967 );
968 }
969
970 /**
971 * Creates element for pasting files.
972 *
973 * @param string Path to the file/directory (target)
974 * @param string target - NOT USED.
975 * @param array Various values for the labels.
976 * @return array Item array, element in $menuItems
977 * @internal
978 */
979 function FILE_paste($path,$target,$elInfo) {
980 $editOnClick='';
981 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
982 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
983 $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])).")";
984 } else {
985 $conf=$loc;
986 }
987
988 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
989 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
990
991 return $this->linkItem(
992 $this->label('pasteinto'),
993 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
994 $editOnClick.'return false;'
995 );
996 }
997
998
999
1000
1001
1002 /***************************************
1003 *
1004 * DRAG AND DROP
1005 *
1006 ***************************************/
1007
1008 /**
1009 * Make 1st level clickmenu:
1010 *
1011 * @param string The absolute path
1012 * @param integer UID for the current record.
1013 * @param integer Destination ID
1014 * @return string HTML content
1015 */
1016 function printDragDropClickMenu($table,$srcId,$dstId) {
1017 $menuItems=array();
1018
1019 // If the drag and drop menu should apply to PAGES use this set of menu items
1020 if ($table == 'pages') {
1021 // Move Into:
1022 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into');
1023 // Move After:
1024 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after');
1025 // Copy Into:
1026 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into');
1027 // Copy After:
1028 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after');
1029 }
1030
1031 // If the drag and drop menu should apply to FOLDERS use this set of menu items
1032 if ($table == 'folders') {
1033 // Move Into:
1034 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move');
1035 // Copy Into:
1036 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy');
1037 }
1038
1039 // Adding external elements to the menuItems array
1040 $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
1041
1042 // Processing by external functions?
1043 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
1044
1045 // Return the printed elements:
1046 return $this->printItems($menuItems,
1047 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)
1048 );
1049 }
1050
1051
1052 /**
1053 * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
1054 *
1055 * @param array $menuItems array for manipulation.
1056 * @return array Processed $menuItems array
1057 */
1058 function externalProcessingOfDragDropMenuItems($menuItems) {
1059 return $menuItems;
1060 }
1061
1062
1063 /**
1064 * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
1065 *
1066 * @param integer source UID code for the record to modify
1067 * @param integer destination UID code for the record to modify
1068 * @param string Action code: either "move" or "copy"
1069 * @param string Parameter code: either "into" or "after"
1070 * @return array Item array, element in $menuItems
1071 * @internal
1072 */
1073 function dragDrop_copymovepage($srcUid,$dstUid,$action,$into) {
1074 $negativeSign = ($into == 'into') ? '' : '-';
1075 $editOnClick='';
1076 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
1077 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
1078 '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
1079
1080 return $this->linkItem(
1081 $this->label($action.'Page_'.$into),
1082 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
1083 $editOnClick.'return false;',
1084 0
1085 );
1086 }
1087
1088
1089 /**
1090 * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
1091 *
1092 * @param string source path for the record to modify
1093 * @param string destination path for the records to modify
1094 * @param string Action code: either "move" or "copy"
1095 * @return array Item array, element in $menuItems
1096 * @internal
1097 */
1098 function dragDrop_copymovefolder($srcPath,$dstPath,$action) {
1099 $editOnClick='';
1100 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
1101 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
1102 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
1103
1104 return $this->linkItem(
1105 $this->label($action.'Folder_into'),
1106 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
1107 $editOnClick.'return false;',
1108 0
1109 );
1110 }
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120 /***************************************
1121 *
1122 * COMMON
1123 *
1124 **************************************/
1125
1126 /**
1127 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
1128 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
1129 *
1130 * @param array $menuItems array
1131 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
1132 * @return string HTML code
1133 */
1134 function printItems($menuItems,$item) {
1135
1136 $out='';
1137
1138 // Enable/Disable items:
1139 $menuItems = $this->enableDisableItems($menuItems);
1140
1141 // Clean up spacers:
1142 $menuItems = $this->cleanUpSpacers($menuItems);
1143
1144 // Adding topframe part (horizontal clickmenu)
1145 if ($this->doDisplayTopFrameCM()) {
1146 $out.= '
1147
1148 <!--
1149 Table, which contains the click menu when shown in the top frame of the backend:
1150 -->
1151 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
1152 <tr>
1153
1154 <!-- Items: -->
1155 <td class="c-item">'.
1156 implode('</td>
1157 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
1158 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
1159 '</td>
1160
1161 <!-- Close button: -->
1162 <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>
1163
1164 <!-- The item of the clickmenu: -->
1165 <td class="c-itemicon">'.$item.'</td>
1166 </tr>
1167 </table>
1168 ';
1169
1170 // Set remaining BACK_PATH to blank (if any)
1171 $out = str_replace($this->PH_backPath,'',$out);
1172 }
1173 // Adding JS part:
1174 $out.=$this->printLayerJScode($menuItems);
1175
1176 // Return the content
1177 return $out;
1178 }
1179
1180 /**
1181 * Create the JavaScript section
1182 *
1183 * @param array The $menuItems array to print
1184 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1185 */
1186 function printLayerJScode($menuItems) {
1187 $script='';
1188 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
1189 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
1190 if ($this->alwaysContentFrame) $frameName='';
1191
1192 // Create the table displayed in the clickmenu layer:
1193 $CMtable = '
1194 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
1195 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
1196 </table>';
1197
1198 // Wrap the inner table in another table to create outer border:
1199 $CMtable = $this->wrapColorTableCM($CMtable);
1200
1201 // Set back path place holder to real back path
1202 $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
1203 if ($this->ajax) {
1204 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
1205 return $innerXML;
1206 } else {
1207 // Create JavaScript section:
1208 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1209
1210 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
1211 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
1212 }
1213 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
1214 );
1215 return $script;
1216 }
1217 }
1218 }
1219
1220 /**
1221 * Wrapping the input string in a table with background color 4 and a black border style.
1222 * For the pop-up menu
1223 *
1224 * @param string HTML content to wrap in table.
1225 * @return string
1226 */
1227 function wrapColorTableCM($str) {
1228
1229 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1230 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1231 <tr class="c-rowA">
1232 <td class="c-aa">'.$str.'</td>
1233 <td class="c-ab"></td>
1234 </tr>
1235 <tr class="c-rowB">
1236 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1237 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1238 </tr>
1239 </table>';
1240 return $str;
1241 }
1242
1243 /**
1244 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1245 *
1246 * @param array $menuItem array
1247 * @param array Array with HTML content to be imploded between <td>-tags
1248 * @return array Array of menu items for top frame.
1249 */
1250 function menuItemsForTopFrame($menuItems) {
1251 reset($menuItems);
1252 $out=array();
1253 while(list(,$i)=each($menuItems)) {
1254 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)
1255 if (is_array($i) && !$i[4]) $out[]=$i[0];
1256 }
1257 return $out;
1258 }
1259
1260 /**
1261 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1262 *
1263 * @param array $menuItem array
1264 * @param array Array with HTML content to be imploded between <td>-tags
1265 * @return array array for implosion in the CM div-layers table.
1266 */
1267 function menuItemsForClickMenu($menuItems) {
1268 reset($menuItems);
1269 $out=array();
1270 while(list($cc,$i)=each($menuItems)) {
1271 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1272 $out[]='
1273 <tr class="bgColor2">
1274 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1275 </tr>';
1276 } else { // Just make normal element:
1277 $onClick=$i[3];
1278 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1279 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1280 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1281 if (!$i[5]) $onClick.='hideEmpty();';
1282
1283 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
1284 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
1285 }
1286
1287 $out[]='
1288 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
1289 '.(!$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>').'
1290 </tr>';
1291 }
1292 }
1293 return $out;
1294 }
1295
1296 /**
1297 * Adds or inserts a menu item
1298 * 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.
1299 *
1300 * @param array Menu items array
1301 * @param array Menu items array to insert
1302 * @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.
1303 * @return array Menu items array, processed.
1304 */
1305 function addMenuItems($menuItems,$newMenuItems,$position='') {
1306 if (is_array($newMenuItems)) {
1307
1308 if($position) {
1309
1310 $posArr = t3lib_div::trimExplode(',', $position, 1);
1311 foreach($posArr as $pos) {
1312 list($place,$menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
1313 list($place,$placeExtra) = t3lib_div::trimExplode('-', $place, 1);
1314
1315 // bottom
1316 $pointer = count($menuItems);
1317
1318 $found=FALSE;
1319
1320 if ($place) {
1321 switch(strtolower($place)) {
1322 case 'after':
1323 case 'before':
1324 if ($menuEntry) {
1325 $p=1;
1326 reset ($menuItems);
1327 while (true) {
1328 if (!strcmp(key($menuItems), $menuEntry)) {
1329 $pointer = $p;
1330 $found=TRUE;
1331 break;
1332 }
1333 if (!next($menuItems)) break;
1334 $p++;
1335 }
1336 if (!$found) break;
1337
1338 if ($place=='before') {
1339 $pointer--;
1340 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
1341 $pointer--;
1342 }
1343 } elseif ($place=='after') {
1344 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
1345 $pointer++;
1346 }
1347 }
1348 }
1349 break;
1350 default:
1351 if (strtolower($place)=='top') {
1352 $pointer = 0;
1353 } else {
1354 $pointer = count($menuItems);
1355 }
1356 $found=TRUE;
1357 break;
1358 }
1359 }
1360 if($found) break;
1361 }
1362 }
1363 $pointer=max(0,$pointer);
1364 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?$pointer:0));
1365 $menuItemsAfter = array_slice($menuItems, $pointer);
1366 $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
1367 }
1368 return $menuItems;
1369 }
1370
1371 /**
1372 * Creating an array with various elements for the clickmenu entry
1373 *
1374 * @param string The label, htmlspecialchar'ed already
1375 * @param string <img>-tag for the icon
1376 * @param string JavaScript onclick event for label/icon
1377 * @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)
1378 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1379 * @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!
1380 */
1381 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1382 global $BACK_PATH;
1383
1384 $this->elCount++;
1385 if($this->ajax) {
1386 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1387 }
1388
1389 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1390
1391 return array(
1392 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
1393 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
1394 $str.$icon.
1395 '</a>',
1396 $str,
1397 $icon,
1398 $onClick,
1399 $onlyCM,
1400 $dontHide
1401 );
1402 }
1403
1404 /**
1405 * Returns the input string IF not a user setting has disabled display of icons.
1406 *
1407 * @param string The icon-image tag
1408 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1409 */
1410 function excludeIcon($iconCode) {
1411 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
1412 }
1413
1414 /**
1415 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1416 *
1417 * @param array Menu items array
1418 * @return array Menu items array, processed.
1419 */
1420 function enableDisableItems($menuItems) {
1421 if ($this->iParts[3]) {
1422
1423 // Detect "only" mode: (only showing listed items)
1424 if (substr($this->iParts[3],0,1)=='+') {
1425 $this->iParts[3] = substr($this->iParts[3],1);
1426 $only = TRUE;
1427 } else {
1428 $only = FALSE;
1429 }
1430
1431 // Do filtering:
1432 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1433 $newMenuArray = array();
1434 foreach($menuItems as $key => $value) {
1435 if (t3lib_div::inList($this->iParts[3], $key) || (is_string($value) && $value=='spacer')) {
1436 $newMenuArray[$key] = $value;
1437 }
1438 }
1439 $menuItems = $newMenuArray;
1440 } else { // Traverse all elements except those listed (just unsetting them):
1441 $elements = t3lib_div::trimExplode(',',$this->iParts[3],1);
1442 foreach($elements as $value) {
1443 unset($menuItems[$value]);
1444 }
1445 }
1446 }
1447
1448 // Return processed menu items:
1449 return $menuItems;
1450 }
1451
1452 /**
1453 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1454 *
1455 * @param array Menu items array
1456 * @return array Menu items array, processed.
1457 */
1458 function cleanUpSpacers($menuItems) {
1459
1460 // Remove doubles:
1461 $prevItemWasSpacer = FALSE;
1462 foreach($menuItems as $key => $value) {
1463 if (is_string($value) && $value=='spacer') {
1464 if ($prevItemWasSpacer) {
1465 unset($menuItems[$key]);
1466 }
1467 $prevItemWasSpacer = TRUE;
1468 } else {
1469 $prevItemWasSpacer = FALSE;
1470 }
1471 }
1472
1473 // Remove first:
1474 reset($menuItems);
1475 $key = key($menuItems);
1476 $value = current($menuItems);
1477 if (is_string($value) && $value=='spacer') {
1478 unset($menuItems[$key]);
1479 }
1480
1481
1482 // Remove last:
1483 end($menuItems);
1484 $key = key($menuItems);
1485 $value = current($menuItems);
1486 if (is_string($value) && $value=='spacer') {
1487 unset($menuItems[$key]);
1488 }
1489
1490 // Return processed menu items:
1491 return $menuItems;
1492 }
1493
1494 /**
1495 * Get label from locallang_core.php:cm.*
1496 *
1497 * @param string The "cm."-suffix to get.
1498 * @return string
1499 */
1500 function label($label) {
1501 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1502 }
1503
1504 /**
1505 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1506 *
1507 * @return boolean
1508 */
1509 function isCMlayers() {
1510 if($this->ajax) {
1511 return !$this->CB;
1512 } else {
1513 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
1514 }
1515 }
1516
1517 /**
1518 * Appends ".location" to input string
1519 *
1520 * @param string Input string, probably a JavaScript document reference
1521 * @return string
1522 */
1523 function frameLocation($str) {
1524 return $str.'.location';
1525 }
1526 }
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540 /**
1541 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1542 *
1543 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1544 * @package TYPO3
1545 * @subpackage core
1546 * @see template::getContextMenuCode()
1547 */
1548 class SC_alt_clickmenu {
1549
1550 // Internal, static: GPvar:
1551 var $backPath; // Back path.
1552 var $item; // Definition of which item the click menu should be made for.
1553 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1554
1555 // Internal:
1556 var $content=''; // Content accumulation
1557 var $doc; // Template object
1558 var $include_once=array(); // Files to include_once() - set in init() function
1559 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1560 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1561
1562 /**
1563 * Constructor function for script class.
1564 *
1565 * @return void
1566 */
1567 function init() {
1568 global $BE_USER,$BACK_PATH;
1569
1570 // Setting GPvars:
1571 $this->backPath = t3lib_div::_GP('backPath');
1572 $this->item = t3lib_div::_GP('item');
1573 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame');
1574
1575 // Setting pseudo module name
1576 $this->MCONF['name']='xMOD_alt_clickmenu.php';
1577
1578 // 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:
1579 $inputBP = explode('|',$this->backPath);
1580 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1581 $this->backPath = $inputBP[0];
1582 } else {
1583 $this->backPath = $BACK_PATH;
1584 }
1585
1586 // Setting internal array of classes for extending the clickmenu:
1587 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1588
1589 // Traversing that array and setting files for inclusion:
1590 if (is_array($this->extClassArray)) {
1591 foreach($this->extClassArray as $extClassConf) {
1592 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1593 }
1594 }
1595
1596 // Initialize template object
1597 if (!$this->ajax) {
1598 $this->doc = t3lib_div::makeInstance('template');
1599 $this->doc->docType='xhtml_trans';
1600 $this->doc->backPath = $BACK_PATH;
1601 }
1602
1603 // Setting mode for display and background image in the top frame
1604 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1605 if ($this->dontDisplayTopFrameCM) {
1606 $this->doc->bodyTagId.= '-notop';
1607 }
1608
1609 // Setting clickmenu timeout
1610 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1611
1612 // Setting the JavaScript controlling the timer on the page
1613 $listFrameDoc = $this->reloadListFrame!=2 ? 'top.content.list_frame' : 'top.content';
1614 $this->doc->JScode.=$this->doc->wrapScriptTags('
1615 var date = new Date();
1616 var mo_timeout = Math.floor(date.getTime()/1000);
1617
1618 roImg =new Image();
1619 roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1620
1621 routImg =new Image();
1622 routImg.src = "clear.gif";
1623
1624 function mo(c) { //
1625 var name="roimg_"+c;
1626 document[name].src = roImg.src;
1627 updateTime();
1628 }
1629 function mout(c) { //
1630 var name="roimg_"+c;
1631 document[name].src = routImg.src;
1632 updateTime();
1633 }
1634 function updateTime() { //
1635 date = new Date();
1636 mo_timeout = Math.floor(date.getTime()/1000);
1637 }
1638 function timeout_func() { //
1639 date = new Date();
1640 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1641 hideCM();
1642 return false;
1643 } else {
1644 window.setTimeout("timeout_func();",1*1000);
1645 }
1646 }
1647 function hideCM() { //
1648 window.location.href="alt_topmenu_dummy.php";
1649 return false;
1650 }
1651
1652 // Start timer
1653 timeout_func();
1654
1655 '.($this->reloadListFrame ? '
1656 // Reload list frame:
1657 if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' :
1658 '').'
1659 ');
1660 }
1661
1662 /**
1663 * Main function - generating the click menu in whatever form it has.
1664 *
1665 * @return void
1666 */
1667 function main() {
1668 $this->ajax = t3lib_div::_GP('ajax') ? TRUE : FALSE;
1669
1670 // Initialize Clipboard object:
1671 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
1672 $clipObj->initializeClipboard();
1673 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1674
1675 // Update clipboard if some actions are sent.
1676 $CB = t3lib_div::_GET('CB');
1677 $clipObj->setCmd($CB);
1678 $clipObj->cleanCurrent();
1679 $clipObj->endClipboard(); // Saves
1680
1681 // Create clickmenu object
1682 $clickMenu = t3lib_div::makeInstance('clickMenu');
1683
1684 // Set internal vars in clickmenu object:
1685 $clickMenu->clipObj = $clipObj;
1686 $clickMenu->extClassArray = $this->extClassArray;
1687 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
1688 $clickMenu->backPath = $this->backPath;
1689
1690 // Start page
1691 if(!$this->ajax) {
1692 $this->content.= $this->doc->startPage('Context Sensitive Menu');
1693 }
1694 // Set content of the clickmenu with the incoming var, "item"
1695 $this->content.= $clickMenu->init();
1696 }
1697
1698 /**
1699 * End page and output content.
1700 *
1701 * @return void
1702 */
1703 function printContent() {
1704 if (!$this->ajax) {
1705 $this->content.= $this->doc->endPage();
1706 $this->content = $this->doc->insertStylesAndJS($this->content);
1707 echo $this->content;
1708 } else {
1709 $this->content = $GLOBALS['LANG']->csConvObj->utf8_encode($this->content,$GLOBALS['LANG']->charSet);
1710 t3lib_ajax::outputXMLreply($this->content);
1711 }
1712 }
1713 }
1714
1715 // Include extension?
1716 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) {
1717 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
1718 }
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729 // Make instance:
1730 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
1731 $SOBE->init();
1732
1733 // Include files?
1734 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1735
1736 $SOBE->main();
1737 $SOBE->printContent();
1738 ?>