【发布时间】:2010-07-15 11:05:47
【问题描述】:
我在本地安装了 MediaWiki。一切正常,但我需要一个从我们的文件服务器链接文件的功能。我偶然发现了一个名为 Extension:NetworkLink 的扩展,它提供了这个功能。您只需在您的维基页面中添加文件路径,它应该可以工作。我的问题是我的本地 wiki 安装路径“http://localhost/w/index.php/”被添加到文件路径,然后链接不起作用。我试图编辑 PHP 文件中的 url 操作以将其删除,但它不起作用。这是编辑后的代码:
<?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;
}
【问题讨论】: