"TYPO3 4.0.1: typo3_src-4.0.1/typo3/alt_clickmenu.php Source File", "datetime" => "Sat Dec 2 19:22:20 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

alt_clickmenu.php

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,1)
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,1)
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 
00414         function urlRefForCM($url,$retUrl='',$hideCM=1) {
00415                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00416                 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
00417                         ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
00418                         ($hideCM?'return hideCM();':'');
00419                 return $editOnClick;
00420         }
00421 
00431         function DB_copycut($table,$uid,$type)  {
00432                 if ($this->clipObj->current=='normal')  {
00433                         $isSel = $this->clipObj->isSelected($table,$uid);
00434                 }
00435 
00436                 $addParam = array();
00437                 if ($this->listFrame)   {
00438                         $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00439                 }
00440 
00441                 return $this->linkItem(
00442                         $this->label($type),
00443                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00444                         "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00445                 );
00446         }
00447 
00460         function DB_paste($table,$uid,$type,$elInfo)    {
00461                 $editOnClick = '';
00462                 $loc = 'top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00463                 if($GLOBALS['BE_USER']->jsConfirmation(2))      {
00464                 $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])).')';
00465                 } else {
00466                         $conf = $loc;
00467                 }
00468                 $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
00469 
00470                 return $this->linkItem(
00471                         $this->label('paste'.$type),
00472                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
00473                         $editOnClick.'return false;'
00474                 );
00475         }
00476 
00485         function DB_info($table,$uid)   {
00486                 return $this->linkItem(
00487                         $this->label('info'),
00488                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
00489                         "top.launchView('".$table."', '".$uid."'); return hideCM();"
00490                 );
00491         }
00492 
00501         function DB_history($table,$uid)        {
00502                 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
00503                 return $this->linkItem(
00504                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
00505                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
00506                         $this->urlRefForCM($url,'returnUrl'),
00507                         0
00508                 );
00509         }
00510 
00520         function DB_perms($table,$uid,$rec)     {
00521                 $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':'');
00522                 return $this->linkItem(
00523                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
00524                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
00525                         $this->urlRefForCM($url),
00526                         0
00527                 );
00528         }
00529 
00539         function DB_db_list($table,$uid,$rec)   {
00540                 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
00541                 return $this->linkItem(
00542                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
00543                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
00544                         "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
00545                         0
00546                 );
00547         }
00548 
00558         function DB_moveWizard($table,$uid,$rec)        {
00559                 $url = 'move_el.php?table='.$table.'&uid='.$uid.
00560                                 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):'');        // Hardcoded field for tt_content elements.
00561 
00562                 return $this->linkItem(
00563                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
00564                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
00565                         $this->urlRefForCM($url,'returnUrl'),
00566                         0
00567                 );
00568         }
00569 
00579         function DB_newWizard($table,$uid,$rec) {
00580                         //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
00581                 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00582                 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
00583                 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00584 
00585                 $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']);
00586                 return $this->linkItem(
00587                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
00588                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
00589                         $this->urlRefForCM($url,'returnUrl'),
00590                         0
00591                 );
00592         }
00593 
00602         function DB_editAccess($table,$uid)     {
00603                 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
00604                 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
00605                 return $this->linkItem(
00606                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
00607                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
00608                         $this->urlRefForCM($url,'returnUrl'),
00609                         1       // no top frame CM!
00610                 );
00611         }
00612 
00621         function DB_editPageHeader($uid)        {
00622                 return $this->DB_editPageProperties($uid);
00623         }
00624 
00632         function DB_editPageProperties($uid)    {
00633                 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
00634                 return $this->linkItem(
00635                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
00636                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
00637                         $this->urlRefForCM($url,'returnUrl'),
00638                         1       // no top frame CM!
00639                 );
00640         }
00641 
00650         function DB_edit($table,$uid)   {
00651                 global $BE_USER;
00652                         // If another module was specified, replace the default Page module with the new one
00653                 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
00654                 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00655 
00656                 $editOnClick='';
00657                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00658                 $addParam='';
00659                 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
00660                 if (
00661                                 $this->iParts[0]=='pages' &&
00662                                 $this->iParts[1] &&
00663                                 $BE_USER->check('modules', $pageModule)
00664                         )       {
00665                         $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
00666                         $this->editPageIconSet=1;
00667                         if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms'))      {
00668                                 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
00669                         } else {
00670                                 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
00671                         }
00672                 }
00673                 if (!$editOnClick)      {
00674                         $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."';}";
00675                 }
00676 
00677                 return $this->linkItem(
00678                         $this->label('edit'),
00679                         $this->excludeIcon('<img'.$theIcon.' alt="" />'),
00680                         $editOnClick.'return hideCM();'
00681                 );
00682         }
00683 
00692         function DB_new($table,$uid)    {
00693                 $editOnClick='';
00694                 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00695                 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
00696                         ($this->listFrame?
00697                                 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
00698                                 'db_new.php?id='.intval($uid)."'").
00699                         ';}';
00700 
00701                 return $this->linkItem(
00702                         $this->label('new'),
00703                         $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="" />'),
00704                         $editOnClick.'return hideCM();'
00705                 );
00706         }
00707 
00717         function DB_delete($table,$uid,$elInfo) {
00718                 $editOnClick='';
00719                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00720                 if($GLOBALS['BE_USER']->jsConfirmation(4))      {
00721                         $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!)')).")";
00722                 } else {
00723                         $conf = '1==1';
00724                 }
00725                 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00726                         "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00727 
00728                 return $this->linkItem(
00729                         $this->label('delete'),
00730                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00731                         $editOnClick.'return false;'
00732                 );
00733         }
00734 
00743         function DB_view($id,$anchor='')        {
00744                 return $this->linkItem(
00745                         $this->label('view'),
00746                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
00747                         t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
00748                 );
00749         }
00750 
00758         function DB_tempMountPoint($page_id)    {
00759                 return $this->linkItem(
00760                         $this->label('tempMountPoint'),
00761                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/placeasroot.gif','width="14" height="12"').' alt="" />'),
00762                         "if (top.content.nav_frame) { top.content.nav_frame.location.href = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
00763                 );
00764         }
00765 
00775         function DB_hideUnhide($table,$rec,$hideField)  {
00776                 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?'un':'').'hide'), 'hide');
00777         }
00778 
00790         function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/')    {
00791             $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
00792             $editOnClick='';
00793             $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00794             $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00795                 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00796 
00797             return $this->linkItem(
00798                 $title,
00799                 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,$iconRelPath.'button_'.($rec[$flagField]?'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
00800                 $editOnClick.'return false;',
00801                 1
00802             );
00803         }
00804 
00805 
00806 
00807 
00808 
00809 
00810 
00811 
00812         /***************************************
00813          *
00814          * FILE
00815          *
00816          ***************************************/
00817 
00824         function printFileClickMenu($path)      {
00825                 $menuItems=array();
00826 
00827                 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path))  {
00828                         $fI = pathinfo($path);
00829                         $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
00830                         $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
00831                         $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
00832 
00833                                 // edit
00834                         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');
00835                                 // rename
00836                         if (!in_array('rename',$this->disabledItems))   $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
00837                                 // upload
00838                         if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
00839                                 // new
00840                         if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
00841                                 // info
00842                         if (!in_array('info',$this->disabledItems))     $menuItems['info']=$this->DB_info($path,'');
00843 
00844                         $menuItems[]='spacer';
00845 
00846                                 // copy:
00847                         if (!in_array('copy',$this->disabledItems))     $menuItems['copy']=$this->FILE_copycut($path,'copy');
00848                                 // cut:
00849                         if (!in_array('cut',$this->disabledItems))      $menuItems['cut']=$this->FILE_copycut($path,'cut');
00850 
00851                                 // Paste:
00852                         $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
00853                         if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path))       {
00854                                 $elArr = $this->clipObj->elFromTable('_FILE');
00855                                 reset($elArr);
00856                                 $selItem = current($elArr);
00857                                 $elInfo=array(
00858                                         basename($selItem),
00859                                         basename($path),
00860                                         $this->clipObj->currentMode()
00861                                 );
00862                                 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
00863                         }
00864 
00865                         $menuItems[]='spacer';
00866 
00867                                 // delete:
00868                         if (!in_array('delete',$this->disabledItems))   $menuItems['delete']=$this->FILE_delete($path);
00869                 }
00870 
00871                         // Adding external elements to the menuItems array
00872                 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
00873 
00874                         // Processing by external functions?
00875                 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
00876 
00877                         // Return the printed elements:
00878                 return $this->printItems($menuItems,$icon.basename($path));
00879         }
00880 
00881 
00888         function externalProcessingOfFileMenuItems($menuItems)  {
00889                 return $menuItems;
00890         }
00891 
00902         function FILE_launch($path,$script,$type,$image)        {
00903                 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00904 
00905                 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
00906 
00907                 return $this->linkItem(
00908                         $this->label($type),
00909                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
00910                         $editOnClick.'return hideCM();'
00911                 );
00912         }
00913 
00922         function FILE_copycut($path,$type)      {
00923                 $table = '_FILE';               // Pseudo table name for use in the clipboard.
00924                 $uid = t3lib_div::shortmd5($path);
00925                 if ($this->clipObj->current=='normal')  {
00926                         $isSel = $this->clipObj->isSelected($table,$uid);
00927                 }
00928 
00929                 $addParam = array();
00930                 if ($this->listFrame)   {
00931                         $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00932                 }
00933 
00934                 return $this->linkItem(
00935                         $this->label($type),
00936                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00937                         "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00938                 );
00939         }
00940 
00948         function FILE_delete($path)     {
00949                 $editOnClick='';
00950                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00951                 if($GLOBALS['BE_USER']->jsConfirmation(4))      {
00952                         $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!)')).")";
00953                 } else {
00954                         $conf = '1==1';
00955                 }
00956                 $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00957                         "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00958 
00959                 return $this->linkItem(
00960                         $this->label('delete'),
00961                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00962                         $editOnClick.'return false;'
00963                 );
00964         }
00965 
00975         function FILE_paste($path,$target,$elInfo)      {
00976                 $editOnClick='';
00977                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00978                 if($GLOBALS['BE_USER']->jsConfirmation(2))      {
00979                 $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])).")";
00980                 } else {
00981                         $conf=$loc;
00982                 }
00983 
00984                 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
00985                         "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
00986 
00987                 return $this->linkItem(
00988                         $this->label('pasteinto'),
00989                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
00990                         $editOnClick.'return false;'
00991                 );
00992         }
00993 
00994 
00995 
00996 
00997 
00998         /***************************************
00999          *
01000          * DRAG AND DROP
01001          *
01002          ***************************************/
01003 
01012         function printDragDropClickMenu($table,$srcId,$dstId)   {
01013                 $menuItems=array();
01014 
01015                         // If the drag and drop menu should apply to PAGES use this set of menu items
01016                 if ($table == 'pages')  {
01017                                 // Move Into:
01018                         $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'move','into');
01019                                 // Move After:
01020                         $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'move','after');
01021                                 // Copy Into:
01022                         $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','into');
01023                                 // Copy After:
01024                         $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId,$dstId,'copy','after');
01025                 }
01026 
01027                         // If the drag and drop menu should apply to FOLDERS use this set of menu items
01028                 if ($table == 'folders')        {
01029                                 // Move Into:
01030                         $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'move');
01031                                 // Copy Into:
01032                         $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId,$dstId,'copy');
01033                 }
01034 
01035                         // Adding external elements to the menuItems array
01036                 $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
01037 
01038                         // Processing by external functions?
01039                 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
01040 
01041                         // Return the printed elements:
01042                 return $this->printItems($menuItems,
01043                         t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
01044                 );
01045         }
01046 
01047 
01054         function externalProcessingOfDragDropMenuItems($menuItems)      {
01055                 return $menuItems;
01056         }
01057 
01058 
01069         function dragDrop_copymovepage($srcUid,$dstUid,$action,$into)   {
01070                 $negativeSign = ($into == 'into') ? '' : '-';
01071                 $editOnClick='';
01072                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
01073                 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
01074                         '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
01075 
01076                 return $this->linkItem(
01077                         $this->label($action.'Page_'.$into),
01078                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
01079                         $editOnClick.'return false;',
01080                         0
01081                 );
01082         }
01083 
01084 
01094         function dragDrop_copymovefolder($srcPath,$dstPath,$action)     {
01095                 $editOnClick='';
01096                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
01097                 $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
01098                         '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
01099 
01100                 return $this->linkItem(
01101                         $this->label($action.'Folder_into'),
01102                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
01103                         $editOnClick.'return false;',
01104                         0
01105                 );
01106         }
01107 
01108 
01109 
01110 
01111 
01112 
01113 
01114 
01115 
01116         /***************************************
01117          *
01118          * COMMON
01119          *
01120          **************************************/
01121 
01130         function printItems($menuItems,$item)   {
01131 
01132                 $out='';
01133 
01134                         // Enable/Disable items:
01135                 $menuItems = $this->enableDisableItems($menuItems);
01136 
01137                         // Clean up spacers:
01138                 $menuItems = $this->cleanUpSpacers($menuItems);
01139 
01140                         // Adding topframe part (horizontal clickmenu)
01141                 if ($this->doDisplayTopFrameCM())       {
01142                         $out.= '
01143 
01144                                 <!--
01145                                         Table, which contains the click menu when shown in the top frame of the backend:
01146                                 -->
01147                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
01148                                         <tr>
01149 
01150                                                         <!-- Items: -->
01151                                                 <td class="c-item">'.
01152                                                         implode('</td>
01153                                                 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
01154                                                 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
01155                                                 '</td>
01156 
01157                                                         <!-- Close button: -->
01158                                                 <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>
01159 
01160                                                         <!-- The item of the clickmenu: -->
01161                                                 <td class="c-itemicon">'.$item.'</td>
01162                                         </tr>
01163                                 </table>
01164                         ';
01165 
01166                                 // Set remaining BACK_PATH to blank (if any)
01167                         $out = str_replace($this->PH_backPath,'',$out);
01168                 }
01169                         // Adding JS part:
01170                 $out.=$this->printLayerJScode($menuItems);
01171 
01172                         // Return the content
01173                 return $out;
01174         }
01175 
01182         function printLayerJScode($menuItems)   {
01183                 $script='';
01184                 if ($this->isCMlayers())        {       // Clipboard must not be submitted - then it's probably a copy/cut situation.
01185                         $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
01186                         if ($this->alwaysContentFrame)  $frameName='';
01187 
01188                                 // Create the table displayed in the clickmenu layer:
01189                         $CMtable = '
01190                                 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
01191                                         '.implode('',$this->menuItemsForClickMenu($menuItems)).'
01192                                 </table>';
01193 
01194                                 // Wrap the inner table in another table to create outer border:
01195                         $CMtable = $this->wrapColorTableCM($CMtable);
01196 
01197                                 // Set back path place holder to real back path
01198                         $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
01199                         if ($this->ajax)        {
01200                                 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
01201                                 return $innerXML;
01202                         } else {
01203                                         // Create JavaScript section:
01204                                 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
01205 
01206                                 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj)  {
01207                                         top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
01208                                 }
01209                                 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
01210                                 );
01211                                 return $script;
01212                         }
01213                 }
01214         }
01215 
01223         function wrapColorTableCM($str) {
01224 
01225                         // Clear-gifs needed if opera is to set the table row height correctly in skins.
01226                 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
01227                                 <tr class="c-rowA">
01228                                         <td class="c-aa">'.$str.'</td>
01229                                         <td class="c-ab"></td>
01230                                 </tr>
01231                                 <tr class="c-rowB">
01232                                         <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
01233                                         <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
01234                                 </tr>
01235                         </table>';
01236                 return $str;
01237         }
01238 
01246         function menuItemsForTopFrame($menuItems)       {
01247                 reset($menuItems);
01248                 $out=array();
01249                 while(list(,$i)=each($menuItems))       {
01250                         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)
01251                         if (is_array($i) && !$i[4])     $out[]=$i[0];
01252                 }
01253                 return $out;
01254         }
01255 
01263         function menuItemsForClickMenu($menuItems)      {
01264                 reset($menuItems);
01265                 $out=array();
01266                 while(list($cc,$i)=each($menuItems))    {
01267                         if (is_string($i) && $i=='spacer')      {       // MAKE horizontal spacer
01268                                 $out[]='
01269                                         <tr class="bgColor2">
01270                                                 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
01271                                         </tr>';
01272                         } else {        // Just make normal element:
01273                                 $onClick=$i[3];
01274                                 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
01275                                 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
01276                                 $onClick=eregi_replace('hideCM\(\);','',$onClick);
01277                                 if (!$i[5])     $onClick.='hideEmpty();';
01278 
01279                                 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])   {
01280                                         $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
01281                                 }
01282 
01283                                 $out[]='
01284                                         <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
01285                                                 '.(!$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>').'
01286                                         </tr>';
01287                         }
01288                 }
01289                 return $out;
01290         }
01291 
01301         function addMenuItems($menuItems,$newMenuItems,$position='')    {
01302                 if (is_array($newMenuItems))    {
01303 
01304                         if($position) {
01305 
01306                                 $posArr = t3lib_div::trimExplode(',', $position, 1);
01307                                 foreach($posArr as $pos) {
01308                                         list($place,$menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
01309                                         list($place,$placeExtra) = t3lib_div::trimExplode('-', $place, 1);
01310 
01311                                                 // bottom
01312                                         $pointer = count($menuItems);
01313 
01314                                         $found=FALSE;
01315 
01316                                         if ($place) {
01317                                                 switch(strtolower($place))      {
01318                                                         case 'after':
01319                                                         case 'before':
01320                                                                 if ($menuEntry) {
01321                                                                         $p=1;
01322                                                                         reset ($menuItems);
01323                                                                         while (true) {
01324                                                                                 if (!strcmp(key($menuItems), $menuEntry))       {
01325                                                                                         $pointer = $p;
01326                                                                                         $found=TRUE;
01327                                                                                         break;
01328                                                                                 }
01329                                                                                 if (!next($menuItems)) break;
01330                                                                                 $p++;
01331                                                                         }
01332                                                                         if (!$found) break;
01333 
01334                                                                         if ($place=='before') {
01335                                                                                 $pointer--;
01336                                                                                 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
01337                                                                                         $pointer--;
01338                                                                                 }
01339                                                                         } elseif ($place=='after') {
01340                                                                                 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
01341                                                                                         $pointer++;
01342                                                                                 }
01343                                                                         }
01344                                                                 }
01345                                                         break;
01346                                                         default:
01347                                                                 if (strtolower($place)=='top')  {
01348                                                                         $pointer = 0;
01349                                                                 } else {
01350                                                                         $pointer = count($menuItems);
01351                                                                 }
01352                                                                 $found=TRUE;
01353                                                         break;
01354                                                 }
01355                                         }
01356                                         if($found) break;
01357                                 }
01358                         }
01359                         $pointer=max(0,$pointer);
01360                         $menuItemsBefore = array_slice($menuItems, 0, ($pointer?$pointer:0));
01361                         $menuItemsAfter = array_slice($menuItems, $pointer);
01362                         $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
01363                 }
01364                 return $menuItems;
01365         }
01366 
01377         function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)    {
01378                 global $BACK_PATH;
01379 
01380                 $this->elCount++;
01381                 if($this->ajax) {
01382                         $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
01383                 }
01384 
01385                 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
01386 
01387                 return array(
01388                         '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
01389                                 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
01390                                 $str.$icon.
01391                                 '</a>',
01392                         $str,
01393                         $icon,
01394                         $onClick,
01395                         $onlyCM,
01396                         $dontHide
01397                 );
01398         }
01399 
01406         function excludeIcon($iconCode) {
01407                 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
01408         }
01409 
01416         function enableDisableItems($menuItems) {
01417                 if ($this->iParts[3])   {
01418 
01419                                 // Detect "only" mode: (only showing listed items)
01420                         if (substr($this->iParts[3],0,1)=='+')  {
01421                                 $this->iParts[3] = substr($this->iParts[3],1);
01422                                 $only = TRUE;
01423                         } else {
01424                                 $only = FALSE;
01425                         }
01426 
01427                                 // Do filtering:
01428                         if ($only)      {       // Transfer ONLY elements which are mentioned (or are spacers)
01429                                 $newMenuArray = array();
01430                                 foreach($menuItems as $key => $value)   {
01431                                         if (t3lib_div::inList($this->iParts[3], $key) || (is_string($value) && $value=='spacer'))       {
01432                                                 $newMenuArray[$key] = $value;
01433                                         }
01434                                 }
01435                                 $menuItems = $newMenuArray;
01436                         } else {        // Traverse all elements except those listed (just unsetting them):
01437                                 $elements = t3lib_div::trimExplode(',',$this->iParts[3],1);
01438                                 foreach($elements as $value)    {
01439                                         unset($menuItems[$value]);
01440                                 }
01441                         }
01442                 }
01443 
01444                         // Return processed menu items:
01445                 return $menuItems;
01446         }
01447 
01454         function cleanUpSpacers($menuItems)     {
01455 
01456                         // Remove doubles:
01457                 $prevItemWasSpacer = FALSE;
01458                 foreach($menuItems as $key => $value)   {
01459                         if (is_string($value) && $value=='spacer')      {
01460                                 if ($prevItemWasSpacer) {
01461                                         unset($menuItems[$key]);
01462                                 }
01463                                 $prevItemWasSpacer = TRUE;
01464                         } else {
01465                                 $prevItemWasSpacer = FALSE;
01466                         }
01467                 }
01468 
01469                         // Remove first:
01470                 reset($menuItems);
01471                 $key = key($menuItems);
01472                 $value = current($menuItems);
01473                 if (is_string($value) && $value=='spacer')      {
01474                         unset($menuItems[$key]);
01475                 }
01476 
01477 
01478                         // Remove last:
01479                 end($menuItems);
01480                 $key = key($menuItems);
01481                 $value = current($menuItems);
01482                 if (is_string($value) && $value=='spacer')      {
01483                         unset($menuItems[$key]);
01484                 }
01485 
01486                         // Return processed menu items:
01487                 return $menuItems;
01488         }
01489 
01496         function label($label)  {
01497                 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
01498         }
01499 
01505         function isCMlayers()   {
01506                 if($this->ajax) {
01507                         return !$this->CB;
01508                 } else {
01509                         return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
01510                 }
01511         }
01512 
01519         function frameLocation($str)    {
01520                 return $str.'.location';
01521         }
01522 }
01523 
01524 
01525 
01526 
01527 
01528 
01529 
01530 
01531 
01532 
01533 
01534 
01535 
01544 class SC_alt_clickmenu {
01545 
01546                 // Internal, static: GPvar:
01547         var $backPath;                                  // Back path.
01548         var $item;                                              // Definition of which item the click menu should be made for.
01549         var $reloadListFrame;                   // Defines the name of the document object for which to reload the URL.
01550 
01551                 // Internal:
01552         var $content='';                                // Content accumulation
01553         var $doc;                                               // Template object
01554         var $include_once=array();              // Files to include_once() - set in init() function
01555         var $extClassArray=array();             // Internal array of classes for extending the clickmenu
01556         var $dontDisplayTopFrameCM=0;   // If set, then the clickmenu will NOT display in the top frame.
01557 
01563         function init() {
01564                 global $BE_USER,$BACK_PATH;
01565 
01566                         // Setting GPvars:
01567                 $this->backPath = t3lib_div::_GP('backPath');
01568                 $this->item = t3lib_div::_GP('item');
01569                 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame');
01570 
01571                         // Setting pseudo module name
01572                 $this->MCONF['name']='xMOD_alt_clickmenu.php';
01573 
01574                         // 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:
01575                 $inputBP = explode('|',$this->backPath);
01576                 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
01577                         $this->backPath = $inputBP[0];
01578                 } else {
01579                         $this->backPath = $BACK_PATH;
01580                 }
01581 
01582                         // Setting internal array of classes for extending the clickmenu:
01583                 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
01584 
01585                         // Traversing that array and setting files for inclusion:
01586                 if (is_array($this->extClassArray))     {
01587                         foreach($this->extClassArray as $extClassConf)  {
01588                                 if ($extClassConf['path'])      $this->include_once[]=$extClassConf['path'];
01589                         }
01590                 }
01591 
01592                         // Initialize template object
01593                 if(!$this->ajax)        {
01594                         $this->doc = t3lib_div::makeInstance('template');
01595                         $this->doc->docType='xhtml_trans';
01596                         $this->doc->backPath = $BACK_PATH;
01597                 }
01598 
01599                         // Setting mode for display and background image in the top frame
01600                 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
01601                 if ($this->dontDisplayTopFrameCM)       {
01602                         $this->doc->bodyTagId.= '-notop';
01603                 }
01604 
01605                         // Setting clickmenu timeout
01606                 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5);        // default is 5
01607 
01608                         // Setting the JavaScript controlling the timer on the page
01609                 $listFrameDoc = $this->reloadListFrame!=2 ? 'top.content.list_frame' : 'top.content';
01610                 $this->doc->JScode.=$this->doc->wrapScriptTags('
01611         var date = new Date();
01612         var mo_timeout = Math.floor(date.getTime()/1000);
01613 
01614         roImg =new Image();
01615         roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
01616 
01617         routImg =new Image();
01618         routImg.src = "clear.gif";
01619 
01620         function mo(c)  {       //
01621                 var name="roimg_"+c;
01622                 document[name].src = roImg.src;
01623                 updateTime();
01624         }
01625         function mout(c)        {       //
01626                 var name="roimg_"+c;
01627                 document[name].src = routImg.src;
01628                 updateTime();
01629         }
01630         function updateTime()   {       //
01631                 date = new Date();
01632                 mo_timeout = Math.floor(date.getTime()/1000);
01633         }
01634         function timeout_func() {       //
01635                 date = new Date();
01636                 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.')     {
01637                         hideCM();
01638                         return false;
01639                 } else {
01640                         window.setTimeout("timeout_func();",1*1000);
01641                 }
01642         }
01643         function hideCM()       {       //
01644                 window.location.href="alt_topmenu_dummy.php";
01645                 return false;
01646         }
01647 
01648                 // Start timer
01649         timeout_func();
01650 
01651         '.($this->reloadListFrame ? '
01652                 // Reload list frame:
01653         if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' :
01654         '').'
01655                 ');
01656         }
01657 
01663         function main() {
01664                 $this->ajax = t3lib_div::_GP('ajax') ? TRUE : FALSE;
01665 
01666                         // Initialize Clipboard object:
01667                 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
01668                 $clipObj->initializeClipboard();
01669                 $clipObj->lockToNormal();       // This locks the clipboard to the Normal for this request.
01670 
01671                         // Update clipboard if some actions are sent.
01672                 $CB = t3lib_div::_GET('CB');
01673                 $clipObj->setCmd($CB);
01674                 $clipObj->cleanCurrent();
01675                 $clipObj->endClipboard();       // Saves
01676 
01677                         // Create clickmenu object
01678                 $clickMenu = t3lib_div::makeInstance('clickMenu');
01679 
01680                         // Set internal vars in clickmenu object:
01681                 $clickMenu->clipObj = $clipObj;
01682                 $clickMenu->extClassArray = $this->extClassArray;
01683                 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
01684                 $clickMenu->backPath = $this->backPath;
01685 
01686                         // Start page
01687                 if(!$this->ajax)        {
01688                         $this->content.=$this->doc->startPage('Context Sensitive Menu');
01689                 }
01690                         // Set content of the clickmenu with the incoming var, "item"
01691                 $this->content.= $clickMenu->init();
01692         }
01693 
01699         function printContent() {
01700                 if(!$this->ajax)        {
01701                         $this->content.= $this->doc->endPage();
01702                         $this->content = $this->doc->insertStylesAndJS($this->content);
01703                         echo $this->content;
01704                 } else {
01705                         t3lib_ajax::outputXMLreply($this->content);
01706                 }
01707         }
01708 }
01709 
01710 // Include extension?
01711 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) {
01712         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
01713 }
01714 
01715 
01716 
01717 
01718 
01719 
01720 
01721 
01722 
01723 
01724 // Make instance:
01725 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
01726 $SOBE->init();
01727 
01728 // Include files?
01729 foreach($SOBE->include_once as $INC_FILE)       include_once($INC_FILE);
01730 
01731 $SOBE->main();
01732 $SOBE->printContent();
01733 ?>