2012-06-22 2 views
1

안녕하세요. 다음과 같은 문제가 있습니다.mediawiki 확장 txt 파일의 데이터를 읽습니다.

나는 txt 파일의 데이터가 필요한 Mediawiki Extension을 작성합니다. 하지만 일반적으로 사용되는 readfile (yourtxtfile.txt)은 Mediawiki에서 작동하지 않습니다 ....

Mediawiki 확장 프로그램의 txt 파일에서 데이터를 가져올 수 있습니까?

<?php 

$wgExtensionCredits['parserhook'][] = array(

'path' => __FILE__, 
'name' => 'UniChecker', 
'description' => 'Check the all names of specific universities', 
'descriptionmsg' => 'UniChecker-desc', 
'version' => 1, 
'author' => 'me', 
'url' => 'https://www.mediawiki.org/wiki/Manual:UniChecker', 

); 

// Specify the function that will initialize the parser function. 
$wgHooks['ParserFirstCallInit'][] = 'UniSetupFunc'; 

// Allow translation of the parser function name 
$wgExtensionMessagesFiles['ExampleExtensionMagic'] = dirname(__FILE__) .'/UniChecker.i18n.magic.php'; 


function UniSetupFunc(&$parser) { 

    // Create a function hook associating the "example" magic word with the 
    // UniParsefunc() function. 
    $parser->setFunctionHook('Uni', 'UniParsefunc'); 

    // Return true so that MediaWiki continues to load extensions. 
    return true; 
     } 

// Render the output of the parser function. 
function UniParsefunc($parser, $param1 = '') 
{ 
    if(!file_exists("Uni.txt")) echo "Data not found"; 

    // here i want to open my txt file 
    // readfile not work 


    return $txt_data; 
} 

답변

3

예를 들어 전체 경로를 입력하십시오. file_exists('/var/foo/bar/Uni.txt');

+0

작동은 주 경로에서 시작된다는 것을 잊지 마십시오. :) –

관련 문제