2010-07-15 93 views
0

我在本地安装了MediaWiki。一切正常,但我需要一个功能来链接文件从我们的文件服务器。我偶然发现了一个名为Extension:NetworkLink的扩展,它提供了这个功能。你只需要在你的wikipage中添加文件路径,它应该可以工作。我的问题是,我的本地wiki安装路径“http://localhost/w/index.php/”被添加到文件路径,然后链接不起作用。我试图编辑PHP文件中的URL操作来切断它,但它不起作用。下面是编辑的代码:MediaWiki本地扩展链接

<?php 

function linkExtension() { 
    global $wgParser; 
    $wgParser->setHook("link", "renderlink"); 
} 

# The callback function for converting the input text to HTML output 
function renderlink($loc='', $argv=array()) { 
    global $wgOut, $wgTitle, $wgParser; 

    $loc = htmlspecialchars($loc); 

    $pos = strrpos($loc, "/"); 
    if ($pos != false) 
    { 
     $loc = substr($loc, $pos + 1); 
    } 

    switch(strtoupper($argv['TARGET'])) { 
    case "SELF": 
     $out = "<a href=\"{$loc}\" target=\"_self\">$loc</a>"; 
     break; 
    case "TOP": 
     $out = "<a href=\"{$loc}\" target=\"_top\">$loc</a>"; 
     break; 
    case "PARENT": 
     $out = "<a href=\"{$loc}\" target=\"_parent\">$loc</a>"; 
     break; 
    default: 
     $out = "<a href=\"{$loc}\" target=\"_blank\">$loc</a>"; 
    } 

    return $out; 

} 

回答

1

我发现了另一个更好的解决方案。首先安装FF插件LocalLink。然后添加MediaWiki扩展:FileProtocolLinks。在此之后,你可以像这样在网络上加入您的wiki本地文件或链接股份:

LAN: < “文件> \文件服务器\ directory1中\ Directory2 \ MyFile.zip <”/文件>

本地: < “文件> C:/Directory1/Directory2/MyFile.zip <”(!忽略引号)/文件>