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