Fixed bug 10056: Misspelling english word "guesbooks"
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
index 46f3e40..44f96c5 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -171,7 +171,8 @@ class clickMenu {
                $this->CB = t3lib_div::_GP('CB');
                if(t3lib_div::_GP('ajax'))      {
                        $this->ajax = 1;
-                       ini_set('display_errors',0);    // XML has to be parsed, no parse errors allowed
+                       // XML has to be parsed, no parse errors allowed
+                       @ini_set('display_errors', 0);
                }
 
                        // Deal with Drag&Drop context menus
@@ -257,11 +258,17 @@ class clickMenu {
                        // Get record:
                $this->rec = t3lib_BEfunc::getRecordWSOL($table,$uid);
                $menuItems=array();
+
                $root=0;
+               $DBmount = FALSE;
                if ($table=='pages' && !strcmp($uid,'0'))       {       // Rootlevel
                        $root=1;
                }
 
+               if ($table=='pages' && in_array($uid,$GLOBALS['BE_USER']->returnWebmounts()))   {       // DB mount
+                       $DBmount = TRUE;
+               }
+
                        // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
                if (is_array($this->rec) || $root)      {
 
@@ -272,7 +279,7 @@ class clickMenu {
                        if (!in_array('view',$this->disabledItems))     {
                                if ($table=='pages')    $menuItems['view']=$this->DB_view($uid);
                                if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
-                                       $ws_rec = t3lib_BEfunc::getRecordWSOL($table,$this->rec['t3ver_oid']);
+                                       $ws_rec = t3lib_BEfunc::getRecordWSOL($table, $this->rec['uid']);
                                        $menuItems['view']=$this->DB_view($ws_rec['pid']);
                                }
                        }
@@ -292,9 +299,9 @@ class clickMenu {
                        $menuItems['spacer1']='spacer';
 
                                // Copy:
-                       if(!in_array('copy',$this->disabledItems) && !$root)    $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
+                       if(!in_array('copy',$this->disabledItems) && !$root && !$DBmount)       $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
                                // Cut:
-                       if(!in_array('cut',$this->disabledItems) && !$root)     $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
+                       if(!in_array('cut',$this->disabledItems) && !$root && !$DBmount)        $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
 
                                // Paste:
                        $elFromAllTables = count($this->clipObj->elFromTable(''));
@@ -310,12 +317,12 @@ class clickMenu {
                                }
 
                                $elFromTable = count($this->clipObj->elFromTable($table));
-                               if (!$root && $elFromTable  && $TCA[$table]['ctrl']['sortby'])  $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
+                               if (!$root && !$DBmount && $elFromTable  && $TCA[$table]['ctrl']['sortby'])     $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
                        }
 
                                // Delete:
                        $elInfo=array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen']));
-                       if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete'))        {
+                       if(!in_array('delete',$this->disabledItems) && !$root && !$DBmount && $BE_USER->isPSet($lCP,$table,'delete'))   {
                                $menuItems['spacer2']='spacer';
                                $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
                        }
@@ -418,7 +425,7 @@ class clickMenu {
        function urlRefForCM($url,$retUrl='',$hideCM=1,$overrideLoc='') {
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
                $editOnClick= ($overrideLoc ? 'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
-                       ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
+                       ($retUrl ? "+'&" . $retUrl . "='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation('docRef.document') . ')' :'') . ';' .
                        ($hideCM?'return hideCM();':'');
                return $editOnClick;
        }
@@ -469,7 +476,7 @@ class clickMenu {
                } else {
                        $conf = $loc;
                }
-               $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
+               $editOnClick = 'if(' . $conf . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $this->clipObj->pasteUrl($table, $uid, 0) . '&redirect=\'+top.rawurlencodeAndRemoveSiteUrl(' . $this->frameLocation($loc . '.document') . '); hideCM();}';
 
                return $this->linkItem(
                        $this->label('paste'.$type),
@@ -620,7 +627,7 @@ class clickMenu {
         * @param       integer         page uid to edit (PID)
         * @return      array           Item array, element in $menuItems
         * @internal
-        * @deprecated          Use DB_editPageProperties instead
+        * @deprecated since TYPO3 4.0 - Use DB_editPageProperties instead
         */
        function DB_editPageHeader($uid)        {
                return $this->DB_editPageProperties($uid);
@@ -671,11 +678,11 @@ class clickMenu {
                        if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms'))      {
                                $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
                        } else {
-                               $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
+                               $editOnClick='if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
                        }
                }
                if (!$editOnClick)      {
-                       $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."';}";
+                       $editOnClick='if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
                }
 
                return $this->linkItem(
@@ -698,7 +705,7 @@ class clickMenu {
                $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
                $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
                        ($this->listFrame?
-                               "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
+                               "alt_doc.php?returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'&edit[".$table."][-".$uid."]=new'":
                                'db_new.php?id='.intval($uid)."'").
                        ';}';
 
@@ -726,7 +733,7 @@ class clickMenu {
                } else {
                        $conf = '1==1';
                }
-               $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+               $editOnClick = 'if(' . $loc . " && " . $conf . " ){" . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'".
                        "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
                return $this->linkItem(
@@ -792,18 +799,18 @@ class clickMenu {
         * @return      array           Item array, element in $menuItems
         */
        function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/')    {
-           $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
-           $editOnClick='';
-           $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-           $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
-               "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
-
-           return $this->linkItem(
-               $title,
-               $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,$iconRelPath.'button_'.($rec[$flagField]?'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
-               $editOnClick.'return false;',
-               1
-           );
+               $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
+               $editOnClick='';
+               $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
+               $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'" .
+                       "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
+
+               return $this->linkItem(
+                       $title,
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,$iconRelPath.'button_'.($rec[$flagField]?'un':'').$name.'.gif','width="11" height="10"').' alt="" />'),
+                       $editOnClick.'return false;',
+                       1
+               );
        }
 
 
@@ -828,7 +835,7 @@ class clickMenu {
        function printFileClickMenu($path)      {
                $menuItems=array();
 
-               if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path))  {
+               if (file_exists($path) && t3lib_div::isAllowedAbsPath($path))   {
                        $fI = pathinfo($path);
                        $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
                        $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
@@ -907,7 +914,7 @@ class clickMenu {
        function FILE_launch($path,$script,$type,$image,$noReturnUrl=FALSE)     {
                $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
 
-               $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path).($noReturnUrl ? "'" : "&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")").";}";
+               $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'".$script.'?target=' . rawurlencode($path) . ($noReturnUrl ? "'" : "&returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")") . ";}";
 
                return $this->linkItem(
                        $this->label($type),
@@ -958,7 +965,7 @@ class clickMenu {
                } else {
                        $conf = '1==1';
                }
-               $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+               $editOnClick = 'if(' . $loc . " && " . $conf . " ){" . $loc . ".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'" .
                        "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
                return $this->linkItem(
@@ -987,7 +994,7 @@ class clickMenu {
                }
 
                $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
-                       "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
+                       "&redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') .'); hideCM();}';
 
                return $this->linkItem(
                        $this->label('pasteinto'),
@@ -1075,7 +1082,7 @@ class clickMenu {
                $negativeSign = ($into == 'into') ? '' : '-';
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
+               $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencodeAndRemoveSiteUrl(' . $this->frameLocation($loc . '.document') . ')+"' .
                        '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
 
                return $this->linkItem(
@@ -1099,7 +1106,7 @@ class clickMenu {
        function dragDrop_copymovefolder($srcPath,$dstPath,$action)     {
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
+               $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencodeAndRemoveSiteUrl(' . $this->frameLocation($loc . '.document') .')+"' .
                        '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
 
                return $this->linkItem(
@@ -1208,8 +1215,8 @@ class clickMenu {
                                        // Create JavaScript section:
                                $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
 
-                               if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj)  {
-                                       top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
+                               if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.Clickmenu)    {
+                                       top.content'.$frameName.'.Clickmenu.populateData(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
                                }
                                '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
                                );
@@ -1279,7 +1286,7 @@ class clickMenu {
                                $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
                                $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
                                $onClick=eregi_replace('hideCM\(\);','',$onClick);
-                               if (!$i[5])     $onClick.='hideEmpty();';
+                               if (!$i[5])     $onClick.='Clickmenu.hideAll();';
 
                                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])   {
                                        $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
@@ -1597,7 +1604,6 @@ class SC_alt_clickmenu {
                        // Initialize template object
                if (!$this->ajax)       {
                        $this->doc = t3lib_div::makeInstance('template');
-                       $this->doc->docType='xhtml_trans';
                        $this->doc->backPath = $BACK_PATH;
                }
 
@@ -1713,20 +1719,13 @@ class SC_alt_clickmenu {
        }
 }
 
-// Include extension?
+
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php'])        {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
 }
 
 
 
-
-
-
-
-
-
-
 // Make instance:
 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
 $SOBE->init();
@@ -1736,4 +1735,5 @@ foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
 
 $SOBE->main();
 $SOBE->printContent();
-?>
\ No newline at end of file
+
+?>