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