Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 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 // Internal, static: GPvar: 00139 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu. 00140 var $CB; // Clipboard array (submitted by eg. pressing the paste button) 00141 00142 // Internal, static: 00143 var $backPath=''; // Backpath for scripts/images. 00144 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) 00145 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset. 00146 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) 00147 var $alwaysContentFrame=0; // If true, the "content" frame is always used for reference (when condensed mode is enabled) 00148 var $iParts=array(); // Stores the parts of the input $item string, splitted by "|": [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame, If "2" then "content frame" is forced [3] = ("+" prefix = disable all by default, enable these. Default is to disable) Items key list 00149 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu 00150 var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer. 00151 var $leftIcons=0; // If true, Show icons on the left. 00152 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. 00153 var $ajax=0; // enable/disable ajax behavior 00154 00155 // Internal, dynamic: 00156 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon. 00157 var $editPageIconSet=0; // Set, when edit icon is drawn. 00158 var $editOK=0; // Set to true, if editing of the element is OK. 00159 var $rec=array(); 00160 00161 00162 00168 function init() { 00169 // Setting GPvars: 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); // XML has to be parsed, no parse errors allowed 00175 } 00176 00177 // Deal with Drag&Drop context menus 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 // can be set differently as well 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 // Setting flags: 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 // &cmLevel flag detected (2nd level menu) 00199 if (!$this->cmLevel) { 00200 // Make 1st level clickmenu: 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 // Make 2nd level clickmenu (only for DBmenus) 00208 if ($this->isDBmenu) { 00209 $CMcontent = $this->printNewDBLevel($this->iParts[0],$this->iParts[1]); 00210 } 00211 } 00212 00213 // Return clickmenu content: 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 * DATABASE 00244 * 00245 ***************************************/ 00246 00254 function printDBClickMenu($table,$uid) { 00255 global $TCA, $BE_USER; 00256 00257 // Get record: 00258 $this->rec = t3lib_BEfunc::getRecordWSOL($table,$uid); 00259 $menuItems=array(); 00260 $root=0; 00261 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel 00262 $root=1; 00263 } 00264 00265 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render. 00266 if (is_array($this->rec) || $root) { 00267 00268 // Get permissions 00269 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid']))); 00270 00271 // View 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 // Edit: 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 // New: 00284 if (!in_array('new',$this->disabledItems) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid); 00285 00286 // Info: 00287 if(!in_array('info',$this->disabledItems) && !$root) $menuItems['info']=$this->DB_info($table,$uid); 00288 00289 $menuItems['spacer1']='spacer'; 00290 00291 // Copy: 00292 if(!in_array('copy',$this->disabledItems) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy'); 00293 // Cut: 00294 if(!in_array('cut',$this->disabledItems) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut'); 00295 00296 // Paste: 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 // Delete: 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 // Adding external elements to the menuItems array 00326 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid); 00327 00328 // Processing by external functions? 00329 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems); 00330 00331 // Return the printed elements: 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 // Setting internal record to the table/uid : 00350 $this->rec = t3lib_BEfunc::getRecordWSOL($table,$uid); 00351 $menuItems=array(); 00352 $root=0; 00353 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel 00354 $root=1; 00355 } 00356 00357 // If record was found, check permissions and get menu items. 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 // Edit: 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 // Return the printed elements: 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']):''); // Hardcoded field for tt_content elements. 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 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead: 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 // no top frame CM! 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 // no top frame CM! 00640 ); 00641 } 00642 00651 function DB_edit($table,$uid) { 00652 global $BE_USER; 00653 // If another module was specified, replace the default Page module with the new one 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 * FILE 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 // edit 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 // rename 00837 if (!in_array('rename',$this->disabledItems)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif'); 00838 // upload 00839 if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif'); 00840 // new 00841 if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif'); 00842 // info 00843 if (!in_array('info',$this->disabledItems)) $menuItems['info']=$this->DB_info($path,''); 00844 00845 $menuItems[]='spacer'; 00846 00847 // copy: 00848 if (!in_array('copy',$this->disabledItems)) $menuItems['copy']=$this->FILE_copycut($path,'copy'); 00849 // cut: 00850 if (!in_array('cut',$this->disabledItems)) $menuItems['cut']=$this->FILE_copycut($path,'cut'); 00851 00852 // Paste: 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 // delete: 00869 if (!in_array('delete',$this->disabledItems)) $menuItems['delete']=$this->FILE_delete($path); 00870 } 00871 00872 // Adding external elements to the menuItems array 00873 $menuItems = $this->processingByExtClassArray($menuItems,$path,0); 00874 00875 // Processing by external functions? 00876 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems); 00877 00878 // Return the printed elements: 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'; // Pseudo table name for use in the clipboard. 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 * DRAG AND DROP 01002 * 01003 ***************************************/ 01004 01013 function printDragDropClickMenu($table,$srcId,$dstId) { 01014 $menuItems=array(); 01015 01016 // If the drag and drop menu should apply to PAGES use this set of menu items 01017 if ($table == 'pages') { 01018 // Move Into: 01019 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into'); 01020 // Move After: 01021 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after'); 01022 // Copy Into: 01023 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into'); 01024 // Copy After: 01025 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after'); 01026 } 01027 01028 // If the drag and drop menu should apply to FOLDERS use this set of menu items 01029 if ($table == 'folders') { 01030 // Move Into: 01031 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move'); 01032 // Copy Into: 01033 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy'); 01034 } 01035 01036 // Adding external elements to the menuItems array 01037 $menuItems = $this->processingByExtClassArray($menuItems,"dragDrop_".$table,$srcId); // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar 01038 01039 // Processing by external functions? 01040 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems); 01041 01042 // Return the printed elements: 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 * COMMON 01120 * 01121 **************************************/ 01122 01131 function printItems($menuItems,$item) { 01132 01133 $out=''; 01134 01135 // Enable/Disable items: 01136 $menuItems = $this->enableDisableItems($menuItems); 01137 01138 // Clean up spacers: 01139 $menuItems = $this->cleanUpSpacers($menuItems); 01140 01141 // Adding topframe part (horizontal clickmenu) 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 // Set remaining BACK_PATH to blank (if any) 01168 $out = str_replace($this->PH_backPath,'',$out); 01169 } 01170 // Adding JS part: 01171 $out.=$this->printLayerJScode($menuItems); 01172 01173 // Return the content 01174 return $out; 01175 } 01176 01183 function printLayerJScode($menuItems) { 01184 $script=''; 01185 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation. 01186 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame'); 01187 if ($this->alwaysContentFrame) $frameName=''; 01188 01189 // Create the table displayed in the clickmenu layer: 01190 $CMtable = ' 01191 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4"> 01192 '.implode('',$this->menuItemsForClickMenu($menuItems)).' 01193 </table>'; 01194 01195 // Wrap the inner table in another table to create outer border: 01196 $CMtable = $this->wrapColorTableCM($CMtable); 01197 01198 // Set back path place holder to real back path 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 // Create JavaScript section: 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 // Clear-gifs needed if opera is to set the table row height correctly in skins. 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; // 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) 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') { // MAKE horizontal 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 { // Just make normal element: 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 // bottom 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 = count($menuItems); 01352 } 01353 $found=TRUE; 01354 break; 01355 } 01356 } 01357 if($found) break; 01358 } 01359 } 01360 $pointer=max(0,$pointer); 01361 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?$pointer:0)); 01362 $menuItemsAfter = array_slice($menuItems, $pointer); 01363 $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter; 01364 } 01365 return $menuItems; 01366 } 01367 01378 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) { 01379 global $BACK_PATH; 01380 01381 $this->elCount++; 01382 if($this->ajax) { 01383 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick); 01384 } 01385 01386 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2); 01387 01388 return array( 01389 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'. 01390 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'. 01391 $str.$icon. 01392 '</a>', 01393 $str, 01394 $icon, 01395 $onClick, 01396 $onlyCM, 01397 $dontHide 01398 ); 01399 } 01400 01407 function excludeIcon($iconCode) { 01408 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode; 01409 } 01410 01417 function enableDisableItems($menuItems) { 01418 if ($this->iParts[3]) { 01419 01420 // Detect "only" mode: (only showing listed items) 01421 if (substr($this->iParts[3],0,1)=='+') { 01422 $this->iParts[3] = substr($this->iParts[3],1); 01423 $only = TRUE; 01424 } else { 01425 $only = FALSE; 01426 } 01427 01428 // Do filtering: 01429 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers) 01430 $newMenuArray = array(); 01431 foreach($menuItems as $key => $value) { 01432 if (t3lib_div::inList($this->iParts[3], $key) || (is_string($value) && $value=='spacer')) { 01433 $newMenuArray[$key] = $value; 01434 } 01435 } 01436 $menuItems = $newMenuArray; 01437 } else { // Traverse all elements except those listed (just unsetting them): 01438 $elements = t3lib_div::trimExplode(',',$this->iParts[3],1); 01439 foreach($elements as $value) { 01440 unset($menuItems[$value]); 01441 } 01442 } 01443 } 01444 01445 // Return processed menu items: 01446 return $menuItems; 01447 } 01448 01455 function cleanUpSpacers($menuItems) { 01456 01457 // Remove doubles: 01458 $prevItemWasSpacer = FALSE; 01459 foreach($menuItems as $key => $value) { 01460 if (is_string($value) && $value=='spacer') { 01461 if ($prevItemWasSpacer) { 01462 unset($menuItems[$key]); 01463 } 01464 $prevItemWasSpacer = TRUE; 01465 } else { 01466 $prevItemWasSpacer = FALSE; 01467 } 01468 } 01469 01470 // Remove first: 01471 reset($menuItems); 01472 $key = key($menuItems); 01473 $value = current($menuItems); 01474 if (is_string($value) && $value=='spacer') { 01475 unset($menuItems[$key]); 01476 } 01477 01478 01479 // Remove last: 01480 end($menuItems); 01481 $key = key($menuItems); 01482 $value = current($menuItems); 01483 if (is_string($value) && $value=='spacer') { 01484 unset($menuItems[$key]); 01485 } 01486 01487 // Return processed menu items: 01488 return $menuItems; 01489 } 01490 01497 function label($label) { 01498 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1)); 01499 } 01500 01506 function isCMlayers() { 01507 if($this->ajax) { 01508 return !$this->CB; 01509 } else { 01510 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB; 01511 } 01512 } 01513 01520 function frameLocation($str) { 01521 return $str.'.location'; 01522 } 01523 } 01524 01525 01526 01527 01528 01529 01530 01531 01532 01533 01534 01535 01536 01545 class SC_alt_clickmenu { 01546 01547 // Internal, static: GPvar: 01548 var $backPath; // Back path. 01549 var $item; // Definition of which item the click menu should be made for. 01550 var $reloadListFrame; // Defines the name of the document object for which to reload the URL. 01551 01552 // Internal: 01553 var $content=''; // Content accumulation 01554 var $doc; // Template object 01555 var $include_once=array(); // Files to include_once() - set in init() function 01556 var $extClassArray=array(); // Internal array of classes for extending the clickmenu 01557 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame. 01558 01564 function init() { 01565 global $BE_USER,$BACK_PATH; 01566 01567 // Setting GPvars: 01568 $this->backPath = t3lib_div::_GP('backPath'); 01569 $this->item = t3lib_div::_GP('item'); 01570 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame'); 01571 01572 // Setting pseudo module name 01573 $this->MCONF['name']='xMOD_alt_clickmenu.php'; 01574 01575 // 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: 01576 $inputBP = explode('|',$this->backPath); 01577 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { 01578 $this->backPath = $inputBP[0]; 01579 } else { 01580 $this->backPath = $BACK_PATH; 01581 } 01582 01583 // Setting internal array of classes for extending the clickmenu: 01584 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses']; 01585 01586 // Traversing that array and setting files for inclusion: 01587 if (is_array($this->extClassArray)) { 01588 foreach($this->extClassArray as $extClassConf) { 01589 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path']; 01590 } 01591 } 01592 01593 // Initialize template object 01594 if (!$this->ajax) { 01595 $this->doc = t3lib_div::makeInstance('template'); 01596 $this->doc->docType='xhtml_trans'; 01597 $this->doc->backPath = $BACK_PATH; 01598 } 01599 01600 // Setting mode for display and background image in the top frame 01601 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame'); 01602 if ($this->dontDisplayTopFrameCM) { 01603 $this->doc->bodyTagId.= '-notop'; 01604 } 01605 01606 // Setting clickmenu timeout 01607 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5 01608 01609 // Setting the JavaScript controlling the timer on the page 01610 $listFrameDoc = $this->reloadListFrame!=2 ? 'top.content.list_frame' : 'top.content'; 01611 $this->doc->JScode.=$this->doc->wrapScriptTags(' 01612 var date = new Date(); 01613 var mo_timeout = Math.floor(date.getTime()/1000); 01614 01615 roImg =new Image(); 01616 roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'"; 01617 01618 routImg =new Image(); 01619 routImg.src = "clear.gif"; 01620 01621 function mo(c) { // 01622 var name="roimg_"+c; 01623 document[name].src = roImg.src; 01624 updateTime(); 01625 } 01626 function mout(c) { // 01627 var name="roimg_"+c; 01628 document[name].src = routImg.src; 01629 updateTime(); 01630 } 01631 function updateTime() { // 01632 date = new Date(); 01633 mo_timeout = Math.floor(date.getTime()/1000); 01634 } 01635 function timeout_func() { // 01636 date = new Date(); 01637 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') { 01638 hideCM(); 01639 return false; 01640 } else { 01641 window.setTimeout("timeout_func();",1*1000); 01642 } 01643 } 01644 function hideCM() { // 01645 window.location.href="alt_topmenu_dummy.php"; 01646 return false; 01647 } 01648 01649 // Start timer 01650 timeout_func(); 01651 01652 '.($this->reloadListFrame ? ' 01653 // Reload list frame: 01654 if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' : 01655 '').' 01656 '); 01657 } 01658 01664 function main() { 01665 $this->ajax = t3lib_div::_GP('ajax') ? TRUE : FALSE; 01666 01667 // Initialize Clipboard object: 01668 $clipObj = t3lib_div::makeInstance('t3lib_clipboard'); 01669 $clipObj->initializeClipboard(); 01670 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request. 01671 01672 // Update clipboard if some actions are sent. 01673 $CB = t3lib_div::_GET('CB'); 01674 $clipObj->setCmd($CB); 01675 $clipObj->cleanCurrent(); 01676 $clipObj->endClipboard(); // Saves 01677 01678 // Create clickmenu object 01679 $clickMenu = t3lib_div::makeInstance('clickMenu'); 01680 01681 // Set internal vars in clickmenu object: 01682 $clickMenu->clipObj = $clipObj; 01683 $clickMenu->extClassArray = $this->extClassArray; 01684 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM; 01685 $clickMenu->backPath = $this->backPath; 01686 01687 // Start page 01688 if(!$this->ajax) { 01689 $this->content.= $this->doc->startPage('Context Sensitive Menu'); 01690 } 01691 // Set content of the clickmenu with the incoming var, "item" 01692 $this->content.= $clickMenu->init(); 01693 } 01694 01700 function printContent() { 01701 if (!$this->ajax) { 01702 $this->content.= $this->doc->endPage(); 01703 $this->content = $this->doc->insertStylesAndJS($this->content); 01704 echo $this->content; 01705 } else { 01706 $this->content = $GLOBALS['LANG']->csConvObj->utf8_encode($this->content,$GLOBALS['LANG']->charSet); 01707 t3lib_ajax::outputXMLreply($this->content); 01708 } 01709 } 01710 } 01711 01712 // Include extension? 01713 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) { 01714 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']); 01715 } 01716 01717 01718 01719 01720 01721 01722 01723 01724 01725 01726 // Make instance: 01727 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu'); 01728 $SOBE->init(); 01729 01730 // Include files? 01731 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE); 01732 01733 $SOBE->main(); 01734 $SOBE->printContent(); 01735 ?>