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