/**
 * Smarty {wiki}{/wiki} block plugin
 * 
 * @param string $content contents of the block
 * @param object $template template object
 * @param boolean $ &$repeat repeat flag
 * @return string content re-formatted
 */
function smarty_block_wiki2($params, $content, $template, &$repeat)
{
    global $smarty, $config_q;
    define('MEDIAWIKI', true);
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/Exception.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/User.php";
    //require_once($config_q["code_path"]."/externals/mediawiki/includes/StubUserLang.php");
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/StubObject.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/WebRequest.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/GlobalFunctions.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/ObjectCache.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/maintenance/tests/testHelpers.inc";
    require_once $config_q["code_path"] . "/externals/mediawiki/maintenance/tests/parser/parserTest.inc";
    $test = new ParserTest();
    $parser = $test->fuzzTest('foo.php');
    /*$parser->setupGlobals();
    	$p = $parser->getParser();
             * 
             */
    /*define('MEDIAWIKI', true);
            require_once($config_q["code_path"]."/externals/mediawiki/includes/Exception.php");
            require_once($config_q["code_path"]."/externals/mediawiki/includes/User.php");
            require_once($config_q["code_path"]."/externals/mediawiki/includes/StubUserLang.php");
            
    
            require_once($config_q["code_path"]."/externals/mediawiki/includes/GlobalFunctions.php");
            require_once($config_q["code_path"]."/externals/mediawiki/includes/ProfilerStub.php");
    	require_once($config_q["code_path"]."/externals/mediawiki/includes/parser/Parser.php");
    
    arr('f');
            $wgUser = new User;
            $wgLang = new StubUserLang;
            $wgOut = new StubObject( 'wgOut', 'OutputPage' );
            $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
    
            arr('f');
    
            /*$parser = new Parser();
    	return $parser->recursiveTagParse( $content );
             *
             */
}
    exit(0);
}
# Cases of weird db corruption were encountered when running tests on earlyish
# versions of SQLite
if ($wgDBtype == 'sqlite') {
    $db = wfGetDB(DB_MASTER);
    $version = $db->getServerVersion();
    if (version_compare($version, '3.6') < 0) {
        die("Parser tests require SQLite version 3.6 or later, you have {$version}\n");
    }
}
# There is a convention that the parser should never
# refer to $wgTitle directly, but instead use the title
# passed to it.
$wgTitle = Title::newFromText('Parser test script do not use');
$tester = new ParserTest($options);
if (isset($options['file'])) {
    $files = array($options['file']);
} else {
    // Default parser tests and any set from extensions or local config
    $files = $wgParserTestFiles;
}
# Print out software version to assist with locating regressions
$version = SpecialVersion::getVersion();
echo "This is MediaWiki version {$version}.\n\n";
if (isset($options['fuzz'])) {
    $tester->fuzzTest($files);
} else {
    $ok = $tester->runTestsFromFiles($files);
    exit($ok ? 0 : 1);
}