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