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