2 /***************************************************************
5 * (c) 1999-2004 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, [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->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) {
245 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
248 if (!in_array('view',$this->disabledItems
)) {
249 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
250 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec
['pid'],'#'.$uid);
254 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
255 if (!in_array('edit',$this->disabledItems
)) $menuItems['edit']=$this->DB_edit($table,$uid);
260 if (!in_array('new',$this->disabledItems
) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
263 if(!in_array('info',$this->disabledItems
) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
265 $menuItems['spacer1']='spacer';
268 if(!in_array('copy',$this->disabledItems
) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
270 if(!in_array('cut',$this->disabledItems
) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
273 $elFromAllTables = count($this->clipObj
->elFromTable(''));
274 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables) {
275 $selItem = $this->clipObj
->getSelectedRecord();
277 $selItem['_RECORD_TITLE'],
278 ($root?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen'])),
279 $this->clipObj
->currentMode()
281 if ($table=='pages' && ($lCP & 8)) {
282 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
285 $elFromTable = count($this->clipObj
->elFromTable($table));
286 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
290 $elInfo=array(t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen']));
291 if(!in_array('delete',$this->disabledItems
) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
292 $menuItems['spacer2']='spacer';
293 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
297 // Adding external elements to the menuItems array
298 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
300 // Processing by external functions?
301 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
303 // Return the printed elements:
304 return $this->printItems($menuItems,
306 '<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']):
307 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)
312 * Make 2nd level clickmenu (only for DBmenus)
314 * @param string Table name
315 * @param integer UID for the current record.
316 * @return string HTML content
318 function printNewDBLevel($table,$uid) {
319 global $TCA, $BE_USER;
321 // Setting internal record to the table/uid :
322 $this->rec
= t3lib_BEfunc
::getRecord($table,$uid);
325 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
329 // If record was found, check permissions and get menu items.
330 if (is_array($this->rec
) ||
$root) {
331 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
333 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
337 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
340 // Return the printed elements:
341 if (!is_array($menuItems)) $menuItems=array();
342 return $this->printItems($menuItems,
344 '<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']):
345 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)
350 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
352 * @param array $menuItems array for manipulation.
353 * @return array Processed $menuItems array
355 function externalProcessingOfDBMenuItems($menuItems) {
360 * Processing the $menuItems array by external classes (typ. adding items)
362 * @param array $menuItems array for manipulation.
363 * @param string Table name
364 * @param integer UID for the current record.
365 * @return array Processed $menuItems array
367 function processingByExtClassArray($menuItems,$table,$uid) {
368 if (is_array($this->extClassArray
)) {
369 reset($this->extClassArray
);
370 while(list(,$conf)=each($this->extClassArray
)) {
371 $obj=t3lib_div
::makeInstance($conf['name']);
372 $menuItems = $obj->main($this,$menuItems,$table,$uid);
379 * Returning JavaScript for the onClick event linking to the input URL.
381 * @param string The URL relative to TYPO3_mainDir
382 * @param string The return_url-parameter
383 * @param boolean If set, the "hideCM()" will be called
384 * @return string JavaScript for an onClick event.
386 function urlRefForCM($url,$retUrl='',$hideCM=1) {
387 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
388 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.document.location=top.TS.PATH_typo3+\''.$url.'\''.
389 ($retUrl?
"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
390 ($hideCM?
'return hideCM();':'');
395 * Adding CM element for Clipboard "copy" and "cut"
397 * @param string Table name
398 * @param integer UID for the current record.
399 * @param string Type: "copy" or "cut"
400 * @return array Item array, element in $menuItems
403 function DB_copycut($table,$uid,$type) {
404 if ($this->clipObj
->current
=='normal') {
405 $isSel = $this->clipObj
->isSelected($table,$uid);
409 if ($this->listFrame
) {
410 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
413 return $this->linkItem(
415 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
416 "top.loadTopMenu('".$this->clipObj
->selUrlDB($table,$uid,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
421 * Adding CM element for Clipboard "paste into"/"paste after"
422 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
424 * @param string Table name
425 * @param integer UID for the current record. NOTICE: Special syntax!
426 * @param string Type: "into" or "after"
427 * @param array Contains instructions about whether to copy or cut an element.
428 * @return array Item array, element in $menuItems
429 * @see t3lib_clipboard::pasteUrl()
432 function DB_paste($table,$uid,$type,$elInfo) {
434 $loc = 'top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
435 $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])).')';
436 $editOnClick = 'if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj
->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
438 return $this->linkItem(
439 $this->label('paste'.$type),
440 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
441 $editOnClick.'return false;'
446 * Adding CM element for Info
448 * @param string Table name
449 * @param integer UID for the current record.
450 * @return array Item array, element in $menuItems
453 function DB_info($table,$uid) {
454 return $this->linkItem(
455 $this->label('info'),
456 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
457 "top.launchView('".$table."', '".$uid."'); return hideCM();"
462 * Adding CM element for History
464 * @param string Table name
465 * @param integer UID for the current record.
466 * @return array Item array, element in $menuItems
469 function DB_history($table,$uid) {
470 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
471 return $this->linkItem(
472 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
473 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
474 $this->urlRefForCM($url,'returnUrl'),
480 * Adding CM element for Permission setting
482 * @param string Table name
483 * @param integer UID for the current record.
484 * @param array The "pages" record with "perms_*" fields inside.
485 * @return array Item array, element in $menuItems
488 function DB_perms($table,$uid,$rec) {
489 $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':'');
490 return $this->linkItem(
491 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
492 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
493 $this->urlRefForCM($url),
499 * Adding CM element for DBlist
501 * @param string Table name
502 * @param integer UID for the current record.
503 * @param array Record of the element (needs "pid" field if not pages-record)
504 * @return array Item array, element in $menuItems
507 function DB_db_list($table,$uid,$rec) {
508 $url = t3lib_div
::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?
'':$table).'&id='.($table=='pages'?
$uid:$rec['pid']);
509 return $this->linkItem(
510 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
511 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/list.gif','width="11" height="11"').' alt="" />'),
512 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
518 * Adding CM element for Moving wizard
520 * @param string Table name
521 * @param integer UID for the current record.
522 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
523 * @return array Item array, element in $menuItems
526 function DB_moveWizard($table,$uid,$rec) {
527 $url = 'move_el.php?table='.$table.'&uid='.$uid.
528 ($table=='tt_content'?
'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
530 return $this->linkItem(
531 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?
'_page':''))),
532 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/move_'.($table=='pages'?
'page':'record').'.gif','width="11" height="12"').' alt="" />'),
533 $this->urlRefForCM($url,'returnUrl'),
539 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
541 * @param string Table name
542 * @param integer UID for the current record.
543 * @param array Record.
544 * @return array Item array, element in $menuItems
547 function DB_newWizard($table,$uid,$rec) {
548 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
549 $tmpTSc = t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
550 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
551 $newContentWizScriptPath = t3lib_extMgm
::isLoaded($tmpTSc) ?
(t3lib_extMgm
::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
553 $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']);
554 return $this->linkItem(
555 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
556 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/new_'.($table=='pages'?
'page':'record').'.gif','width="'.($table=='pages'?
'13':'16').'" height="12"').' alt="" />'),
557 $this->urlRefForCM($url,'returnUrl'),
563 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
565 * @param string Table name
566 * @param integer UID for the current record.
567 * @return array Item array, element in $menuItems
570 function DB_editAccess($table,$uid) {
571 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ?
',extendToSubpages' :''));
572 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
573 return $this->linkItem(
574 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
575 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
576 $this->urlRefForCM($url,'returnUrl'),
577 1 // no top frame CM!
582 * Adding CM element for edit page header
584 * @param integer page uid to edit (PID)
585 * @return array Item array, element in $menuItems
588 function DB_editPageHeader($uid) {
589 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
590 return $this->linkItem(
591 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
592 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
593 $this->urlRefForCM($url,'returnUrl'),
594 1 // no top frame CM!
599 * Adding CM element for regular editing of the element!
601 * @param string Table name
602 * @param integer UID for the current record.
603 * @return array Item array, element in $menuItems
606 function DB_edit($table,$uid) {
608 // If another module was specified, replace the default Page module with the new one
609 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
610 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
613 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
615 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"');
617 $this->iParts
[0]=='pages' &&
619 $BE_USER->check('modules', $pageModule)
621 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit_page.gif','width="12" height="12"');
622 $this->editPageIconSet
=1;
623 if ($BE_USER->uc
['classicPageEditMode'] ||
!t3lib_extMgm
::isLoaded('cms')) {
624 $addParam='&editRegularContentFromId='.intval($this->iParts
[1]);
626 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts
[1]).";top.goToModule('".$pageModule."',1);";
630 $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."';}";
633 return $this->linkItem(
634 $this->label('edit'),
635 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
636 $editOnClick.'return hideCM();'
641 * Adding CM element for regular Create new element
643 * @param string Table name
644 * @param integer UID for the current record.
645 * @return array Item array, element in $menuItems
648 function DB_new($table,$uid) {
650 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
651 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
653 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
654 'db_new.php?id='.intval($uid)."'").
657 return $this->linkItem(
659 $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="" />'),
660 $editOnClick.'return hideCM();'
665 * Adding CM element for Delete
667 * @param string Table name
668 * @param integer UID for the current record.
669 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
670 * @return array Item array, element in $menuItems
673 function DB_delete($table,$uid,$elInfo) {
675 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
676 $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').")+'".
677 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
679 return $this->linkItem(
680 $this->label('delete'),
681 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
682 $editOnClick.'return false;'
687 * Adding CM element for View Page
689 * @param integer Page uid (PID)
690 * @param string Anchor, if any
691 * @return array Item array, element in $menuItems
694 function DB_view($id,$anchor='') {
695 return $this->linkItem(
696 $this->label('view'),
697 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
698 t3lib_BEfunc
::viewOnClick($id,$this->PH_backPath
,t3lib_BEfunc
::BEgetRootLine($id),$anchor).'return hideCM();'
703 * Adding element for setting temporary mount point.
705 * @param integer Page uid (PID)
706 * @return array Item array, element in $menuItems
709 function DB_tempMountPoint($page_id) {
710 return $this->linkItem(
711 $this->label('tempMountPoint'),
712 #$this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/___.gif','width="12" height="12"').' alt="" />'),
714 "if (top.content.nav_frame) { top.content.nav_frame.document.location = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
719 * Adding CM element for hide/unhide of the input record
721 * @param string Table name
722 * @param array Record array
723 * @param string Name of the hide field
724 * @return array Item array, element in $menuItems
727 function DB_hideUnhide($table,$rec,$hideField) {
728 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?
'un':'').'hide'), 'hide');
732 * Adding CM element for a flag field of the input record
734 * @param string Table name
735 * @param array Record array
736 * @param string Name of the flag field
737 * @param string Menu item Title
738 * @param string Name of the item used for icons and labels
739 * @param string Icon path relative to typo3/ folder
740 * @return array Item array, element in $menuItems
742 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
745 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
746 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
747 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?
0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
749 return $this->linkItem(
751 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,$iconRelPath.'button_'.($rec[$flagField]?
'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
752 $editOnClick.'return false;',
764 /***************************************
768 ***************************************/
771 * Make 1st level clickmenu:
773 * @param string The absolute path
774 * @return string HTML content
776 function printFileClickMenu($path) {
779 if (@file_exists
($path) && t3lib_div
::isAllowedAbsPath($path)) {
780 $fI = pathinfo($path);
781 $icon = is_dir($path) ?
'folder.gif' : t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
782 $size=' ('.t3lib_div
::formatSize(filesize($path)).'bytes)';
783 $icon = '<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
786 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');
788 if (!in_array('rename',$this->disabledItems
)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
790 if (!in_array('upload',$this->disabledItems
) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
792 if (!in_array('new',$this->disabledItems
) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
794 if (!in_array('info',$this->disabledItems
)) $menuItems['info']=$this->DB_info($path,'');
796 $menuItems[]='spacer';
799 if (!in_array('copy',$this->disabledItems
)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
801 if (!in_array('cut',$this->disabledItems
)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
804 $elFromAllTables = count($this->clipObj
->elFromTable('_FILE'));
805 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables && is_dir($path)) {
806 $elArr = $this->clipObj
->elFromTable('_FILE');
808 $selItem = current($elArr);
812 $this->clipObj
->currentMode()
814 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
817 $menuItems[]='spacer';
820 if (!in_array('delete',$this->disabledItems
)) $menuItems['delete']=$this->FILE_delete($path);
823 // Adding external elements to the menuItems array
824 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
826 // Processing by external functions?
827 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
829 // Return the printed elements:
830 return $this->printItems($menuItems,$icon.basename($path));
835 * Processing the $menuItems array (for extension classes) (FILES)
837 * @param array $menuItems array for manipulation.
838 * @return array Processed $menuItems array
840 function externalProcessingOfFileMenuItems($menuItems) {
845 * Multi-function for adding an entry to the $menuItems array
847 * @param string Path to the file/directory (target)
848 * @param string Script (eg. file_edit.php) to pass &target= to
849 * @param string "type" is the code which fetches the correct label for the element from "cm."
850 * @param string icon image-filename from "gfx/" (12x12 icon)
851 * @return array Item array, element in $menuItems
854 function FILE_launch($path,$script,$type,$image) {
855 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
857 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
859 return $this->linkItem(
861 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
862 $editOnClick.'return hideCM();'
867 * Returns element for copy or cut of files.
869 * @param string Path to the file/directory (target)
870 * @param string Type: "copy" or "cut"
871 * @return array Item array, element in $menuItems
874 function FILE_copycut($path,$type) {
875 $table = '_FILE'; // Pseudo table name for use in the clipboard.
876 $uid = t3lib_div
::shortmd5($path);
877 if ($this->clipObj
->current
=='normal') {
878 $isSel = $this->clipObj
->isSelected($table,$uid);
882 if ($this->listFrame
) {
883 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
886 return $this->linkItem(
888 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
889 "top.loadTopMenu('".$this->clipObj
->selUrlFile($path,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
894 * Creates element for deleting of target
896 * @param string Path to the file/directory (target)
897 * @return array Item array, element in $menuItems
900 function FILE_delete($path) {
902 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
903 $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').")+'".
904 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
906 return $this->linkItem(
907 $this->label('delete'),
908 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
909 $editOnClick.'return false;'
914 * Creates element for pasting files.
916 * @param string Path to the file/directory (target)
917 * @param string target - NOT USED.
918 * @param array Various values for the labels.
919 * @return array Item array, element in $menuItems
922 function FILE_paste($path,$target,$elInfo) {
924 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
925 $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])).")";
926 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj
->pasteUrl('_FILE',$path,0).
927 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
929 return $this->linkItem(
930 $this->label('pasteinto'),
931 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
932 $editOnClick.'return false;'
948 /***************************************
952 **************************************/
955 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
956 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
958 * @param array $menuItems array
959 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
960 * @return string HTML code
962 function printItems($menuItems,$item) {
966 // Enable/Disable items:
967 $menuItems = $this->enableDisableItems($menuItems);
970 $menuItems = $this->cleanUpSpacers($menuItems);
972 // Adding topframe part (horizontal clickmenu)
973 if ($this->doDisplayTopFrameCM()) {
977 Table, which contains the click menu when shown in the top frame of the backend:
979 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
983 <td class="c-item">'.
985 <td><img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
986 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
989 <!-- Close button: -->
990 <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>
992 <!-- The item of the clickmenu: -->
993 <td class="c-itemicon">'.$item.'</td>
998 // Set remaining BACK_PATH to blank (if any)
999 $out = str_replace($this->PH_backPath
,'',$out);
1002 $out.=$this->printLayerJScode($menuItems);
1004 // Return the content
1009 * Create the JavaScript section
1011 * @param array The $menuItems array to print
1012 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1014 function printLayerJScode($menuItems) {
1016 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
1017 $frameName = '.'.($this->listFrame ?
'list_frame' : 'nav_frame');
1018 if ($this->alwaysContentFrame
) $frameName='';
1020 // Create the table displayed in the clickmenu layer:
1022 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
1023 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
1026 // Wrap the inner table in another table to create outer border:
1027 $CMtable = $this->wrapColorTableCM($CMtable);
1029 // Set back path place holder to real back path
1030 $CMtable = str_replace($this->PH_backPath
,$this->backPath
,$CMtable);
1032 // Create JavaScript section:
1033 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1035 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
1036 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div
::rawurlencodeJS($CMtable).'"),'.$this->cmLevel
.');
1038 '.(!$this->doDisplayTopFrameCM()?
'hideCM();':'')
1046 * Wrapping the input string in a table with background color 4 and a black border style.
1047 * For the pop-up menu
1049 * @param string HTML content to wrap in table.
1052 function wrapColorTableCM($str) {
1054 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1055 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1057 <td class="c-aa">'.$str.'</td>
1058 <td class="c-ab"></td>
1061 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1062 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1069 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1071 * @param array $menuItem array
1072 * @param array Array with HTML content to be imploded between <td>-tags
1073 * @return array Array of menu items for top frame.
1075 function menuItemsForTopFrame($menuItems) {
1078 while(list(,$i)=each($menuItems)) {
1079 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)
1080 if (is_array($i) && !$i[4]) $out[]=$i[0];
1086 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1088 * @param array $menuItem array
1089 * @param array Array with HTML content to be imploded between <td>-tags
1090 * @return array array for implosion in the CM div-layers table.
1092 function menuItemsForClickMenu($menuItems) {
1095 while(list($cc,$i)=each($menuItems)) {
1096 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1098 <tr class="bgColor2">
1099 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1101 } else { // Just make normal element:
1103 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1104 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1105 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1106 if (!$i[5]) $onClick.='hideEmpty();';
1109 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5
.'\';" onmouseout="this.bgColor=\'\';">
1110 '.(!$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>').'
1118 * Adds or inserts a menu item
1119 * 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.
1121 * @param array Menu items array
1122 * @param array Menu items array to insert
1123 * @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.
1124 * @return array Menu items array, processed.
1126 function addMenuItems($menuItems,$newMenuItems,$position='') {
1127 if (is_array($newMenuItems)) {
1131 $posArr = t3lib_div
::trimExplode(',', $position, 1);
1132 foreach($posArr as $pos) {
1133 list($place,$menuEntry) = t3lib_div
::trimExplode(':', $pos, 1);
1134 list($place,$placeExtra) = t3lib_div
::trimExplode('-', $place, 1);
1137 $pointer = count($menuItems);
1142 switch(strtolower($place)) {
1149 if (!strcmp(key($menuItems), $menuEntry)) {
1154 if (!next($menuItems)) break;
1159 if ($place=='before') {
1161 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
1164 } elseif ($place=='after') {
1165 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
1172 if (strtolower($place)=='top') {
1175 $pointer = count($menuItems);
1184 $pointer=max(0,$pointer);
1185 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?
$pointer:0));
1186 $menuItemsAfter = array_slice($menuItems, $pointer);
1187 $menuItems = $menuItemsBefore +
$newMenuItems +
$menuItemsAfter;
1193 * Creating an array with various elements for the clickmenu entry
1195 * @param string The label, htmlspecialchar'ed already
1196 * @param string <img>-tag for the icon
1197 * @param string JavaScript onclick event for label/icon
1198 * @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)
1199 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1200 * @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!
1202 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1205 $WHattribs = t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1208 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount
.'" alt="" />'.
1209 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount
.');" onmouseout="mout('.$this->elCount
.');">'.
1221 * Returns the input string IF not a user setting has disabled display of icons.
1223 * @param string The icon-image tag
1224 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1226 function excludeIcon($iconCode) {
1227 return ($GLOBALS['BE_USER']->uc
['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc
['noMenuMode'],'icons')) ?
'' : ' '.$iconCode;
1231 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1233 * @param array Menu items array
1234 * @return array Menu items array, processed.
1236 function enableDisableItems($menuItems) {
1237 if ($this->iParts
[3]) {
1239 // Detect "only" mode: (only showing listed items)
1240 if (substr($this->iParts
[3],0,1)=='+') {
1241 $this->iParts
[3] = substr($this->iParts
[3],1);
1248 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1249 $newMenuArray = array();
1250 foreach($menuItems as $key => $value) {
1251 if (t3lib_div
::inList($this->iParts
[3], $key) ||
(is_string($value) && $value=='spacer')) {
1252 $newMenuArray[$key] = $value;
1255 $menuItems = $newMenuArray;
1256 } else { // Traverse all elements except those listed (just unsetting them):
1257 $elements = t3lib_div
::trimExplode(',',$this->iParts
[3],1);
1258 foreach($elements as $value) {
1259 unset($menuItems[$value]);
1264 // Return processed menu items:
1269 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1271 * @param array Menu items array
1272 * @return array Menu items array, processed.
1274 function cleanUpSpacers($menuItems) {
1277 $prevItemWasSpacer = FALSE;
1278 foreach($menuItems as $key => $value) {
1279 if (is_string($value) && $value=='spacer') {
1280 if ($prevItemWasSpacer) {
1281 unset($menuItems[$key]);
1283 $prevItemWasSpacer = TRUE;
1285 $prevItemWasSpacer = FALSE;
1291 $key = key($menuItems);
1292 $value = current($menuItems);
1293 if (is_string($value) && $value=='spacer') {
1294 unset($menuItems[$key]);
1300 $key = key($menuItems);
1301 $value = current($menuItems);
1302 if (is_string($value) && $value=='spacer') {
1303 unset($menuItems[$key]);
1306 // Return processed menu items:
1311 * Get label from locallang_core.php:cm.*
1313 * @param string The "cm."-suffix to get.
1316 function label($label) {
1317 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1321 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1325 function isCMlayers() {
1326 return $GLOBALS['SOBE']->doc
->isCMlayers() && !$this->CB
;
1330 * Appends ".location" to input string
1332 * @param string Input string, probably a JavaScript document reference
1335 function frameLocation($str) {
1336 return $str.'.location';
1353 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1355 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1358 * @see template::getContextMenuCode()
1360 class SC_alt_clickmenu
{
1362 // Internal, static: GPvar:
1363 var $backPath; // Back path.
1364 var $item; // Definition of which item the click menu should be made for.
1365 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1368 var $content=''; // Content accumulation
1369 var $doc; // Template object
1370 var $include_once=array(); // Files to include_once() - set in init() function
1371 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1372 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1375 * Constructor function for script class.
1380 global $BE_USER,$BACK_PATH;
1383 $this->backPath
= t3lib_div
::_GP('backPath');
1384 $this->item
= t3lib_div
::_GP('item');
1385 $this->reloadListFrame
= t3lib_div
::_GP('reloadListFrame');
1387 // Setting pseudo module name
1388 $this->MCONF
['name']='xMOD_alt_clickmenu.php';
1390 // 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:
1391 $inputBP = explode('|',$this->backPath
);
1392 if (count($inputBP)==2 && $inputBP[1]==t3lib_div
::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1393 $this->backPath
= $inputBP[0];
1395 $this->backPath
= $BACK_PATH;
1398 // Setting internal array of classes for extending the clickmenu:
1399 $this->extClassArray
= $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1401 // Traversing that array and setting files for inclusion:
1402 if (is_array($this->extClassArray
)) {
1403 foreach($this->extClassArray
as $extClassConf) {
1404 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1408 // Initialize template object
1409 $this->doc
= t3lib_div
::makeInstance('template');
1410 $this->doc
->docType
='xhtml_trans';
1411 $this->doc
->backPath
= $BACK_PATH;
1413 // Setting mode for display and background image in the top frame
1414 $this->dontDisplayTopFrameCM
= $this->doc
->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1415 if ($this->dontDisplayTopFrameCM
) {
1416 $this->doc
->bodyTagId
.= '-notop';
1419 // Setting clickmenu timeout
1420 $secs = t3lib_div
::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1422 // Setting the JavaScript controlling the timer on the page
1423 $listFrameDoc = $this->reloadListFrame
!=2 ?
'top.content.list_frame' : 'top.content';
1424 $this->doc
->JScode
.=$this->doc
->wrapScriptTags('
1425 var date = new Date();
1426 var mo_timeout = Math.floor(date.getTime()/1000);
1429 roImg.src = "'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1431 routImg =new Image();
1432 routImg.src = "clear.gif";
1435 var name="roimg_"+c;
1436 document[name].src = roImg.src;
1439 function mout(c) { //
1440 var name="roimg_"+c;
1441 document[name].src = routImg.src;
1444 function updateTime() { //
1446 mo_timeout = Math.floor(date.getTime()/1000);
1448 function timeout_func() { //
1450 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1454 window.setTimeout("timeout_func();",1*1000);
1457 function hideCM() { //
1458 document.location="alt_topmenu_dummy.php";
1465 '.($this->reloadListFrame ?
'
1466 // Reload list frame:
1467 if('.$listFrameDoc.'){'.$listFrameDoc.'.document.location='.$listFrameDoc.'.document.location;}' :
1473 * Main function - generating the click menu in whatever form it has.
1479 // Initialize Clipboard object:
1480 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
1481 $clipObj->initializeClipboard();
1482 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1484 // Update clipboard if some actions are sent.
1485 $CB = t3lib_div
::_GET('CB');
1486 $clipObj->setCmd($CB);
1487 $clipObj->cleanCurrent();
1488 $clipObj->endClipboard(); // Saves
1490 // Create clickmenu object
1491 $clickMenu = t3lib_div
::makeInstance('clickMenu');
1493 // Set internal vars in clickmenu object:
1494 $clickMenu->clipObj
= $clipObj;
1495 $clickMenu->extClassArray
= $this->extClassArray
;
1496 $clickMenu->dontDisplayTopFrameCM
= $this->dontDisplayTopFrameCM
;
1497 $clickMenu->backPath
= $this->backPath
;
1500 $this->content
.=$this->doc
->startPage('Context Sensitive Menu');
1502 // Set content of the clickmenu with the incoming var, "item"
1503 $this->content
.= $clickMenu->init($this->item
);
1507 * End page and output content.
1511 function printContent() {
1512 $this->content
.= $this->doc
->endPage();
1513 echo $this->content
;
1517 // Include extension?
1518 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']) {
1519 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']);
1532 $SOBE = t3lib_div
::makeInstance('SC_alt_clickmenu');
1536 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1539 $SOBE->printContent();