2012-11-28 26 views
0

我正在尝试为RTE浏览链接窗口创建一个新选项卡,目的是允许链接到网络共享上的文件。使用外部链接将不起作用,因为TYPO3自动将http://<domain>/typo3预加载到链接。t3lib_browseLinksHook和自定义链接格式

我在自定义选项卡中遇到同样的问题。当例如输入\\<share>\<file>,链接结束为http://<domain>/typo3/\\<share>\<file>

钩类:

class Tx_Test_Hooks_NetworkFolderTree implements t3lib_browseLinksHook 
{ 
    public function init($browseLinks, $additionalParameters) 
    { 
    $this->browseLinks = &$browseLinks; 
    } 

    public function getTab($linkSelectorAction) 
    { 
    global $BE_USER, $LANG; 

    $content = ' 
     <form action="" name="lurlform" id="lurlform"> 
     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL"> 
      <tr> 
     <td>URL:</td> 
     <td><input type="text" name="lurl"'.$this->browseLinks->doc->formWidth(20).' value="" /> '. 
     '<input type="submit" value="set" onclick="browse_links_setHref(document.lurlform.lurl.value); browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); return link_current();" /></td> 
      </tr> 
     </table> 
     </form>'; 

    $content .= $this->browseLinks->addAttributesForm(); 

    return $content; 
    } 

    public function parseCurrentUrl($href, $siteUrl, $info) 
    { 
    if(preg_match('/^([a-z]\:[\/\\\]|\\\{2})/', $href, $matchData)) $info['act'] = 'unc'; 

    return $info; 
    } 

    public function modifyMenuDefinition($menuDefinition) 
    { 
    global $LANG; 

    return array_merge($menuDefinition, array(
       'unc' => array(
       'isActive' => ($this->browseLinks->act == 'unc'), 
       'label'  => 'Network file', 
       'url'  => '#', 
       'addParams' => 'onclick="jumpToUrl(\''.htmlspecialchars('?act=unc&mode='.$this->browseLinks->mode.'&bparams='.$this->browseLinks->bparams).'\');return false;"' 
      ) 
     ) 
    ); 
    } 

    public function addAllowedItems($currentlyAllowedItems) 
    { 
    return array_merge($currentlyAllowedItems, array('unc')); 
    } 

} 

回答

0

发现这个问题。通过PHP的parse_url进行检查,返回一个关于url的信息数组。如果架构丢失(这里是这种情况),http://被追加。