2 /***************************************************************
5 * (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
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.
36 * If you want to integrate a context menu in your scripts, please see template::getContextMenuCode()
39 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
42 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
45 * [CLASS/FUNCTION INDEX of SCRIPT]
49 * 136: class clickMenu
50 * 168: function init()
51 * 222: function doDisplayTopFrameCM()
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/')
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)
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)
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)
108 * 1544: class SC_alt_clickmenu
109 * 1563: function init()
110 * 1663: function main()
111 * 1699: function printContent()
113 * TOTAL FUNCTIONS: 51
114 * (This index is automatically created/updated by the extension "extdeveval")
119 require ('init.php');
120 require ('template.php');
121 require_once (PATH_t3lib
.'class.t3lib_clipboard.php');
122 require_once(PATH_t3lib
.'class.t3lib_ajax.php');
123 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
129 * Class for generating the click menu
131 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
138 // Internal, static: GPvar:
139 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
140 var $CB; // Clipboard array (submitted by eg. pressing the paste button)
143 var $backPath=''; // Backpath for scripts/images.
144 var $PH_backPath='###BACK_PATH###'; // BackPath place holder: We need different backPath set whether the clickmenu is written back to a frame which is not in typo3/ dir or if the clickmenu is shown in the top frame (no backpath)
145 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset.
146 var $isDBmenu=0; // If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
147 var $alwaysContentFrame=0; // If true, the "content" frame is always used for reference (when condensed mode is enabled)
148 var $iParts=array(); // Stores the parts of the input $item string, splitted by "|": [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame, If "2" then "content frame" is forced [3] = ("+" prefix = disable all by default, enable these. Default is to disable) Items key list
149 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu
150 var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer.
151 var $leftIcons=0; // If true, Show icons on the left.
152 var $extClassArray=array(); // Array of classes to be used for user processing of the menu content. This is for the API of adding items to the menu from outside.
153 var $ajax=0; // enable/disable ajax behavior
155 // Internal, dynamic:
156 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
157 var $editPageIconSet=0; // Set, when edit icon is drawn.
158 var $editOK=0; // Set to true, if editing of the element is OK.
164 * Initialize click menu
166 * @return string The clickmenu HTML content
170 $this->cmLevel
= intval(t3lib_div
::_GP('cmLevel'));
171 $this->CB
= t3lib_div
::_GP('CB');
172 if(t3lib_div
::_GP('ajax')) {
174 ini_set('display_errors',0); // XML has to be parsed, no parse errors allowed
177 // Deal with Drag&Drop context menus
178 if (strcmp(t3lib_div
::_GP('dragDrop'),'')) {
179 $CMcontent = $this->printDragDropClickMenu(t3lib_div
::_GP('dragDrop'),t3lib_div
::_GP('srcId'),t3lib_div
::_GP('dstId'));
183 // can be set differently as well
184 $this->iParts
[0] = t3lib_div
::_GP('table');
185 $this->iParts
[1] = t3lib_div
::_GP('uid');
186 $this->iParts
[2] = t3lib_div
::_GP('listFr');
187 $this->iParts
[3] = t3lib_div
::_GP('enDisItems');
190 if ($this->iParts
[2]) $this->listFrame
=1;
191 if ($GLOBALS['BE_USER']->uc
['condensedMode'] ||
$this->iParts
[2]==2) $this->alwaysContentFrame
=1;
192 if (strcmp($this->iParts
[1],'')) $this->isDBmenu
=1;
194 $TSkey =($this->isDBmenu?
'page':'folder').($this->listFrame?
'List':'Tree');
195 $this->disabledItems
= t3lib_div
::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
196 $this->leftIcons
= $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
198 // &cmLevel flag detected (2nd level menu)
199 if (!$this->cmLevel
) {
200 // Make 1st level clickmenu:
201 if ($this->isDBmenu
) {
202 $CMcontent = $this->printDBClickMenu($this->iParts
[0],$this->iParts
[1]);
204 $CMcontent = $this->printFileClickMenu($this->iParts
[0]);
207 // Make 2nd level clickmenu (only for DBmenus)
208 if ($this->isDBmenu
) {
209 $CMcontent = $this->printNewDBLevel($this->iParts
[0],$this->iParts
[1]);
213 // Return clickmenu content:
218 * Returns true if the menu should (also?) be displayed in topframe, not just <div>-layers
222 function doDisplayTopFrameCM() {
226 return !$GLOBALS['SOBE']->doc
->isCMlayers() ||
!$this->dontDisplayTopFrameCM
;
241 /***************************************
245 ***************************************/
248 * Make 1st level clickmenu:
250 * @param string Table name
251 * @param integer UID for the current record.
252 * @return string HTML content
254 function printDBClickMenu($table,$uid) {
255 global $TCA, $BE_USER;
258 $this->rec
= t3lib_BEfunc
::getRecordWSOL($table,$uid);
263 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
267 if ($table=='pages' && in_array($uid,$GLOBALS['BE_USER']->returnWebmounts())) { // DB mount
271 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
272 if (is_array($this->rec
) ||
$root) {
275 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
278 if (!in_array('view',$this->disabledItems
)) {
279 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
280 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
281 $ws_rec = t3lib_BEfunc
::getRecordWSOL($table,$this->rec
['t3ver_oid']);
282 $menuItems['view']=$this->DB_view($ws_rec['pid']);
287 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
288 if (!in_array('edit',$this->disabledItems
)) $menuItems['edit']=$this->DB_edit($table,$uid);
293 if (!in_array('new',$this->disabledItems
) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
296 if(!in_array('info',$this->disabledItems
) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
298 $menuItems['spacer1']='spacer';
301 if(!in_array('copy',$this->disabledItems
) && !$root && !$DBmount) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
303 if(!in_array('cut',$this->disabledItems
) && !$root && !$DBmount) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
306 $elFromAllTables = count($this->clipObj
->elFromTable(''));
307 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables) {
308 $selItem = $this->clipObj
->getSelectedRecord();
310 t3lib_div
::fixed_lgd_cs($selItem['_RECORD_TITLE'],$BE_USER->uc
['titleLen']),
311 ($root?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen'])),
312 $this->clipObj
->currentMode()
314 if ($table=='pages' && ($lCP & 8)) {
315 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
318 $elFromTable = count($this->clipObj
->elFromTable($table));
319 if (!$root && !$DBmount && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
323 $elInfo=array(t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen']));
324 if(!in_array('delete',$this->disabledItems
) && !$root && !$DBmount && $BE_USER->isPSet($lCP,$table,'delete')) {
325 $menuItems['spacer2']='spacer';
326 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
329 if(!in_array('history',$this->disabledItems
)) {
330 $menuItems['history']=$this->DB_history($table,$uid,$elInfo);
334 // Adding external elements to the menuItems array
335 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
337 // Processing by external functions?
338 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
340 // Return the printed elements:
341 return $this->printItems($menuItems,
343 '<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']):
344 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)
349 * Make 2nd level clickmenu (only for DBmenus)
351 * @param string Table name
352 * @param integer UID for the current record.
353 * @return string HTML content
355 function printNewDBLevel($table,$uid) {
356 global $TCA, $BE_USER;
358 // Setting internal record to the table/uid :
359 $this->rec
= t3lib_BEfunc
::getRecordWSOL($table,$uid);
362 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
366 // If record was found, check permissions and get menu items.
367 if (is_array($this->rec
) ||
$root) {
368 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
370 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
374 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
377 // Return the printed elements:
378 if (!is_array($menuItems)) $menuItems=array();
379 return $this->printItems($menuItems,
381 '<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']):
382 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)
387 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
389 * @param array $menuItems array for manipulation.
390 * @return array Processed $menuItems array
392 function externalProcessingOfDBMenuItems($menuItems) {
397 * Processing the $menuItems array by external classes (typ. adding items)
399 * @param array $menuItems array for manipulation.
400 * @param string Table name
401 * @param integer UID for the current record.
402 * @return array Processed $menuItems array
404 function processingByExtClassArray($menuItems,$table,$uid) {
405 if (is_array($this->extClassArray
)) {
406 reset($this->extClassArray
);
407 while(list(,$conf)=each($this->extClassArray
)) {
408 $obj=t3lib_div
::makeInstance($conf['name']);
409 $menuItems = $obj->main($this,$menuItems,$table,$uid);
416 * Returning JavaScript for the onClick event linking to the input URL.
418 * @param string The URL relative to TYPO3_mainDir
419 * @param string The return_url-parameter
420 * @param boolean If set, the "hideCM()" will be called
421 * @param string If set, gives alternative location to load in (for example top frame or somewhere else)
422 * @return string JavaScript for an onClick event.
424 function urlRefForCM($url,$retUrl='',$hideCM=1,$overrideLoc='') {
425 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
426 $editOnClick= ($overrideLoc ?
'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
427 ($retUrl?
"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
428 ($hideCM?
'return hideCM();':'');
433 * Adding CM element for Clipboard "copy" and "cut"
435 * @param string Table name
436 * @param integer UID for the current record.
437 * @param string Type: "copy" or "cut"
438 * @return array Item array, element in $menuItems
441 function DB_copycut($table,$uid,$type) {
442 if ($this->clipObj
->current
=='normal') {
443 $isSel = $this->clipObj
->isSelected($table,$uid);
447 if ($this->listFrame
) {
448 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
451 return $this->linkItem(
453 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
454 "top.loadTopMenu('".$this->clipObj
->selUrlDB($table,$uid,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
459 * Adding CM element for Clipboard "paste into"/"paste after"
460 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
462 * @param string Table name
463 * @param integer UID for the current record. NOTICE: Special syntax!
464 * @param string Type: "into" or "after"
465 * @param array Contains instructions about whether to copy or cut an element.
466 * @return array Item array, element in $menuItems
467 * @see t3lib_clipboard::pasteUrl()
470 function DB_paste($table,$uid,$type,$elInfo) {
472 $loc = 'top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
473 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
474 $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])).')';
478 $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj
->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
480 return $this->linkItem(
481 $this->label('paste'.$type),
482 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
483 $editOnClick.'return false;'
488 * Adding CM element for Info
490 * @param string Table name
491 * @param integer UID for the current record.
492 * @return array Item array, element in $menuItems
495 function DB_info($table,$uid) {
496 return $this->linkItem(
497 $this->label('info'),
498 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
499 "top.launchView('".$table."', '".$uid."'); return hideCM();"
504 * Adding CM element for History
506 * @param string Table name
507 * @param integer UID for the current record.
508 * @return array Item array, element in $menuItems
511 function DB_history($table,$uid) {
512 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
513 return $this->linkItem(
514 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
515 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
516 $this->urlRefForCM($url,'returnUrl'),
522 * Adding CM element for Permission setting
524 * @param string Table name
525 * @param integer UID for the current record.
526 * @param array The "pages" record with "perms_*" fields inside.
527 * @return array Item array, element in $menuItems
530 function DB_perms($table,$uid,$rec) {
531 $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':'');
532 return $this->linkItem(
533 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
534 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
535 $this->urlRefForCM($url),
541 * Adding CM element for DBlist
543 * @param string Table name
544 * @param integer UID for the current record.
545 * @param array Record of the element (needs "pid" field if not pages-record)
546 * @return array Item array, element in $menuItems
549 function DB_db_list($table,$uid,$rec) {
550 $url = t3lib_div
::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?
'':$table).'&id='.($table=='pages'?
$uid:$rec['pid']);
551 return $this->linkItem(
552 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
553 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/list.gif','width="11" height="11"').' alt="" />'),
554 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
560 * Adding CM element for Moving wizard
562 * @param string Table name
563 * @param integer UID for the current record.
564 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
565 * @return array Item array, element in $menuItems
568 function DB_moveWizard($table,$uid,$rec) {
569 $url = 'move_el.php?table='.$table.'&uid='.$uid.
570 ($table=='tt_content'?
'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
572 return $this->linkItem(
573 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?
'_page':''))),
574 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/move_'.($table=='pages'?
'page':'record').'.gif','width="11" height="12"').' alt="" />'),
575 $this->urlRefForCM($url,'returnUrl'),
581 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
583 * @param string Table name
584 * @param integer UID for the current record.
585 * @param array Record.
586 * @return array Item array, element in $menuItems
589 function DB_newWizard($table,$uid,$rec) {
590 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
591 $tmpTSc = t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
592 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
593 $newContentWizScriptPath = t3lib_extMgm
::isLoaded($tmpTSc) ?
(t3lib_extMgm
::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
595 $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']);
596 return $this->linkItem(
597 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
598 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/new_'.($table=='pages'?
'page':'record').'.gif','width="'.($table=='pages'?
'13':'16').'" height="12"').' alt="" />'),
599 $this->urlRefForCM($url,'returnUrl'),
605 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
607 * @param string Table name
608 * @param integer UID for the current record.
609 * @return array Item array, element in $menuItems
612 function DB_editAccess($table,$uid) {
613 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ?
',extendToSubpages' :''));
614 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
615 return $this->linkItem(
616 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
617 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
618 $this->urlRefForCM($url,'returnUrl'),
619 1 // no top frame CM!
624 * Adding CM element for edit page header
626 * @param integer page uid to edit (PID)
627 * @return array Item array, element in $menuItems
629 * @deprecated Use DB_editPageProperties instead
631 function DB_editPageHeader($uid) {
632 return $this->DB_editPageProperties($uid);
636 * Adding CM element for edit page properties
638 * @param integer page uid to edit (PID)
639 * @return array Item array, element in $menuItems
642 function DB_editPageProperties($uid) {
643 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
644 return $this->linkItem(
645 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
646 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
647 $this->urlRefForCM($url,'returnUrl'),
648 1 // no top frame CM!
653 * Adding CM element for regular editing of the element!
655 * @param string Table name
656 * @param integer UID for the current record.
657 * @return array Item array, element in $menuItems
660 function DB_edit($table,$uid) {
662 // If another module was specified, replace the default Page module with the new one
663 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
664 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
667 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
669 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"');
671 $this->iParts
[0]=='pages' &&
673 $BE_USER->check('modules', $pageModule)
675 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit_page.gif','width="12" height="12"');
676 $this->editPageIconSet
=1;
677 if ($BE_USER->uc
['classicPageEditMode'] ||
!t3lib_extMgm
::isLoaded('cms')) {
678 $addParam='&editRegularContentFromId='.intval($this->iParts
[1]);
680 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts
[1]).";top.goToModule('".$pageModule."',1);";
684 $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."';}";
687 return $this->linkItem(
688 $this->label('edit'),
689 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
690 $editOnClick.'return hideCM();'
695 * Adding CM element for regular Create new element
697 * @param string Table name
698 * @param integer UID for the current record.
699 * @return array Item array, element in $menuItems
702 function DB_new($table,$uid) {
704 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
705 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
707 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
708 'db_new.php?id='.intval($uid)."'").
711 return $this->linkItem(
713 $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="" />'),
714 $editOnClick.'return hideCM();'
719 * Adding CM element for Delete
721 * @param string Table name
722 * @param integer UID for the current record.
723 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
724 * @return array Item array, element in $menuItems
727 function DB_delete($table,$uid,$elInfo) {
729 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
730 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
731 $conf = "confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0]).t3lib_BEfunc
::referenceCount($table,$uid,' (There are %s reference(s) to this record!)')).")";
735 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
736 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
738 return $this->linkItem(
739 $this->label('delete'),
740 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
741 $editOnClick.'return false;'
746 * Adding CM element for View Page
748 * @param integer Page uid (PID)
749 * @param string Anchor, if any
750 * @return array Item array, element in $menuItems
753 function DB_view($id,$anchor='') {
754 return $this->linkItem(
755 $this->label('view'),
756 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
757 t3lib_BEfunc
::viewOnClick($id,$this->PH_backPath
,t3lib_BEfunc
::BEgetRootLine($id),$anchor).'return hideCM();'
762 * Adding element for setting temporary mount point.
764 * @param integer Page uid (PID)
765 * @return array Item array, element in $menuItems
768 function DB_tempMountPoint($page_id) {
769 return $this->linkItem(
770 $this->label('tempMountPoint'),
771 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/placeasroot.gif','width="14" height="12"').' alt="" />'),
772 "if (top.content.nav_frame) { top.content.nav_frame.location.href = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
777 * Adding CM element for hide/unhide of the input record
779 * @param string Table name
780 * @param array Record array
781 * @param string Name of the hide field
782 * @return array Item array, element in $menuItems
785 function DB_hideUnhide($table,$rec,$hideField) {
786 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?
'un':'').'hide'), 'hide');
790 * Adding CM element for a flag field of the input record
792 * @param string Table name
793 * @param array Record array
794 * @param string Name of the flag field
795 * @param string Menu item Title
796 * @param string Name of the item used for icons and labels
797 * @param string Icon path relative to typo3/ folder
798 * @return array Item array, element in $menuItems
800 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
801 $uid = $rec['_ORIG_uid'] ?
$rec['_ORIG_uid'] : $rec['uid'];
803 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
804 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
805 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?
0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
807 return $this->linkItem(
809 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,$iconRelPath.'button_'.($rec[$flagField]?
'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
810 $editOnClick.'return false;',
822 /***************************************
826 ***************************************/
829 * Make 1st level clickmenu:
831 * @param string The absolute path
832 * @return string HTML content
834 function printFileClickMenu($path) {
837 if (@file_exists
($path) && t3lib_div
::isAllowedAbsPath($path)) {
838 $fI = pathinfo($path);
839 $icon = is_dir($path) ?
'folder.gif' : t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
840 $size=' ('.t3lib_div
::formatSize(filesize($path)).'bytes)';
841 $icon = '<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
844 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');
846 if (!in_array('rename',$this->disabledItems
)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
848 if (!in_array('upload',$this->disabledItems
) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif',TRUE);
850 if (!in_array('new',$this->disabledItems
) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
852 if (!in_array('info',$this->disabledItems
)) $menuItems['info']=$this->DB_info($path,'');
854 $menuItems[]='spacer';
857 if (!in_array('copy',$this->disabledItems
)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
859 if (!in_array('cut',$this->disabledItems
)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
862 $elFromAllTables = count($this->clipObj
->elFromTable('_FILE'));
863 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables && is_dir($path)) {
864 $elArr = $this->clipObj
->elFromTable('_FILE');
866 $selItem = current($elArr);
870 $this->clipObj
->currentMode()
872 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
875 $menuItems[]='spacer';
878 if (!in_array('delete',$this->disabledItems
)) $menuItems['delete']=$this->FILE_delete($path);
881 // Adding external elements to the menuItems array
882 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
884 // Processing by external functions?
885 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
887 // Return the printed elements:
888 return $this->printItems($menuItems,$icon.basename($path));
893 * Processing the $menuItems array (for extension classes) (FILES)
895 * @param array $menuItems array for manipulation.
896 * @return array Processed $menuItems array
898 function externalProcessingOfFileMenuItems($menuItems) {
903 * Multi-function for adding an entry to the $menuItems array
905 * @param string Path to the file/directory (target)
906 * @param string Script (eg. file_edit.php) to pass &target= to
907 * @param string "type" is the code which fetches the correct label for the element from "cm."
908 * @param string icon image-filename from "gfx/" (12x12 icon)
909 * @param boolean If set, the return URL parameter will not be set in the link
910 * @return array Item array, element in $menuItems
913 function FILE_launch($path,$script,$type,$image,$noReturnUrl=FALSE) {
914 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
916 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path).($noReturnUrl ?
"'" : "&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")").";}";
918 return $this->linkItem(
920 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
921 $editOnClick.'return hideCM();'
926 * Returns element for copy or cut of files.
928 * @param string Path to the file/directory (target)
929 * @param string Type: "copy" or "cut"
930 * @return array Item array, element in $menuItems
933 function FILE_copycut($path,$type) {
934 $table = '_FILE'; // Pseudo table name for use in the clipboard.
935 $uid = t3lib_div
::shortmd5($path);
936 if ($this->clipObj
->current
=='normal') {
937 $isSel = $this->clipObj
->isSelected($table,$uid);
941 if ($this->listFrame
) {
942 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
945 return $this->linkItem(
947 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
948 "top.loadTopMenu('".$this->clipObj
->selUrlFile($path,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
953 * Creates element for deleting of target
955 * @param string Path to the file/directory (target)
956 * @return array Item array, element in $menuItems
959 function FILE_delete($path) {
961 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
962 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
963 $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!)')).")";
967 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
968 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
970 return $this->linkItem(
971 $this->label('delete'),
972 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
973 $editOnClick.'return false;'
978 * Creates element for pasting files.
980 * @param string Path to the file/directory (target)
981 * @param string target - NOT USED.
982 * @param array Various values for the labels.
983 * @return array Item array, element in $menuItems
986 function FILE_paste($path,$target,$elInfo) {
988 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
989 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
990 $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])).")";
995 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj
->pasteUrl('_FILE',$path,0).
996 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
998 return $this->linkItem(
999 $this->label('pasteinto'),
1000 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
1001 $editOnClick.'return false;'
1009 /***************************************
1013 ***************************************/
1016 * Make 1st level clickmenu:
1018 * @param string The absolute path
1019 * @param integer UID for the current record.
1020 * @param integer Destination ID
1021 * @return string HTML content
1023 function printDragDropClickMenu($table,$srcId,$dstId) {
1026 // If the drag and drop menu should apply to PAGES use this set of menu items
1027 if ($table == 'pages') {
1029 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into');
1031 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after');
1033 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into');
1035 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after');
1038 // If the drag and drop menu should apply to FOLDERS use this set of menu items
1039 if ($table == 'folders') {
1041 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move');
1043 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy');
1046 // Adding external elements to the menuItems array
1047 $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
1049 // Processing by external functions?
1050 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
1052 // Return the printed elements:
1053 return $this->printItems($menuItems,
1054 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)
1060 * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
1062 * @param array $menuItems array for manipulation.
1063 * @return array Processed $menuItems array
1065 function externalProcessingOfDragDropMenuItems($menuItems) {
1071 * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
1073 * @param integer source UID code for the record to modify
1074 * @param integer destination UID code for the record to modify
1075 * @param string Action code: either "move" or "copy"
1076 * @param string Parameter code: either "into" or "after"
1077 * @return array Item array, element in $menuItems
1080 function dragDrop_copymovepage($srcUid,$dstUid,$action,$into) {
1081 $negativeSign = ($into == 'into') ?
'' : '-';
1083 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
1084 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
1085 '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
1087 return $this->linkItem(
1088 $this->label($action.'Page_'.$into),
1089 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
1090 $editOnClick.'return false;',
1097 * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
1099 * @param string source path for the record to modify
1100 * @param string destination path for the records to modify
1101 * @param string Action code: either "move" or "copy"
1102 * @return array Item array, element in $menuItems
1105 function dragDrop_copymovefolder($srcPath,$dstPath,$action) {
1107 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
1108 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
1109 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
1111 return $this->linkItem(
1112 $this->label($action.'Folder_into'),
1113 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
1114 $editOnClick.'return false;',
1127 /***************************************
1131 **************************************/
1134 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
1135 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
1137 * @param array $menuItems array
1138 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
1139 * @return string HTML code
1141 function printItems($menuItems,$item) {
1145 // Enable/Disable items:
1146 $menuItems = $this->enableDisableItems($menuItems);
1148 // Clean up spacers:
1149 $menuItems = $this->cleanUpSpacers($menuItems);
1151 // Adding topframe part (horizontal clickmenu)
1152 if ($this->doDisplayTopFrameCM()) {
1156 Table, which contains the click menu when shown in the top frame of the backend:
1158 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
1162 <td class="c-item">'.
1164 <td><img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
1165 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
1168 <!-- Close button: -->
1169 <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>
1171 <!-- The item of the clickmenu: -->
1172 <td class="c-itemicon">'.$item.'</td>
1177 // Set remaining BACK_PATH to blank (if any)
1178 $out = str_replace($this->PH_backPath
,'',$out);
1181 $out.=$this->printLayerJScode($menuItems);
1183 // Return the content
1188 * Create the JavaScript section
1190 * @param array The $menuItems array to print
1191 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1193 function printLayerJScode($menuItems) {
1195 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
1196 $frameName = '.'.($this->listFrame ?
'list_frame' : 'nav_frame');
1197 if ($this->alwaysContentFrame
) $frameName='';
1199 // Create the table displayed in the clickmenu layer:
1201 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
1202 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
1205 // Wrap the inner table in another table to create outer border:
1206 $CMtable = $this->wrapColorTableCM($CMtable);
1208 // Set back path place holder to real back path
1209 $CMtable = str_replace($this->PH_backPath
,$this->backPath
,$CMtable);
1211 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel
.'</cmlevel></clickmenu></data>';
1214 // Create JavaScript section:
1215 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1217 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.Clickmenu) {
1218 top.content'.$frameName.'.Clickmenu.populateData(unescape("'.t3lib_div
::rawurlencodeJS($CMtable).'"),'.$this->cmLevel
.');
1220 '.(!$this->doDisplayTopFrameCM()?
'hideCM();':'')
1228 * Wrapping the input string in a table with background color 4 and a black border style.
1229 * For the pop-up menu
1231 * @param string HTML content to wrap in table.
1234 function wrapColorTableCM($str) {
1236 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1237 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1239 <td class="c-aa">'.$str.'</td>
1240 <td class="c-ab"></td>
1243 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1244 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1251 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1253 * @param array $menuItem array
1254 * @param array Array with HTML content to be imploded between <td>-tags
1255 * @return array Array of menu items for top frame.
1257 function menuItemsForTopFrame($menuItems) {
1260 while(list(,$i)=each($menuItems)) {
1261 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)
1262 if (is_array($i) && !$i[4]) $out[]=$i[0];
1268 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1270 * @param array $menuItem array
1271 * @param array Array with HTML content to be imploded between <td>-tags
1272 * @return array array for implosion in the CM div-layers table.
1274 function menuItemsForClickMenu($menuItems) {
1277 while(list($cc,$i)=each($menuItems)) {
1278 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1280 <tr class="bgColor2">
1281 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1283 } else { // Just make normal element:
1285 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1286 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1287 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1288 if (!$i[5]) $onClick.='Clickmenu.hideAll();';
1290 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
1291 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
1295 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5
.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
1296 '.(!$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>').'
1304 * Adds or inserts a menu item
1305 * 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.
1307 * @param array Menu items array
1308 * @param array Menu items array to insert
1309 * @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.
1310 * @return array Menu items array, processed.
1312 function addMenuItems($menuItems,$newMenuItems,$position='') {
1313 if (is_array($newMenuItems)) {
1317 $posArr = t3lib_div
::trimExplode(',', $position, 1);
1318 foreach($posArr as $pos) {
1319 list($place,$menuEntry) = t3lib_div
::trimExplode(':', $pos, 1);
1320 list($place,$placeExtra) = t3lib_div
::trimExplode('-', $place, 1);
1323 $pointer = count($menuItems);
1328 switch(strtolower($place)) {
1335 if (!strcmp(key($menuItems), $menuEntry)) {
1340 if (!next($menuItems)) break;
1345 if ($place=='before') {
1347 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
1350 } elseif ($place=='after') {
1351 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
1358 if (strtolower($place)=='top') {
1361 $pointer = count($menuItems);
1370 $pointer=max(0,$pointer);
1371 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?
$pointer:0));
1372 $menuItemsAfter = array_slice($menuItems, $pointer);
1373 $menuItems = $menuItemsBefore +
$newMenuItems +
$menuItemsAfter;
1379 * Creating an array with various elements for the clickmenu entry
1381 * @param string The label, htmlspecialchar'ed already
1382 * @param string <img>-tag for the icon
1383 * @param string JavaScript onclick event for label/icon
1384 * @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)
1385 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1386 * @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!
1388 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1393 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1396 $WHattribs = t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1399 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount
.'" alt="" />'.
1400 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount
.');" onmouseout="mout('.$this->elCount
.');">'.
1412 * Returns the input string IF not a user setting has disabled display of icons.
1414 * @param string The icon-image tag
1415 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1417 function excludeIcon($iconCode) {
1418 return ($GLOBALS['BE_USER']->uc
['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc
['noMenuMode'],'icons')) ?
'' : ' '.$iconCode;
1422 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1424 * @param array Menu items array
1425 * @return array Menu items array, processed.
1427 function enableDisableItems($menuItems) {
1428 if ($this->iParts
[3]) {
1430 // Detect "only" mode: (only showing listed items)
1431 if (substr($this->iParts
[3],0,1)=='+') {
1432 $this->iParts
[3] = substr($this->iParts
[3],1);
1439 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1440 $newMenuArray = array();
1441 foreach($menuItems as $key => $value) {
1442 if (t3lib_div
::inList($this->iParts
[3], $key) ||
(is_string($value) && $value=='spacer')) {
1443 $newMenuArray[$key] = $value;
1446 $menuItems = $newMenuArray;
1447 } else { // Traverse all elements except those listed (just unsetting them):
1448 $elements = t3lib_div
::trimExplode(',',$this->iParts
[3],1);
1449 foreach($elements as $value) {
1450 unset($menuItems[$value]);
1455 // Return processed menu items:
1460 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1462 * @param array Menu items array
1463 * @return array Menu items array, processed.
1465 function cleanUpSpacers($menuItems) {
1468 $prevItemWasSpacer = FALSE;
1469 foreach($menuItems as $key => $value) {
1470 if (is_string($value) && $value=='spacer') {
1471 if ($prevItemWasSpacer) {
1472 unset($menuItems[$key]);
1474 $prevItemWasSpacer = TRUE;
1476 $prevItemWasSpacer = FALSE;
1482 $key = key($menuItems);
1483 $value = current($menuItems);
1484 if (is_string($value) && $value=='spacer') {
1485 unset($menuItems[$key]);
1491 $key = key($menuItems);
1492 $value = current($menuItems);
1493 if (is_string($value) && $value=='spacer') {
1494 unset($menuItems[$key]);
1497 // Return processed menu items:
1502 * Get label from locallang_core.php:cm.*
1504 * @param string The "cm."-suffix to get.
1507 function label($label) {
1508 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1512 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1516 function isCMlayers() {
1520 return $GLOBALS['SOBE']->doc
->isCMlayers() && !$this->CB
;
1525 * Appends ".location" to input string
1527 * @param string Input string, probably a JavaScript document reference
1530 function frameLocation($str) {
1531 return $str.'.location';
1548 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1550 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1553 * @see template::getContextMenuCode()
1555 class SC_alt_clickmenu
{
1557 // Internal, static: GPvar:
1558 var $backPath; // Back path.
1559 var $item; // Definition of which item the click menu should be made for.
1560 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1563 var $content=''; // Content accumulation
1564 var $doc; // Template object
1565 var $include_once=array(); // Files to include_once() - set in init() function
1566 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1567 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1570 * Constructor function for script class.
1575 global $BE_USER,$BACK_PATH;
1578 $this->backPath
= t3lib_div
::_GP('backPath');
1579 $this->item
= t3lib_div
::_GP('item');
1580 $this->reloadListFrame
= t3lib_div
::_GP('reloadListFrame');
1582 // Setting pseudo module name
1583 $this->MCONF
['name']='xMOD_alt_clickmenu.php';
1585 // 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:
1586 $inputBP = explode('|',$this->backPath
);
1587 if (count($inputBP)==2 && $inputBP[1]==t3lib_div
::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1588 $this->backPath
= $inputBP[0];
1590 $this->backPath
= $BACK_PATH;
1593 // Setting internal array of classes for extending the clickmenu:
1594 $this->extClassArray
= $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1596 // Traversing that array and setting files for inclusion:
1597 if (is_array($this->extClassArray
)) {
1598 foreach($this->extClassArray
as $extClassConf) {
1599 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1603 // Initialize template object
1605 $this->doc
= t3lib_div
::makeInstance('template');
1606 $this->doc
->docType
='xhtml_trans';
1607 $this->doc
->backPath
= $BACK_PATH;
1610 // Setting mode for display and background image in the top frame
1611 $this->dontDisplayTopFrameCM
= $this->doc
->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1612 if ($this->dontDisplayTopFrameCM
) {
1613 $this->doc
->bodyTagId
.= '-notop';
1616 // Setting clickmenu timeout
1617 $secs = t3lib_div
::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1619 // Setting the JavaScript controlling the timer on the page
1620 $listFrameDoc = $this->reloadListFrame
!=2 ?
'top.content.list_frame' : 'top.content';
1621 $this->doc
->JScode
.=$this->doc
->wrapScriptTags('
1622 var date = new Date();
1623 var mo_timeout = Math.floor(date.getTime()/1000);
1626 roImg.src = "'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1628 routImg =new Image();
1629 routImg.src = "clear.gif";
1632 var name="roimg_"+c;
1633 document[name].src = roImg.src;
1636 function mout(c) { //
1637 var name="roimg_"+c;
1638 document[name].src = routImg.src;
1641 function updateTime() { //
1643 mo_timeout = Math.floor(date.getTime()/1000);
1645 function timeout_func() { //
1647 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1651 window.setTimeout("timeout_func();",1*1000);
1654 function hideCM() { //
1655 window.location.href="alt_topmenu_dummy.php";
1662 '.($this->reloadListFrame ?
'
1663 // Reload list frame:
1664 if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' :
1670 * Main function - generating the click menu in whatever form it has.
1675 $this->ajax
= t3lib_div
::_GP('ajax') ?
TRUE : FALSE;
1677 // Initialize Clipboard object:
1678 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
1679 $clipObj->initializeClipboard();
1680 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1682 // Update clipboard if some actions are sent.
1683 $CB = t3lib_div
::_GET('CB');
1684 $clipObj->setCmd($CB);
1685 $clipObj->cleanCurrent();
1686 $clipObj->endClipboard(); // Saves
1688 // Create clickmenu object
1689 $clickMenu = t3lib_div
::makeInstance('clickMenu');
1691 // Set internal vars in clickmenu object:
1692 $clickMenu->clipObj
= $clipObj;
1693 $clickMenu->extClassArray
= $this->extClassArray
;
1694 $clickMenu->dontDisplayTopFrameCM
= $this->dontDisplayTopFrameCM
;
1695 $clickMenu->backPath
= $this->backPath
;
1699 $this->content
.= $this->doc
->startPage('Context Sensitive Menu');
1701 // Set content of the clickmenu with the incoming var, "item"
1702 $this->content
.= $clickMenu->init();
1706 * End page and output content.
1710 function printContent() {
1712 $this->content
.= $this->doc
->endPage();
1713 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
1714 echo $this->content
;
1716 $this->content
= $GLOBALS['LANG']->csConvObj
->utf8_encode($this->content
,$GLOBALS['LANG']->charSet
);
1717 t3lib_ajax
::outputXMLreply($this->content
);
1722 // Include extension?
1723 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']) {
1724 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']);
1737 $SOBE = t3lib_div
::makeInstance('SC_alt_clickmenu');
1741 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1744 $SOBE->printContent();