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