Documentation TYPO3 par Ameos

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 ***************************************************************/
00112 require ('init.php');
00113 require ('template.php');
00114 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00115 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00116 
00117 
00118 
00119 
00128 class clickMenu {
00129 
00130                 // Internal, static: GPvar:
00131         var $cmLevel=0;                         // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
00132         var $CB;                                        // Clipboard array (submitted by eg. pressing the paste button)
00133 
00134                 // Internal, static:
00135         var $backPath='';                       // Backpath for scripts/images.
00136         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)
00137         var $listFrame=0;                       // If set, the calling document should be in the listframe of a frameset.
00138         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)
00139         var $alwaysContentFrame=0;      // If true, the "content" frame is always used for reference (when condensed mode is enabled)
00140         var $iParts=array();            // Stores the parts of the input $item string, splitted by "|": [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame, [3] = ("+" prefix = disable all by default, enable these. Default is to disable) Items key list
00141         var $disabledItems=array();     // Contains list of keywords of items to disable in the menu
00142         var $dontDisplayTopFrameCM=0;   // If true, the context sensitive menu will not appear in the top frame, only as a layer.
00143         var $leftIcons=0;                       // If true, Show icons on the left.
00144         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.
00145 
00146                 // Internal, dynamic:
00147         var $elCount=0;                         // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
00148         var $editPageIconSet=0;         // Set, when edit icon is drawn.
00149         var $editOK=0;                          // Set to true, if editing of the element is OK.
00150         var $rec=array();
00151 
00152 
00153 
00160         function init($item)    {
00161 
00162                         // Setting GPvars:
00163                 $this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
00164                 $this->CB = t3lib_div::_GP('CB');
00165 
00166 
00167                         // Explode the incoming command:
00168                 $this->iParts = explode('|',$item);
00169 
00170                         // Setting flags:
00171                 if ($this->iParts[2])   $this->listFrame=1;
00172                 if ($GLOBALS['BE_USER']->uc['condensedMode']) $this->alwaysContentFrame=1;
00173                 if (strcmp($this->iParts[1],''))        $this->isDBmenu=1;
00174 
00175                 $TSkey =($this->isDBmenu?'page':'folder').($this->listFrame?'List':'Tree');
00176                 $this->disabledItems = t3lib_div::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
00177                 $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
00178 
00179                         // &cmLevel flag detected (2nd level menu)
00180                 if (!$this->cmLevel)    {
00181                                 // Make 1st level clickmenu:
00182                         if ($this->isDBmenu)    {
00183                                 $CMcontent = $this->printDBClickMenu($this->iParts[0],$this->iParts[1]);
00184                         } else {
00185                                 $CMcontent = $this->printFileClickMenu($this->iParts[0]);
00186                         }
00187                 } else {
00188                                 // Make 2nd level clickmenu (only for DBmenus)
00189                         if ($this->isDBmenu)    {
00190                                 $CMcontent = $this->printNewDBLevel($this->iParts[0],$this->iParts[1]);
00191                         }
00192                 }
00193 
00194                         // Return clickmenu conten:
00195                 return $CMcontent;
00196         }
00197 
00203         function doDisplayTopFrameCM()  {
00204                 return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
00205         }
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218         /***************************************
00219          *
00220          * DATABASE
00221          *
00222          ***************************************/
00223 
00231         function printDBClickMenu($table,$uid)  {
00232                 global $TCA, $BE_USER;
00233 
00234                         // Get record:
00235                 $this->rec = t3lib_BEfunc::getRecord($table,$uid);
00236                 $menuItems=array();
00237                 $root=0;
00238                 if ($table=='pages' && !strcmp($uid,'0'))       {       // Rootlevel
00239                         $root=1;
00240                 }
00241 
00242                         // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
00243                 if (is_array($this->rec) || $root)      {
00244                                 // Get permissions
00245                         $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
00246 
00247                                 // View
00248                         if (!in_array('view',$this->disabledItems))     {
00249                                 if ($table=='pages')    $menuItems['view']=$this->DB_view($uid);
00250                                 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec['pid'],'#'.$uid);
00251                         }
00252 
00253                                 // Edit:
00254                         if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent')))       {
00255                                 if (!in_array('edit',$this->disabledItems))             $menuItems['edit']=$this->DB_edit($table,$uid);
00256                                 $this->editOK=1;
00257                         }
00258 
00259                                 // New:
00260                         if (!in_array('new',$this->disabledItems) && $BE_USER->isPSet($lCP,$table,'new'))       $menuItems['new']=$this->DB_new($table,$uid);
00261 
00262                                 // Info:
00263                         if(!in_array('info',$this->disabledItems) && !$root)    $menuItems['info']=$this->DB_info($table,$uid);
00264 
00265                         $menuItems['spacer1']='spacer';
00266 
00267                                 // Copy:
00268                         if(!in_array('copy',$this->disabledItems) && !$root)    $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
00269                                 // Cut:
00270                         if(!in_array('cut',$this->disabledItems) && !$root)     $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
00271 
00272                                 // Paste:
00273                         $elFromAllTables = count($this->clipObj->elFromTable(''));
00274                         if (!in_array('paste',$this->disabledItems) && $elFromAllTables)        {
00275                                 $selItem = $this->clipObj->getSelectedRecord();
00276                                 $elInfo=array(
00277                                         t3lib_div::fixed_lgd_cs($selItem['_RECORD_TITLE'],$BE_USER->uc['titleLen']),
00278                                         ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen'])),
00279                                         $this->clipObj->currentMode()
00280                                 );
00281                                 if ($table=='pages' && ($lCP & 8))      {
00282                                         if ($elFromAllTables)   $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
00283                                 }
00284 
00285                                 $elFromTable = count($this->clipObj->elFromTable($table));
00286                                 if (!$root && $elFromTable  && $TCA[$table]['ctrl']['sortby'])  $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
00287                         }
00288 
00289                                 // Delete:
00290                         $elInfo=array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen']));
00291                         if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete'))        {
00292                                 $menuItems['spacer2']='spacer';
00293                                 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
00294                         }
00295                 }
00296 
00297                         // Adding external elements to the menuItems array
00298                 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
00299 
00300                         // Processing by external functions?
00301                 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
00302 
00303                         // Return the printed elements:
00304                 return $this->printItems($menuItems,
00305                         $root?
00306                         '<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']):
00307                         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)
00308                 );
00309         }
00310 
00318         function printNewDBLevel($table,$uid)   {
00319                 global $TCA, $BE_USER;
00320 
00321                         // Setting internal record to the table/uid :
00322                 $this->rec = t3lib_BEfunc::getRecord($table,$uid);
00323                 $menuItems=array();
00324                 $root=0;
00325                 if ($table=='pages' && !strcmp($uid,'0'))       {       // Rootlevel
00326                         $root=1;
00327                 }
00328 
00329                         // If record was found, check permissions and get menu items.
00330                 if (is_array($this->rec) || $root)      {
00331                         $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
00332                                 // Edit:
00333                         if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent')))       {
00334                                 $this->editOK=1;
00335                         }
00336 
00337                         $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
00338                 }
00339 
00340                         // Return the printed elements:
00341                 if (!is_array($menuItems))      $menuItems=array();
00342                 return $this->printItems($menuItems,
00343                         $root?
00344                         '<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']):
00345                         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)
00346                 );
00347         }
00348 
00355         function externalProcessingOfDBMenuItems($menuItems)    {
00356                 return $menuItems;
00357         }
00358 
00367         function processingByExtClassArray($menuItems,$table,$uid)      {
00368                 if (is_array($this->extClassArray))     {
00369                         reset($this->extClassArray);
00370                         while(list(,$conf)=each($this->extClassArray))  {
00371                                 $obj=t3lib_div::makeInstance($conf['name']);
00372                                 $menuItems = $obj->main($this,$menuItems,$table,$uid);
00373                         }
00374                 }
00375                 return $menuItems;
00376         }
00377 
00386         function urlRefForCM($url,$retUrl='',$hideCM=1) {
00387                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00388                 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.document.location=top.TS.PATH_typo3+\''.$url.'\''.
00389                         ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
00390                         ($hideCM?'return hideCM();':'');
00391                 return $editOnClick;
00392         }
00393 
00403         function DB_copycut($table,$uid,$type)  {
00404                 if ($this->clipObj->current=='normal')  {
00405                         $isSel = $this->clipObj->isSelected($table,$uid);
00406                 }
00407 
00408                 $addParam = array();
00409                 if ($this->listFrame)   {
00410                         $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00411                 }
00412 
00413                 return $this->linkItem(
00414                         $this->label($type),
00415                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00416                         "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00417                 );
00418         }
00419 
00432         function DB_paste($table,$uid,$type,$elInfo)    {
00433                 $editOnClick = '';
00434                 $loc = 'top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00435                 $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])).')';
00436                 $editOnClick = 'if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
00437 
00438                 return $this->linkItem(
00439                         $this->label('paste'.$type),
00440                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
00441                         $editOnClick.'return false;'
00442                 );
00443         }
00444 
00453         function DB_info($table,$uid)   {
00454                 return $this->linkItem(
00455                         $this->label('info'),
00456                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
00457                         "top.launchView('".$table."', '".$uid."'); return hideCM();"
00458                 );
00459         }
00460 
00469         function DB_history($table,$uid)        {
00470                 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
00471                 return $this->linkItem(
00472                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
00473                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
00474                         $this->urlRefForCM($url,'returnUrl'),
00475                         0
00476                 );
00477         }
00478 
00488         function DB_perms($table,$uid,$rec)     {
00489                 $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':'');
00490                 return $this->linkItem(
00491                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
00492                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
00493                         $this->urlRefForCM($url),
00494                         0
00495                 );
00496         }
00497 
00507         function DB_db_list($table,$uid,$rec)   {
00508                 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
00509                 return $this->linkItem(
00510                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
00511                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
00512                         "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
00513                         0
00514                 );
00515         }
00516 
00526         function DB_moveWizard($table,$uid,$rec)        {
00527                 $url = 'move_el.php?table='.$table.'&uid='.$uid.
00528                                 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):'');        // Hardcoded field for tt_content elements.
00529 
00530                 return $this->linkItem(
00531                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
00532                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
00533                         $this->urlRefForCM($url,'returnUrl'),
00534                         0
00535                 );
00536         }
00537 
00547         function DB_newWizard($table,$uid,$rec) {
00548                         //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
00549                 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00550                 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
00551                 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00552 
00553                 $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']);
00554                 return $this->linkItem(
00555                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
00556                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
00557                         $this->urlRefForCM($url,'returnUrl'),
00558                         0
00559                 );
00560         }
00561 
00570         function DB_editAccess($table,$uid)     {
00571                 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
00572                 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
00573                 return $this->linkItem(
00574                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
00575                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
00576                         $this->urlRefForCM($url,'returnUrl'),
00577                         1       // no top frame CM!
00578                 );
00579         }
00580 
00588         function DB_editPageHeader($uid)        {
00589                 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
00590                 return $this->linkItem(
00591                         $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
00592                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
00593                         $this->urlRefForCM($url,'returnUrl'),
00594                         1       // no top frame CM!
00595                 );
00596         }
00597 
00606         function DB_edit($table,$uid)   {
00607                 global $BE_USER;
00608                         // If another module was specified, replace the default Page module with the new one
00609                 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
00610                 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00611 
00612                 $editOnClick='';
00613                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00614                 $addParam='';
00615                 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
00616                 if (
00617                                 $this->iParts[0]=='pages' &&
00618                                 $this->iParts[1] &&
00619                                 $BE_USER->check('modules', $pageModule)
00620                         )       {
00621                         $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
00622                         $this->editPageIconSet=1;
00623                         if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms'))      {
00624                                 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
00625                         } else {
00626                                 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
00627                         }
00628                 }
00629                 if (!$editOnClick)      {
00630                         $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
00631                 }
00632 
00633                 return $this->linkItem(
00634                         $this->label('edit'),
00635                         $this->excludeIcon('<img'.$theIcon.' alt="" />'),
00636                         $editOnClick.'return hideCM();'
00637                 );
00638         }
00639 
00648         function DB_new($table,$uid)    {
00649                 $editOnClick='';
00650                 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00651                 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
00652                         ($this->listFrame?
00653                                 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
00654                                 'db_new.php?id='.intval($uid)."'").
00655                         ';}';
00656 
00657                 return $this->linkItem(
00658                         $this->label('new'),
00659                         $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="" />'),
00660                         $editOnClick.'return hideCM();'
00661                 );
00662         }
00663 
00673         function DB_delete($table,$uid,$elInfo) {
00674                 $editOnClick='';
00675                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00676                 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0])).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00677                         "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00678 
00679                 return $this->linkItem(
00680                         $this->label('delete'),
00681                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00682                         $editOnClick.'return false;'
00683                 );
00684         }
00685 
00694         function DB_view($id,$anchor='')        {
00695                 return $this->linkItem(
00696                         $this->label('view'),
00697                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
00698                         t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
00699                 );
00700         }
00701 
00709         function DB_tempMountPoint($page_id)    {
00710                 return $this->linkItem(
00711                         $this->label('tempMountPoint'),
00712                         #$this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/___.gif','width="12" height="12"').' alt="" />'),
00713                         '',
00714                         "if (top.content.nav_frame) { top.content.nav_frame.document.location = 'alt_db_navframe.php?setTempDBmount=".intval($page_id)."'; } return hideCM();"
00715                 );
00716         }
00717 
00727         function DB_hideUnhide($table,$rec,$hideField)  {
00728                 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?'un':'').'hide'), 'hide');
00729         }
00730 
00742         function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/')    {
00743             $uid=$rec['uid'];
00744             $editOnClick='';
00745             $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00746             $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00747                 "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00748 
00749             return $this->linkItem(
00750                 $title,
00751                 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,$iconRelPath.'button_'.($rec[$flagField]?'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
00752                 $editOnClick.'return false;',
00753                 1
00754             );
00755         }
00756 
00757 
00758 
00759 
00760 
00761 
00762 
00763 
00764         /***************************************
00765          *
00766          * FILE
00767          *
00768          ***************************************/
00769 
00776         function printFileClickMenu($path)      {
00777                 $menuItems=array();
00778 
00779                 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path))  {
00780                         $fI = pathinfo($path);
00781                         $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
00782                         $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
00783                         $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
00784 
00785                                 // edit
00786                         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');
00787                                 // rename
00788                         if (!in_array('rename',$this->disabledItems))   $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
00789                                 // upload
00790                         if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
00791                                 // new
00792                         if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
00793                                 // info
00794                         if (!in_array('info',$this->disabledItems))     $menuItems['info']=$this->DB_info($path,'');
00795 
00796                         $menuItems[]='spacer';
00797 
00798                                 // copy:
00799                         if (!in_array('copy',$this->disabledItems))     $menuItems['copy']=$this->FILE_copycut($path,'copy');
00800                                 // cut:
00801                         if (!in_array('cut',$this->disabledItems))      $menuItems['cut']=$this->FILE_copycut($path,'cut');
00802 
00803                                 // Paste:
00804                         $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
00805                         if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path))       {
00806                                 $elArr = $this->clipObj->elFromTable('_FILE');
00807                                 reset($elArr);
00808                                 $selItem = current($elArr);
00809                                 $elInfo=array(
00810                                         basename($selItem),
00811                                         basename($path),
00812                                         $this->clipObj->currentMode()
00813                                 );
00814                                 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
00815                         }
00816 
00817                         $menuItems[]='spacer';
00818 
00819                                 // delete:
00820                         if (!in_array('delete',$this->disabledItems))   $menuItems['delete']=$this->FILE_delete($path);
00821                 }
00822 
00823                         // Adding external elements to the menuItems array
00824                 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
00825 
00826                         // Processing by external functions?
00827                 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
00828 
00829                         // Return the printed elements:
00830                 return $this->printItems($menuItems,$icon.basename($path));
00831         }
00832 
00833 
00840         function externalProcessingOfFileMenuItems($menuItems)  {
00841                 return $menuItems;
00842         }
00843 
00854         function FILE_launch($path,$script,$type,$image)        {
00855                 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
00856 
00857                 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').");}";
00858 
00859                 return $this->linkItem(
00860                         $this->label($type),
00861                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
00862                         $editOnClick.'return hideCM();'
00863                 );
00864         }
00865 
00874         function FILE_copycut($path,$type)      {
00875                 $table = '_FILE';               // Pseudo table name for use in the clipboard.
00876                 $uid = t3lib_div::shortmd5($path);
00877                 if ($this->clipObj->current=='normal')  {
00878                         $isSel = $this->clipObj->isSelected($table,$uid);
00879                 }
00880 
00881                 $addParam = array();
00882                 if ($this->listFrame)   {
00883                         $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
00884                 }
00885 
00886                 return $this->linkItem(
00887                         $this->label($type),
00888                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
00889                         "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type),$addParam)."');return false;"
00890                 );
00891         }
00892 
00900         function FILE_delete($path)     {
00901                 $editOnClick='';
00902                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00903                 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path))).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
00904                         "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
00905 
00906                 return $this->linkItem(
00907                         $this->label('delete'),
00908                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
00909                         $editOnClick.'return false;'
00910                 );
00911         }
00912 
00922         function FILE_paste($path,$target,$elInfo)      {
00923                 $editOnClick='';
00924                 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
00925                 $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])).")";
00926                 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
00927                         "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
00928 
00929                 return $this->linkItem(
00930                         $this->label('pasteinto'),
00931                         $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
00932                         $editOnClick.'return false;'
00933                 );
00934         }
00935 
00936 
00937 
00938 
00939 
00940 
00941 
00942 
00943 
00944 
00945 
00946 
00947 
00948         /***************************************
00949          *
00950          * COMMON
00951          *
00952          **************************************/
00953 
00962         function printItems($menuItems,$item)   {
00963 
00964                 $out='';
00965 
00966                         // Enable/Disable items:
00967                 $menuItems = $this->enableDisableItems($menuItems);
00968 
00969                         // Clean up spacers:
00970                 $menuItems = $this->cleanUpSpacers($menuItems);
00971 
00972                         // Adding topframe part (horizontal clickmenu)
00973                 if ($this->doDisplayTopFrameCM())       {
00974                         $out.= '
00975 
00976                                 <!--
00977                                         Table, which contains the click menu when shown in the top frame of the backend:
00978                                 -->
00979                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
00980                                         <tr>
00981 
00982                                                         <!-- Items: -->
00983                                                 <td class="c-item">'.
00984                                                         implode('</td>
00985                                                 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
00986                                                 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
00987                                                 '</td>
00988 
00989                                                         <!-- Close button: -->
00990                                                 <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>
00991 
00992                                                         <!-- The item of the clickmenu: -->
00993                                                 <td class="c-itemicon">'.$item.'</td>
00994                                         </tr>
00995                                 </table>
00996                         ';
00997 
00998                                 // Set remaining BACK_PATH to blank (if any)
00999                         $out = str_replace($this->PH_backPath,'',$out);
01000                 }
01001                         // Adding JS part:
01002                 $out.=$this->printLayerJScode($menuItems);
01003 
01004                         // Return the content
01005                 return $out;
01006         }
01007 
01014         function printLayerJScode($menuItems)   {
01015                 $script='';
01016                 if ($this->isCMlayers())        {       // Clipboard must not be submitted - then it's probably a copy/cut situation.
01017                         $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
01018                         if ($this->alwaysContentFrame)  $frameName='';
01019 
01020                                 // Create the table displayed in the clickmenu layer:
01021                         $CMtable = '
01022                                 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
01023                                         '.implode('',$this->menuItemsForClickMenu($menuItems)).'
01024                                 </table>';
01025 
01026                                 // Wrap the inner table in another table to create outer border:
01027                         $CMtable = $this->wrapColorTableCM($CMtable);
01028 
01029                                 // Set back path place holder to real back path
01030                         $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
01031 
01032                                 // Create JavaScript section:
01033                         $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
01034 
01035 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj)  {
01036         top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
01037 }
01038 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
01039 );
01040                 }
01041 
01042                 return $script;
01043         }
01044 
01052         function wrapColorTableCM($str) {
01053 
01054                         // Clear-gifs needed if opera is to set the table row height correctly in skins.
01055                 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
01056                                 <tr class="c-rowA">
01057                                         <td class="c-aa">'.$str.'</td>
01058                                         <td class="c-ab"></td>
01059                                 </tr>
01060                                 <tr class="c-rowB">
01061                                         <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
01062                                         <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
01063                                 </tr>
01064                         </table>';
01065                 return $str;
01066         }
01067 
01075         function menuItemsForTopFrame($menuItems)       {
01076                 reset($menuItems);
01077                 $out=array();
01078                 while(list(,$i)=each($menuItems))       {
01079                         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)
01080                         if (is_array($i) && !$i[4])     $out[]=$i[0];
01081                 }
01082                 return $out;
01083         }
01084 
01092         function menuItemsForClickMenu($menuItems)      {
01093                 reset($menuItems);
01094                 $out=array();
01095                 while(list($cc,$i)=each($menuItems))    {
01096                         if (is_string($i) && $i=='spacer')      {       // MAKE horizontal spacer
01097                                 $out[]='
01098                                         <tr class="bgColor2">
01099                                                 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
01100                                         </tr>';
01101                         } else {        // Just make normal element:
01102                                 $onClick=$i[3];
01103                                 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
01104                                 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
01105                                 $onClick=eregi_replace('hideCM\(\);','',$onClick);
01106                                 if (!$i[5])     $onClick.='hideEmpty();';
01107 
01108                                 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])   {
01109                                         $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
01110                                 }
01111 
01112                                 $out[]='
01113                                         <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
01114                                                 '.(!$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>').'
01115                                         </tr>';
01116                         }
01117                 }
01118                 return $out;
01119         }
01120 
01130         function addMenuItems($menuItems,$newMenuItems,$position='')    {
01131                 if (is_array($newMenuItems))    {
01132 
01133                         if($position) {
01134 
01135                                 $posArr = t3lib_div::trimExplode(',', $position, 1);
01136                                 foreach($posArr as $pos) {
01137                                         list($place,$menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
01138                                         list($place,$placeExtra) = t3lib_div::trimExplode('-', $place, 1);
01139 
01140                                                 // bottom
01141                                         $pointer = count($menuItems);
01142 
01143                                         $found=FALSE;
01144 
01145                                         if ($place) {
01146                                                 switch(strtolower($place))      {
01147                                                         case 'after':
01148                                                         case 'before':
01149                                                                 if ($menuEntry) {
01150                                                                         $p=1;
01151                                                                         reset ($menuItems);
01152                                                                         while (true) {
01153                                                                                 if (!strcmp(key($menuItems), $menuEntry))       {
01154                                                                                         $pointer = $p;
01155                                                                                         $found=TRUE;
01156                                                                                         break;
01157                                                                                 }
01158                                                                                 if (!next($menuItems)) break;
01159                                                                                 $p++;
01160                                                                         }
01161                                                                         if (!$found) break;
01162 
01163                                                                         if ($place=='before') {
01164                                                                                 $pointer--;
01165                                                                                 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
01166                                                                                         $pointer--;
01167                                                                                 }
01168                                                                         } elseif ($place=='after') {
01169                                                                                 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
01170                                                                                         $pointer++;
01171                                                                                 }
01172                                                                         }
01173                                                                 }
01174                                                         break;
01175                                                         default:
01176                                                                 if (strtolower($place)=='top')  {
01177                                                                         $pointer = 0;
01178                                                                 } else {
01179                                                                         $pointer = count($menuItems);
01180                                                                 }
01181                                                                 $found=TRUE;
01182                                                         break;
01183                                                 }
01184                                         }
01185                                         if($found) break;
01186                                 }
01187                         }
01188                         $pointer=max(0,$pointer);
01189                         $menuItemsBefore = array_slice($menuItems, 0, ($pointer?$pointer:0));
01190                         $menuItemsAfter = array_slice($menuItems, $pointer);
01191                         $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
01192                 }
01193                 return $menuItems;
01194         }
01195 
01206         function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)    {
01207                 $this->elCount++;
01208 
01209                 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
01210 
01211                 return array(
01212                         '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
01213                                 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
01214                                 $str.$icon.
01215                                 '</a>',
01216                         $str,
01217                         $icon,
01218                         $onClick,
01219                         $onlyCM,
01220                         $dontHide
01221                 );
01222         }
01223 
01230         function excludeIcon($iconCode) {
01231                 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
01232         }
01233 
01240         function enableDisableItems($menuItems) {
01241                 if ($this->iParts[3])   {
01242 
01243                                 // Detect "only" mode: (only showing listed items)
01244                         if (substr($this->iParts[3],0,1)=='+')  {
01245                                 $this->iParts[3] = substr($this->iParts[3],1);
01246                                 $only = TRUE;
01247                         } else {
01248                                 $only = FALSE;
01249                         }
01250 
01251                                 // Do filtering:
01252                         if ($only)      {       // Transfer ONLY elements which are mentioned (or are spacers)
01253                                 $newMenuArray = array();
01254                                 foreach($menuItems as $key => $value)   {
01255                                         if (t3lib_div::inList($this->iParts[3], $key) || (is_string($value) && $value=='spacer'))       {
01256                                                 $newMenuArray[$key] = $value;
01257                                         }
01258                                 }
01259                                 $menuItems = $newMenuArray;
01260                         } else {        // Traverse all elements except those listed (just unsetting them):
01261                                 $elements = t3lib_div::trimExplode(',',$this->iParts[3],1);
01262                                 foreach($elements as $value)    {
01263                                         unset($menuItems[$value]);
01264                                 }
01265                         }
01266                 }
01267 
01268                         // Return processed menu items:
01269                 return $menuItems;
01270         }
01271 
01278         function cleanUpSpacers($menuItems)     {
01279 
01280                         // Remove doubles:
01281                 $prevItemWasSpacer = FALSE;
01282                 foreach($menuItems as $key => $value)   {
01283                         if (is_string($value) && $value=='spacer')      {
01284                                 if ($prevItemWasSpacer) {
01285                                         unset($menuItems[$key]);
01286                                 }
01287                                 $prevItemWasSpacer = TRUE;
01288                         } else {
01289                                 $prevItemWasSpacer = FALSE;
01290                         }
01291                 }
01292 
01293                         // Remove first:
01294                 reset($menuItems);
01295                 $key = key($menuItems);
01296                 $value = current($menuItems);
01297                 if (is_string($value) && $value=='spacer')      {
01298                         unset($menuItems[$key]);
01299                 }
01300 
01301 
01302                         // Remove last:
01303                 end($menuItems);
01304                 $key = key($menuItems);
01305                 $value = current($menuItems);
01306                 if (is_string($value) && $value=='spacer')      {
01307                         unset($menuItems[$key]);
01308                 }
01309 
01310                         // Return processed menu items:
01311                 return $menuItems;
01312         }
01313 
01320         function label($label)  {
01321                 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
01322         }
01323 
01329         function isCMlayers()   {
01330                 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
01331         }
01332 
01339         function frameLocation($str)    {
01340                 return $str.'.location';
01341         }
01342 }
01343 
01344 
01345 
01346 
01347 
01348 
01349 
01350 
01351 
01352 
01353 
01354 
01355 
01364 class SC_alt_clickmenu {
01365 
01366                 // Internal, static: GPvar:
01367         var $backPath;                                  // Back path.
01368         var $item;                                              // Definition of which item the click menu should be made for.
01369         var $reloadListFrame;                   // Defines the name of the document object for which to reload the URL.
01370 
01371                 // Internal:
01372         var $content='';                                // Content accumulation
01373         var $doc;                                               // Template object
01374         var $include_once=array();              // Files to include_once() - set in init() function
01375         var $extClassArray=array();             // Internal array of classes for extending the clickmenu
01376         var $dontDisplayTopFrameCM=0;   // If set, then the clickmenu will NOT display in the top frame.
01377 
01383         function init() {
01384                 global $BE_USER,$BACK_PATH;
01385 
01386                         // Setting GPvars:
01387                 $this->backPath = t3lib_div::_GP('backPath');
01388                 $this->item = t3lib_div::_GP('item');
01389                 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame');
01390 
01391                         // Setting pseudo module name
01392                 $this->MCONF['name']='xMOD_alt_clickmenu.php';
01393 
01394                         // 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:
01395                 $inputBP = explode('|',$this->backPath);
01396                 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
01397                         $this->backPath = $inputBP[0];
01398                 } else {
01399                         $this->backPath = $BACK_PATH;
01400                 }
01401 
01402                         // Setting internal array of classes for extending the clickmenu:
01403                 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
01404 
01405                         // Traversing that array and setting files for inclusion:
01406                 if (is_array($this->extClassArray))     {
01407                         foreach($this->extClassArray as $extClassConf)  {
01408                                 if ($extClassConf['path'])      $this->include_once[]=$extClassConf['path'];
01409                         }
01410                 }
01411 
01412                         // Initialize template object
01413                 $this->doc = t3lib_div::makeInstance('template');
01414                 $this->doc->docType='xhtml_trans';
01415                 $this->doc->backPath = $BACK_PATH;
01416 
01417                         // Setting mode for display and background image in the top frame
01418                 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
01419                 if ($this->dontDisplayTopFrameCM)       {
01420                         $this->doc->bodyTagId.= '-notop';
01421                 }
01422 
01423                         // Setting clickmenu timeout
01424                 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5);        // default is 5
01425 
01426                         // Setting the JavaScript controlling the timer on the page
01427                 $listFrameDoc = $this->reloadListFrame!=2 ? 'top.content.list_frame' : 'top.content';
01428                 $this->doc->JScode.=$this->doc->wrapScriptTags('
01429         var date = new Date();
01430         var mo_timeout = Math.floor(date.getTime()/1000);
01431 
01432         roImg =new Image();
01433         roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
01434 
01435         routImg =new Image();
01436         routImg.src = "clear.gif";
01437 
01438         function mo(c)  {       //
01439                 var name="roimg_"+c;
01440                 document[name].src = roImg.src;
01441                 updateTime();
01442         }
01443         function mout(c)        {       //
01444                 var name="roimg_"+c;
01445                 document[name].src = routImg.src;
01446                 updateTime();
01447         }
01448         function updateTime()   {       //
01449                 date = new Date();
01450                 mo_timeout = Math.floor(date.getTime()/1000);
01451         }
01452         function timeout_func() {       //
01453                 date = new Date();
01454                 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.')     {
01455                         hideCM();
01456                         return false;
01457                 } else {
01458                         window.setTimeout("timeout_func();",1*1000);
01459                 }
01460         }
01461         function hideCM()       {       //
01462                 document.location="alt_topmenu_dummy.php";
01463                 return false;
01464         }
01465 
01466                 // Start timer
01467         timeout_func();
01468 
01469         '.($this->reloadListFrame ? '
01470                 // Reload list frame:
01471         if('.$listFrameDoc.'){'.$listFrameDoc.'.document.location='.$listFrameDoc.'.document.location;}' :
01472         '').'
01473                 ');
01474         }
01475 
01481         function main() {
01482 
01483                         // Initialize Clipboard object:
01484                 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
01485                 $clipObj->initializeClipboard();
01486                 $clipObj->lockToNormal();       // This locks the clipboard to the Normal for this request.
01487 
01488                         // Update clipboard if some actions are sent.
01489                 $CB = t3lib_div::_GET('CB');
01490                 $clipObj->setCmd($CB);
01491                 $clipObj->cleanCurrent();
01492                 $clipObj->endClipboard();       // Saves
01493 
01494                         // Create clickmenu object
01495                 $clickMenu = t3lib_div::makeInstance('clickMenu');
01496 
01497                         // Set internal vars in clickmenu object:
01498                 $clickMenu->clipObj = $clipObj;
01499                 $clickMenu->extClassArray = $this->extClassArray;
01500                 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
01501                 $clickMenu->backPath = $this->backPath;
01502 
01503                         // Start page
01504                 $this->content.=$this->doc->startPage('Context Sensitive Menu');
01505 
01506                         // Set content of the clickmenu with the incoming var, "item"
01507                 $this->content.= $clickMenu->init($this->item);
01508         }
01509 
01515         function printContent() {
01516                 $this->content.= $this->doc->endPage();
01517                 echo $this->content;
01518         }
01519 }
01520 
01521 // Include extension?
01522 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) {
01523         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
01524 }
01525 
01526 
01527 
01528 
01529 
01530 
01531 
01532 
01533 
01534 
01535 // Make instance:
01536 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
01537 $SOBE->init();
01538 
01539 // Include files?
01540 foreach($SOBE->include_once as $INC_FILE)       include_once($INC_FILE);
01541 
01542 $SOBE->main();
01543 $SOBE->printContent();
01544 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6