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;
}