[Mediawiki-l] Need Help: Embeding php scripts in wiki pages.

Mortico mortico at yahoo.com
Thu Jun 1 17:56:30 UTC 2006


I've made a parser hook extention that parses the tags <php> and </php> into
the tags for actual php code.  it is working so far, but somthing in
wikimedia keeps adding additional code to the closing bracket, rendering it
non-functional.

This is my extention:
$wgExtensionFunctions[] = "wfembededphp";

function wfembededphp() {
    global $wgParser;
    $wgParser->setHook( "php", "renderscript" );
}

function renderscript( $input, $argv ) {
    $output = "<?php $input ?>";
    return $output;
}

This is the code i'm testing, it is simply typed into the wiki page like
normal.
<php>
print "this is some php code";
</php>

This is what it shoudl look like in the page source:
<?php
print "this is some php code";
?>

This is what it ACTUALLY gives me:
<p><? 
print "this is some php code";
</p>
<pre>?>
</pre>

The additional tags of </p> and <pre> contained within the php code are
screwing it up and causing nothing to display, instead of running the script
as it should.

I think that the wiki is parsing more tags into the final code, after the
code has been rendered how i want it.  I would think that a solution would
be to get my extention to run after all other rendering on the page is done. 
But i don't know how to do that, and i think there must be an easier way.

I'm pretty new to php, so please don't be overly technical.  thanks!


--
View this message in context: http://www.nabble.com/Need+Help%3A+Embeding+php+scripts+in+wiki+pages.-t1718237.html#a4666698
Sent from the WikiMedia General forum at Nabble.com.




More information about the MediaWiki-l mailing list