Fixed bug 10056: Misspelling english word "guesbooks"
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
index 926c32a..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)      {
 
@@ -271,7 +278,10 @@ class clickMenu {
                                // View
                        if (!in_array('view',$this->disabledItems))     {
                                if ($table=='pages')    $menuItems['view']=$this->DB_view($uid);
-                               if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec['pid'],'#'.$uid);
+                               if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
+                                       $ws_rec = t3lib_BEfunc::getRecordWSOL($table, $this->rec['uid']);
+                                       $menuItems['view']=$this->DB_view($ws_rec['pid']);
+                               }
                        }
 
                                // Edit:
@@ -289,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(''));
@@ -307,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);
                        }
@@ -332,7 +342,7 @@ class clickMenu {
                return $this->printItems($menuItems,
                        $root?
                        '<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']):
-                       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)
+                       t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,TRUE)
                );
        }
 
@@ -370,7 +380,7 @@ class clickMenu {
                return $this->printItems($menuItems,
                        $root?
                        '<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']):
-                       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)
+                       t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,TRUE)
                );
        }
 
@@ -415,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;
        }
@@ -466,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),
@@ -617,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);
@@ -668,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(
@@ -695,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)."'").
                        ';}';
 
@@ -723,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(
@@ -789,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
+               );
        }
 
 
@@ -825,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)';
@@ -836,7 +846,7 @@ class clickMenu {
                                // rename
                        if (!in_array('rename',$this->disabledItems))   $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
                                // upload
-                       if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
+                       if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif',TRUE);
                                // new
                        if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
                                // info
@@ -897,13 +907,14 @@ class clickMenu {
         * @param       string          Script (eg. file_edit.php) to pass &target= to
         * @param       string          "type" is the code which fetches the correct label for the element from "cm."
         * @param       string          icon image-filename from "gfx/" (12x12 icon)
+        * @param       boolean         If set, the return URL parameter will not be set in the link
         * @return      array           Item array, element in $menuItems
         * @internal
         */
-       function FILE_launch($path,$script,$type,$image)        {
+       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)."&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),
@@ -954,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(
@@ -983,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'),
@@ -1041,7 +1052,7 @@ class clickMenu {
 
                        // Return the printed elements:
                return $this->printItems($menuItems,
-                       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)
+                       t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,TRUE)
                );
        }
 
@@ -1071,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(
@@ -1095,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(
@@ -1204,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();':'')
                                );
@@ -1275,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;"';
@@ -1591,9 +1602,8 @@ class SC_alt_clickmenu {
                }
 
                        // Initialize template object
-               if(!$this->ajax)        {
+               if (!$this->ajax)       {
                        $this->doc = t3lib_div::makeInstance('template');
-                       $this->doc->docType='xhtml_trans';
                        $this->doc->backPath = $BACK_PATH;
                }
 
@@ -1686,7 +1696,7 @@ class SC_alt_clickmenu {
 
                        // Start page
                if(!$this->ajax)        {
-                       $this->content.=$this->doc->startPage('Context Sensitive Menu');
+                       $this->content.= $this->doc->startPage('Context Sensitive Menu');
                }
                        // Set content of the clickmenu with the incoming var, "item"
                $this->content.= $clickMenu->init();
@@ -1698,30 +1708,24 @@ class SC_alt_clickmenu {
         * @return      void
         */
        function printContent() {
-               if(!$this->ajax)        {
+               if (!$this->ajax)       {
                        $this->content.= $this->doc->endPage();
                        $this->content = $this->doc->insertStylesAndJS($this->content);
                        echo $this->content;
                } else {
+                       $this->content = $GLOBALS['LANG']->csConvObj->utf8_encode($this->content,$GLOBALS['LANG']->charSet);
                        t3lib_ajax::outputXMLreply($this->content);
                }
        }
 }
 
-// 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();
@@ -1731,4 +1735,5 @@ foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
 
 $SOBE->main();
 $SOBE->printContent();
-?>
\ No newline at end of file
+
+?>