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 * 128: class clickMenu
50 * 160: function init($item)
51 * 203: function doDisplayTopFrameCM()
54 * 231: function printDBClickMenu($table,$uid)
55 * 318: function printNewDBLevel($table,$uid)
56 * 355: function externalProcessingOfDBMenuItems($menuItems)
57 * 367: function processingByExtClassArray($menuItems,$table,$uid)
58 * 386: function urlRefForCM($url,$retUrl='',$hideCM=1)
59 * 403: function DB_copycut($table,$uid,$type)
60 * 432: function DB_paste($table,$uid,$type,$elInfo)
61 * 453: function DB_info($table,$uid)
62 * 469: function DB_history($table,$uid)
63 * 488: function DB_perms($table,$uid,$rec)
64 * 507: function DB_db_list($table,$uid,$rec)
65 * 526: function DB_moveWizard($table,$uid,$rec)
66 * 547: function DB_newWizard($table,$uid,$rec)
67 * 570: function DB_editAccess($table,$uid)
68 * 588: function DB_editPageHeader($uid)
69 * 606: function DB_edit($table,$uid)
70 * 648: function DB_new($table,$uid)
71 * 673: function DB_delete($table,$uid,$elInfo)
72 * 694: function DB_view($id,$anchor='')
73 * 709: function DB_tempMountPoint($page_id)
74 * 727: function DB_hideUnhide($table,$rec,$hideField)
75 * 742: function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/')
78 * 776: function printFileClickMenu($path)
79 * 840: function externalProcessingOfFileMenuItems($menuItems)
80 * 854: function FILE_launch($path,$script,$type,$image)
81 * 874: function FILE_copycut($path,$type)
82 * 900: function FILE_delete($path)
83 * 922: function FILE_paste($path,$target,$elInfo)
86 * 962: function printItems($menuItems,$item)
87 * 1014: function printLayerJScode($menuItems)
88 * 1052: function wrapColorTableCM($str)
89 * 1075: function menuItemsForTopFrame($menuItems)
90 * 1092: function menuItemsForClickMenu($menuItems)
91 * 1126: function addMenuItems($menuItems,$newMenuItems,$position='')
92 * 1202: function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)
93 * 1226: function excludeIcon($iconCode)
94 * 1236: function enableDisableItems($menuItems)
95 * 1274: function cleanUpSpacers($menuItems)
96 * 1316: function label($label)
97 * 1325: function isCMlayers()
98 * 1335: function frameLocation($str)
101 * 1360: class SC_alt_clickmenu
102 * 1379: function init()
103 * 1477: function main()
104 * 1511: function printContent()
106 * TOTAL FUNCTIONS: 46
107 * (This index is automatically created/updated by the extension "extdeveval")
112 require ('init.php');
113 require ('template.php');
114 require_once (PATH_t3lib
.'class.t3lib_clipboard.php');
115 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
121 * Class for generating the click menu
123 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
130 // Internal, static: GPvar:
131 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
132 var $CB; // Clipboard array (submitted by eg. pressing the paste button)
135 var $backPath=''; // Backpath for scripts/images.
136 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)
137 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset.
138 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)
139 var $alwaysContentFrame=0; // If true, the "content" frame is always used for reference (when condensed mode is enabled)
140 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
141 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu
142 var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer.
143 var $leftIcons=0; // If true, Show icons on the left.
144 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.
146 // Internal, dynamic:
147 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
148 var $editPageIconSet=0; // Set, when edit icon is drawn.
149 var $editOK=0; // Set to true, if editing of the element is OK.
155 * Initialize click menu
157 * @param string Input "item" GET var.
158 * @return string The clickmenu HTML content
160 function init($item) {
163 $this->cmLevel
= intval(t3lib_div
::_GP('cmLevel'));
164 $this->CB
= t3lib_div
::_GP('CB');
167 // Explode the incoming command:
168 $this->iParts
= explode('|',$item);
171 if ($this->iParts
[2]) $this->listFrame
=1;
172 if ($GLOBALS['BE_USER']->uc
['condensedMode'] ||
$this->iParts
[2]==2) $this->alwaysContentFrame
=1;
173 if (strcmp($this->iParts
[1],'')) $this->isDBmenu
=1;
175 $TSkey =($this->isDBmenu?
'page':'folder').($this->listFrame?
'List':'Tree');
176 $this->disabledItems
= t3lib_div
::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
177 $this->leftIcons
= $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
179 // &cmLevel flag detected (2nd level menu)
180 if (!$this->cmLevel
) {
181 // Make 1st level clickmenu:
182 if ($this->isDBmenu
) {
183 $CMcontent = $this->printDBClickMenu($this->iParts
[0],$this->iParts
[1]);
185 $CMcontent = $this->printFileClickMenu($this->iParts
[0]);
188 // Make 2nd level clickmenu (only for DBmenus)
189 if ($this->isDBmenu
) {
190 $CMcontent = $this->printNewDBLevel($this->iParts
[0],$this->iParts
[1]);
194 // Return clickmenu conten:
199 * Returns true if the menu should (also?) be displayed in topframe, not just <div>-layers
203 function doDisplayTopFrameCM() {
204 return !$GLOBALS['SOBE']->doc
->isCMlayers() ||
!$this->dontDisplayTopFrameCM
;
218 /***************************************
222 ***************************************/
225 * Make 1st level clickmenu:
227 * @param string Table name
228 * @param integer UID for the current record.
229 * @return string HTML content
231 function printDBClickMenu($table,$uid) {
232 global $TCA, $BE_USER;
235 $this->rec
= t3lib_BEfunc
::getRecord($table,$uid);
238 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
242 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
243 if (is_array($this->rec
) ||
$root) {
244 t3lib_BEfunc
::workspaceOL($table,$this->rec
);
247 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
250 if (!in_array('view',$this->disabledItems
)) {
251 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
252 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec
['pid'],'#'.$uid);
256 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
257 if (!in_array('edit',$this->disabledItems
)) $menuItems['edit']=$this->DB_edit($table,$uid);
262 if (!in_array('new',$this->disabledItems
) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
265 if(!in_array('info',$this->disabledItems
) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
267 $menuItems['spacer1']='spacer';
270 if(!in_array('copy',$this->disabledItems
) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
272 if(!in_array('cut',$this->disabledItems
) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
275 $elFromAllTables = count($this->clipObj
->elFromTable(''));
276 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables) {
277 $selItem = $this->clipObj
->getSelectedRecord();
279 t3lib_div
::fixed_lgd_cs($selItem['_RECORD_TITLE'],$BE_USER->uc
['titleLen']),
280 ($root?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen'])),
281 $this->clipObj
->currentMode()
283 if ($table=='pages' && ($lCP & 8)) {
284 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
287 $elFromTable = count($this->clipObj
->elFromTable($table));
288 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
292 $elInfo=array(t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen']));
293 if(!in_array('delete',$this->disabledItems
) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
294 $menuItems['spacer2']='spacer';
295 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
299 // Adding external elements to the menuItems array
300 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
302 // Processing by external functions?
303 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
305 // Return the printed elements:
306 return $this->printItems($menuItems,
308 '<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']):
309 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
,1)
314 * Make 2nd level clickmenu (only for DBmenus)
316 * @param string Table name
317 * @param integer UID for the current record.
318 * @return string HTML content
320 function printNewDBLevel($table,$uid) {
321 global $TCA, $BE_USER;
323 // Setting internal record to the table/uid :
324 $this->rec
= t3lib_BEfunc
::getRecord($table,$uid);
327 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
331 // If record was found, check permissions and get menu items.
332 if (is_array($this->rec
) ||
$root) {
333 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
335 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
339 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
342 // Return the printed elements:
343 if (!is_array($menuItems)) $menuItems=array();
344 return $this->printItems($menuItems,
346 '<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']):
347 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
,1)
352 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
354 * @param array $menuItems array for manipulation.
355 * @return array Processed $menuItems array
357 function externalProcessingOfDBMenuItems($menuItems) {
362 * Processing the $menuItems array by external classes (typ. adding items)
364 * @param array $menuItems array for manipulation.
365 * @param string Table name
366 * @param integer UID for the current record.
367 * @return array Processed $menuItems array
369 function processingByExtClassArray($menuItems,$table,$uid) {
370 if (is_array($this->extClassArray
)) {
371 reset($this->extClassArray
);
372 while(list(,$conf)=each($this->extClassArray
)) {
373 $obj=t3lib_div
::makeInstance($conf['name']);
374 $menuItems = $obj->main($this,$menuItems,$table,$uid);
381 * Returning JavaScript for the onClick event linking to the input URL.
383 * @param string The URL relative to TYPO3_mainDir
384 * @param string The return_url-parameter
385 * @param boolean If set, the "hideCM()" will be called
386 * @return string JavaScript for an onClick event.
388 function urlRefForCM($url,$retUrl='',$hideCM=1) {
389 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
390 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.document.location=top.TS.PATH_typo3+\''.$url.'\''.
391 ($retUrl?
"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
392 ($hideCM?
'return hideCM();':'');
397 * Adding CM element for Clipboard "copy" and "cut"
399 * @param string Table name
400 * @param integer UID for the current record.
401 * @param string Type: "copy" or "cut"
402 * @return array Item array, element in $menuItems
405 function DB_copycut($table,$uid,$type) {
406 if ($this->clipObj
->current
=='normal') {
407 $isSel = $this->clipObj
->isSelected($table,$uid);
411 if ($this->listFrame
) {
412 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
415 return $this->linkItem(
417 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
418 "top.loadTopMenu('".$this->clipObj
->selUrlDB($table,$uid,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
423 * Adding CM element for Clipboard "paste into"/"paste after"
424 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
426 * @param string Table name
427 * @param integer UID for the current record. NOTICE: Special syntax!
428 * @param string Type: "into" or "after"
429 * @param array Contains instructions about whether to copy or cut an element.
430 * @return array Item array, element in $menuItems
431 * @see t3lib_clipboard::pasteUrl()
434 function DB_paste($table,$uid,$type,$elInfo) {
436 $loc = 'top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
437 $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])).')';
438 $editOnClick = 'if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj
->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
440 return $this->linkItem(
441 $this->label('paste'.$type),
442 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
443 $editOnClick.'return false;'
448 * Adding CM element for Info
450 * @param string Table name
451 * @param integer UID for the current record.
452 * @return array Item array, element in $menuItems
455 function DB_info($table,$uid) {
456 return $this->linkItem(
457 $this->label('info'),
458 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
459 "top.launchView('".$table."', '".$uid."'); return hideCM();"
464 * Adding CM element for History
466 * @param string Table name
467 * @param integer UID for the current record.
468 * @return array Item array, element in $menuItems
471 function DB_history($table,$uid) {
472 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
473 return $this->linkItem(
474 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
475 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
476 $this->urlRefForCM($url,'returnUrl'),
482 * Adding CM element for Permission setting
484 * @param string Table name
485 * @param integer UID for the current record.
486 * @param array The "pages" record with "perms_*" fields inside.
487 * @return array Item array, element in $menuItems
490 function DB_perms($table,$uid,$rec) {
491 $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':'');
492 return $this->linkItem(
493 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
494 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
495 $this->urlRefForCM($url),
501 * Adding CM element for DBlist
503 * @param string Table name
504 * @param integer UID for the current record.
505 * @param array Record of the element (needs "pid" field if not pages-record)
506 * @return array Item array, element in $menuItems
509 function DB_db_list($table,$uid,$rec) {
510 $url = t3lib_div
::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?
'':$table).'&id='.($table=='pages'?
$uid:$rec['pid']);
511 return $this->linkItem(
512 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
513 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/list.gif','width="11" height="11"').' alt="" />'),
514 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
520 * Adding CM element for Moving wizard
522 * @param string Table name
523 * @param integer UID for the current record.
524 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
525 * @return array Item array, element in $menuItems
528 function DB_moveWizard($table,$uid,$rec) {
529 $url = 'move_el.php?table='.$table.'&uid='.$uid.
530 ($table=='tt_content'?
'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
532 return $this->linkItem(
533 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?
'_page':''))),
534 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/move_'.($table=='pages'?
'page':'record').'.gif','width="11" height="12"').' alt="" />'),
535 $this->urlRefForCM($url,'returnUrl'),
541 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
543 * @param string Table name
544 * @param integer UID for the current record.
545 * @param array Record.
546 * @return array Item array, element in $menuItems
549 function DB_newWizard($table,$uid,$rec) {
550 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
551 $tmpTSc = t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
552 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
553 $newContentWizScriptPath = t3lib_extMgm
::isLoaded($tmpTSc) ?
(t3lib_extMgm
::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
555 $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']);
556 return $this->linkItem(
557 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
558 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/new_'.($table=='pages'?
'page':'record').'.gif','width="'.($table=='pages'?
'13':'16').'" height="12"').' alt="" />'),
559 $this->urlRefForCM($url,'returnUrl'),
565 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
567 * @param string Table name
568 * @param integer UID for the current record.
569 * @return array Item array, element in $menuItems
572 function DB_editAccess($table,$uid) {
573 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ?
',extendToSubpages' :''));
574 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
575 return $this->linkItem(
576 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
577 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
578 $this->urlRefForCM($url,'returnUrl'),
579 1 // no top frame CM!
584 * Adding CM element for edit page header
586 * @param integer page uid to edit (PID)
587 * @return array Item array, element in $menuItems
590 function DB_editPageHeader($uid) {
591 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
592 return $this->linkItem(
593 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
594 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
595 $this->urlRefForCM($url,'returnUrl'),
596 1 // no top frame CM!
601 * Adding CM element for regular editing of the element!
603 * @param string Table name
604 * @param integer UID for the current record.
605 * @return array Item array, element in $menuItems
608 function DB_edit($table,$uid) {
610 // If another module was specified, replace the default Page module with the new one
611 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
612 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
615 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
617 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"');
619 $this->iParts
[0]=='pages' &&
621 $BE_USER->check('modules', $pageModule)
623 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit_page.gif','width="12" height="12"');
624 $this->editPageIconSet
=1;
625 if ($BE_USER->uc
['classicPageEditMode'] ||
!t3lib_extMgm
::isLoaded('cms')) {
626 $addParam='&editRegularContentFromId='.intval($this->iParts
[1]);
628 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts
[1]).";top.goToModule('".$pageModule."',1);";
632 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
635 return $this->linkItem(
636 $this->label('edit'),
637 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
638 $editOnClick.'return hideCM();'
643 * Adding CM element for regular Create new element
645 * @param string Table name
646 * @param integer UID for the current record.
647 * @return array Item array, element in $menuItems
650 function DB_new($table,$uid) {
652 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
653 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
655 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
656 'db_new.php?id='.intval($uid)."'").
659 return $this->linkItem(
661 $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="" />'),
662 $editOnClick.'return hideCM();'
667 * Adding CM element for Delete
669 * @param string Table name
670 * @param integer UID for the current record.
671 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
672 * @return array Item array, element in $menuItems
675 function DB_delete($table,$uid,$elInfo) {
677 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
678 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0])).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
679 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
681 return $this->linkItem(
682 $this->label('delete'),
683 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
684 $editOnClick.'return false;'
689 * Adding CM element for View Page
691 * @param integer Page uid (PID)
692 * @param string Anchor, if any
693 * @return array Item array, element in $menuItems
696 function DB_view($id,$anchor='') {
697 return $this->linkItem(
698 $this->label('view'),
699 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
700 t3lib_BEfunc
::viewOnClick($id,$this->PH_backPath
,t3lib_BEfunc
::BEgetRootLine($id),$anchor).'return hideCM();'
705 * Adding element for setting temporary mount point.
707 * @param integer Page uid (PID)
708 * @return array Item array, element in $menuItems
711 function DB_tempMountPoint($page_id) {
712 return $this->linkItem(
713 $this->label('tempMountPoint'),
714 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/placeasroot.gif','width="14" height="12"').' alt="" />'),
716 "if (top.content.nav_frame) { top.content.nav_frame.document.location = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
721 * Adding CM element for hide/unhide of the input record
723 * @param string Table name
724 * @param array Record array
725 * @param string Name of the hide field
726 * @return array Item array, element in $menuItems
729 function DB_hideUnhide($table,$rec,$hideField) {
730 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?
'un':'').'hide'), 'hide');
734 * Adding CM element for a flag field of the input record
736 * @param string Table name
737 * @param array Record array
738 * @param string Name of the flag field
739 * @param string Menu item Title
740 * @param string Name of the item used for icons and labels
741 * @param string Icon path relative to typo3/ folder
742 * @return array Item array, element in $menuItems
744 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
745 $uid = $rec['_ORIG_uid'] ?
$rec['_ORIG_uid'] : $rec['uid'];
747 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
748 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
749 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?
0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
751 return $this->linkItem(
753 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,$iconRelPath.'button_'.($rec[$flagField]?
'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
754 $editOnClick.'return false;',
766 /***************************************
770 ***************************************/
773 * Make 1st level clickmenu:
775 * @param string The absolute path
776 * @return string HTML content
778 function printFileClickMenu($path) {
781 if (@file_exists
($path) && t3lib_div
::isAllowedAbsPath($path)) {
782 $fI = pathinfo($path);
783 $icon = is_dir($path) ?
'folder.gif' : t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
784 $size=' ('.t3lib_div
::formatSize(filesize($path)).'bytes)';
785 $icon = '<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
788 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');
790 if (!in_array('rename',$this->disabledItems
)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
792 if (!in_array('upload',$this->disabledItems
) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
794 if (!in_array('new',$this->disabledItems
) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
796 if (!in_array('info',$this->disabledItems
)) $menuItems['info']=$this->DB_info($path,'');
798 $menuItems[]='spacer';
801 if (!in_array('copy',$this->disabledItems
)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
803 if (!in_array('cut',$this->disabledItems
)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
806 $elFromAllTables = count($this->clipObj
->elFromTable('_FILE'));
807 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables && is_dir($path)) {
808 $elArr = $this->clipObj
->elFromTable('_FILE');
810 $selItem = current($elArr);
814 $this->clipObj
->currentMode()
816 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
819 $menuItems[]='spacer';
822 if (!in_array('delete',$this->disabledItems
)) $menuItems['delete']=$this->FILE_delete($path);
825 // Adding external elements to the menuItems array
826 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
828 // Processing by external functions?
829 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
831 // Return the printed elements:
832 return $this->printItems($menuItems,$icon.basename($path));
837 * Processing the $menuItems array (for extension classes) (FILES)
839 * @param array $menuItems array for manipulation.
840 * @return array Processed $menuItems array
842 function externalProcessingOfFileMenuItems($menuItems) {
847 * Multi-function for adding an entry to the $menuItems array
849 * @param string Path to the file/directory (target)
850 * @param string Script (eg. file_edit.php) to pass &target= to
851 * @param string "type" is the code which fetches the correct label for the element from "cm."
852 * @param string icon image-filename from "gfx/" (12x12 icon)
853 * @return array Item array, element in $menuItems
856 function FILE_launch($path,$script,$type,$image) {
857 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
859 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
861 return $this->linkItem(
863 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
864 $editOnClick.'return hideCM();'
869 * Returns element for copy or cut of files.
871 * @param string Path to the file/directory (target)
872 * @param string Type: "copy" or "cut"
873 * @return array Item array, element in $menuItems
876 function FILE_copycut($path,$type) {
877 $table = '_FILE'; // Pseudo table name for use in the clipboard.
878 $uid = t3lib_div
::shortmd5($path);
879 if ($this->clipObj
->current
=='normal') {
880 $isSel = $this->clipObj
->isSelected($table,$uid);
884 if ($this->listFrame
) {
885 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
888 return $this->linkItem(
890 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
891 "top.loadTopMenu('".$this->clipObj
->selUrlFile($path,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
896 * Creates element for deleting of target
898 * @param string Path to the file/directory (target)
899 * @return array Item array, element in $menuItems
902 function FILE_delete($path) {
904 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
905 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path))).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
906 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
908 return $this->linkItem(
909 $this->label('delete'),
910 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
911 $editOnClick.'return false;'
916 * Creates element for pasting files.
918 * @param string Path to the file/directory (target)
919 * @param string target - NOT USED.
920 * @param array Various values for the labels.
921 * @return array Item array, element in $menuItems
924 function FILE_paste($path,$target,$elInfo) {
926 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
927 $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])).")";
928 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj
->pasteUrl('_FILE',$path,0).
929 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
931 return $this->linkItem(
932 $this->label('pasteinto'),
933 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
934 $editOnClick.'return false;'
950 /***************************************
954 **************************************/
957 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
958 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
960 * @param array $menuItems array
961 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
962 * @return string HTML code
964 function printItems($menuItems,$item) {
968 // Enable/Disable items:
969 $menuItems = $this->enableDisableItems($menuItems);
972 $menuItems = $this->cleanUpSpacers($menuItems);
974 // Adding topframe part (horizontal clickmenu)
975 if ($this->doDisplayTopFrameCM()) {
979 Table, which contains the click menu when shown in the top frame of the backend:
981 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
985 <td class="c-item">'.
987 <td><img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
988 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
991 <!-- Close button: -->
992 <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>
994 <!-- The item of the clickmenu: -->
995 <td class="c-itemicon">'.$item.'</td>
1000 // Set remaining BACK_PATH to blank (if any)
1001 $out = str_replace($this->PH_backPath
,'',$out);
1004 $out.=$this->printLayerJScode($menuItems);
1006 // Return the content
1011 * Create the JavaScript section
1013 * @param array The $menuItems array to print
1014 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1016 function printLayerJScode($menuItems) {
1018 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
1019 $frameName = '.'.($this->listFrame ?
'list_frame' : 'nav_frame');
1020 if ($this->alwaysContentFrame
) $frameName='';
1022 // Create the table displayed in the clickmenu layer:
1024 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
1025 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
1028 // Wrap the inner table in another table to create outer border:
1029 $CMtable = $this->wrapColorTableCM($CMtable);
1031 // Set back path place holder to real back path
1032 $CMtable = str_replace($this->PH_backPath
,$this->backPath
,$CMtable);
1034 // Create JavaScript section:
1035 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1037 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
1038 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div
::rawurlencodeJS($CMtable).'"),'.$this->cmLevel
.');
1040 '.(!$this->doDisplayTopFrameCM()?
'hideCM();':'')
1048 * Wrapping the input string in a table with background color 4 and a black border style.
1049 * For the pop-up menu
1051 * @param string HTML content to wrap in table.
1054 function wrapColorTableCM($str) {
1056 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1057 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1059 <td class="c-aa">'.$str.'</td>
1060 <td class="c-ab"></td>
1063 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1064 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1071 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1073 * @param array $menuItem array
1074 * @param array Array with HTML content to be imploded between <td>-tags
1075 * @return array Array of menu items for top frame.
1077 function menuItemsForTopFrame($menuItems) {
1080 while(list(,$i)=each($menuItems)) {
1081 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)
1082 if (is_array($i) && !$i[4]) $out[]=$i[0];
1088 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1090 * @param array $menuItem array
1091 * @param array Array with HTML content to be imploded between <td>-tags
1092 * @return array array for implosion in the CM div-layers table.
1094 function menuItemsForClickMenu($menuItems) {
1097 while(list($cc,$i)=each($menuItems)) {
1098 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1100 <tr class="bgColor2">
1101 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1103 } else { // Just make normal element:
1105 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1106 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1107 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1108 if (!$i[5]) $onClick.='hideEmpty();';
1110 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
1111 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
1115 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5
.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
1116 '.(!$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>').'
1124 * Adds or inserts a menu item
1125 * 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.
1127 * @param array Menu items array
1128 * @param array Menu items array to insert
1129 * @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.
1130 * @return array Menu items array, processed.
1132 function addMenuItems($menuItems,$newMenuItems,$position='') {
1133 if (is_array($newMenuItems)) {
1137 $posArr = t3lib_div
::trimExplode(',', $position, 1);
1138 foreach($posArr as $pos) {
1139 list($place,$menuEntry) = t3lib_div
::trimExplode(':', $pos, 1);
1140 list($place,$placeExtra) = t3lib_div
::trimExplode('-', $place, 1);
1143 $pointer = count($menuItems);
1148 switch(strtolower($place)) {
1155 if (!strcmp(key($menuItems), $menuEntry)) {
1160 if (!next($menuItems)) break;
1165 if ($place=='before') {
1167 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
1170 } elseif ($place=='after') {
1171 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
1178 if (strtolower($place)=='top') {
1181 $pointer = count($menuItems);
1190 $pointer=max(0,$pointer);
1191 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?
$pointer:0));
1192 $menuItemsAfter = array_slice($menuItems, $pointer);
1193 $menuItems = $menuItemsBefore +
$newMenuItems +
$menuItemsAfter;
1199 * Creating an array with various elements for the clickmenu entry
1201 * @param string The label, htmlspecialchar'ed already
1202 * @param string <img>-tag for the icon
1203 * @param string JavaScript onclick event for label/icon
1204 * @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)
1205 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1206 * @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!
1208 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1211 $WHattribs = t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1214 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount
.'" alt="" />'.
1215 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount
.');" onmouseout="mout('.$this->elCount
.');">'.
1227 * Returns the input string IF not a user setting has disabled display of icons.
1229 * @param string The icon-image tag
1230 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1232 function excludeIcon($iconCode) {
1233 return ($GLOBALS['BE_USER']->uc
['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc
['noMenuMode'],'icons')) ?
'' : ' '.$iconCode;
1237 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1239 * @param array Menu items array
1240 * @return array Menu items array, processed.
1242 function enableDisableItems($menuItems) {
1243 if ($this->iParts
[3]) {
1245 // Detect "only" mode: (only showing listed items)
1246 if (substr($this->iParts
[3],0,1)=='+') {
1247 $this->iParts
[3] = substr($this->iParts
[3],1);
1254 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1255 $newMenuArray = array();
1256 foreach($menuItems as $key => $value) {
1257 if (t3lib_div
::inList($this->iParts
[3], $key) ||
(is_string($value) && $value=='spacer')) {
1258 $newMenuArray[$key] = $value;
1261 $menuItems = $newMenuArray;
1262 } else { // Traverse all elements except those listed (just unsetting them):
1263 $elements = t3lib_div
::trimExplode(',',$this->iParts
[3],1);
1264 foreach($elements as $value) {
1265 unset($menuItems[$value]);
1270 // Return processed menu items:
1275 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1277 * @param array Menu items array
1278 * @return array Menu items array, processed.
1280 function cleanUpSpacers($menuItems) {
1283 $prevItemWasSpacer = FALSE;
1284 foreach($menuItems as $key => $value) {
1285 if (is_string($value) && $value=='spacer') {
1286 if ($prevItemWasSpacer) {
1287 unset($menuItems[$key]);
1289 $prevItemWasSpacer = TRUE;
1291 $prevItemWasSpacer = FALSE;
1297 $key = key($menuItems);
1298 $value = current($menuItems);
1299 if (is_string($value) && $value=='spacer') {
1300 unset($menuItems[$key]);
1306 $key = key($menuItems);
1307 $value = current($menuItems);
1308 if (is_string($value) && $value=='spacer') {
1309 unset($menuItems[$key]);
1312 // Return processed menu items:
1317 * Get label from locallang_core.php:cm.*
1319 * @param string The "cm."-suffix to get.
1322 function label($label) {
1323 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1327 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1331 function isCMlayers() {
1332 return $GLOBALS['SOBE']->doc
->isCMlayers() && !$this->CB
;
1336 * Appends ".location" to input string
1338 * @param string Input string, probably a JavaScript document reference
1341 function frameLocation($str) {
1342 return $str.'.location';
1359 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1361 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1364 * @see template::getContextMenuCode()
1366 class SC_alt_clickmenu
{
1368 // Internal, static: GPvar:
1369 var $backPath; // Back path.
1370 var $item; // Definition of which item the click menu should be made for.
1371 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1374 var $content=''; // Content accumulation
1375 var $doc; // Template object
1376 var $include_once=array(); // Files to include_once() - set in init() function
1377 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1378 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1381 * Constructor function for script class.
1386 global $BE_USER,$BACK_PATH;
1389 $this->backPath
= t3lib_div
::_GP('backPath');
1390 $this->item
= t3lib_div
::_GP('item');
1391 $this->reloadListFrame
= t3lib_div
::_GP('reloadListFrame');
1393 // Setting pseudo module name
1394 $this->MCONF
['name']='xMOD_alt_clickmenu.php';
1396 // 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:
1397 $inputBP = explode('|',$this->backPath
);
1398 if (count($inputBP)==2 && $inputBP[1]==t3lib_div
::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1399 $this->backPath
= $inputBP[0];
1401 $this->backPath
= $BACK_PATH;
1404 // Setting internal array of classes for extending the clickmenu:
1405 $this->extClassArray
= $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1407 // Traversing that array and setting files for inclusion:
1408 if (is_array($this->extClassArray
)) {
1409 foreach($this->extClassArray
as $extClassConf) {
1410 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1414 // Initialize template object
1415 $this->doc
= t3lib_div
::makeInstance('template');
1416 $this->doc
->docType
='xhtml_trans';
1417 $this->doc
->backPath
= $BACK_PATH;
1419 // Setting mode for display and background image in the top frame
1420 $this->dontDisplayTopFrameCM
= $this->doc
->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1421 if ($this->dontDisplayTopFrameCM
) {
1422 $this->doc
->bodyTagId
.= '-notop';
1425 // Setting clickmenu timeout
1426 $secs = t3lib_div
::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1428 // Setting the JavaScript controlling the timer on the page
1429 $listFrameDoc = $this->reloadListFrame
!=2 ?
'top.content.list_frame' : 'top.content';
1430 $this->doc
->JScode
.=$this->doc
->wrapScriptTags('
1431 var date = new Date();
1432 var mo_timeout = Math.floor(date.getTime()/1000);
1435 roImg.src = "'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1437 routImg =new Image();
1438 routImg.src = "clear.gif";
1441 var name="roimg_"+c;
1442 document[name].src = roImg.src;
1445 function mout(c) { //
1446 var name="roimg_"+c;
1447 document[name].src = routImg.src;
1450 function updateTime() { //
1452 mo_timeout = Math.floor(date.getTime()/1000);
1454 function timeout_func() { //
1456 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1460 window.setTimeout("timeout_func();",1*1000);
1463 function hideCM() { //
1464 document.location="alt_topmenu_dummy.php";
1471 '.($this->reloadListFrame ?
'
1472 // Reload list frame:
1473 if('.$listFrameDoc.'){'.$listFrameDoc.'.document.location='.$listFrameDoc.'.document.location;}' :
1479 * Main function - generating the click menu in whatever form it has.
1485 // Initialize Clipboard object:
1486 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
1487 $clipObj->initializeClipboard();
1488 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1490 // Update clipboard if some actions are sent.
1491 $CB = t3lib_div
::_GET('CB');
1492 $clipObj->setCmd($CB);
1493 $clipObj->cleanCurrent();
1494 $clipObj->endClipboard(); // Saves
1496 // Create clickmenu object
1497 $clickMenu = t3lib_div
::makeInstance('clickMenu');
1499 // Set internal vars in clickmenu object:
1500 $clickMenu->clipObj
= $clipObj;
1501 $clickMenu->extClassArray
= $this->extClassArray
;
1502 $clickMenu->dontDisplayTopFrameCM
= $this->dontDisplayTopFrameCM
;
1503 $clickMenu->backPath
= $this->backPath
;
1506 $this->content
.=$this->doc
->startPage('Context Sensitive Menu');
1508 // Set content of the clickmenu with the incoming var, "item"
1509 $this->content
.= $clickMenu->init($this->item
);
1513 * End page and output content.
1517 function printContent() {
1518 $this->content
.= $this->doc
->endPage();
1519 echo $this->content
;
1523 // Include extension?
1524 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']) {
1525 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']);
1538 $SOBE = t3lib_div
::makeInstance('SC_alt_clickmenu');
1542 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1545 $SOBE->printContent();