2 /***************************************************************
5 * (c) 1999-2005 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);
261 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
265 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
266 if (is_array($this->rec
) ||
$root) {
269 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
272 if (!in_array('view',$this->disabledItems
)) {
273 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
274 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
275 $ws_rec = t3lib_BEfunc
::getRecordWSOL($table,$this->rec
['t3ver_oid']);
276 $menuItems['view']=$this->DB_view($ws_rec['pid']);
281 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
282 if (!in_array('edit',$this->disabledItems
)) $menuItems['edit']=$this->DB_edit($table,$uid);
287 if (!in_array('new',$this->disabledItems
) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
290 if(!in_array('info',$this->disabledItems
) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
292 $menuItems['spacer1']='spacer';
295 if(!in_array('copy',$this->disabledItems
) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
297 if(!in_array('cut',$this->disabledItems
) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
300 $elFromAllTables = count($this->clipObj
->elFromTable(''));
301 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables) {
302 $selItem = $this->clipObj
->getSelectedRecord();
304 t3lib_div
::fixed_lgd_cs($selItem['_RECORD_TITLE'],$BE_USER->uc
['titleLen']),
305 ($root?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen'])),
306 $this->clipObj
->currentMode()
308 if ($table=='pages' && ($lCP & 8)) {
309 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
312 $elFromTable = count($this->clipObj
->elFromTable($table));
313 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
317 $elInfo=array(t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen']));
318 if(!in_array('delete',$this->disabledItems
) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
319 $menuItems['spacer2']='spacer';
320 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
323 if(!in_array('history',$this->disabledItems
)) {
324 $menuItems['history']=$this->DB_history($table,$uid,$elInfo);
328 // Adding external elements to the menuItems array
329 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
331 // Processing by external functions?
332 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
334 // Return the printed elements:
335 return $this->printItems($menuItems,
337 '<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']):
338 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)
343 * Make 2nd level clickmenu (only for DBmenus)
345 * @param string Table name
346 * @param integer UID for the current record.
347 * @return string HTML content
349 function printNewDBLevel($table,$uid) {
350 global $TCA, $BE_USER;
352 // Setting internal record to the table/uid :
353 $this->rec
= t3lib_BEfunc
::getRecordWSOL($table,$uid);
356 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
360 // If record was found, check permissions and get menu items.
361 if (is_array($this->rec
) ||
$root) {
362 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
364 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
368 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
371 // Return the printed elements:
372 if (!is_array($menuItems)) $menuItems=array();
373 return $this->printItems($menuItems,
375 '<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']):
376 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)
381 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
383 * @param array $menuItems array for manipulation.
384 * @return array Processed $menuItems array
386 function externalProcessingOfDBMenuItems($menuItems) {
391 * Processing the $menuItems array by external classes (typ. adding items)
393 * @param array $menuItems array for manipulation.
394 * @param string Table name
395 * @param integer UID for the current record.
396 * @return array Processed $menuItems array
398 function processingByExtClassArray($menuItems,$table,$uid) {
399 if (is_array($this->extClassArray
)) {
400 reset($this->extClassArray
);
401 while(list(,$conf)=each($this->extClassArray
)) {
402 $obj=t3lib_div
::makeInstance($conf['name']);
403 $menuItems = $obj->main($this,$menuItems,$table,$uid);
410 * Returning JavaScript for the onClick event linking to the input URL.
412 * @param string The URL relative to TYPO3_mainDir
413 * @param string The return_url-parameter
414 * @param boolean If set, the "hideCM()" will be called
415 * @param string If set, gives alternative location to load in (for example top frame or somewhere else)
416 * @return string JavaScript for an onClick event.
418 function urlRefForCM($url,$retUrl='',$hideCM=1,$overrideLoc='') {
419 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
420 $editOnClick= ($overrideLoc ?
'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
421 ($retUrl?
"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
422 ($hideCM?
'return hideCM();':'');
427 * Adding CM element for Clipboard "copy" and "cut"
429 * @param string Table name
430 * @param integer UID for the current record.
431 * @param string Type: "copy" or "cut"
432 * @return array Item array, element in $menuItems
435 function DB_copycut($table,$uid,$type) {
436 if ($this->clipObj
->current
=='normal') {
437 $isSel = $this->clipObj
->isSelected($table,$uid);
441 if ($this->listFrame
) {
442 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
445 return $this->linkItem(
447 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
448 "top.loadTopMenu('".$this->clipObj
->selUrlDB($table,$uid,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
453 * Adding CM element for Clipboard "paste into"/"paste after"
454 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
456 * @param string Table name
457 * @param integer UID for the current record. NOTICE: Special syntax!
458 * @param string Type: "into" or "after"
459 * @param array Contains instructions about whether to copy or cut an element.
460 * @return array Item array, element in $menuItems
461 * @see t3lib_clipboard::pasteUrl()
464 function DB_paste($table,$uid,$type,$elInfo) {
466 $loc = 'top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
467 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
468 $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])).')';
472 $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj
->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
474 return $this->linkItem(
475 $this->label('paste'.$type),
476 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
477 $editOnClick.'return false;'
482 * Adding CM element for Info
484 * @param string Table name
485 * @param integer UID for the current record.
486 * @return array Item array, element in $menuItems
489 function DB_info($table,$uid) {
490 return $this->linkItem(
491 $this->label('info'),
492 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
493 "top.launchView('".$table."', '".$uid."'); return hideCM();"
498 * Adding CM element for History
500 * @param string Table name
501 * @param integer UID for the current record.
502 * @return array Item array, element in $menuItems
505 function DB_history($table,$uid) {
506 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
507 return $this->linkItem(
508 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
509 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
510 $this->urlRefForCM($url,'returnUrl'),
516 * Adding CM element for Permission setting
518 * @param string Table name
519 * @param integer UID for the current record.
520 * @param array The "pages" record with "perms_*" fields inside.
521 * @return array Item array, element in $menuItems
524 function DB_perms($table,$uid,$rec) {
525 $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':'');
526 return $this->linkItem(
527 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
528 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
529 $this->urlRefForCM($url),
535 * Adding CM element for DBlist
537 * @param string Table name
538 * @param integer UID for the current record.
539 * @param array Record of the element (needs "pid" field if not pages-record)
540 * @return array Item array, element in $menuItems
543 function DB_db_list($table,$uid,$rec) {
544 $url = t3lib_div
::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?
'':$table).'&id='.($table=='pages'?
$uid:$rec['pid']);
545 return $this->linkItem(
546 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
547 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/list.gif','width="11" height="11"').' alt="" />'),
548 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
554 * Adding CM element for Moving wizard
556 * @param string Table name
557 * @param integer UID for the current record.
558 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
559 * @return array Item array, element in $menuItems
562 function DB_moveWizard($table,$uid,$rec) {
563 $url = 'move_el.php?table='.$table.'&uid='.$uid.
564 ($table=='tt_content'?
'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
566 return $this->linkItem(
567 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?
'_page':''))),
568 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/move_'.($table=='pages'?
'page':'record').'.gif','width="11" height="12"').' alt="" />'),
569 $this->urlRefForCM($url,'returnUrl'),
575 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
577 * @param string Table name
578 * @param integer UID for the current record.
579 * @param array Record.
580 * @return array Item array, element in $menuItems
583 function DB_newWizard($table,$uid,$rec) {
584 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
585 $tmpTSc = t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
586 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
587 $newContentWizScriptPath = t3lib_extMgm
::isLoaded($tmpTSc) ?
(t3lib_extMgm
::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
589 $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']);
590 return $this->linkItem(
591 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
592 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/new_'.($table=='pages'?
'page':'record').'.gif','width="'.($table=='pages'?
'13':'16').'" height="12"').' alt="" />'),
593 $this->urlRefForCM($url,'returnUrl'),
599 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
601 * @param string Table name
602 * @param integer UID for the current record.
603 * @return array Item array, element in $menuItems
606 function DB_editAccess($table,$uid) {
607 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ?
',extendToSubpages' :''));
608 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
609 return $this->linkItem(
610 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
611 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
612 $this->urlRefForCM($url,'returnUrl'),
613 1 // no top frame CM!
618 * Adding CM element for edit page header
620 * @param integer page uid to edit (PID)
621 * @return array Item array, element in $menuItems
623 * @deprecated Use DB_editPageProperties instead
625 function DB_editPageHeader($uid) {
626 return $this->DB_editPageProperties($uid);
630 * Adding CM element for edit page properties
632 * @param integer page uid to edit (PID)
633 * @return array Item array, element in $menuItems
636 function DB_editPageProperties($uid) {
637 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
638 return $this->linkItem(
639 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
640 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
641 $this->urlRefForCM($url,'returnUrl'),
642 1 // no top frame CM!
647 * Adding CM element for regular editing of the element!
649 * @param string Table name
650 * @param integer UID for the current record.
651 * @return array Item array, element in $menuItems
654 function DB_edit($table,$uid) {
656 // If another module was specified, replace the default Page module with the new one
657 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
658 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
661 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
663 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"');
665 $this->iParts
[0]=='pages' &&
667 $BE_USER->check('modules', $pageModule)
669 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit_page.gif','width="12" height="12"');
670 $this->editPageIconSet
=1;
671 if ($BE_USER->uc
['classicPageEditMode'] ||
!t3lib_extMgm
::isLoaded('cms')) {
672 $addParam='&editRegularContentFromId='.intval($this->iParts
[1]);
674 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts
[1]).";top.goToModule('".$pageModule."',1);";
678 $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."';}";
681 return $this->linkItem(
682 $this->label('edit'),
683 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
684 $editOnClick.'return hideCM();'
689 * Adding CM element for regular Create new element
691 * @param string Table name
692 * @param integer UID for the current record.
693 * @return array Item array, element in $menuItems
696 function DB_new($table,$uid) {
698 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
699 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
701 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
702 'db_new.php?id='.intval($uid)."'").
705 return $this->linkItem(
707 $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="" />'),
708 $editOnClick.'return hideCM();'
713 * Adding CM element for Delete
715 * @param string Table name
716 * @param integer UID for the current record.
717 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
718 * @return array Item array, element in $menuItems
721 function DB_delete($table,$uid,$elInfo) {
723 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
724 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
725 $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!)')).")";
729 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
730 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
732 return $this->linkItem(
733 $this->label('delete'),
734 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
735 $editOnClick.'return false;'
740 * Adding CM element for View Page
742 * @param integer Page uid (PID)
743 * @param string Anchor, if any
744 * @return array Item array, element in $menuItems
747 function DB_view($id,$anchor='') {
748 return $this->linkItem(
749 $this->label('view'),
750 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
751 t3lib_BEfunc
::viewOnClick($id,$this->PH_backPath
,t3lib_BEfunc
::BEgetRootLine($id),$anchor).'return hideCM();'
756 * Adding element for setting temporary mount point.
758 * @param integer Page uid (PID)
759 * @return array Item array, element in $menuItems
762 function DB_tempMountPoint($page_id) {
763 return $this->linkItem(
764 $this->label('tempMountPoint'),
765 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/placeasroot.gif','width="14" height="12"').' alt="" />'),
766 "if (top.content.nav_frame) { top.content.nav_frame.location.href = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
771 * Adding CM element for hide/unhide of the input record
773 * @param string Table name
774 * @param array Record array
775 * @param string Name of the hide field
776 * @return array Item array, element in $menuItems
779 function DB_hideUnhide($table,$rec,$hideField) {
780 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?
'un':'').'hide'), 'hide');
784 * Adding CM element for a flag field of the input record
786 * @param string Table name
787 * @param array Record array
788 * @param string Name of the flag field
789 * @param string Menu item Title
790 * @param string Name of the item used for icons and labels
791 * @param string Icon path relative to typo3/ folder
792 * @return array Item array, element in $menuItems
794 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
795 $uid = $rec['_ORIG_uid'] ?
$rec['_ORIG_uid'] : $rec['uid'];
797 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
798 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
799 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?
0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
801 return $this->linkItem(
803 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,$iconRelPath.'button_'.($rec[$flagField]?
'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
804 $editOnClick.'return false;',
816 /***************************************
820 ***************************************/
823 * Make 1st level clickmenu:
825 * @param string The absolute path
826 * @return string HTML content
828 function printFileClickMenu($path) {
831 if (@file_exists
($path) && t3lib_div
::isAllowedAbsPath($path)) {
832 $fI = pathinfo($path);
833 $icon = is_dir($path) ?
'folder.gif' : t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
834 $size=' ('.t3lib_div
::formatSize(filesize($path)).'bytes)';
835 $icon = '<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
838 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');
840 if (!in_array('rename',$this->disabledItems
)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
842 if (!in_array('upload',$this->disabledItems
) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
844 if (!in_array('new',$this->disabledItems
) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
846 if (!in_array('info',$this->disabledItems
)) $menuItems['info']=$this->DB_info($path,'');
848 $menuItems[]='spacer';
851 if (!in_array('copy',$this->disabledItems
)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
853 if (!in_array('cut',$this->disabledItems
)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
856 $elFromAllTables = count($this->clipObj
->elFromTable('_FILE'));
857 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables && is_dir($path)) {
858 $elArr = $this->clipObj
->elFromTable('_FILE');
860 $selItem = current($elArr);
864 $this->clipObj
->currentMode()
866 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
869 $menuItems[]='spacer';
872 if (!in_array('delete',$this->disabledItems
)) $menuItems['delete']=$this->FILE_delete($path);
875 // Adding external elements to the menuItems array
876 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
878 // Processing by external functions?
879 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
881 // Return the printed elements:
882 return $this->printItems($menuItems,$icon.basename($path));
887 * Processing the $menuItems array (for extension classes) (FILES)
889 * @param array $menuItems array for manipulation.
890 * @return array Processed $menuItems array
892 function externalProcessingOfFileMenuItems($menuItems) {
897 * Multi-function for adding an entry to the $menuItems array
899 * @param string Path to the file/directory (target)
900 * @param string Script (eg. file_edit.php) to pass &target= to
901 * @param string "type" is the code which fetches the correct label for the element from "cm."
902 * @param string icon image-filename from "gfx/" (12x12 icon)
903 * @return array Item array, element in $menuItems
906 function FILE_launch($path,$script,$type,$image) {
907 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
909 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
911 return $this->linkItem(
913 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
914 $editOnClick.'return hideCM();'
919 * Returns element for copy or cut of files.
921 * @param string Path to the file/directory (target)
922 * @param string Type: "copy" or "cut"
923 * @return array Item array, element in $menuItems
926 function FILE_copycut($path,$type) {
927 $table = '_FILE'; // Pseudo table name for use in the clipboard.
928 $uid = t3lib_div
::shortmd5($path);
929 if ($this->clipObj
->current
=='normal') {
930 $isSel = $this->clipObj
->isSelected($table,$uid);
934 if ($this->listFrame
) {
935 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
938 return $this->linkItem(
940 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
941 "top.loadTopMenu('".$this->clipObj
->selUrlFile($path,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
946 * Creates element for deleting of target
948 * @param string Path to the file/directory (target)
949 * @return array Item array, element in $menuItems
952 function FILE_delete($path) {
954 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
955 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
956 $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!)')).")";
960 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
961 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
963 return $this->linkItem(
964 $this->label('delete'),
965 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
966 $editOnClick.'return false;'
971 * Creates element for pasting files.
973 * @param string Path to the file/directory (target)
974 * @param string target - NOT USED.
975 * @param array Various values for the labels.
976 * @return array Item array, element in $menuItems
979 function FILE_paste($path,$target,$elInfo) {
981 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
982 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
983 $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])).")";
988 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj
->pasteUrl('_FILE',$path,0).
989 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
991 return $this->linkItem(
992 $this->label('pasteinto'),
993 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
994 $editOnClick.'return false;'
1002 /***************************************
1006 ***************************************/
1009 * Make 1st level clickmenu:
1011 * @param string The absolute path
1012 * @param integer UID for the current record.
1013 * @param integer Destination ID
1014 * @return string HTML content
1016 function printDragDropClickMenu($table,$srcId,$dstId) {
1019 // If the drag and drop menu should apply to PAGES use this set of menu items
1020 if ($table == 'pages') {
1022 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into');
1024 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after');
1026 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into');
1028 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after');
1031 // If the drag and drop menu should apply to FOLDERS use this set of menu items
1032 if ($table == 'folders') {
1034 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move');
1036 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy');
1039 // Adding external elements to the menuItems array
1040 $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
1042 // Processing by external functions?
1043 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
1045 // Return the printed elements:
1046 return $this->printItems($menuItems,
1047 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)
1053 * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
1055 * @param array $menuItems array for manipulation.
1056 * @return array Processed $menuItems array
1058 function externalProcessingOfDragDropMenuItems($menuItems) {
1064 * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
1066 * @param integer source UID code for the record to modify
1067 * @param integer destination UID code for the record to modify
1068 * @param string Action code: either "move" or "copy"
1069 * @param string Parameter code: either "into" or "after"
1070 * @return array Item array, element in $menuItems
1073 function dragDrop_copymovepage($srcUid,$dstUid,$action,$into) {
1074 $negativeSign = ($into == 'into') ?
'' : '-';
1076 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
1077 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
1078 '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
1080 return $this->linkItem(
1081 $this->label($action.'Page_'.$into),
1082 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
1083 $editOnClick.'return false;',
1090 * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
1092 * @param string source path for the record to modify
1093 * @param string destination path for the records to modify
1094 * @param string Action code: either "move" or "copy"
1095 * @return array Item array, element in $menuItems
1098 function dragDrop_copymovefolder($srcPath,$dstPath,$action) {
1100 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
1101 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
1102 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
1104 return $this->linkItem(
1105 $this->label($action.'Folder_into'),
1106 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
1107 $editOnClick.'return false;',
1120 /***************************************
1124 **************************************/
1127 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
1128 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
1130 * @param array $menuItems array
1131 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
1132 * @return string HTML code
1134 function printItems($menuItems,$item) {
1138 // Enable/Disable items:
1139 $menuItems = $this->enableDisableItems($menuItems);
1141 // Clean up spacers:
1142 $menuItems = $this->cleanUpSpacers($menuItems);
1144 // Adding topframe part (horizontal clickmenu)
1145 if ($this->doDisplayTopFrameCM()) {
1149 Table, which contains the click menu when shown in the top frame of the backend:
1151 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
1155 <td class="c-item">'.
1157 <td><img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
1158 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
1161 <!-- Close button: -->
1162 <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>
1164 <!-- The item of the clickmenu: -->
1165 <td class="c-itemicon">'.$item.'</td>
1170 // Set remaining BACK_PATH to blank (if any)
1171 $out = str_replace($this->PH_backPath
,'',$out);
1174 $out.=$this->printLayerJScode($menuItems);
1176 // Return the content
1181 * Create the JavaScript section
1183 * @param array The $menuItems array to print
1184 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1186 function printLayerJScode($menuItems) {
1188 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
1189 $frameName = '.'.($this->listFrame ?
'list_frame' : 'nav_frame');
1190 if ($this->alwaysContentFrame
) $frameName='';
1192 // Create the table displayed in the clickmenu layer:
1194 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
1195 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
1198 // Wrap the inner table in another table to create outer border:
1199 $CMtable = $this->wrapColorTableCM($CMtable);
1201 // Set back path place holder to real back path
1202 $CMtable = str_replace($this->PH_backPath
,$this->backPath
,$CMtable);
1204 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel
.'</cmlevel></clickmenu></data>';
1207 // Create JavaScript section:
1208 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1210 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
1211 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div
::rawurlencodeJS($CMtable).'"),'.$this->cmLevel
.');
1213 '.(!$this->doDisplayTopFrameCM()?
'hideCM();':'')
1221 * Wrapping the input string in a table with background color 4 and a black border style.
1222 * For the pop-up menu
1224 * @param string HTML content to wrap in table.
1227 function wrapColorTableCM($str) {
1229 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1230 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1232 <td class="c-aa">'.$str.'</td>
1233 <td class="c-ab"></td>
1236 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1237 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1244 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1246 * @param array $menuItem array
1247 * @param array Array with HTML content to be imploded between <td>-tags
1248 * @return array Array of menu items for top frame.
1250 function menuItemsForTopFrame($menuItems) {
1253 while(list(,$i)=each($menuItems)) {
1254 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)
1255 if (is_array($i) && !$i[4]) $out[]=$i[0];
1261 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1263 * @param array $menuItem array
1264 * @param array Array with HTML content to be imploded between <td>-tags
1265 * @return array array for implosion in the CM div-layers table.
1267 function menuItemsForClickMenu($menuItems) {
1270 while(list($cc,$i)=each($menuItems)) {
1271 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1273 <tr class="bgColor2">
1274 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1276 } else { // Just make normal element:
1278 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1279 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1280 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1281 if (!$i[5]) $onClick.='hideEmpty();';
1283 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
1284 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
1288 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5
.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
1289 '.(!$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>').'
1297 * Adds or inserts a menu item
1298 * 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.
1300 * @param array Menu items array
1301 * @param array Menu items array to insert
1302 * @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.
1303 * @return array Menu items array, processed.
1305 function addMenuItems($menuItems,$newMenuItems,$position='') {
1306 if (is_array($newMenuItems)) {
1310 $posArr = t3lib_div
::trimExplode(',', $position, 1);
1311 foreach($posArr as $pos) {
1312 list($place,$menuEntry) = t3lib_div
::trimExplode(':', $pos, 1);
1313 list($place,$placeExtra) = t3lib_div
::trimExplode('-', $place, 1);
1316 $pointer = count($menuItems);
1321 switch(strtolower($place)) {
1328 if (!strcmp(key($menuItems), $menuEntry)) {
1333 if (!next($menuItems)) break;
1338 if ($place=='before') {
1340 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
1343 } elseif ($place=='after') {
1344 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
1351 if (strtolower($place)=='top') {
1354 $pointer = count($menuItems);
1363 $pointer=max(0,$pointer);
1364 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?
$pointer:0));
1365 $menuItemsAfter = array_slice($menuItems, $pointer);
1366 $menuItems = $menuItemsBefore +
$newMenuItems +
$menuItemsAfter;
1372 * Creating an array with various elements for the clickmenu entry
1374 * @param string The label, htmlspecialchar'ed already
1375 * @param string <img>-tag for the icon
1376 * @param string JavaScript onclick event for label/icon
1377 * @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)
1378 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1379 * @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!
1381 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1386 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1389 $WHattribs = t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1392 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount
.'" alt="" />'.
1393 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount
.');" onmouseout="mout('.$this->elCount
.');">'.
1405 * Returns the input string IF not a user setting has disabled display of icons.
1407 * @param string The icon-image tag
1408 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1410 function excludeIcon($iconCode) {
1411 return ($GLOBALS['BE_USER']->uc
['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc
['noMenuMode'],'icons')) ?
'' : ' '.$iconCode;
1415 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1417 * @param array Menu items array
1418 * @return array Menu items array, processed.
1420 function enableDisableItems($menuItems) {
1421 if ($this->iParts
[3]) {
1423 // Detect "only" mode: (only showing listed items)
1424 if (substr($this->iParts
[3],0,1)=='+') {
1425 $this->iParts
[3] = substr($this->iParts
[3],1);
1432 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1433 $newMenuArray = array();
1434 foreach($menuItems as $key => $value) {
1435 if (t3lib_div
::inList($this->iParts
[3], $key) ||
(is_string($value) && $value=='spacer')) {
1436 $newMenuArray[$key] = $value;
1439 $menuItems = $newMenuArray;
1440 } else { // Traverse all elements except those listed (just unsetting them):
1441 $elements = t3lib_div
::trimExplode(',',$this->iParts
[3],1);
1442 foreach($elements as $value) {
1443 unset($menuItems[$value]);
1448 // Return processed menu items:
1453 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1455 * @param array Menu items array
1456 * @return array Menu items array, processed.
1458 function cleanUpSpacers($menuItems) {
1461 $prevItemWasSpacer = FALSE;
1462 foreach($menuItems as $key => $value) {
1463 if (is_string($value) && $value=='spacer') {
1464 if ($prevItemWasSpacer) {
1465 unset($menuItems[$key]);
1467 $prevItemWasSpacer = TRUE;
1469 $prevItemWasSpacer = FALSE;
1475 $key = key($menuItems);
1476 $value = current($menuItems);
1477 if (is_string($value) && $value=='spacer') {
1478 unset($menuItems[$key]);
1484 $key = key($menuItems);
1485 $value = current($menuItems);
1486 if (is_string($value) && $value=='spacer') {
1487 unset($menuItems[$key]);
1490 // Return processed menu items:
1495 * Get label from locallang_core.php:cm.*
1497 * @param string The "cm."-suffix to get.
1500 function label($label) {
1501 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1505 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1509 function isCMlayers() {
1513 return $GLOBALS['SOBE']->doc
->isCMlayers() && !$this->CB
;
1518 * Appends ".location" to input string
1520 * @param string Input string, probably a JavaScript document reference
1523 function frameLocation($str) {
1524 return $str.'.location';
1541 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1543 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1546 * @see template::getContextMenuCode()
1548 class SC_alt_clickmenu
{
1550 // Internal, static: GPvar:
1551 var $backPath; // Back path.
1552 var $item; // Definition of which item the click menu should be made for.
1553 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1556 var $content=''; // Content accumulation
1557 var $doc; // Template object
1558 var $include_once=array(); // Files to include_once() - set in init() function
1559 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1560 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1563 * Constructor function for script class.
1568 global $BE_USER,$BACK_PATH;
1571 $this->backPath
= t3lib_div
::_GP('backPath');
1572 $this->item
= t3lib_div
::_GP('item');
1573 $this->reloadListFrame
= t3lib_div
::_GP('reloadListFrame');
1575 // Setting pseudo module name
1576 $this->MCONF
['name']='xMOD_alt_clickmenu.php';
1578 // 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:
1579 $inputBP = explode('|',$this->backPath
);
1580 if (count($inputBP)==2 && $inputBP[1]==t3lib_div
::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1581 $this->backPath
= $inputBP[0];
1583 $this->backPath
= $BACK_PATH;
1586 // Setting internal array of classes for extending the clickmenu:
1587 $this->extClassArray
= $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1589 // Traversing that array and setting files for inclusion:
1590 if (is_array($this->extClassArray
)) {
1591 foreach($this->extClassArray
as $extClassConf) {
1592 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1596 // Initialize template object
1598 $this->doc
= t3lib_div
::makeInstance('template');
1599 $this->doc
->docType
='xhtml_trans';
1600 $this->doc
->backPath
= $BACK_PATH;
1603 // Setting mode for display and background image in the top frame
1604 $this->dontDisplayTopFrameCM
= $this->doc
->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1605 if ($this->dontDisplayTopFrameCM
) {
1606 $this->doc
->bodyTagId
.= '-notop';
1609 // Setting clickmenu timeout
1610 $secs = t3lib_div
::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1612 // Setting the JavaScript controlling the timer on the page
1613 $listFrameDoc = $this->reloadListFrame
!=2 ?
'top.content.list_frame' : 'top.content';
1614 $this->doc
->JScode
.=$this->doc
->wrapScriptTags('
1615 var date = new Date();
1616 var mo_timeout = Math.floor(date.getTime()/1000);
1619 roImg.src = "'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1621 routImg =new Image();
1622 routImg.src = "clear.gif";
1625 var name="roimg_"+c;
1626 document[name].src = roImg.src;
1629 function mout(c) { //
1630 var name="roimg_"+c;
1631 document[name].src = routImg.src;
1634 function updateTime() { //
1636 mo_timeout = Math.floor(date.getTime()/1000);
1638 function timeout_func() { //
1640 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1644 window.setTimeout("timeout_func();",1*1000);
1647 function hideCM() { //
1648 window.location.href="alt_topmenu_dummy.php";
1655 '.($this->reloadListFrame ?
'
1656 // Reload list frame:
1657 if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' :
1663 * Main function - generating the click menu in whatever form it has.
1668 $this->ajax
= t3lib_div
::_GP('ajax') ?
TRUE : FALSE;
1670 // Initialize Clipboard object:
1671 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
1672 $clipObj->initializeClipboard();
1673 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1675 // Update clipboard if some actions are sent.
1676 $CB = t3lib_div
::_GET('CB');
1677 $clipObj->setCmd($CB);
1678 $clipObj->cleanCurrent();
1679 $clipObj->endClipboard(); // Saves
1681 // Create clickmenu object
1682 $clickMenu = t3lib_div
::makeInstance('clickMenu');
1684 // Set internal vars in clickmenu object:
1685 $clickMenu->clipObj
= $clipObj;
1686 $clickMenu->extClassArray
= $this->extClassArray
;
1687 $clickMenu->dontDisplayTopFrameCM
= $this->dontDisplayTopFrameCM
;
1688 $clickMenu->backPath
= $this->backPath
;
1692 $this->content
.= $this->doc
->startPage('Context Sensitive Menu');
1694 // Set content of the clickmenu with the incoming var, "item"
1695 $this->content
.= $clickMenu->init();
1699 * End page and output content.
1703 function printContent() {
1705 $this->content
.= $this->doc
->endPage();
1706 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
1707 echo $this->content
;
1709 $this->content
= $GLOBALS['LANG']->csConvObj
->utf8_encode($this->content
,$GLOBALS['LANG']->charSet
);
1710 t3lib_ajax
::outputXMLreply($this->content
);
1715 // Include extension?
1716 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']) {
1717 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']);
1730 $SOBE = t3lib_div
::makeInstance('SC_alt_clickmenu');
1734 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1737 $SOBE->printContent();