2010-07-15 91 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 <」(!忽略引號)/文件>