Fixed bug #7839: Linking between domains in the pagetree with checkRootline does...
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 1 Apr 2008 10:39:38 +0000 (10:39 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 1 Apr 2008 10:39:38 +0000 (10:39 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3495 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_menu.php

index 95fe4d3..e92a60d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-04-01  Dmitry Dulepov  <dmitry@typo3.org>
+
+       * Fixed bug #7839: Linking between domains in the pagetree with checkRootline does not work with menus
+
 2008-03-31  Jeff Segars  <jeff@webempoweredchurch.org>
 
        * Fixed bug #7768: TCEForms extraFormHeaders do not work with docheaders
index 8e89e2a..7adb50c 100755 (executable)
  *
  *
  *
- *  257: class tslib_cObj
- *  351:     function start($data,$table='')
- *  366:     function setParent($data,$currentRecord)
+ *  256: class tslib_cObj
+ *  353:     function start($data,$table='')
+ *  387:     function setParent($data,$currentRecord)
  *
  *              SECTION: CONTENT_OBJ:
- *  391:     function getCurrentVal()
- *  402:     function setCurrentVal($value)
- *  415:     function cObjGet($setup,$addKey='')
- *  439:     function cObjGetSingle($name,$conf,$TSkey='__')
+ *  412:     function getCurrentVal()
+ *  423:     function setCurrentVal($value)
+ *  436:     function cObjGet($setup,$addKey='')
+ *  460:     function cObjGetSingle($name,$conf,$TSkey='__')
  *
  *              SECTION: Functions rendering content objects (cObjects)
- *  585:     function HTML($conf)
- *  596:     function TEXT($conf)
- *  607:     function CLEARGIF($conf)
- *  626:     function COBJ_ARRAY($conf,$ext='')
- *  662:     function USER($conf,$ext='')
- *  689:     function FILE($conf)
- *  705:     function IMAGE($conf)
- *  724:     function IMG_RESOURCE($conf)
- *  736:     function IMGTEXT($conf)
- * 1145:     function CONTENT($conf)
- * 1231:     function RECORDS($conf)
- * 1311:     function HMENU($conf)
- * 1343:     function CTABLE ($conf)
- * 1381:     function OTABLE ($conf)
- * 1396:     function COLUMNS ($conf)
- * 1475:     function HRULER ($conf)
- * 1500:     function CASEFUNC ($conf)
- * 1525:     function LOAD_REGISTER($conf,$name)
- * 1565:     function FORM($conf,$formData='')
- * 2062:     function SEARCHRESULT($conf)
- * 2228:     function PHP_SCRIPT($conf,$ext='')
- * 2271:     function TEMPLATE($conf)
- * 2422:     function MULTIMEDIA($conf)
+ *  629:     function HTML($conf)
+ *  640:     function TEXT($conf)
+ *  651:     function CLEARGIF($conf)
+ *  670:     function COBJ_ARRAY($conf,$ext='')
+ *  706:     function USER($conf,$ext='')
+ *  733:     function FILE($conf)
+ *  749:     function IMAGE($conf)
+ *  768:     function IMG_RESOURCE($conf)
+ *  780:     function IMGTEXT($conf)
+ * 1203:     function CONTENT($conf)
+ * 1290:     function RECORDS($conf)
+ * 1370:     function HMENU($conf)
+ * 1402:     function CTABLE ($conf)
+ * 1440:     function OTABLE ($conf)
+ * 1455:     function COLUMNS ($conf)
+ * 1534:     function HRULER ($conf)
+ * 1559:     function CASEFUNC ($conf)
+ * 1584:     function LOAD_REGISTER($conf,$name)
+ * 1624:     function FORM($conf,$formData='')
+ * 2145:     function SEARCHRESULT($conf)
+ * 2311:     function PHP_SCRIPT($conf,$ext='')
+ * 2354:     function TEMPLATE($conf)
+ * 2505:     function MULTIMEDIA($conf)
  *
  *              SECTION: Various helper functions for content objects:
- * 2509:     function getSlidePids($pidList, $pidConf)
- * 2582:     function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
- * 2600:     function cImage($file,$conf)
- * 2628:     function getBorderAttr($borderAttr)
- * 2644:     function imageLinkWrap($string,$imageFile,$conf)
- * 2724:     function fileResource($fName, $addParams='alt="" title=""')
- * 2747:     function lastChanged($tstamp)
- * 2764:     function linkWrap($content,$wrap)
- * 2782:     function getAltParam($conf)
- * 2817:     function cleanFormName($name)
- * 2833:     function getATagParams($conf, $addGlobal=1)
+ * 2592:     function getSlidePids($pidList, $pidConf)
+ * 2623:     function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
+ * 2641:     function cImage($file,$conf)
+ * 2669:     function getBorderAttr($borderAttr)
+ * 2685:     function imageLinkWrap($string,$imageFile,$conf)
+ * 2765:     function fileResource($fName, $addParams='alt="" title=""')
+ * 2788:     function lastChanged($tstamp)
+ * 2805:     function linkWrap($content,$wrap)
+ * 2824:     function getAltParam($conf, $longDesc=true)
+ * 2859:     function cleanFormName($name)
+ * 2875:     function getATagParams($conf, $addGlobal=1)
  *
  *              SECTION: HTML template processing functions
- * 2880:     function getSubpart($content, $marker)
- * 2896:     function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
- * 2909:     function substituteMarker($content,$marker,$markContent)
- * 2929:     function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
- * 3027:     function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
- * 3048:     function substituteMarkerInObject(&$tree, $markContentArray)
- * 3071:     function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
+ * 2922:     function getSubpart($content, $marker)
+ * 2938:     function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
+ * 2951:     function substituteMarker($content,$marker,$markContent)
+ * 2971:     function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
+ * 3069:     function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
+ * 3081:     function substituteMarkerInObject(&$tree, $markContentArray)
+ * 3104:     function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
  *
  *              SECTION: "stdWrap" + sub functions
- * 3134:     function stdWrap($content,$conf)
- * 3308:     function numRows($conf)
- * 3329:     function listNum($content,$listNum,$char)
- * 3349:     function checkIf($conf)
- * 3412:     function filelist($data)
- * 3494:     function clean_directory($theDir)
- * 3512:     function HTMLparser_TSbridge($theValue, $conf)
- * 3526:     function dataWrap($content,$wrap)
- * 3539:     function insertData($str)
- * 3569:     function prefixComment($str,$conf,$content)
- * 3593:     function substring($content,$options)
- * 3611:     function crop($content,$options)
- * 3643:     function removeBadHTML($text, $conf)
- * 3687:     function textStyle($theValue, $conf)
- * 3754:     function tableStyle($theValue, $conf)
- * 3795:     function addParams($content,$conf)
- * 3838:     function filelink($theValue, $conf)
- * 3908:     function locDataJU($jumpUrl,$conf)
- * 3939:     function calc($val)
- * 3968:     function calcIntExplode($delim, $string)
- * 3988:     function splitObj($value, $conf)
- * 4050:     function parseFunc($theValue, $conf, $ref='')
- * 4160:     function _parseFunc ($theValue, $conf)
- * 4362:     function encaps_lineSplit($theValue, $conf)
- * 4445:     function http_makelinks($data,$conf)
- * 4512:     function mailto_makelinks($data,$conf)
- * 4555:     function getImgResource($file,$fileArray)
+ * 3167:     function stdWrap($content,$conf)
+ * 3364:     function numRows($conf)
+ * 3388:     function listNum($content,$listNum,$char)
+ * 3408:     function checkIf($conf)
+ * 3471:     function filelist($data)
+ * 3553:     function clean_directory($theDir)
+ * 3571:     function HTMLparser_TSbridge($theValue, $conf)
+ * 3585:     function dataWrap($content,$wrap)
+ * 3598:     function insertData($str)
+ * 3628:     function prefixComment($str,$conf,$content)
+ * 3652:     function substring($content,$options)
+ * 3670:     function crop($content,$options)
+ * 3702:     function removeBadHTML($text, $conf)
+ * 3746:     function textStyle($theValue, $conf)
+ * 3813:     function tableStyle($theValue, $conf)
+ * 3854:     function addParams($content,$conf)
+ * 3895:     function filelink($theValue, $conf)
+ * 3966:     function locDataJU($jumpUrl,$conf)
+ * 3997:     function calc($val)
+ * 4026:     function calcIntExplode($delim, $string)
+ * 4046:     function splitObj($value, $conf)
+ * 4108:     function parseFunc($theValue, $conf, $ref='')
+ * 4218:     function _parseFunc ($theValue, $conf)
+ * 4424:     function encaps_lineSplit($theValue, $conf)
+ * 4507:     function http_makelinks($data,$conf)
+ * 4574:     function mailto_makelinks($data,$conf)
+ * 4617:     function getImgResource($file,$fileArray)
  *
  *              SECTION: Data retrieval etc.
- * 4747:     function getFieldVal($field)
- * 4767:     function getData($string,$fieldArray)
- * 4897:     function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
- * 4919:     function getGlobal($var, $source=NULL)
- * 4955:     function getKey($key,$arr)
- * 4978:     function TCAlookup($inputValue,$conf)
+ * 4810:     function getFieldVal($field)
+ * 4830:     function getData($string,$fieldArray)
+ * 4975:     function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
+ * 4997:     function getGlobal($var, $source=NULL)
+ * 5033:     function getKey($key,$arr)
+ * 5056:     function TCAlookup($inputValue,$conf)
  *
  *              SECTION: Link functions (typolink)
- * 5038:     function typoLink($linktxt, $conf)
- * 5335:     function typoLink_URL($conf)
- * 5353:     function getTypoLink($label,$params,$urlParameters=array(),$target='')
- * 5380:     function getTypoLink_URL($params,$urlParameters=array(),$target='')
- * 5392:     function typolinkWrap($conf)
- * 5405:     function currentPageUrl($urlParameters=array(),$id=0)
- * 5418:     function getClosestMPvalueForPage($pageId, $raw=FALSE)
- * 5468:     function getMailTo($mailAddress,$linktxt,$initP='?')
- * 5506:     function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE)
+ * 5116:     function typoLink($linktxt, $conf)
+ * 5481:     function typoLink_URL($conf)
+ * 5499:     function getTypoLink($label,$params,$urlParameters=array(),$target='')
+ * 5526:     function getTypoLink_URL($params,$urlParameters=array(),$target='')
+ * 5538:     function typolinkWrap($conf)
+ * 5551:     function currentPageUrl($urlParameters=array(),$id=0)
+ * 5564:     function getClosestMPvalueForPage($pageId, $raw=FALSE)
+ * 5619:     function getMailTo($mailAddress,$linktxt,$initP='?')
+ * 5658:     function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE)
  *
  *              SECTION: Miscellaneous functions, stand alone
- * 5591:     function wrap($content,$wrap,$char='|')
- * 5607:     function noTrimWrap($content,$wrap)
- * 5621:     function wrapSpace($content, $wrap)
- * 5647:     function callUserFunction($funcName,$conf,$content)
- * 5688:     function processParams($params)
- * 5706:     function keywords($content)
- * 5723:     function caseshift($theValue, $case)
- * 5748:     function HTMLcaseshift($theValue, $case)
- * 5777:     function bytes($sizeInBytes,$labels)
- * 5788:     function calcAge($seconds,$labels)
- * 5820:     function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
- * 5847:     function URLqMark($url,$params)
- * 5863:     function checkEmail($email)
- * 5875:     function clearTSProperties($TSArr,$propList)
- * 5894:     function mergeTSRef($confArr,$prop)
- * 5917:     function joinTSarrays($conf,$old_conf)
- * 5940:     function gifBuilderTextBox($gifbuilderConf, $conf, $text)
- * 5996:     function linebreaks($string,$chars,$maxLines=0)
- * 6027:     function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
+ * 5754:     function wrap($content,$wrap,$char='|')
+ * 5770:     function noTrimWrap($content,$wrap)
+ * 5784:     function wrapSpace($content, $wrap)
+ * 5810:     function callUserFunction($funcName,$conf,$content)
+ * 5851:     function processParams($params)
+ * 5869:     function keywords($content)
+ * 5886:     function caseshift($theValue, $case)
+ * 5911:     function HTMLcaseshift($theValue, $case)
+ * 5940:     function bytes($sizeInBytes,$labels)
+ * 5951:     function calcAge($seconds,$labels)
+ * 5983:     function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
+ * 6010:     function URLqMark($url,$params)
+ * 6026:     function checkEmail($email)
+ * 6038:     function clearTSProperties($TSArr,$propList)
+ * 6057:     function mergeTSRef($confArr,$prop)
+ * 6080:     function joinTSarrays($conf,$old_conf)
+ * 6103:     function gifBuilderTextBox($gifbuilderConf, $conf, $text)
+ * 6159:     function linebreaks($string,$chars,$maxLines=0)
+ * 6190:     function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
  *
  *              SECTION: Database functions, making of queries
- * 6096:     function DBgetDelete($table, $uid, $doExec=FALSE)
- * 6128:     function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
- * 6170:     function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
- * 6207:     function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
- * 6247:     function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
- * 6287:     function enableFields($table,$show_hidden=0)
- * 6311:     function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
- * 6417:     function whereSelectFromList($field,$value)
- * 6435:     function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
- * 6462:     function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
- * 6483:     function searchWhere($sw,$searchFieldList,$searchTable='')
- * 6519:     function exec_getQuery($table, $conf)
- * 6537:     function getQuery($table, $conf, $returnQueryArray=FALSE)
- * 6616:     function getWhere($table,$conf, $returnQueryArray=FALSE)
- * 6711:     function checkPidArray($listArr)
- * 6734:     function checkPid($uid)
+ * 6260:     function DBgetDelete($table, $uid, $doExec=FALSE)
+ * 6292:     function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
+ * 6334:     function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
+ * 6371:     function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
+ * 6411:     function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
+ * 6451:     function enableFields($table,$show_hidden=0)
+ * 6475:     function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
+ * 6583:     function whereSelectFromList($field,$value)
+ * 6601:     function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
+ * 6628:     function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
+ * 6649:     function searchWhere($sw,$searchFieldList,$searchTable='')
+ * 6685:     function exec_getQuery($table, $conf)
+ * 6703:     function getQuery($table, $conf, $returnQueryArray=FALSE)
+ * 6783:     function getWhere($table,$conf, $returnQueryArray=FALSE)
+ * 6878:     function checkPidArray($listArr)
+ * 6902:     function checkPid($uid)
  *
  *              SECTION: Frontend editing functions
- * 6790:     function editPanel($content, $conf, $currentRecord='', $dataArr=array())
- * 6965:     function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
- * 7033:     function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')
- * 7075:     function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
- * 7103:     function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())
- * 7125:     function isDisabled($table,$row)
+ * 6959:     function editPanel($content, $conf, $currentRecord='', $dataArr=array())
+ * 7146:     function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
+ * 7228:     function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')
+ * 7270:     function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
+ * 7298:     function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())
+ * 7320:     function isDisabled($table,$row)
  *
  *
- * 7156: class tslib_frameset
- * 7166:     function make($setup)
- * 7203:     function frameParams($setup, $typeNum)
- * 7246:     function framesetParams($setup)
+ * 7351: class tslib_frameset
+ * 7361:     function make($setup)
+ * 7398:     function frameParams($setup, $typeNum)
+ * 7426:     function framesetParams($setup)
  *
  *
- * 7279: class tslib_tableOffset
- * 7291:     function start($content,$offset)
+ * 7459: class tslib_tableOffset
+ * 7471:     function start($content,$offset)
  *
  *
- * 7369: class tslib_controlTable
- * 7404:     function start($offset,$cMargins)
+ * 7549: class tslib_controlTable
+ * 7584:     function start($offset,$cMargins)
  *
- * TOTAL FUNCTIONS: 136
+ * TOTAL FUNCTIONS: 135
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -335,6 +335,7 @@ class tslib_cObj {
        var $checkPid_badDoktypeList = '255';
        var $lastTypoLinkUrl='';        // This will be set by typoLink() to the url of the most recent link created.
        var $lastTypoLinkTarget='';     // DO. link target.
+       var $lastTypoLinkLD = array();
        var $substMarkerCache=array();  // Caching substituteMarkerArrayCached function
        var $recordRegister=array();    // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
        var $cObjHookObjectsArr = array();              // Containig hooks for userdefined cObjects
@@ -5113,6 +5114,7 @@ class tslib_cObj {
         * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=321&cHash=59bd727a5e
         */
        function typoLink($linktxt, $conf)      {
+               $LD = array();
                $finalTagParts = array();
                $finalTagParts['aTagParams'] = $this->getATagParams($conf);
 
@@ -5298,11 +5300,28 @@ class tslib_cObj {
                                                        $addQueryParams.= '&MP='.rawurlencode(implode(',',$MPvarAcc));
                                                }
                                                elseif ($GLOBALS['TSFE']->config['config']['typolinkCheckRootline']) {
+
+                                                       // If we link across domains and page is free type shortcut, we must resolve the shortcut first!
+                                                       // If we do not do it, TYPO3 will fail to (1) link proper page in RealURL/CoolURI because
+                                                       // they return relative links and (2) show proper page if no RealURL/CoolURI exists when link is clicked
+                                                       if ($GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains'] && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) {
+                                                               $page2 = $page; // Save in case of broken destination or endless loop
+                                                               $maxLoopCount = 20;     // Same as in RealURL, seems enough
+                                                               while ($maxLoopCount && is_array($page) && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) {
+                                                                       $page = $GLOBALS['TSFE']->sys_page->getPage($page['shortcut'], $disableGroupAccessCheck);
+                                                                       $maxLoopCount--;
+                                                               }
+                                                               if (count($page) == 0 || $maxLoopCount == 0) {
+                                                                       // We revert if shortcut is broken or maximum number of loops is exceeded (indicates endless loop)
+                                                                       $page = $page2;
+                                                               }
+                                                       }
+
                                                        // This checks if the linked id is in the rootline of this site and if not it will find the domain for that ID and prefix it:
                                                        $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']);  // Gets rootline of linked-to page
                                                        $tCR_flag = 0;
                                                        foreach ($tCR_rootline as $tCR_data)    {
-                                                               if ($tCR_data['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid'])       {
+                                                               if ($tCR_data['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid'])     {
                                                                        $tCR_flag = 1;  // OK, it was in rootline!
                                                                        break;
                                                                }
@@ -5322,17 +5341,25 @@ class tslib_cObj {
                                                        // If other domain, overwrite
                                                if (strlen($tCR_domain) && !$GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains']) {
                                                        $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
-                                                       if ($conf['extTarget.'])        {$target = $this->stdWrap($target, $conf['extTarget.']);}
-                                                       if ($forceTarget)       {$target=$forceTarget;}
+                                                       if ($conf['extTarget.']) {
+                                                               $target = $this->stdWrap($target, $conf['extTarget.']);
+                                                       }
+                                                       if ($forceTarget) {
+                                                               $target = $forceTarget;
+                                                       }
                                                        $LD['target'] = $target;
                                                        $this->lastTypoLinkUrl = $this->URLqMark('http://'.$tCR_domain.'/index.php?id='.$page['uid'],$addQueryParams).$sectionMark;
                                                } else {        // Internal link:
                                                        if ($forceTarget) {
-                                                               $target=$forceTarget;
+                                                               $target = $forceTarget;
                                                        }
                                                        $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP);
                                                        if (strlen($tCR_domain)) {
-                                                               $LD['totalURL'] = 'http://' . $tCR_domain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL'];
+                                                               // We will add domain only if URL does not have it already.
+                                                               $urlParts = parse_url($LD['totalURL']);
+                                                               if ($urlParts['host'] == '') {
+                                                                       $LD['totalURL'] = 'http://' . $tCR_domain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL'];
+                                                               }
                                                        }
                                                        $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark;
                                                }
@@ -5378,9 +5405,13 @@ class tslib_cObj {
                                }
                        }
 
-                       if ($forceTitle)        {$title=$forceTitle;}
+                       $this->lastTypoLinkLD = $LD;
+
+                       if ($forceTitle) {
+                               $title=$forceTitle;
+                       }
 
-                       if ($JSwindowParams)    {
+                       if ($JSwindowParams) {
 
                                        // Create TARGET-attribute only if the right doctype is used
                                if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype))        {
index ab0ba94..e9a3b7c 100755 (executable)
  *
  *
  *
- *  145: class tslib_menu
- *  191:     function start(&$tmpl,&$sys_page,$id,$conf,$menuNumber,$objSuffix='')
- *  324:     function makeMenu()
- *  865:     function includeMakeMenu($conf,$altSortField)
- *  881:     function filterMenuPages(&$data,$banUidArray,$spacer)
- *  937:     function procesItemStates($splitCount)
- * 1147:     function link($key,$altTarget='',$typeOverride='')
- * 1212:     function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride)
- * 1233:     function subMenu($uid, $objSuffix='')
- * 1278:     function isNext($uid, $MPvar='')
- * 1299:     function isActive($uid, $MPvar='')
- * 1320:     function isCurrent($uid, $MPvar='')
- * 1335:     function isSubMenu($uid)
- * 1360:     function isItemState($kind,$key)
- * 1400:     function accessKey($title)
- * 1426:     function userProcess($mConfKey,$passVar)
- * 1441:     function setATagParts()
- * 1454:     function getPageTitle($title,$nav_title)
- * 1466:     function getMPvar($key)
- * 1481:     function getDoktypeExcludeWhere()
- * 1491:     function getBannedUids()
+ *  146: class tslib_menu
+ *  211:     function start(&$tmpl,&$sys_page,$id,$conf,$menuNumber,$objSuffix='')
+ *  357:     function makeMenu()
+ *  909:     function includeMakeMenu($conf,$altSortField)
+ *  925:     function filterMenuPages(&$data,$banUidArray,$spacer)
+ *  981:     function procesItemStates($splitCount)
+ * 1191:     function link($key,$altTarget='',$typeOverride='')
+ * 1263:     function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride)
+ * 1284:     function subMenu($uid, $objSuffix='')
+ * 1330:     function isNext($uid, $MPvar='')
+ * 1351:     function isActive($uid, $MPvar='')
+ * 1372:     function isCurrent($uid, $MPvar='')
+ * 1387:     function isSubMenu($uid)
+ * 1412:     function isItemState($kind,$key)
+ * 1452:     function accessKey($title)
+ * 1480:     function userProcess($mConfKey,$passVar)
+ * 1495:     function setATagParts()
+ * 1508:     function getPageTitle($title,$nav_title)
+ * 1520:     function getMPvar($key)
+ * 1535:     function getDoktypeExcludeWhere()
+ * 1545:     function getBannedUids()
+ * 1568:     function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '')
  *
  *
- * 1530: class tslib_tmenu extends tslib_menu
- * 1539:     function generate()
- * 1555:     function writeMenu()
- * 1699:     function getBeforeAfter($pref)
- * 1729:     function addJScolorShiftFunction()
- * 1751:     function extProc_init()
- * 1762:     function extProc_RO($key)
- * 1773:     function extProc_beforeLinking($key)
- * 1785:     function extProc_afterLinking($key)
- * 1802:     function extProc_beforeAllWrap($item,$key)
- * 1813:     function extProc_finish()
+ * 1618: class tslib_tmenu extends tslib_menu
+ * 1627:     function generate()
+ * 1643:     function writeMenu()
+ * 1796:     function getBeforeAfter($pref)
+ * 1826:     function addJScolorShiftFunction()
+ * 1848:     function extProc_init()
+ * 1859:     function extProc_RO($key)
+ * 1870:     function extProc_beforeLinking($key)
+ * 1882:     function extProc_afterLinking($key)
+ * 1900:     function extProc_beforeAllWrap($item,$key)
+ * 1911:     function extProc_finish()
  *
  *
- * 1849: class tslib_gmenu extends tslib_menu
- * 1858:     function generate()
- * 1896:     function makeGifs($conf, $resKey)
- * 2101:     function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim)
- * 2173:     function writeMenu()
- * 2294:     function extProc_init()
- * 2305:     function extProc_RO($key)
- * 2316:     function extProc_beforeLinking($key)
- * 2329:     function extProc_afterLinking($key)
- * 2346:     function extProc_beforeAllWrap($item,$key)
- * 2357:     function extProc_finish()
+ * 1951: class tslib_gmenu extends tslib_menu
+ * 1960:     function generate()
+ * 1998:     function makeGifs($conf, $resKey)
+ * 2196:     function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim)
+ * 2268:     function writeMenu()
+ * 2392:     function extProc_init()
+ * 2403:     function extProc_RO($key)
+ * 2414:     function extProc_beforeLinking($key)
+ * 2427:     function extProc_afterLinking($key)
+ * 2444:     function extProc_beforeAllWrap($item,$key)
+ * 2455:     function extProc_finish()
  *
  *
- * 2391: class tslib_imgmenu extends tslib_menu
- * 2400:     function generate()
- * 2418:     function makeImageMap($conf)
- * 2604:     function writeMenu()
+ * 2493: class tslib_imgmenu extends tslib_menu
+ * 2502:     function generate()
+ * 2520:     function makeImageMap($conf)
+ * 2706:     function writeMenu()
  *
  *
- * 2647: class tslib_jsmenu extends tslib_menu
- * 2654:     function generate()
- * 2662:     function writeMenu()
- * 2723:     function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array())
+ * 2749: class tslib_jsmenu extends tslib_menu
+ * 2756:     function generate()
+ * 2764:     function writeMenu()
+ * 2825:     function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array())
  *
- * TOTAL FUNCTIONS: 46
+ * TOTAL FUNCTIONS: 47
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -1210,9 +1211,9 @@ class tslib_menu {
                        // Creating link:
                if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)))    {
                        $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
-                       $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
+                       $LD = $this->menuTypoLink($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
                } else {
-                       $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
+                       $LD = $this->menuTypoLink($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
                }
 
                        // Override URL if using "External URL" as doktype with a valid e-mail address:
@@ -1268,7 +1269,7 @@ class tslib_menu {
                        $addParams = $this->mconf['showAccessRestrictedPages.']['addParams'];
                        $addParams = str_replace('###RETURN_URL###',rawurlencode($LD['totalURL']),$addParams);
                        $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams);
-                       $LD = $this->tmpl->linkData($thePage,$mainTarget,'','','', $addParams, $typeOverride);
+                       $LD = $this->menuTypoLink($thePage,$mainTarget,'','','', $addParams, $typeOverride);
                }
        }
 
@@ -1552,6 +1553,40 @@ class tslib_menu {
                return $banUidArray;
        }
 
+       /**
+        * Calls typolink to create menu item links.
+        *
+        * @param       array           $page   Page record (uid points where to link to)
+        * @param       string          $oTarget        Target frame/window
+        * @param       boolean         $no_cache       true if caching should be disabled
+        * @param       string          $script Alternative script name
+        * @param       array           $overrideArray  Array to override values in $page
+        * @param       string          $addParams      Parameters to add to URL
+        * @param       array           $typeOverride   "type" value
+        * @return      array           See linkData
+        */
+       function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '') {
+               $conf = array(
+                       'parameter' => is_array($overrideArray) && $overrideArray['uid'] ? $overrideArray['uid'] : $page['uid'],
+               );
+               if ($typeOverride && t3lib_div::testInt($typeOverride)) {
+                       $conf['parameter'] .= ',' . $typeOverride;
+               }
+               if ($addParams) {
+                       $conf['additionalParams'] = $addParams;
+               }
+               if ($no_cache) {
+                       $conf['no_cache'] = true;
+               }
+               if ($oTarget) {
+                       $conf['target'] = $oTarget;
+               }
+               $this->parent_cObj->typoLink('|', $conf);
+               $LD = $this->parent_cObj->lastTypoLinkLD;
+               $LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
+               return $LD;
+       }
+
 }
 
 
@@ -1795,9 +1830,9 @@ class tslib_tmenu extends tslib_menu {
                                        document.getElementById(id).style.background = color;
                                        return true;
                                } else if (document.layers && document.layers[id]) {
-                               document.layers[id].bgColor = color;
+                                       document.layers[id].bgColor = color;
                                        return true;
-                           }
+                               }
                        }
                ';
        }
@@ -1849,7 +1884,7 @@ class tslib_tmenu extends tslib_menu {
                if (!$this->I['spacer'])        {
                        $this->I['theItem'].= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
                }
-               $part = $this->WMcObj->stdWrap($this->I['val']['wrapItemAndSub'],$this->I['val']['wrapItemAndSub.']); 
+               $part = $this->WMcObj->stdWrap($this->I['val']['wrapItemAndSub'],$this->I['val']['wrapItemAndSub.']);
                $this->WMresult.= $part ? $this->tmpl->wrap($this->I['theItem'],$part) : $this->I['theItem'];
        }
 
@@ -2526,7 +2561,7 @@ class tslib_imgmenu extends tslib_menu {
                                                                        unset($theValArr['text.']);     // if this is not done it seems that imageMaps will be rendered wrong!!
                                                                                // check links
 
-                                                                       $LD = $this->tmpl->linkData($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']);
+                                                                       $LD = $this->menuTypoLink($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']);
 
                                                                                // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
                                                                        $this->changeLinksForAccessRestrictedPages($LD, $this->menuArr[$key], $this->mconf['target'], $this->mconf['forceTypeValue']);
@@ -2825,7 +2860,7 @@ class tslib_jsmenu extends tslib_menu {
                                        $url='';
                                        $target='';
                                        if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) {
-                                               $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']);
+                                               $LD = $this->menuTypoLink($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']);
 
                                                        // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
                                                $this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']);