2

是否可以有一个 wiki 页面,其中包含两个表,反映来自两个不同的 3rd 方站点的数据?

如果是这样,如何完成它?页面模板在这里会有所帮助吗?

4

2 回答 2

2

简短的回答是否定的,没有简单的内置方法可以将外部内容拉入 MediaWiki 站点。允许第三方注入任意内容将带来巨大的安全风险。

很长的答案是,任何扩展都是可能的,无论是现有的还是你自己编写的。MediaWiki 站点有一整类“远程内容扩展”列表,这些列表以一种或另一种形式执行此类操作,外部数据看起来特别有用。您需要管理员权限才能安装其中任何一个,并且您需要信任扩展代码和您提取的数据。

于 2013-09-06T01:22:38.797 回答
0

I already wrote exactly what you describe. Might be helpful for you.

# Define a setup function
$wgHooks['ParserFirstCallInit'][] = 'efStackOverflow_Setup';
# Add a hook to initialise the magic word
$wgHooks['LanguageGetMagic'][]       = 'efStackOverflow_Magic';

function efStackOverflow_Setup( &$parser ) {
        # Set a function hook associating the "example" magic word with our function
 $parser->setFunctionHook( 'stag', 'efStackOverflow_Render' );
        return true;
}

function efStackOverflow_Magic( &$magicWords, $langCode ) {
        # Add the magic word
        # The first array element is whether to be case sensitive, in this case (0) it is not case sensitive, 1 would be sensitive
        # All remaining elements are synonyms for our parser function
        $magicWords['stag'] = array(1, 'stag');
        # unless we return true, other parser functions extensions won't get loaded.
        return true;
}

function efStackOverflow_Render( $parser, $param1 = '', $param2 = '' ) {
  // there was filtering
  $modif = 0;

  $cache_file_path = "cache/".$param1."_".$param2;

  if (file_exists($cache_file_path))
  $modif = time() - @filemtime ($cache_file_path);

  if (file_exists($cache_file_path) and $modif < 60*60*24) {

    return file_get_contents($cache_file_path);

  }

  $page = file_get_contents("http://www.google.com/rss/".$param1);

  $xml = new SimpleXMLElement($page);

  foreach ($xml as $key => $value) {
// do some
  }

  if (!empty($output))
  file_put_contents($cache_file_path, $output);

  return $output;

}

Mediawiki version was 1.16.

于 2013-09-09T07:57:11.320 回答