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