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']) {
00275 $ws_rec = t3lib_BEfunc::getRecordWSOL($table,$this->rec['t3ver_oid']);
00276 $menuItems['view']=$this->DB_view($ws_rec['pid']);
00277 }
00278 }
00279
00280
00281 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
00282 if (!in_array('edit',$this->disabledItems)) $menuItems['edit']=$this->DB_edit($table,$uid);
00283 $this->editOK=1;
00284 }
00285
00286
00287 if (!in_array('new',$this->disabledItems) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
00288
00289
00290 if(!in_array('info',$this->disabledItems) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
00291
00292 $menuItems['spacer1']='spacer';
00293
00294
00295 if(!in_array('copy',$this->disabledItems) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
00296
00297 if(!in_array('cut',$this->disabledItems) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
00298
00299
00300 $elFromAllTables = count($this->clipObj->elFromTable(''));
00301 if (!in_array('paste',$this->disabledItems) && $elFromAllTables) {
00302 $selItem = $this->clipObj->getSelectedRecord();
00303 $elInfo=array(
00304 t3lib_div::fixed_lgd_cs($selItem['_RECORD_TITLE'],$BE_USER->uc['titleLen']),
00305 ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen'])),
00306 $this->clipObj->currentMode()
00307 );
00308 if ($table=='pages' && ($lCP & 8)) {
00309 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
00310 }
00311
00312 $elFromTable = count($this->clipObj->elFromTable($table));
00313 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
00314 }
00315
00316
00317 $elInfo=array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen']));
00318 if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
00319 $menuItems['spacer2']='spacer';
00320 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
00321 }
00322
00323 if(!in_array('history',$this->disabledItems)) {
00324 $menuItems['history']=$this->DB_history($table,$uid,$elInfo);
00325 }
00326 }
00327
00328
00329 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
00330
00331
00332 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
00333
00334
00335 return $this->printItems($menuItems,
00336 $root?
00337 '<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']):
00338 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)
00339 );
00340 }
00341
00349 function printNewDBLevel($table,$uid) {
00350 global $TCA, $BE_USER;
00351
00352
00353 $this->rec = t3lib_BEfunc::getRecordWSOL($table,$uid);
00354 $menuItems=array();
00355 $root=0;
00356 if ($table=='pages' && !strcmp($uid,'0')) {
00357 $root=1;
00358 }
00359
00360
00361 if (is_array($this->rec) || $root) {
00362 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
00363
00364 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
00365 $this->editOK=1;
00366 }
00367
00368 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
00369 }
00370
00371
00372 if (!is_array($menuItems)) $menuItems=array();
00373 return $this->printItems($menuItems,
00374 $root?
00375 '<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']):
00376 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)
00377 );
00378 }
00379
00386 function externalProcessingOfDBMenuItems($menuItems) {
00387 return $menuItems;
00388 }
00389
00398 function processingByExtClassArray($menuItems,$table,$uid) {
00399 if (is_array($this->extClassArray)) {
00400 reset($this->extClassArray);
00401 while(list(,$conf)=each($this->extClassArray)) {
00402 $obj=t3lib_div::makeInstance($conf['name']);
00403 $menuItems = $obj->main($this,$menuItems,$table,$uid);
00404 }
00405 }
00406 return $menuItems;
00407 }
00408
00418 function urlRefForCM($url,$retUrl='',$hideCM=1,$overrideLoc='') {
00419 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00420 $editOnClick= ($overrideLoc ? 'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
00421 ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
00422 ($hideCM?'return hideCM();':'');
00423 return $editOnClick;
00424 }
00425
00435 function DB_copycut($table,$uid,$type) {
00436 if ($this->clipObj->current=='normal') {
00437 $isSel = $this->clipObj->isSelected($table,$uid);
00438 }
00439
00440 $addParam = array();
00441 if ($this->listFrame) {
00442 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00443 }
00444
00445 return $this->linkItem(
00446 $this->label($type),
00447 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00448 "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00449 );
00450 }
00451
00464 function DB_paste($table,$uid,$type,$elInfo) {
00465 $editOnClick = '';
00466 $loc = 'top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00467 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
00468 $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])).')';
00469 } else {
00470 $conf = $loc;
00471 }
00472 $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
00473
00474 return $this->linkItem(
00475 $this->label('paste'.$type),
00476 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
00477 $editOnClick.'return false;'
00478 );
00479 }
00480
00489 function DB_info($table,$uid) {
00490 return $this->linkItem(
00491 $this->label('info'),
00492 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
00493 "top.launchView('".$table."', '".$uid."'); return hideCM();"
00494 );
00495 }
00496
00505 function DB_history($table,$uid) {
00506 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
00507 return $this->linkItem(
00508 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
00509 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
00510 $this->urlRefForCM($url,'returnUrl'),
00511 0
00512 );
00513 }
00514
00524 function DB_perms($table,$uid,$rec) {
00525 $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':'');
00526 return $this->linkItem(
00527 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
00528 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
00529 $this->urlRefForCM($url),
00530 0
00531 );
00532 }
00533
00543 function DB_db_list($table,$uid,$rec) {
00544 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
00545 return $this->linkItem(
00546 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
00547 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
00548 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
00549 0
00550 );
00551 }
00552
00562 function DB_moveWizard($table,$uid,$rec) {
00563 $url = 'move_el.php?table='.$table.'&uid='.$uid.
00564 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):'');
00565
00566 return $this->linkItem(
00567 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
00568 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
00569 $this->urlRefForCM($url,'returnUrl'),
00570 0
00571 );
00572 }
00573
00583 function DB_newWizard($table,$uid,$rec) {
00584
00585 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00586 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
00587 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00588
00589 $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']);
00590 return $this->linkItem(
00591 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
00592 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
00593 $this->urlRefForCM($url,'returnUrl'),
00594 0
00595 );
00596 }
00597
00606 function DB_editAccess($table,$uid) {
00607 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
00608 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
00609 return $this->linkItem(
00610 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
00611 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
00612 $this->urlRefForCM($url,'returnUrl'),
00613 1
00614 );
00615 }
00616
00625 function DB_editPageHeader($uid) {
00626 return $this->DB_editPageProperties($uid);
00627 }
00628
00636 function DB_editPageProperties($uid) {
00637 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
00638 return $this->linkItem(
00639 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
00640 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
00641 $this->urlRefForCM($url,'returnUrl'),
00642 1
00643 );
00644 }
00645
00654 function DB_edit($table,$uid) {
00655 global $BE_USER;
00656
00657 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
00658 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00659
00660 $editOnClick='';
00661 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00662 $addParam='';
00663 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
00664 if (
00665 $this->iParts[0]=='pages' &&
00666 $this->iParts[1] &&
00667 $BE_USER->check('modules', $pageModule)
00668 ) {
00669 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
00670 $this->editPageIconSet=1;
00671 if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
00672 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
00673 } else {
00674 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
00675 }
00676 }
00677 if (!$editOnClick) {
00678 $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."';}";
00679 }
00680
00681 return $this->linkItem(
00682 $this->label('edit'),
00683 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
00684 $editOnClick.'return hideCM();'
00685 );
00686 }
00687
00696 function DB_new($table,$uid) {
00697 $editOnClick='';
00698 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00699 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
00700 ($this->listFrame?
00701 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
00702 'db_new.php?id='.intval($uid)."'").
00703 ';}';
00704
00705 return $this->linkItem(
00706 $this->label('new'),
00707 $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="" />'),
00708 $editOnClick.'return hideCM();'
00709 );
00710 }
00711
00721 function DB_delete($table,$uid,$elInfo) {
00722 $editOnClick='';
00723 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00724 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
00725 $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!)')).")";
00726 } else {
00727 $conf = '1==1';
00728 }
00729 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00730 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00731
00732 return $this->linkItem(
00733 $this->label('delete'),
00734 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00735 $editOnClick.'return false;'
00736 );
00737 }
00738
00747 function DB_view($id,$anchor='') {
00748 return $this->linkItem(
00749 $this->label('view'),
00750 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
00751 t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
00752 );
00753 }
00754
00762 function DB_tempMountPoint($page_id) {
00763 return $this->linkItem(
00764 $this->label('tempMountPoint'),
00765 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/placeasroot.gif','width="14" height="12"').' alt="" />'),
00766 "if (top.content.nav_frame) { top.content.nav_frame.location.href = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
00767 );
00768 }
00769
00779 function DB_hideUnhide($table,$rec,$hideField) {
00780 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?'un':'').'hide'), 'hide');
00781 }
00782
00794 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
00795 $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
00796 $editOnClick='';
00797 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00798 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00799 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00800
00801 return $this->linkItem(
00802 $title,
00803 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,$iconRelPath.'button_'.($rec[$flagField]?'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
00804 $editOnClick.'return false;',
00805 1
00806 );
00807 }
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00828 function printFileClickMenu($path) {
00829 $menuItems=array();
00830
00831 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path)) {
00832 $fI = pathinfo($path);
00833 $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
00834 $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
00835 $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
00836
00837
00838 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');
00839
00840 if (!in_array('rename',$this->disabledItems)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
00841
00842 if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
00843
00844 if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
00845
00846 if (!in_array('info',$this->disabledItems)) $menuItems['info']=$this->DB_info($path,'');
00847
00848 $menuItems[]='spacer';
00849
00850
00851 if (!in_array('copy',$this->disabledItems)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
00852
00853 if (!in_array('cut',$this->disabledItems)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
00854
00855
00856 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
00857 if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path)) {
00858 $elArr = $this->clipObj->elFromTable('_FILE');
00859 reset($elArr);
00860 $selItem = current($elArr);
00861 $elInfo=array(
00862 basename($selItem),
00863 basename($path),
00864 $this->clipObj->currentMode()
00865 );
00866 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
00867 }
00868
00869 $menuItems[]='spacer';
00870
00871
00872 if (!in_array('delete',$this->disabledItems)) $menuItems['delete']=$this->FILE_delete($path);
00873 }
00874
00875
00876 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
00877
00878
00879 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
00880
00881
00882 return $this->printItems($menuItems,$icon.basename($path));
00883 }
00884
00885
00892 function externalProcessingOfFileMenuItems($menuItems) {
00893 return $menuItems;
00894 }
00895
00906 function FILE_launch($path,$script,$type,$image) {
00907 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00908
00909 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
00910
00911 return $this->linkItem(
00912 $this->label($type),
00913 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
00914 $editOnClick.'return hideCM();'
00915 );
00916 }
00917
00926 function FILE_copycut($path,$type) {
00927 $table = '_FILE';
00928 $uid = t3lib_div::shortmd5($path);
00929 if ($this->clipObj->current=='normal') {
00930 $isSel = $this->clipObj->isSelected($table,$uid);
00931 }
00932
00933 $addParam = array();
00934 if ($this->listFrame) {
00935 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00936 }
00937
00938 return $this->linkItem(
00939 $this->label($type),
00940 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00941 "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00942 );
00943 }
00944
00952 function FILE_delete($path) {
00953 $editOnClick='';
00954 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00955 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
00956 $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!)')).")";
00957 } else {
00958 $conf = '1==1';
00959 }
00960 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00961 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00962
00963 return $this->linkItem(
00964 $this->label('delete'),
00965 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00966 $editOnClick.'return false;'
00967 );
00968 }
00969
00979 function FILE_paste($path,$target,$elInfo) {
00980 $editOnClick='';
00981 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00982 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
00983 $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])).")";
00984 } else {
00985 $conf=$loc;
00986 }
00987
00988 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
00989 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
00990
00991 return $this->linkItem(
00992 $this->label('pasteinto'),
00993 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
00994 $editOnClick.'return false;'
00995 );
00996 }
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01016 function printDragDropClickMenu($table,$srcId,$dstId) {
01017 $menuItems=array();
01018
01019
01020 if ($table == 'pages') {
01021
01022 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into');
01023
01024 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after');
01025
01026 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into');
01027
01028 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after');
01029 }
01030
01031
01032 if ($table == 'folders') {
01033
01034 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move');
01035
01036 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy');
01037 }
01038
01039
01040 $menuItems = $this->processingByExtClassArray($menuItems,"dragDrop_".$table,$srcId);
01041
01042
01043 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
01044
01045
01046 return $this->printItems($menuItems,
01047 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)
01048 );
01049 }
01050
01051
01058 function externalProcessingOfDragDropMenuItems($menuItems) {
01059 return $menuItems;
01060 }
01061
01062
01073 function dragDrop_copymovepage($srcUid,$dstUid,$action,$into) {
01074 $negativeSign = ($into == 'into') ? '' : '-';
01075 $editOnClick='';
01076 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
01077 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
01078 '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
01079
01080 return $this->linkItem(
01081 $this->label($action.'Page_'.$into),
01082 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
01083 $editOnClick.'return false;',
01084 0
01085 );
01086 }
01087
01088
01098 function dragDrop_copymovefolder($srcPath,$dstPath,$action) {
01099 $editOnClick='';
01100 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
01101 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
01102 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
01103
01104 return $this->linkItem(
01105 $this->label($action.'Folder_into'),
01106 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
01107 $editOnClick.'return false;',
01108 0
01109 );
01110 }
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01134 function printItems($menuItems,$item) {
01135
01136 $out='';
01137
01138
01139 $menuItems = $this->enableDisableItems($menuItems);
01140
01141
01142 $menuItems = $this->cleanUpSpacers($menuItems);
01143
01144
01145 if ($this->doDisplayTopFrameCM()) {
01146 $out.= '
01147
01148 <!--
01149 Table, which contains the click menu when shown in the top frame of the backend:
01150 -->
01151 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
01152 <tr>
01153
01154 <!-- Items: -->
01155 <td class="c-item">'.
01156 implode('</td>
01157 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
01158 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
01159 '</td>
01160
01161 <!-- Close button: -->
01162 <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>
01163
01164 <!-- The item of the clickmenu: -->
01165 <td class="c-itemicon">'.$item.'</td>
01166 </tr>
01167 </table>
01168 ';
01169
01170
01171 $out = str_replace($this->PH_backPath,'',$out);
01172 }
01173
01174 $out.=$this->printLayerJScode($menuItems);
01175
01176
01177 return $out;
01178 }
01179
01186 function printLayerJScode($menuItems) {
01187 $script='';
01188 if ($this->isCMlayers()) {
01189 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
01190 if ($this->alwaysContentFrame) $frameName='';
01191
01192
01193 $CMtable = '
01194 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
01195 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
01196 </table>';
01197
01198
01199 $CMtable = $this->wrapColorTableCM($CMtable);
01200
01201
01202 $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
01203 if ($this->ajax) {
01204 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
01205 return $innerXML;
01206 } else {
01207
01208 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
01209
01210 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
01211 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
01212 }
01213 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
01214 );
01215 return $script;
01216 }
01217 }
01218 }
01219
01227 function wrapColorTableCM($str) {
01228
01229
01230 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
01231 <tr class="c-rowA">
01232 <td class="c-aa">'.$str.'</td>
01233 <td class="c-ab"></td>
01234 </tr>
01235 <tr class="c-rowB">
01236 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
01237 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
01238 </tr>
01239 </table>';
01240 return $str;
01241 }
01242
01250 function menuItemsForTopFrame($menuItems) {
01251 reset($menuItems);
01252 $out=array();
01253 while(list(,$i)=each($menuItems)) {
01254 if ($i[4]==1 && !$GLOBALS['SOBE']->doc->isCMlayers()) $i[4]=0;
01255 if (is_array($i) && !$i[4]) $out[]=$i[0];
01256 }
01257 return $out;
01258 }
01259
01267 function menuItemsForClickMenu($menuItems) {
01268 reset($menuItems);
01269 $out=array();
01270 while(list($cc,$i)=each($menuItems)) {
01271 if (is_string($i) && $i=='spacer') {
01272 $out[]='
01273 <tr class="bgColor2">
01274 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
01275 </tr>';
01276 } else {
01277 $onClick=$i[3];
01278 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
01279 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
01280 $onClick=eregi_replace('hideCM\(\);','',$onClick);
01281 if (!$i[5]) $onClick.='hideEmpty();';
01282
01283 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
01284 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
01285 }
01286
01287 $out[]='
01288 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
01289 '.(!$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>').'
01290 </tr>';
01291 }
01292 }
01293 return $out;
01294 }
01295
01305 function addMenuItems($menuItems,$newMenuItems,$position='') {
01306 if (is_array($newMenuItems)) {
01307
01308 if($position) {
01309
01310 $posArr = t3lib_div::trimExplode(',', $position, 1);
01311 foreach($posArr as $pos) {
01312 list($place,$menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
01313 list($place,$placeExtra) = t3lib_div::trimExplode('-', $place, 1);
01314
01315
01316 $pointer = count($menuItems);
01317
01318 $found=FALSE;
01319
01320 if ($place) {
01321 switch(strtolower($place)) {
01322 case 'after':
01323 case 'before':
01324 if ($menuEntry) {
01325 $p=1;
01326 reset ($menuItems);
01327 while (true) {
01328 if (!strcmp(key($menuItems), $menuEntry)) {
01329 $pointer = $p;
01330 $found=TRUE;
01331 break;
01332 }
01333 if (!next($menuItems)) break;
01334 $p++;
01335 }
01336 if (!$found) break;
01337
01338 if ($place=='before') {
01339 $pointer--;
01340 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
01341 $pointer--;
01342 }
01343 } elseif ($place=='after') {
01344 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
01345 $pointer++;
01346 }
01347 }
01348 }
01349 break;
01350 default:
01351 if (strtolower($place)=='top') {
01352 $pointer = 0;
01353 } else {
01354 $pointer = count($menuItems);
01355