00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00119 require ('init.php');
00120 require ('template.php');
00121 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00122 require_once(PATH_t3lib.'class.t3lib_ajax.php');
00123 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00124
00125
00126
00127
00136 class clickMenu {
00137
00138
00139 var $cmLevel=0;
00140 var $CB;
00141
00142
00143 var $backPath='';
00144 var $PH_backPath='###BACK_PATH###';
00145 var $listFrame=0;
00146 var $isDBmenu=0;
00147 var $alwaysContentFrame=0;
00148 var $iParts=array();
00149 var $disabledItems=array();
00150 var $dontDisplayTopFrameCM=0;
00151 var $leftIcons=0;
00152 var $extClassArray=array();
00153 var $ajax=0;
00154
00155
00156 var $elCount=0;
00157 var $editPageIconSet=0;
00158 var $editOK=0;
00159 var $rec=array();
00160
00161
00162
00168 function init() {
00169
00170 $this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
00171 $this->CB = t3lib_div::_GP('CB');
00172 if(t3lib_div::_GP('ajax')) {
00173 $this->ajax = 1;
00174 ini_set('display_errors',0);
00175 }
00176
00177
00178 if (strcmp(t3lib_div::_GP('dragDrop'),'')) {
00179 $CMcontent = $this->printDragDropClickMenu(t3lib_div::_GP('dragDrop'),t3lib_div::_GP('srcId'),t3lib_div::_GP('dstId'));
00180 return $CMcontent;
00181 }
00182
00183
00184 $this->iParts[0] = t3lib_div::_GP('table');
00185 $this->iParts[1] = t3lib_div::_GP('uid');
00186 $this->iParts[2] = t3lib_div::_GP('listFr');
00187 $this->iParts[3] = t3lib_div::_GP('enDisItems');
00188
00189
00190 if ($this->iParts[2]) $this->listFrame=1;
00191 if ($GLOBALS['BE_USER']->uc['condensedMode'] || $this->iParts[2]==2) $this->alwaysContentFrame=1;
00192 if (strcmp($this->iParts[1],'')) $this->isDBmenu=1;
00193
00194 $TSkey =($this->isDBmenu?'page':'folder').($this->listFrame?'List':'Tree');
00195 $this->disabledItems = t3lib_div::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
00196 $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
00197
00198
00199 if (!$this->cmLevel) {
00200
00201 if ($this->isDBmenu) {
00202 $CMcontent = $this->printDBClickMenu($this->iParts[0],$this->iParts[1]);
00203 } else {
00204 $CMcontent = $this->printFileClickMenu($this->iParts[0]);
00205 }
00206 } else {
00207
00208 if ($this->isDBmenu) {
00209 $CMcontent = $this->printNewDBLevel($this->iParts[0],$this->iParts[1]);
00210 }
00211 }
00212
00213
00214 return $CMcontent;
00215 }
00216
00222 function doDisplayTopFrameCM() {
00223 if($this->ajax) {
00224 return false;
00225 } else {
00226 return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
00227 }
00228 }
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00254 function printDBClickMenu($table,$uid) {
00255 global $TCA, $BE_USER;
00256
00257
00258 $this->rec = t3lib_BEfunc::getRecordWSOL($table,$uid);
00259 $menuItems=array();
00260 $root=0;
00261 if ($table=='pages' && !strcmp($uid,'0')) {
00262 $root=1;
00263 }
00264
00265
00266 if (is_array($this->rec) || $root) {
00267
00268
00269 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
00270
00271
00272 if (!in_array('view',$this->disabledItems)) {
00273 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
00274 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec['pid'],'#'.$uid);
00275 }
00276
00277
00278 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
00279 if (!in_array('edit',$this->disabledItems)) $menuItems['edit']=$this->DB_edit($table,$uid);
00280 $this->editOK=1;
00281 }
00282
00283
00284 if (!in_array('new',$this->disabledItems) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
00285
00286
00287 if(!in_array('info',$this->disabledItems) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
00288
00289 $menuItems['spacer1']='spacer';
00290
00291
00292 if(!in_array('copy',$this->disabledItems) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
00293
00294 if(!in_array('cut',$this->disabledItems) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
00295
00296
00297 $elFromAllTables = count($this->clipObj->elFromTable(''));
00298 if (!in_array('paste',$this->disabledItems) && $elFromAllTables) {
00299 $selItem = $this->clipObj->getSelectedRecord();
00300 $elInfo=array(
00301 t3lib_div::fixed_lgd_cs($selItem['_RECORD_TITLE'],$BE_USER->uc['titleLen']),
00302 ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen'])),
00303 $this->clipObj->currentMode()
00304 );
00305 if ($table=='pages' && ($lCP & 8)) {
00306 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
00307 }
00308
00309 $elFromTable = count($this->clipObj->elFromTable($table));
00310 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
00311 }
00312
00313
00314 $elInfo=array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen']));
00315 if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
00316 $menuItems['spacer2']='spacer';
00317 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
00318 }
00319
00320 if(!in_array('history',$this->disabledItems)) {
00321 $menuItems['history']=$this->DB_history($table,$uid,$elInfo);
00322 }
00323 }
00324
00325
00326 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
00327
00328
00329 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
00330
00331
00332 return $this->printItems($menuItems,
00333 $root?
00334 '<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']):
00335 t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,TRUE)
00336 );
00337 }
00338
00346 function printNewDBLevel($table,$uid) {
00347 global $TCA, $BE_USER;
00348
00349
00350 $this->rec = t3lib_BEfunc::getRecordWSOL($table,$uid);
00351 $menuItems=array();
00352 $root=0;
00353 if ($table=='pages' && !strcmp($uid,'0')) {
00354 $root=1;
00355 }
00356
00357
00358 if (is_array($this->rec) || $root) {
00359 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
00360
00361 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
00362 $this->editOK=1;
00363 }
00364
00365 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
00366 }
00367
00368
00369 if (!is_array($menuItems)) $menuItems=array();
00370 return $this->printItems($menuItems,
00371 $root?
00372 '<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']):
00373 t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,TRUE)
00374 );
00375 }
00376
00383 function externalProcessingOfDBMenuItems($menuItems) {
00384 return $menuItems;
00385 }
00386
00395 function processingByExtClassArray($menuItems,$table,$uid) {
00396 if (is_array($this->extClassArray)) {
00397 reset($this->extClassArray);
00398 while(list(,$conf)=each($this->extClassArray)) {
00399 $obj=t3lib_div::makeInstance($conf['name']);
00400 $menuItems = $obj->main($this,$menuItems,$table,$uid);
00401 }
00402 }
00403 return $menuItems;
00404 }
00405
00415 function urlRefForCM($url,$retUrl='',$hideCM=1,$overrideLoc='') {
00416 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00417 $editOnClick= ($overrideLoc ? 'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
00418 ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
00419 ($hideCM?'return hideCM();':'');
00420 return $editOnClick;
00421 }
00422
00432 function DB_copycut($table,$uid,$type) {
00433 if ($this->clipObj->current=='normal') {
00434 $isSel = $this->clipObj->isSelected($table,$uid);
00435 }
00436
00437 $addParam = array();
00438 if ($this->listFrame) {
00439 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00440 }
00441
00442 return $this->linkItem(
00443 $this->label($type),
00444 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00445 "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00446 );
00447 }
00448
00461 function DB_paste($table,$uid,$type,$elInfo) {
00462 $editOnClick = '';
00463 $loc = 'top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00464 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
00465 $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])).')';
00466 } else {
00467 $conf = $loc;
00468 }
00469 $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
00470
00471 return $this->linkItem(
00472 $this->label('paste'.$type),
00473 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
00474 $editOnClick.'return false;'
00475 );
00476 }
00477
00486 function DB_info($table,$uid) {
00487 return $this->linkItem(
00488 $this->label('info'),
00489 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
00490 "top.launchView('".$table."', '".$uid."'); return hideCM();"
00491 );
00492 }
00493
00502 function DB_history($table,$uid) {
00503 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
00504 return $this->linkItem(
00505 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
00506 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
00507 $this->urlRefForCM($url,'returnUrl'),
00508 0
00509 );
00510 }
00511
00521 function DB_perms($table,$uid,$rec) {
00522 $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':'');
00523 return $this->linkItem(
00524 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
00525 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
00526 $this->urlRefForCM($url),
00527 0
00528 );
00529 }
00530
00540 function DB_db_list($table,$uid,$rec) {
00541 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
00542 return $this->linkItem(
00543 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
00544 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
00545 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
00546 0
00547 );
00548 }
00549
00559 function DB_moveWizard($table,$uid,$rec) {
00560 $url = 'move_el.php?table='.$table.'&uid='.$uid.
00561 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):'');
00562
00563 return $this->linkItem(
00564 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
00565 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
00566 $this->urlRefForCM($url,'returnUrl'),
00567 0
00568 );
00569 }
00570
00580 function DB_newWizard($table,$uid,$rec) {
00581
00582 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00583 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
00584 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00585
00586 $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']);
00587 return $this->linkItem(
00588 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
00589 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
00590 $this->urlRefForCM($url,'returnUrl'),
00591 0
00592 );
00593 }
00594
00603 function DB_editAccess($table,$uid) {
00604 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
00605 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
00606 return $this->linkItem(
00607 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
00608 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
00609 $this->urlRefForCM($url,'returnUrl'),
00610 1
00611 );
00612 }
00613
00622 function DB_editPageHeader($uid) {
00623 return $this->DB_editPageProperties($uid);
00624 }
00625
00633 function DB_editPageProperties($uid) {
00634 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
00635 return $this->linkItem(
00636 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
00637 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
00638 $this->urlRefForCM($url,'returnUrl'),
00639 1
00640 );
00641 }
00642
00651 function DB_edit($table,$uid) {
00652 global $BE_USER;
00653
00654 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
00655 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00656
00657 $editOnClick='';
00658 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00659 $addParam='';
00660 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
00661 if (
00662 $this->iParts[0]=='pages' &&
00663 $this->iParts[1] &&
00664 $BE_USER->check('modules', $pageModule)
00665 ) {
00666 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
00667 $this->editPageIconSet=1;
00668 if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
00669 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
00670 } else {
00671 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
00672 }
00673 }
00674 if (!$editOnClick) {
00675 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
00676 }
00677
00678 return $this->linkItem(
00679 $this->label('edit'),
00680 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
00681 $editOnClick.'return hideCM();'
00682 );
00683 }
00684
00693 function DB_new($table,$uid) {
00694 $editOnClick='';
00695 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00696 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
00697 ($this->listFrame?
00698 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
00699 'db_new.php?id='.intval($uid)."'").
00700 ';}';
00701
00702 return $this->linkItem(
00703 $this->label('new'),
00704 $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="" />'),
00705 $editOnClick.'return hideCM();'
00706 );
00707 }
00708
00718 function DB_delete($table,$uid,$elInfo) {
00719 $editOnClick='';
00720 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00721 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
00722 $conf = "confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0]).t3lib_BEfunc::referenceCount($table,$uid,' (There are %s reference(s) to this record!)')).")";
00723 } else {
00724 $conf = '1==1';
00725 }
00726 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00727 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00728
00729 return $this->linkItem(
00730 $this->label('delete'),
00731 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00732 $editOnClick.'return false;'
00733 );
00734 }
00735
00744 function DB_view($id,$anchor='') {
00745 return $this->linkItem(
00746 $this->label('view'),
00747 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
00748 t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
00749 );
00750 }
00751
00759 function DB_tempMountPoint($page_id) {
00760 return $this->linkItem(
00761 $this->label('tempMountPoint'),
00762 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/placeasroot.gif','width="14" height="12"').' alt="" />'),
00763 "if (top.content.nav_frame) { top.content.nav_frame.location.href = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
00764 );
00765 }
00766
00776 function DB_hideUnhide($table,$rec,$hideField) {
00777 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?'un':'').'hide'), 'hide');
00778 }
00779
00791 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
00792 $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
00793 $editOnClick='';
00794 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00795 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00796 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00797
00798 return $this->linkItem(
00799 $title,
00800 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,$iconRelPath.'button_'.($rec[$flagField]?'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
00801 $editOnClick.'return false;',
00802 1
00803 );
00804 }
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00825 function printFileClickMenu($path) {
00826 $menuItems=array();
00827
00828 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path)) {
00829 $fI = pathinfo($path);
00830 $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
00831 $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
00832 $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
00833
00834
00835 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');
00836
00837 if (!in_array('rename',$this->disabledItems)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
00838
00839 if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
00840
00841 if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
00842
00843 if (!in_array('info',$this->disabledItems)) $menuItems['info']=$this->DB_info($path,'');
00844
00845 $menuItems[]='spacer';
00846
00847
00848 if (!in_array('copy',$this->disabledItems)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
00849
00850 if (!in_array('cut',$this->disabledItems)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
00851
00852
00853 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
00854 if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path)) {
00855 $elArr = $this->clipObj->elFromTable('_FILE');
00856 reset($elArr);
00857 $selItem = current($elArr);
00858 $elInfo=array(
00859 basename($selItem),
00860 basename($path),
00861 $this->clipObj->currentMode()
00862 );
00863 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
00864 }
00865
00866 $menuItems[]='spacer';
00867
00868
00869 if (!in_array('delete',$this->disabledItems)) $menuItems['delete']=$this->FILE_delete($path);
00870 }
00871
00872
00873 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
00874
00875
00876 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
00877
00878
00879 return $this->printItems($menuItems,$icon.basename($path));
00880 }
00881
00882
00889 function externalProcessingOfFileMenuItems($menuItems) {
00890 return $menuItems;
00891 }
00892
00903 function FILE_launch($path,$script,$type,$image) {
00904 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00905
00906 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
00907
00908 return $this->linkItem(
00909 $this->label($type),
00910 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
00911 $editOnClick.'return hideCM();'
00912 );
00913 }
00914
00923 function FILE_copycut($path,$type) {
00924 $table = '_FILE';
00925 $uid = t3lib_div::shortmd5($path);
00926 if ($this->clipObj->current=='normal') {
00927 $isSel = $this->clipObj->isSelected($table,$uid);
00928 }
00929
00930 $addParam = array();
00931 if ($this->listFrame) {
00932 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00933 }
00934
00935 return $this->linkItem(
00936 $this->label($type),
00937 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00938 "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00939 );
00940 }
00941
00949 function FILE_delete($path) {
00950 $editOnClick='';
00951 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00952 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
00953 $conf = "confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path)).t3lib_BEfunc::referenceCount('_FILE',$path,' (There are %s reference(s) to this file!)')).")";
00954 } else {
00955 $conf = '1==1';
00956 }
00957 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00958 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00959
00960 return $this->linkItem(
00961 $this->label('delete'),
00962 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00963 $editOnClick.'return false;'
00964 );
00965 }
00966
00976 function FILE_paste($path,$target,$elInfo) {
00977 $editOnClick='';
00978 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00979 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
00980 $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])).")";
00981 } else {
00982 $conf=$loc;
00983 }
00984
00985 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
00986 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
00987
00988 return $this->linkItem(
00989 $this->label('pasteinto'),
00990 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
00991 $editOnClick.'return false;'
00992 );
00993 }
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01013 function printDragDropClickMenu($table,$srcId,$dstId) {
01014 $menuItems=array();
01015
01016
01017 if ($table == 'pages') {
01018
01019 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into');
01020
01021 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after');
01022
01023 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into');
01024
01025 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after');
01026 }
01027
01028
01029 if ($table == 'folders') {
01030
01031 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move');
01032
01033 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy');
01034 }
01035
01036
01037 $menuItems = $this->processingByExtClassArray($menuItems,"dragDrop_".$table,$srcId);
01038
01039
01040 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
01041
01042
01043 return $this->printItems($menuItems,
01044 t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,TRUE)
01045 );
01046 }
01047
01048
01055 function externalProcessingOfDragDropMenuItems($menuItems) {
01056 return $menuItems;
01057 }
01058
01059
01070 function dragDrop_copymovepage($srcUid,$dstUid,$action,$into) {
01071 $negativeSign = ($into == 'into') ? '' : '-';
01072 $editOnClick='';
01073 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
01074 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
01075 '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
01076
01077 return $this->linkItem(
01078 $this->label($action.'Page_'.$into),
01079 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
01080 $editOnClick.'return false;',
01081 0
01082 );
01083 }
01084
01085
01095 function dragDrop_copymovefolder($srcPath,$dstPath,$action) {
01096 $editOnClick='';
01097 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
01098 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
01099 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
01100
01101 return $this->linkItem(
01102 $this->label($action.'Folder_into'),
01103 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
01104 $editOnClick.'return false;',
01105 0
01106 );
01107 }
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01131 function printItems($menuItems,$item) {
01132
01133 $out='';
01134
01135
01136 $menuItems = $this->enableDisableItems($menuItems);
01137
01138
01139 $menuItems = $this->cleanUpSpacers($menuItems);
01140
01141
01142 if ($this->doDisplayTopFrameCM()) {
01143 $out.= '
01144
01145 <!--
01146 Table, which contains the click menu when shown in the top frame of the backend:
01147 -->
01148 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
01149 <tr>
01150
01151 <!-- Items: -->
01152 <td class="c-item">'.
01153 implode('</td>
01154 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
01155 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
01156 '</td>
01157
01158 <!-- Close button: -->
01159 <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>
01160
01161 <!-- The item of the clickmenu: -->
01162 <td class="c-itemicon">'.$item.'</td>
01163 </tr>
01164 </table>
01165 ';
01166
01167
01168 $out = str_replace($this->PH_backPath,'',$out);
01169 }
01170
01171 $out.=$this->printLayerJScode($menuItems);
01172
01173
01174 return $out;
01175 }
01176
01183 function printLayerJScode($menuItems) {
01184 $script='';
01185 if ($this->isCMlayers()) {
01186 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
01187 if ($this->alwaysContentFrame) $frameName='';
01188
01189
01190 $CMtable = '
01191 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
01192 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
01193 </table>';
01194
01195
01196 $CMtable = $this->wrapColorTableCM($CMtable);
01197
01198
01199 $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
01200 if ($this->ajax) {
01201 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
01202 return $innerXML;
01203 } else {
01204
01205 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
01206
01207 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
01208 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
01209 }
01210 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
01211 );
01212 return $script;
01213 }
01214 }
01215 }
01216
01224 function wrapColorTableCM($str) {
01225
01226
01227 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
01228 <tr class="c-rowA">
01229 <td class="c-aa">'.$str.'</td>
01230 <td class="c-ab"></td>
01231 </tr>
01232 <tr class="c-rowB">
01233 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
01234 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
01235 </tr>
01236 </table>';
01237 return $str;
01238 }
01239
01247 function menuItemsForTopFrame($menuItems) {
01248 reset($menuItems);
01249 $out=array();
01250 while(list(,$i)=each($menuItems)) {
01251 if ($i[4]==1 && !$GLOBALS['SOBE']->doc->isCMlayers()) $i[4]=0;
01252 if (is_array($i) && !$i[4]) $out[]=$i[0];
01253 }
01254 return $out;
01255 }
01256
01264 function menuItemsForClickMenu($menuItems) {
01265 reset($menuItems);
01266 $out=array();
01267 while(list($cc,$i)=each($menuItems)) {
01268 if (is_string($i) && $i=='spacer') {
01269 $out[]='
01270 <tr class="bgColor2">
01271 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
01272 </tr>';
01273 } else {
01274 $onClick=$i[3];
01275 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
01276 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
01277 $onClick=eregi_replace('hideCM\(\);','',$onClick);
01278 if (!$i[5]) $onClick.='hideEmpty();';
01279
01280 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
01281 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
01282 }
01283
01284 $out[]='
01285 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
01286 '.(!$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>').'
01287 </tr>';
01288 }
01289 }
01290 return $out;
01291 }
01292
01302 function addMenuItems($menuItems,$newMenuItems,$position='') {
01303 if (is_array($newMenuItems)) {
01304
01305 if($position) {
01306
01307 $posArr = t3lib_div::trimExplode(',', $position, 1);
01308 foreach($posArr as $pos) {
01309 list($place,$menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
01310 list($place,$placeExtra) = t3lib_div::trimExplode('-', $place, 1);
01311
01312
01313 $pointer = count($menuItems);
01314
01315 $found=FALSE;
01316
01317 if ($place) {
01318 switch(strtolower($place)) {
01319 case 'after':
01320 case 'before':
01321 if ($menuEntry) {
01322 $p=1;
01323 reset ($menuItems);
01324 while (true) {
01325 if (!strcmp(key($menuItems), $menuEntry)) {
01326 $pointer = $p;
01327 $found=TRUE;
01328 break;
01329 }
01330 if (!next($menuItems)) break;
01331 $p++;
01332 }
01333 if (!$found) break;
01334
01335 if ($place=='before') {
01336 $pointer--;
01337 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
01338 $pointer--;
01339 }
01340 } elseif ($place=='after') {
01341 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
01342 $pointer++;
01343 }
01344 }
01345 }
01346 break;
01347 default:
01348 if (strtolower($place)=='top') {
01349 $pointer = 0;
01350 } else {
01351 $pointer