2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
45 * [CLASS/FUNCTION INDEX of SCRIPT]
49 * 125: class clickMenu
50 * 157: function init($item)
51 * 200: function doDisplayTopFrameCM()
54 * 228: function printDBClickMenu($table,$uid)
55 * 315: function printNewDBLevel($table,$uid)
56 * 352: function externalProcessingOfDBMenuItems($menuItems)
57 * 364: function processingByExtClassArray($menuItems,$table,$uid)
58 * 383: function urlRefForCM($url,$retUrl='',$hideCM=1)
59 * 400: function DB_copycut($table,$uid,$type)
60 * 429: function DB_paste($table,$uid,$type,$elInfo)
61 * 450: function DB_info($table,$uid)
62 * 466: function DB_history($table,$uid)
63 * 485: function DB_perms($table,$uid,$rec)
64 * 504: function DB_db_list($table,$uid,$rec)
65 * 523: function DB_moveWizard($table,$uid,$rec)
66 * 544: function DB_newWizard($table,$uid,$rec)
67 * 567: function DB_editAccess($table,$uid)
68 * 585: function DB_editPageHeader($uid)
69 * 603: function DB_edit($table,$uid)
70 * 645: function DB_new($table,$uid)
71 * 670: function DB_hideUnhide($table,$rec,$hideField)
72 * 694: function DB_delete($table,$uid,$elInfo)
73 * 715: function DB_view($id,$anchor='')
76 * 744: function printFileClickMenu($path)
77 * 808: function externalProcessingOfFileMenuItems($menuItems)
78 * 822: function FILE_launch($path,$script,$type,$image)
79 * 841: function FILE_copycut($path,$type)
80 * 867: function FILE_delete($path)
81 * 889: function FILE_paste($path,$target,$elInfo)
84 * 929: function printItems($menuItems,$item)
85 * 981: function printLayerJScode($menuItems)
86 * 1019: function wrapColorTableCM($str)
87 * 1042: function menuItemsForTopFrame($menuItems)
88 * 1059: function menuItemsForClickMenu($menuItems)
89 * 1094: function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)
90 * 1118: function excludeIcon($iconCode)
91 * 1128: function enableDisableItems($menuItems)
92 * 1166: function cleanUpSpacers($menuItems)
93 * 1208: function label($label)
94 * 1217: function isCMlayers()
95 * 1227: function frameLocation($str)
98 * 1252: class SC_alt_clickmenu
99 * 1271: function init()
100 * 1369: function main()
101 * 1403: function printContent()
103 * TOTAL FUNCTIONS: 43
104 * (This index is automatically created/updated by the extension "extdeveval")
109 require ('init.php');
110 require ('template.php');
111 require_once (PATH_t3lib
.'class.t3lib_clipboard.php');
112 $LANG->includeLLFile('EXT:lang/locallang_misc.php');
118 * Class for generating the click menu
120 * @author Kasper Skaarhoj <kasper@typo3.com>
127 // Internal, static: GPvar:
128 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
129 var $CB; // Clipboard array (submitted by eg. pressing the paste button)
132 var $backPath=''; // Backpath for scripts/images.
133 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)
134 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset.
135 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)
136 var $alwaysContentFrame=0; // If true, the "content" frame is always used for reference (when condensed mode is enabled)
137 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
138 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu
139 var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer.
140 var $leftIcons=0; // If true, Show icons on the left.
141 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.
143 // Internal, dynamic:
144 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
145 var $editPageIconSet=0; // Set, when edit icon is drawn.
146 var $editOK=0; // Set to true, if editing of the element is OK.
152 * Initialize click menu
154 * @param string Input "item" GET var.
155 * @return string The clickmenu HTML content
157 function init($item) {
160 $this->cmLevel
= intval(t3lib_div
::_GP('cmLevel'));
161 $this->CB
= t3lib_div
::_GP('CB');
164 // Explode the incoming command:
165 $this->iParts
= explode('|',$item);
168 if ($this->iParts
[2]) $this->listFrame
=1;
169 if ($GLOBALS['BE_USER']->uc
['condensedMode']) $this->alwaysContentFrame
=1;
170 if (strcmp($this->iParts
[1],'')) $this->isDBmenu
=1;
172 $TSkey =($this->isDBmenu?
'page':'folder').($this->listFrame?
'List':'Tree');
173 $this->disabledItems
= t3lib_div
::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
174 $this->leftIcons
= $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
176 // &cmLevel flag detected (2nd level menu)
177 if (!$this->cmLevel
) {
178 // Make 1st level clickmenu:
179 if ($this->isDBmenu
) {
180 $CMcontent = $this->printDBClickMenu($this->iParts
[0],$this->iParts
[1]);
182 $CMcontent = $this->printFileClickMenu($this->iParts
[0]);
185 // Make 2nd level clickmenu (only for DBmenus)
186 if ($this->isDBmenu
) {
187 $CMcontent = $this->printNewDBLevel($this->iParts
[0],$this->iParts
[1]);
191 // Return clickmenu conten:
196 * Returns true if the menu should (also?) be displayed in topframe, not just <div>-layers
200 function doDisplayTopFrameCM() {
201 return !$GLOBALS['SOBE']->doc
->isCMlayers() ||
!$this->dontDisplayTopFrameCM
;
215 /***************************************
219 ***************************************/
222 * Make 1st level clickmenu:
224 * @param string Table name
225 * @param integer UID for the current record.
226 * @return string HTML content
228 function printDBClickMenu($table,$uid) {
229 global $TCA, $BE_USER;
232 $this->rec
= t3lib_BEfunc
::getRecord($table,$uid);
235 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
239 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
240 if (is_array($this->rec
) ||
$root) {
242 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
245 if (!in_array('view',$this->disabledItems
)) {
246 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
247 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec
['pid'],'#'.$uid);
251 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
252 if (!in_array('edit',$this->disabledItems
)) $menuItems['edit']=$this->DB_edit($table,$uid);
257 if (!in_array('new',$this->disabledItems
) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
260 if(!in_array('info',$this->disabledItems
) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
262 $menuItems[]='spacer';
265 if(!in_array('copy',$this->disabledItems
) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
267 if(!in_array('cut',$this->disabledItems
) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
270 $elFromAllTables = count($this->clipObj
->elFromTable(''));
271 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables) {
272 $selItem = $this->clipObj
->getSelectedRecord();
274 $selItem['_RECORD_TITLE'],
275 ($root?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen'])),
276 $this->clipObj
->currentMode()
278 if ($table=='pages' && ($lCP & 8)) {
279 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
282 $elFromTable = count($this->clipObj
->elFromTable($table));
283 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
287 $elInfo=array(t3lib_div
::fixed_lgd_cs(t3lib_BEfunc
::getRecordTitle($table,$this->rec
),$BE_USER->uc
['titleLen']));
288 if(!in_array('delete',$this->disabledItems
) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
289 $menuItems[]='spacer';
290 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
294 // Adding external elements to the menuItems array
295 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
297 // Processing by external functions?
298 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
300 // Return the printed elements:
301 return $this->printItems($menuItems,
303 '<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']):
304 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)
309 * Make 2nd level clickmenu (only for DBmenus)
311 * @param string Table name
312 * @param integer UID for the current record.
313 * @return string HTML content
315 function printNewDBLevel($table,$uid) {
316 global $TCA, $BE_USER;
318 // Setting internal record to the table/uid :
319 $this->rec
= t3lib_BEfunc
::getRecord($table,$uid);
322 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
326 // If record was found, check permissions and get menu items.
327 if (is_array($this->rec
) ||
$root) {
328 $lCP = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',($table=='pages'?
$this->rec
['uid']:$this->rec
['pid'])));
330 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||
$BE_USER->isPSet($lCP,$table,'editcontent'))) {
334 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
337 // Return the printed elements:
338 if (!is_array($menuItems)) $menuItems=array();
339 return $this->printItems($menuItems,
341 '<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']):
342 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)
347 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
349 * @param array $menuItems array for manipulation.
350 * @return array Processed $menuItems array
352 function externalProcessingOfDBMenuItems($menuItems) {
357 * Processing the $menuItems array by external classes (typ. adding items)
359 * @param array $menuItems array for manipulation.
360 * @param string Table name
361 * @param integer UID for the current record.
362 * @return array Processed $menuItems array
364 function processingByExtClassArray($menuItems,$table,$uid) {
365 if (is_array($this->extClassArray
)) {
366 reset($this->extClassArray
);
367 while(list(,$conf)=each($this->extClassArray
)) {
368 $obj=t3lib_div
::makeInstance($conf['name']);
369 $menuItems = $obj->main($this,$menuItems,$table,$uid);
376 * Returning JavaScript for the onClick event linking to the input URL.
378 * @param string The URL relative to TYPO3_mainDir
379 * @param string The return_url-parameter
380 * @param boolean If set, the "hideCM()" will be called
381 * @return string JavaScript for an onClick event.
383 function urlRefForCM($url,$retUrl='',$hideCM=1) {
384 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
385 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.document.location=top.TS.PATH_typo3+\''.$url.'\''.
386 ($retUrl?
"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
387 ($hideCM?
'return hideCM();':'');
392 * Adding CM element for Clipboard "copy" and "cut"
394 * @param string Table name
395 * @param integer UID for the current record.
396 * @param string Type: "copy" or "cut"
397 * @return array Item array, element in $menuItems
400 function DB_copycut($table,$uid,$type) {
401 if ($this->clipObj
->current
=='normal') {
402 $isSel = $this->clipObj
->isSelected($table,$uid);
406 if ($this->listFrame
) {
407 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
410 return $this->linkItem(
412 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
413 "top.loadTopMenu('".$this->clipObj
->selUrlDB($table,$uid,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
418 * Adding CM element for Clipboard "paste into"/"paste after"
419 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
421 * @param string Table name
422 * @param integer UID for the current record. NOTICE: Special syntax!
423 * @param string Type: "into" or "after"
424 * @param array Contains instructions about whether to copy or cut an element.
425 * @return array Item array, element in $menuItems
426 * @see t3lib_clipboard::pasteUrl()
429 function DB_paste($table,$uid,$type,$elInfo) {
431 $loc = 'top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
432 $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])).')';
433 $editOnClick = 'if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj
->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
435 return $this->linkItem(
436 $this->label('paste'.$type),
437 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
438 $editOnClick.'return false;'
443 * Adding CM element for Info
445 * @param string Table name
446 * @param integer UID for the current record.
447 * @return array Item array, element in $menuItems
450 function DB_info($table,$uid) {
451 return $this->linkItem(
452 $this->label('info'),
453 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
454 "top.launchView('".$table."', '".$uid."'); return hideCM();"
459 * Adding CM element for History
461 * @param string Table name
462 * @param integer UID for the current record.
463 * @return array Item array, element in $menuItems
466 function DB_history($table,$uid) {
467 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
468 return $this->linkItem(
469 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
470 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
471 $this->urlRefForCM($url,'returnUrl'),
477 * Adding CM element for Permission setting
479 * @param string Table name
480 * @param integer UID for the current record.
481 * @param array The "pages" record with "perms_*" fields inside.
482 * @return array Item array, element in $menuItems
485 function DB_perms($table,$uid,$rec) {
486 $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':'');
487 return $this->linkItem(
488 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
489 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
490 $this->urlRefForCM($url),
496 * Adding CM element for DBlist
498 * @param string Table name
499 * @param integer UID for the current record.
500 * @param array Record of the element (needs "pid" field if not pages-record)
501 * @return array Item array, element in $menuItems
504 function DB_db_list($table,$uid,$rec) {
505 $url = t3lib_div
::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?
'':$table).'&id='.($table=='pages'?
$uid:$rec['pid']);
506 return $this->linkItem(
507 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
508 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/list.gif','width="11" height="11"').' alt="" />'),
509 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
515 * Adding CM element for Moving wizard
517 * @param string Table name
518 * @param integer UID for the current record.
519 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
520 * @return array Item array, element in $menuItems
523 function DB_moveWizard($table,$uid,$rec) {
524 $url = 'move_el.php?table='.$table.'&uid='.$uid.
525 ($table=='tt_content'?
'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
527 return $this->linkItem(
528 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?
'_page':''))),
529 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/move_'.($table=='pages'?
'page':'record').'.gif','width="11" height="12"').' alt="" />'),
530 $this->urlRefForCM($url,'returnUrl'),
536 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
538 * @param string Table name
539 * @param integer UID for the current record.
540 * @param array Record.
541 * @return array Item array, element in $menuItems
544 function DB_newWizard($table,$uid,$rec) {
545 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
546 $tmpTSc = t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
547 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
548 $newContentWizScriptPath = t3lib_extMgm
::isLoaded($tmpTSc) ?
(t3lib_extMgm
::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir
.'sysext/cms/layout/db_new_content_el.php');
550 $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']);
551 return $this->linkItem(
552 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
553 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/new_'.($table=='pages'?
'page':'record').'.gif','width="'.($table=='pages'?
'13':'16').'" height="12"').' alt="" />'),
554 $this->urlRefForCM($url,'returnUrl'),
560 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
562 * @param string Table name
563 * @param integer UID for the current record.
564 * @return array Item array, element in $menuItems
567 function DB_editAccess($table,$uid) {
568 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ?
',extendToSubpages' :''));
569 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
570 return $this->linkItem(
571 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
572 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
573 $this->urlRefForCM($url,'returnUrl'),
574 1 // no top frame CM!
579 * Adding CM element for edit page header
581 * @param integer page uid to edit (PID)
582 * @return array Item array, element in $menuItems
585 function DB_editPageHeader($uid) {
586 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
587 return $this->linkItem(
588 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
589 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
590 $this->urlRefForCM($url,'returnUrl'),
591 1 // no top frame CM!
596 * Adding CM element for regular editing of the element!
598 * @param string Table name
599 * @param integer UID for the current record.
600 * @return array Item array, element in $menuItems
603 function DB_edit($table,$uid) {
605 // If another module was specified, replace the default Page module with the new one
606 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
607 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
610 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
612 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit2.gif','width="11" height="12"');
614 $this->iParts
[0]=='pages' &&
616 $BE_USER->check('modules', $pageModule)
618 $theIcon = t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/edit_page.gif','width="12" height="12"');
619 $this->editPageIconSet
=1;
620 if ($BE_USER->uc
['classicPageEditMode'] ||
!t3lib_extMgm
::isLoaded('cms')) {
621 $addParam='&editRegularContentFromId='.intval($this->iParts
[1]);
623 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts
[1]).";top.goToModule('".$pageModule."',1);";
627 $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."';}";
630 return $this->linkItem(
631 $this->label('edit'),
632 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
633 $editOnClick.'return hideCM();'
638 * Adding CM element for regular Create new element
640 * @param string Table name
641 * @param integer UID for the current record.
642 * @return array Item array, element in $menuItems
645 function DB_new($table,$uid) {
647 $loc='top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
648 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
650 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
651 'db_new.php?id='.intval($uid)."'").
654 return $this->linkItem(
656 $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="" />'),
657 $editOnClick.'return hideCM();'
662 * Adding CM element for hide/unhide of the input record
664 * @param string Table name
665 * @param array Record array
666 * @param string Name of the hide field
667 * @return array Item array, element in $menuItems
670 function DB_hideUnhide($table,$rec,$hideField) {
673 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
674 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
675 "&data[".$table.']['.$uid.']['.$hideField.']='.($rec[$hideField]?
0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
677 return $this->linkItem(
678 $this->label(($rec[$hideField]?
'un':'').'hide'),
679 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/button_'.($rec[$hideField]?
'un':'').'hide.gif','width="11" height="10"').' alt="" />'),
680 $editOnClick.'return false;',
686 * Adding CM element for Delete
688 * @param string Table name
689 * @param integer UID for the current record.
690 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
691 * @return array Item array, element in $menuItems
694 function DB_delete($table,$uid,$elInfo) {
696 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
697 $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').")+'".
698 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
700 return $this->linkItem(
701 $this->label('delete'),
702 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
703 $editOnClick.'return false;'
708 * Adding CM element for View Page
710 * @param integer Page uid (PID)
711 * @param string Anchor, if any
712 * @return array Item array, element in $menuItems
715 function DB_view($id,$anchor='') {
716 return $this->linkItem(
717 $this->label('view'),
718 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
719 t3lib_BEfunc
::viewOnClick($id,$this->PH_backPath
,t3lib_BEfunc
::BEgetRootLine($id),$anchor).'return hideCM();'
732 /***************************************
736 ***************************************/
739 * Make 1st level clickmenu:
741 * @param string The absolute path
742 * @return string HTML content
744 function printFileClickMenu($path) {
747 if (@file_exists
($path) && t3lib_div
::isAllowedAbsPath($path)) {
748 $fI = pathinfo($path);
749 $icon = is_dir($path) ?
'folder.gif' : t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
750 $size=' ('.t3lib_div
::formatSize(filesize($path)).'bytes)';
751 $icon = '<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
754 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');
756 if (!in_array('rename',$this->disabledItems
)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
758 if (!in_array('upload',$this->disabledItems
) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
760 if (!in_array('new',$this->disabledItems
) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
762 if (!in_array('info',$this->disabledItems
)) $menuItems['info']=$this->DB_info($path,'');
764 $menuItems[]='spacer';
767 if (!in_array('copy',$this->disabledItems
)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
769 if (!in_array('cut',$this->disabledItems
)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
772 $elFromAllTables = count($this->clipObj
->elFromTable('_FILE'));
773 if (!in_array('paste',$this->disabledItems
) && $elFromAllTables && is_dir($path)) {
774 $elArr = $this->clipObj
->elFromTable('_FILE');
776 $selItem = current($elArr);
780 $this->clipObj
->currentMode()
782 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
785 $menuItems[]='spacer';
788 if (!in_array('delete',$this->disabledItems
)) $menuItems['delete']=$this->FILE_delete($path);
791 // Adding external elements to the menuItems array
792 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
794 // Processing by external functions?
795 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
797 // Return the printed elements:
798 return $this->printItems($menuItems,$icon.basename($path));
803 * Processing the $menuItems array (for extension classes) (FILES)
805 * @param array $menuItems array for manipulation.
806 * @return array Processed $menuItems array
808 function externalProcessingOfFileMenuItems($menuItems) {
813 * Multi-function for adding an entry to the $menuItems array
815 * @param string Path to the file/directory (target)
816 * @param string Script (eg. file_edit.php) to pass &target= to
817 * @param string "type" is the code which fetches the correct label for the element from "cm."
818 * @param string icon image-filename from "gfx/" (12x12 icon)
819 * @return array Item array, element in $menuItems
822 function FILE_launch($path,$script,$type,$image) {
823 $loc = 'top.content'.(!$this->alwaysContentFrame?
'.list_frame':'');
825 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
827 return $this->linkItem(
829 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
830 $editOnClick.'return hideCM();'
835 * Returns element for copy or cut of files.
837 * @param string Path to the file/directory (target)
838 * @param string Type: "copy" or "cut"
839 * @return array Item array, element in $menuItems
842 function FILE_copycut($path,$type) {
843 $table = '_FILE'; // Pseudo table name for use in the clipboard.
844 $uid = t3lib_div
::shortmd5($path);
845 if ($this->clipObj
->current
=='normal') {
846 $isSel = $this->clipObj
->isSelected($table,$uid);
850 if ($this->listFrame
) {
851 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ?
2 : 1);
854 return $this->linkItem(
856 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_'.$type.($isSel==$type?
'_h':'').'.gif','width="12" height="12"').' alt="" />'),
857 "top.loadTopMenu('".$this->clipObj
->selUrlFile($path,($type=='copy'?
1:0),($isSel==$type),$addParam)."');return false;"
862 * Creates element for deleting of target
864 * @param string Path to the file/directory (target)
865 * @return array Item array, element in $menuItems
868 function FILE_delete($path) {
870 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
871 $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').")+'".
872 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
874 return $this->linkItem(
875 $this->label('delete'),
876 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
877 $editOnClick.'return false;'
882 * Creates element for pasting files.
884 * @param string Path to the file/directory (target)
885 * @param string target - NOT USED.
886 * @param array Various values for the labels.
887 * @return array Item array, element in $menuItems
890 function FILE_paste($path,$target,$elInfo) {
892 $loc='top.content'.($this->listFrame
&& !$this->alwaysContentFrame ?
'.list_frame':'');
893 $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])).")";
894 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj
->pasteUrl('_FILE',$path,0).
895 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
897 return $this->linkItem(
898 $this->label('pasteinto'),
899 $this->excludeIcon('<img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
900 $editOnClick.'return false;'
916 /***************************************
920 **************************************/
923 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
924 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
926 * @param array $menuItems array
927 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
928 * @return string HTML code
930 function printItems($menuItems,$item) {
934 // Enable/Disable items:
935 $menuItems = $this->enableDisableItems($menuItems);
938 $menuItems = $this->cleanUpSpacers($menuItems);
940 // Adding topframe part (horizontal clickmenu)
941 if ($this->doDisplayTopFrameCM()) {
945 Table, which contains the click menu when shown in the top frame of the backend:
947 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
951 <td class="c-item">'.
953 <td><img'.t3lib_iconWorks
::skinImg($this->PH_backPath
,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
954 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
957 <!-- Close button: -->
958 <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>
960 <!-- The item of the clickmenu: -->
961 <td class="c-itemicon">'.$item.'</td>
966 // Set remaining BACK_PATH to blank (if any)
967 $out = str_replace($this->PH_backPath
,'',$out);
970 $out.=$this->printLayerJScode($menuItems);
972 // Return the content
977 * Create the JavaScript section
979 * @param array The $menuItems array to print
980 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
982 function printLayerJScode($menuItems) {
984 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
985 $frameName = '.'.($this->listFrame ?
'list_frame' : 'nav_frame');
986 if ($this->alwaysContentFrame
) $frameName='';
988 // Create the table displayed in the clickmenu layer:
990 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
991 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
994 // Wrap the inner table in another table to create outer border:
995 $CMtable = $this->wrapColorTableCM($CMtable);
997 // Set back path place holder to real back path
998 $CMtable = str_replace($this->PH_backPath
,$this->backPath
,$CMtable);
1000 // Create JavaScript section:
1001 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1003 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
1004 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div
::rawurlencodeJS($CMtable).'"),'.$this->cmLevel
.');
1006 '.(!$this->doDisplayTopFrameCM()?
'hideCM();':'')
1014 * Wrapping the input string in a table with background color 4 and a black border style.
1015 * For the pop-up menu
1017 * @param string HTML content to wrap in table.
1020 function wrapColorTableCM($str) {
1022 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1023 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1025 <td class="c-aa">'.$str.'</td>
1026 <td class="c-ab"></td>
1029 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1030 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1037 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1039 * @param array $menuItem array
1040 * @param array Array with HTML content to be imploded between <td>-tags
1041 * @return array Array of menu items for top frame.
1043 function menuItemsForTopFrame($menuItems) {
1046 while(list(,$i)=each($menuItems)) {
1047 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)
1048 if (is_array($i) && !$i[4]) $out[]=$i[0];
1054 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1056 * @param array $menuItem array
1057 * @param array Array with HTML content to be imploded between <td>-tags
1058 * @return array array for implosion in the CM div-layers table.
1060 function menuItemsForClickMenu($menuItems) {
1063 while(list($cc,$i)=each($menuItems)) {
1064 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1066 <tr class="bgColor2">
1067 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1069 } else { // Just make normal element:
1071 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1072 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1073 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1074 if (!$i[5]) $onClick.='hideEmpty();';
1077 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5
.'\';" onmouseout="this.bgColor=\'\';">
1078 '.(!$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>').'
1086 * Creating an array with various elements for the clickmenu entry
1088 * @param string The label, htmlspecialchar'ed already
1089 * @param string <img>-tag for the icon
1090 * @param string JavaScript onclick event for label/icon
1091 * @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)
1092 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1093 * @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!
1095 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1098 $WHattribs = t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1101 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount
.'" alt="" />'.
1102 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount
.');" onmouseout="mout('.$this->elCount
.');">'.
1114 * Returns the input string IF not a user setting has disabled display of icons.
1116 * @param string The icon-image tag
1117 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1119 function excludeIcon($iconCode) {
1120 return ($GLOBALS['BE_USER']->uc
['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc
['noMenuMode'],'icons')) ?
'' : ' '.$iconCode;
1124 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1126 * @param array Menu items array
1127 * @return array Menu items array, processed.
1129 function enableDisableItems($menuItems) {
1130 if ($this->iParts
[3]) {
1132 // Detect "only" mode: (only showing listed items)
1133 if (substr($this->iParts
[3],0,1)=='+') {
1134 $this->iParts
[3] = substr($this->iParts
[3],1);
1141 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1142 $newMenuArray = array();
1143 foreach($menuItems as $key => $value) {
1144 if (t3lib_div
::inList($this->iParts
[3], $key) ||
(is_string($value) && $value=='spacer')) {
1145 $newMenuArray[$key] = $value;
1148 $menuItems = $newMenuArray;
1149 } else { // Traverse all elements except those listed (just unsetting them):
1150 $elements = t3lib_div
::trimExplode(',',$this->iParts
[3],1);
1151 foreach($elements as $value) {
1152 unset($menuItems[$value]);
1157 // Return processed menu items:
1162 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1164 * @param array Menu items array
1165 * @return array Menu items array, processed.
1167 function cleanUpSpacers($menuItems) {
1170 $prevItemWasSpacer = FALSE;
1171 foreach($menuItems as $key => $value) {
1172 if (is_string($value) && $value=='spacer') {
1173 if ($prevItemWasSpacer) {
1174 unset($menuItems[$key]);
1176 $prevItemWasSpacer = TRUE;
1178 $prevItemWasSpacer = FALSE;
1184 $key = key($menuItems);
1185 $value = current($menuItems);
1186 if (is_string($value) && $value=='spacer') {
1187 unset($menuItems[$key]);
1193 $key = key($menuItems);
1194 $value = current($menuItems);
1195 if (is_string($value) && $value=='spacer') {
1196 unset($menuItems[$key]);
1199 // Return processed menu items:
1204 * Get label from locallang_core.php:cm.*
1206 * @param string The "cm."-suffix to get.
1209 function label($label) {
1210 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1214 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1218 function isCMlayers() {
1219 return $GLOBALS['SOBE']->doc
->isCMlayers() && !$this->CB
;
1223 * Appends ".location" to input string
1225 * @param string Input string, probably a JavaScript document reference
1228 function frameLocation($str) {
1229 return $str.'.location';
1246 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1248 * @author Kasper Skaarhoj <kasper@typo3.com>
1251 * @see template::getContextMenuCode()
1253 class SC_alt_clickmenu
{
1255 // Internal, static: GPvar:
1256 var $backPath; // Back path.
1257 var $item; // Definition of which item the click menu should be made for.
1258 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1261 var $content=''; // Content accumulation
1262 var $doc; // Template object
1263 var $include_once=array(); // Files to include_once() - set in init() function
1264 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1265 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1268 * Constructor function for script class.
1273 global $BE_USER,$BACK_PATH;
1276 $this->backPath
= t3lib_div
::_GP('backPath');
1277 $this->item
= t3lib_div
::_GP('item');
1278 $this->reloadListFrame
= t3lib_div
::_GP('reloadListFrame');
1280 // Setting pseudo module name
1281 $this->MCONF
['name']='xMOD_alt_clickmenu.php';
1283 // 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:
1284 $inputBP = explode('|',$this->backPath
);
1285 if (count($inputBP)==2 && $inputBP[1]==t3lib_div
::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1286 $this->backPath
= $inputBP[0];
1288 $this->backPath
= $BACK_PATH;
1291 // Setting internal array of classes for extending the clickmenu:
1292 $this->extClassArray
= $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1294 // Traversing that array and setting files for inclusion:
1295 if (is_array($this->extClassArray
)) {
1296 foreach($this->extClassArray
as $extClassConf) {
1297 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1301 // Initialize template object
1302 $this->doc
= t3lib_div
::makeInstance('template');
1303 $this->doc
->docType
='xhtml_trans';
1304 $this->doc
->backPath
= $BACK_PATH;
1306 // Setting mode for display and background image in the top frame
1307 $this->dontDisplayTopFrameCM
= $this->doc
->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1308 if ($this->dontDisplayTopFrameCM
) {
1309 $this->doc
->bodyTagId
.= '-notop';
1312 // Setting clickmenu timeout
1313 $secs = t3lib_div
::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1315 // Setting the JavaScript controlling the timer on the page
1316 $listFrameDoc = $this->reloadListFrame
!=2 ?
'top.content.list_frame' : 'top.content';
1317 $this->doc
->JScode
.=$this->doc
->wrapScriptTags('
1318 var date = new Date();
1319 var mo_timeout = Math.floor(date.getTime()/1000);
1322 roImg.src = "'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1324 routImg =new Image();
1325 routImg.src = "clear.gif";
1328 var name="roimg_"+c;
1329 document[name].src = roImg.src;
1332 function mout(c) { //
1333 var name="roimg_"+c;
1334 document[name].src = routImg.src;
1337 function updateTime() { //
1339 mo_timeout = Math.floor(date.getTime()/1000);
1341 function timeout_func() { //
1343 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1347 window.setTimeout("timeout_func();",1*1000);
1350 function hideCM() { //
1351 document.location="alt_topmenu_dummy.php";
1358 '.($this->reloadListFrame ?
'
1359 // Reload list frame:
1360 if('.$listFrameDoc.'){'.$listFrameDoc.'.document.location='.$listFrameDoc.'.document.location;}' :
1366 * Main function - generating the click menu in whatever form it has.
1372 // Initialize Clipboard object:
1373 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
1374 $clipObj->initializeClipboard();
1375 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1377 // Update clipboard if some actions are sent.
1378 $CB = t3lib_div
::_GET('CB');
1379 $clipObj->setCmd($CB);
1380 $clipObj->cleanCurrent();
1381 $clipObj->endClipboard(); // Saves
1383 // Create clickmenu object
1384 $clickMenu = t3lib_div
::makeInstance('clickMenu');
1386 // Set internal vars in clickmenu object:
1387 $clickMenu->clipObj
= $clipObj;
1388 $clickMenu->extClassArray
= $this->extClassArray
;
1389 $clickMenu->dontDisplayTopFrameCM
= $this->dontDisplayTopFrameCM
;
1390 $clickMenu->backPath
= $this->backPath
;
1393 $this->content
.=$this->doc
->startPage('Context Sensitive Menu');
1395 // Set content of the clickmenu with the incoming var, "item"
1396 $this->content
.= $clickMenu->init($this->item
);
1400 * End page and output content.
1404 function printContent() {
1405 $this->content
.= $this->doc
->endPage();
1406 echo $this->content
;
1410 // Include extension?
1411 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']) {
1412 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/alt_clickmenu.php']);
1425 $SOBE = t3lib_div
::makeInstance('SC_alt_clickmenu');
1429 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1432 $SOBE->printContent();