Added TSconfig option (options.overridePageModule) for replacing the default Page...
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
43 */
44 /**
45 * [CLASS/FUNCTION INDEX of SCRIPT]
46 *
47 *
48 *
49 * 123: class clickMenu
50 * 154: function init($item)
51 * 194: function doDisplayTopFrameCM()
52 *
53 * SECTION: DATABASE
54 * 222: function printDBClickMenu($table,$uid)
55 * 309: function printNewDBLevel($table,$uid)
56 * 346: function externalProcessingOfDBMenuItems($menuItems)
57 * 358: function processingByExtClassArray($menuItems,$table,$uid)
58 * 377: function urlRefForCM($url,$retUrl='',$hideCM=1)
59 * 394: function DB_copycut($table,$uid,$type)
60 * 417: function DB_paste($table,$uid,$type,$elInfo)
61 * 438: function DB_info($table,$uid)
62 * 454: function DB_history($table,$uid)
63 * 473: function DB_perms($table,$uid,$rec)
64 * 492: function DB_db_list($table,$uid,$rec)
65 * 511: function DB_moveWizard($table,$uid,$rec)
66 * 532: function DB_newWizard($table,$uid,$rec)
67 * 550: function DB_editAccess($table,$uid)
68 * 568: function DB_editPageHeader($uid)
69 * 586: function DB_edit($table,$uid)
70 * 625: function DB_new($table,$uid)
71 * 650: function DB_hideUnhide($table,$rec,$hideField)
72 * 674: function DB_delete($table,$uid,$elInfo)
73 * 695: function DB_view($id,$anchor='')
74 *
75 * SECTION: FILE
76 * 724: function printFileClickMenu($path)
77 * 788: function externalProcessingOfFileMenuItems($menuItems)
78 * 802: function FILE_launch($path,$script,$type,$image)
79 * 821: function FILE_copycut($path,$type)
80 * 841: function FILE_delete($path)
81 * 863: function FILE_paste($path,$target,$elInfo)
82 *
83 * SECTION: COMMON
84 * 903: function printItems($menuItems,$item)
85 * 945: function printLayerJScode($menuItems)
86 * 980: function wrapColorTableCM($str)
87 * 995: function menuItemsForTopFrame($menuItems)
88 * 1012: function menuItemsForClickMenu($menuItems)
89 * 1047: function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)
90 * 1071: function excludeIcon($iconCode)
91 * 1081: function label($label)
92 * 1090: function isCMlayers()
93 * 1100: function frameLocation($str)
94 *
95 *
96 * 1125: class SC_alt_clickmenu
97 * 1143: function init()
98 * 1226: function main()
99 * 1266: function printContent()
100 *
101 * TOTAL FUNCTIONS: 41
102 * (This index is automatically created/updated by the extension "extdeveval")
103 *
104 */
105
106
107 require ('init.php');
108 require ('template.php');
109 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
110 $LANG->includeLLFile('EXT:lang/locallang_misc.php');
111
112
113
114
115 /**
116 * Class for generating the click menu
117 *
118 * @author Kasper Skaarhoj <kasper@typo3.com>
119 * @package TYPO3
120 * @subpackage core
121 * @internal
122 */
123 class clickMenu {
124
125 // Internal, static: GPvar:
126 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
127 var $CB; // Clipboard array (submitted by eg. pressing the paste button)
128
129 // Internal, static:
130 var $backPath=''; // Backpath for scripts/images.
131 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset.
132 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)
133 var $alwaysContentFrame=0; // If true, the "content" frame is always used for reference (when condensed mode is enabled)
134 var $iParts=array(); // Stores the parts of the input $item string, splitted by "|"
135 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu
136 var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer.
137 var $leftIcons=0; // If true, Show icons on the left.
138 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.
139
140 // Internal, dynamic:
141 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
142 var $editPageIconSet=0; // Set, when edit icon is drawn.
143 var $editOK=0; // Set to true, if editing of the element is OK.
144 var $rec=array();
145
146
147
148 /**
149 * Initialize click menu
150 *
151 * @param string Input "item" GET var.
152 * @return string The clickmenu HTML content
153 */
154 function init($item) {
155
156 // Setting GPvars:
157 $this->cmLevel = intval(t3lib_div::GPvar('cmLevel'));
158 $this->CB = t3lib_div::GPvar('CB');
159
160
161 // Explode the incoming command:
162 $this->iParts = explode('|',$item);
163
164 // Setting flags:
165 if ($this->iParts[2]) $this->listFrame=1;
166 if ($GLOBALS['BE_USER']->uc['condensedMode']) $this->alwaysContentFrame=1;
167 if (strcmp($this->iParts[1],'')) $this->isDBmenu=1;
168
169 $TSkey =($this->isDBmenu?'page':'folder').($this->listFrame?'List':'Tree');
170 $this->disabledItems = t3lib_div::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
171 $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
172
173 // &cmLevel flag detected (2nd level menu)
174 if (!$this->cmLevel) {
175 // Make 1st level clickmenu:
176 if ($this->isDBmenu) {
177 return $this->printDBClickMenu($this->iParts[0],$this->iParts[1]);
178 } else {
179 return $this->printFileClickMenu($this->iParts[0]);
180 }
181 } else {
182 // Make 2nd level clickmenu (only for DBmenus)
183 if ($this->isDBmenu) {
184 return $this->printNewDBLevel($this->iParts[0],$this->iParts[1]);
185 }
186 }
187 }
188
189 /**
190 * Returns true if the menu should (also?) be displayed in topframe, not just <div>-layers
191 *
192 * @return boolean
193 */
194 function doDisplayTopFrameCM() {
195 return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209 /***************************************
210 *
211 * DATABASE
212 *
213 ***************************************/
214
215 /**
216 * Make 1st level clickmenu:
217 *
218 * @param string Table name
219 * @param integer UID for the current record.
220 * @return string HTML content
221 */
222 function printDBClickMenu($table,$uid) {
223 global $TCA, $BE_USER;
224
225 // Get record:
226 $this->rec = t3lib_BEfunc::getRecord($table,$uid);
227 $menuItems=array();
228 $root=0;
229 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
230 $root=1;
231 }
232
233 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
234 if (is_array($this->rec) || $root) {
235 // Get permissions
236 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
237
238 // View
239 if (!in_array('view',$this->disabledItems)) {
240 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
241 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec['pid'],'#'.$uid);
242 }
243
244 // Edit:
245 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
246 if (!in_array('edit',$this->disabledItems)) $menuItems['edit']=$this->DB_edit($table,$uid);
247 $this->editOK=1;
248 }
249
250 // New:
251 if (!in_array('new',$this->disabledItems) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
252
253 // Info:
254 if(!in_array('info',$this->disabledItems) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
255
256 $menuItems[]='spacer';
257
258 // Copy:
259 if(!in_array('copy',$this->disabledItems) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
260 // Cut:
261 if(!in_array('cut',$this->disabledItems) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
262
263 // Paste:
264 $elFromAllTables = count($this->clipObj->elFromTable(''));
265 if (!in_array('paste',$this->disabledItems) && $elFromAllTables) {
266 $selItem = $this->clipObj->getSelectedRecord();
267 $elInfo=array(
268 $selItem['_RECORD_TITLE'],
269 ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$GLOBALS['BE_USER']->uc['titleLen'])),
270 $this->clipObj->currentMode()
271 );
272 if ($table=='pages' && ($lCP & 8)) {
273 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
274 }
275
276 $elFromTable = count($this->clipObj->elFromTable($table));
277 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
278 }
279
280 // Delete:
281 $elInfo=array(t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$GLOBALS['BE_USER']->uc['titleLen']));
282 if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
283 $menuItems[]='spacer';
284 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
285 }
286 }
287
288 // Adding external elements to the menuItems array
289 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
290
291 // Processing by external functions?
292 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
293
294 // Return the printed elements:
295 return $this->printItems($menuItems,
296 $root?
297 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
298 t3lib_iconWorks::getIconImage($table,$this->rec,$this->backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
299 );
300 }
301
302 /**
303 * Make 2nd level clickmenu (only for DBmenus)
304 *
305 * @param string Table name
306 * @param integer UID for the current record.
307 * @return string HTML content
308 */
309 function printNewDBLevel($table,$uid) {
310 global $TCA, $BE_USER;
311
312 // Setting internal record to the table/uid :
313 $this->rec = t3lib_BEfunc::getRecord($table,$uid);
314 $menuItems=array();
315 $root=0;
316 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
317 $root=1;
318 }
319
320 // If record was found, check permissions and get menu items.
321 if (is_array($this->rec) || $root) {
322 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
323 // Edit:
324 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
325 $this->editOK=1;
326 }
327
328 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
329 }
330
331 // Return the printed elements:
332 if (!is_array($menuItems)) $menuItems=array();
333 return $this->printItems($menuItems,
334 $root?
335 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
336 t3lib_iconWorks::getIconImage($table,$this->rec,$this->backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
337 );
338 }
339
340 /**
341 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
342 *
343 * @param array $menuItems array for manipulation.
344 * @return array Processed $menuItems array
345 */
346 function externalProcessingOfDBMenuItems($menuItems) {
347 return $menuItems;
348 }
349
350 /**
351 * Processing the $menuItems array by external classes (typ. adding items)
352 *
353 * @param array $menuItems array for manipulation.
354 * @param string Table name
355 * @param integer UID for the current record.
356 * @return array Processed $menuItems array
357 */
358 function processingByExtClassArray($menuItems,$table,$uid) {
359 if (is_array($this->extClassArray)) {
360 reset($this->extClassArray);
361 while(list(,$conf)=each($this->extClassArray)) {
362 $obj=t3lib_div::makeInstance($conf['name']);
363 $menuItems = $obj->main($this,$menuItems,$table,$uid);
364 }
365 }
366 return $menuItems;
367 }
368
369 /**
370 * Returning JavaScript for the onClick event linking to the input URL.
371 *
372 * @param string The URL relative to TYPO3_mainDir
373 * @param string The return_url-parameter
374 * @param boolean If set, the "hideCM()" will be called
375 * @return string JavaScript for an onClick event.
376 */
377 function urlRefForCM($url,$retUrl='',$hideCM=1) {
378 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
379 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.document.location=top.TS.PATH_typo3+\''.$url.'\''.
380 ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
381 ($hideCM?'return hideCM();':'');
382 return $editOnClick;
383 }
384
385 /**
386 * Adding CM element for Clipboard "copy" and "cut"
387 *
388 * @param string Table name
389 * @param integer UID for the current record.
390 * @param string Type: "copy" or "cut"
391 * @return array Item array, element in $menuItems
392 * @internal
393 */
394 function DB_copycut($table,$uid,$type) {
395 if ($this->clipObj->current=='normal') {
396 $isSel = $this->clipObj->isSelected($table,$uid);
397 }
398 return $this->linkItem(
399 $this->label($type),
400 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
401 "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type))."');return false;"
402 );
403 }
404
405 /**
406 * Adding CM element for Clipboard "paste into"/"paste after"
407 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
408 *
409 * @param string Table name
410 * @param integer UID for the current record. NOTICE: Special syntax!
411 * @param string Type: "into" or "after"
412 * @param array Contains instructions about whether to copy or cut an element.
413 * @return array Item array, element in $menuItems
414 * @see t3lib_clipboard::pasteUrl()
415 * @internal
416 */
417 function DB_paste($table,$uid,$type,$elInfo) {
418 $editOnClick='';
419 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
420 $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])).')';
421 $editOnClick='if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
422
423 return $this->linkItem(
424 $this->label('paste'.$type),
425 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
426 $editOnClick.'return false;'
427 );
428 }
429
430 /**
431 * Adding CM element for Info
432 *
433 * @param string Table name
434 * @param integer UID for the current record.
435 * @return array Item array, element in $menuItems
436 * @internal
437 */
438 function DB_info($table,$uid) {
439 return $this->linkItem(
440 $this->label('info'),
441 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
442 "top.launchView('".$table."', '".$uid."'); return hideCM();"
443 );
444 }
445
446 /**
447 * Adding CM element for History
448 *
449 * @param string Table name
450 * @param integer UID for the current record.
451 * @return array Item array, element in $menuItems
452 * @internal
453 */
454 function DB_history($table,$uid) {
455 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
456 return $this->linkItem(
457 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
458 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
459 $this->urlRefForCM($url,'returnUrl'),
460 0
461 );
462 }
463
464 /**
465 * Adding CM element for Permission setting
466 *
467 * @param string Table name
468 * @param integer UID for the current record.
469 * @param array The "pages" record with "perms_*" fields inside.
470 * @return array Item array, element in $menuItems
471 * @internal
472 */
473 function DB_perms($table,$uid,$rec) {
474 $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':'');
475 return $this->linkItem(
476 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
477 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
478 $this->urlRefForCM($url),
479 0
480 );
481 }
482
483 /**
484 * Adding CM element for DBlist
485 *
486 * @param string Table name
487 * @param integer UID for the current record.
488 * @param array Record of the element (needs "pid" field if not pages-record)
489 * @return array Item array, element in $menuItems
490 * @internal
491 */
492 function DB_db_list($table,$uid,$rec) {
493 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
494 return $this->linkItem(
495 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
496 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
497 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
498 0
499 );
500 }
501
502 /**
503 * Adding CM element for Moving wizard
504 *
505 * @param string Table name
506 * @param integer UID for the current record.
507 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
508 * @return array Item array, element in $menuItems
509 * @internal
510 */
511 function DB_moveWizard($table,$uid,$rec) {
512 $url = 'move_el.php?table='.$table.'&uid='.$uid.
513 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
514
515 return $this->linkItem(
516 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
517 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
518 $this->urlRefForCM($url,'returnUrl'),
519 0
520 );
521 }
522
523 /**
524 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php)
525 *
526 * @param string Table name
527 * @param integer UID for the current record.
528 * @param array Record.
529 * @return array Item array, element in $menuItems
530 * @internal
531 */
532 function DB_newWizard($table,$uid,$rec) {
533 $url = ($table=='pages' || !t3lib_extMgm::isLoaded('cms')) ? 'db_new.php?id='.$uid.'&pagesOnly=1' : 'sysext/cms/layout/db_new_content_el.php?id='.$rec['pid'].'&sys_language_uid='.intval($rec['sys_language_uid']);
534 return $this->linkItem(
535 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
536 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
537 $this->urlRefForCM($url,'returnUrl'),
538 0
539 );
540 }
541
542 /**
543 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
544 *
545 * @param string Table name
546 * @param integer UID for the current record.
547 * @return array Item array, element in $menuItems
548 * @internal
549 */
550 function DB_editAccess($table,$uid) {
551 $addParam='&columnsOnly='.implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
552 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
553 return $this->linkItem(
554 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
555 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
556 $this->urlRefForCM($url,'returnUrl'),
557 1 // no top frame CM!
558 );
559 }
560
561 /**
562 * Adding CM element for edit page header
563 *
564 * @param integer page uid to edit (PID)
565 * @return array Item array, element in $menuItems
566 * @internal
567 */
568 function DB_editPageHeader($uid) {
569 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
570 return $this->linkItem(
571 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
572 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
573 $this->urlRefForCM($url,'returnUrl'),
574 1 // no top frame CM!
575 );
576 }
577
578 /**
579 * Adding CM element for regular editing of the element!
580 *
581 * @param string Table name
582 * @param integer UID for the current record.
583 * @return array Item array, element in $menuItems
584 * @internal
585 */
586 function DB_edit($table,$uid) {
587 global $BE_USER;
588 // If another module was specified, replace the default Page module with the new one
589 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
590 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
591
592 $editOnClick='';
593 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
594 $addParam='';
595 $theIcon = t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"');
596 if (
597 $this->iParts[0]=='pages' &&
598 $this->iParts[1] &&
599 $GLOBALS['BE_USER']->check('modules', $pageModule)
600 ) {
601 $theIcon = t3lib_iconWorks::skinImg($this->backPath,'gfx/edit_page.gif','width="12" height="12"');
602 $this->editPageIconSet=1;
603 if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
604 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
605 } else {
606 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
607 }
608 }
609 if (!$editOnClick) {
610 $editOnClick="if(".$loc."){".$loc.".document.location=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
611 }
612
613 return $this->linkItem(
614 $this->label('edit'),
615 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
616 $editOnClick.'return hideCM();'
617 );
618 }
619
620 /**
621 * Adding CM element for regular Create new element
622 *
623 * @param string Table name
624 * @param integer UID for the current record.
625 * @return array Item array, element in $menuItems
626 * @internal
627 */
628 function DB_new($table,$uid) {
629 $editOnClick='';
630 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
631 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
632 ($this->listFrame?
633 $this->backPath."alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
634 $this->backPath.'db_new.php?id='.intval($uid)."'").
635 ';}';
636
637 return $this->linkItem(
638 $this->label('new'),
639 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'&&$this->listFrame?'page':'el').'.gif','width="'.($table=='pages'?'13':'11').'" height="12"').' alt="" />'),
640 $editOnClick.'return hideCM();'
641 );
642 }
643
644 /**
645 * Adding CM element for hide/unhide of the input record
646 *
647 * @param string Table name
648 * @param array Record array
649 * @param string Name of the hide field
650 * @return array Item array, element in $menuItems
651 * @internal
652 */
653 function DB_hideUnhide($table,$rec,$hideField) {
654 $uid=$rec['uid'];
655 $editOnClick='';
656 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
657 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
658 "&data[".$table.']['.$uid.']['.$hideField.']='.($rec[$hideField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
659
660 return $this->linkItem(
661 $this->label(($rec[$hideField]?'un':'').'hide'),
662 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_'.($rec[$hideField]?'un':'').'hide.gif','width="11" height="10"').' alt="" />'),
663 $editOnClick.'return false;',
664 1
665 );
666 }
667
668 /**
669 * Adding CM element for Delete
670 *
671 * @param string Table name
672 * @param integer UID for the current record.
673 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
674 * @return array Item array, element in $menuItems
675 * @internal
676 */
677 function DB_delete($table,$uid,$elInfo) {
678 $editOnClick='';
679 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
680 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0])).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
681 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
682
683 return $this->linkItem(
684 $this->label('delete'),
685 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
686 $editOnClick.'return false;'
687 );
688 }
689
690 /**
691 * Adding CM element for View Page
692 *
693 * @param integer Page uid (PID)
694 * @param string Anchor, if any
695 * @return array Item array, element in $menuItems
696 * @internal
697 */
698 function DB_view($id,$anchor='') {
699 return $this->linkItem(
700 $this->label('view'),
701 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
702 t3lib_BEfunc::viewOnClick($id,$this->backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
703 );
704 }
705
706
707
708
709
710
711
712
713
714
715 /***************************************
716 *
717 * FILE
718 *
719 ***************************************/
720
721 /**
722 * Make 1st level clickmenu:
723 *
724 * @param string The absolute path
725 * @return string HTML content
726 */
727 function printFileClickMenu($path) {
728 $menuItems=array();
729
730 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path)) {
731 $fI = pathinfo($path);
732 $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
733 $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
734 $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
735
736 // edit
737 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');
738 // rename
739 if (!in_array('rename',$this->disabledItems)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
740 // upload
741 if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
742 // new
743 if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
744 // info
745 if (!in_array('info',$this->disabledItems)) $menuItems['info']=$this->DB_info($path,'');
746
747 $menuItems[]='spacer';
748
749 // copy:
750 if (!in_array('copy',$this->disabledItems)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
751 // cut:
752 if (!in_array('cut',$this->disabledItems)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
753
754 // Paste:
755 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
756 if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path)) {
757 $elArr = $this->clipObj->elFromTable('_FILE');
758 reset($elArr);
759 $selItem = current($elArr);
760 $elInfo=array(
761 basename($selItem),
762 basename($path),
763 $this->clipObj->currentMode()
764 );
765 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
766 }
767
768 $menuItems[]='spacer';
769
770 // delete:
771 if (!in_array('delete',$this->disabledItems)) $menuItems['delete']=$this->FILE_delete($path);
772 }
773
774 // Adding external elements to the menuItems array
775 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
776
777 // Processing by external functions?
778 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
779
780 // Return the printed elements:
781 return $this->printItems($menuItems,$icon.basename($path));
782 }
783
784
785 /**
786 * Processing the $menuItems array (for extension classes) (FILES)
787 *
788 * @param array $menuItems array for manipulation.
789 * @return array Processed $menuItems array
790 */
791 function externalProcessingOfFileMenuItems($menuItems) {
792 return $menuItems;
793 }
794
795 /**
796 * Multi-function for adding an entry to the $menuItems array
797 *
798 * @param string Path to the file/directory (target)
799 * @param string Script (eg. file_edit.php) to pass &target= to
800 * @param string "type" is the code which fetches the correct label for the element from "cm."
801 * @param string icon image-filename from "gfx/" (12x12 icon)
802 * @return array Item array, element in $menuItems
803 * @internal
804 */
805 function FILE_launch($path,$script,$type,$image) {
806 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
807 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."';}";
808
809 return $this->linkItem(
810 $this->label($type),
811 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
812 $editOnClick.'return hideCM();'
813 );
814 }
815
816 /**
817 * Returns element for copy or cut of files.
818 *
819 * @param string Path to the file/directory (target)
820 * @param string Type: "copy" or "cut"
821 * @return array Item array, element in $menuItems
822 * @internal
823 */
824 function FILE_copycut($path,$type) {
825 $table='_FILE'; // Pseudo table name for use in the clipboard.
826 $uid = t3lib_div::shortmd5($path);
827 if ($this->clipObj->current=='normal') {
828 $isSel = $this->clipObj->isSelected($table,$uid);
829 }
830 return $this->linkItem(
831 $this->label($type),
832 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
833 "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type))."');return false;"
834 );
835 }
836
837 /**
838 * Creates element for deleting of target
839 *
840 * @param string Path to the file/directory (target)
841 * @return array Item array, element in $menuItems
842 * @internal
843 */
844 function FILE_delete($path) {
845 $editOnClick='';
846 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
847 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path))).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
848 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
849
850 return $this->linkItem(
851 $this->label('delete'),
852 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
853 $editOnClick.'return false;'
854 );
855 }
856
857 /**
858 * Creates element for pasting files.
859 *
860 * @param string Path to the file/directory (target)
861 * @param string target - NOT USED.
862 * @param array Various values for the labels.
863 * @return array Item array, element in $menuItems
864 * @internal
865 */
866 function FILE_paste($path,$target,$elInfo) {
867 $editOnClick='';
868 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
869 $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])).")";
870 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
871 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
872
873 return $this->linkItem(
874 $this->label('pasteinto'),
875 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
876 $editOnClick.'return false;'
877 );
878 }
879
880
881
882
883
884
885
886
887
888
889
890
891
892 /***************************************
893 *
894 * COMMON
895 *
896 **************************************/
897
898 /**
899 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
900 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
901 *
902 * @param array $menuItems array
903 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
904 * @return string HTML code
905 */
906 function printItems($menuItems,$item) {
907 $out='';
908
909 // Adding topframe part (horizontal clickmenu)
910 if ($this->doDisplayTopFrameCM()) {
911 $out.= '
912
913 <!--
914 Table, which contains the click menu when shown in the top frame of the backend:
915 -->
916 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
917 <tr>
918
919 <!-- Items: -->
920 <td class="c-item">'.
921 implode('</td>
922 <td><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
923 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
924 '</td>
925
926 <!-- Close button: -->
927 <td class="c-closebutton"><a href="#" onclick="hideCM();return false;"><img'.t3lib_iconWorks::skinImg($this->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>
928
929 <!-- The item of the clickmenu: -->
930 <td class="c-itemicon">'.$item.'</td>
931 </tr>
932 </table>
933 ';
934 }
935 // Adding JS part:
936 $out.=$this->printLayerJScode($menuItems);
937
938 // Return the content
939 return $out;
940 }
941
942 /**
943 * Create the JavaScript section
944 *
945 * @param array The $menuItems array to print
946 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
947 */
948 function printLayerJScode($menuItems) {
949 $script='';
950 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
951 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
952 if ($this->alwaysContentFrame) $frameName='';
953
954 // Create the table displayed in the clickmenu layer:
955 $CMtable = '
956 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
957 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
958 </table>';
959
960 // Wrap the inner table in another table to create outer border:
961 $CMtable = $this->wrapColorTableCM($CMtable);
962
963 // Create JavaScript section:
964 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
965
966 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
967 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
968 }
969 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
970 );
971 }
972
973 return $script;
974 }
975
976 /**
977 * Wrapping the input string in a table with background color 4 and a black border style.
978 * For the pop-up menu
979 *
980 * @param string HTML content to wrap in table.
981 * @return string
982 */
983 function wrapColorTableCM($str) {
984 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
985 <tr><td class="c-aa">'.$str.'</td><td class="c-ab"></td></tr>
986 <tr><td class="c-ba"></td><td class="c-bb"></td></tr>
987 </table>';
988 return $str;
989 }
990
991 /**
992 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
993 *
994 * @param array $menuItem array
995 * @param array Array with HTML content to be imploded between <td>-tags
996 * @return array Array of menu items for top frame.
997 */
998 function menuItemsForTopFrame($menuItems) {
999 reset($menuItems);
1000 $out=array();
1001 while(list(,$i)=each($menuItems)) {
1002 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)
1003 if (is_array($i) && !$i[4]) $out[]=$i[0];
1004 }
1005 return $out;
1006 }
1007
1008 /**
1009 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1010 *
1011 * @param array $menuItem array
1012 * @param array Array with HTML content to be imploded between <td>-tags
1013 * @return array array for implosion in the CM div-layers table.
1014 */
1015 function menuItemsForClickMenu($menuItems) {
1016 reset($menuItems);
1017 $out=array();
1018 while(list($cc,$i)=each($menuItems)) {
1019 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1020 $out[]='
1021 <tr class="bgColor2">
1022 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1023 </tr>';
1024 } else { // Just make normal element:
1025 $onClick=$i[3];
1026 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1027 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1028 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1029 if (!$i[5]) $onClick.='hideEmpty();';
1030
1031 $out[]='
1032 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';">
1033 '.(!$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>').'
1034 </tr>';
1035 }
1036 }
1037 return $out;
1038 }
1039
1040 /**
1041 * Creating an array with various elements for the clickmenu entry
1042 *
1043 * @param string The label, htmlspecialchar'ed already
1044 * @param string <img>-tag for the icon
1045 * @param string JavaScript onclick event for label/icon
1046 * @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)
1047 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1048 * @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!
1049 */
1050 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1051 $this->elCount++;
1052
1053 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1054
1055 return array(
1056 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
1057 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
1058 $str.$icon.
1059 '</a>',
1060 $str,
1061 $icon,
1062 $onClick,
1063 $onlyCM,
1064 $dontHide
1065 );
1066 }
1067
1068 /**
1069 * Returns the input string IF not a user setting has disabled display of icons.
1070 *
1071 * @param string The icon-image tag
1072 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1073 */
1074 function excludeIcon($iconCode) {
1075 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
1076 }
1077
1078 /**
1079 * Get label from locallang_core.php:cm.*
1080 *
1081 * @param string The "cm."-suffix to get.
1082 * @return string
1083 */
1084 function label($label) {
1085 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1086 }
1087
1088 /**
1089 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1090 *
1091 * @return boolean
1092 */
1093 function isCMlayers() {
1094 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
1095 }
1096
1097 /**
1098 * Appends ".location" to input string
1099 *
1100 * @param string Input string, probably a JavaScript document reference
1101 * @return string
1102 */
1103 function frameLocation($str) {
1104 return $str.'.location';
1105 }
1106 }
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120 /**
1121 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1122 *
1123 * @author Kasper Skaarhoj <kasper@typo3.com>
1124 * @package TYPO3
1125 * @subpackage core
1126 * @see template::getContextMenuCode()
1127 */
1128 class SC_alt_clickmenu {
1129
1130 // Internal, static: GPvar:
1131 var $backPath; // Back path.
1132 var $item; // Definition of which item the click menu should be made for.
1133
1134 // Internal:
1135 var $content=''; // Content accumulation
1136 var $doc; // Template object
1137 var $include_once=array(); // Files to include_once() - set in init() function
1138 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1139 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1140
1141 /**
1142 * Constructor function for script class.
1143 *
1144 * @return void
1145 */
1146 function init() {
1147 global $BE_USER,$BACK_PATH;
1148
1149 // Setting GPvars:
1150 $this->backPath = t3lib_div::GPvar('backPath');
1151 $this->item = t3lib_div::GPvar('item');
1152
1153 // Setting pseudo module name
1154 $this->MCONF['name']='xMOD_alt_clickmenu.php';
1155
1156 // 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:
1157 $inputBP = explode('|',$this->backPath);
1158 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1159 $this->backPath = $inputBP[0];
1160 } else {
1161 $this->backPath = $BACK_PATH;
1162 }
1163
1164 // Setting internal array of classes for extending the clickmenu:
1165 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1166
1167 // Traversing that array and setting files for inclusion:
1168 if (is_array($this->extClassArray)) {
1169 foreach($this->extClassArray as $extClassConf) {
1170 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1171 }
1172 }
1173
1174 // Initialize template object
1175 $this->doc = t3lib_div::makeInstance('template');
1176 $this->doc->docType='xhtml_trans';
1177 $this->doc->backPath = $BACK_PATH;
1178
1179 // Setting mode for display and background image in the top frame
1180 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1181 if ($this->dontDisplayTopFrameCM) {
1182 $this->doc->bodyTagId.= '-notop';
1183 }
1184
1185 // Setting clickmenu timeout
1186 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1187
1188 // Setting the JavaScript controlling the timer on the page
1189 $this->doc->JScode.=$this->doc->wrapScriptTags('
1190 var date = new Date();
1191 var mo_timeout = Math.floor(date.getTime()/1000);
1192
1193 roImg =new Image();
1194 roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1195
1196 routImg =new Image();
1197 routImg.src = "clear.gif";
1198
1199 function mo(c) { //
1200 var name="roimg_"+c;
1201 document[name].src = roImg.src;
1202 updateTime();
1203 }
1204 function mout(c) { //
1205 var name="roimg_"+c;
1206 document[name].src = routImg.src;
1207 updateTime();
1208 }
1209 function updateTime() { //
1210 date = new Date();
1211 mo_timeout = Math.floor(date.getTime()/1000);
1212 }
1213 function timeout_func() { //
1214 date = new Date();
1215 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1216 hideCM();
1217 return false;
1218 } else {
1219 window.setTimeout("timeout_func();",1*1000);
1220 }
1221 }
1222 function hideCM() { //
1223 document.location="alt_topmenu_dummy.php";
1224 return false;
1225 }
1226
1227 // Start timer
1228 timeout_func();
1229 ');
1230 }
1231
1232 /**
1233 * Main function - generating the click menu in whatever form it has.
1234 *
1235 * @return void
1236 */
1237 function main() {
1238 global $HTTP_GET_VARS;
1239
1240 // Initialize Clipboard object:
1241 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
1242 $clipObj->initializeClipboard();
1243 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1244
1245 // Update clipboard if some actions are sent.
1246 $CB = $HTTP_GET_VARS['CB'];
1247 $clipObj->setCmd($CB);
1248 $clipObj->cleanCurrent();
1249 $clipObj->endClipboard(); // Saves
1250
1251 // Create clickmenu object
1252 $clickMenu = t3lib_div::makeInstance('clickMenu');
1253
1254 // Set internal vars in clickmenu object:
1255 $clickMenu->clipObj = $clipObj;
1256 $clickMenu->extClassArray = $this->extClassArray;
1257 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
1258 $clickMenu->backPath = $this->backPath;
1259
1260 // 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:
1261 $inputBP = explode('|',$this->backPath);
1262 if (count($inputBP)==2 && $inputBP[1]==md5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1263 $clickMenu->backPath = $inputBP[0];
1264 }
1265
1266 // Start page
1267 $this->content.=$this->doc->startPage('Context Sensitive Menu');
1268
1269 // Set content of the clickmenu with the incoming var, "item"
1270 $this->content.= $clickMenu->init($this->item);
1271 }
1272
1273 /**
1274 * End page and output content.
1275 *
1276 * @return void
1277 */
1278 function printContent() {
1279 $this->content.= $this->doc->endPage();
1280 echo $this->content;
1281 }
1282 }
1283
1284 // Include extension?
1285 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) {
1286 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
1287 }
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298 // Make instance:
1299 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
1300 $SOBE->init();
1301
1302 // Include files?
1303 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1304
1305 $SOBE->main();
1306 $SOBE->printContent();
1307 ?>