Hey all,
I'm trying to use MediaWiki in a pretty non-standard way, and I'm hoping someone can give me a definitely answer about what works / wont work:
The site is a collection of a few different open-source document, chat, and database tools. As such, it has it's own PHP code that drives the site, and includes MediaWiki and other systems to generate parts of pages where required.
As a simple example, I'm trying to do something like this:
function renderWiki($title) { $_R = $_REQUEST; $_G = $_GET; $_P = $_POST; $_REQUEST = array(); $_POST = array();
$_GET = array( 'action' => 'render', 'title' => $title );
chdir('wiki');
ob_start(); require('index.php'); // run MediaWiki here $output = ob_get_contents(); ob_end_clean();
$_REQUEST = $_R; $_GET = $_G; $_POST = $_P;
chdir('..');
return($output); }
The first result I get is something like this:
require(/includes/WebRequest.php) [function.require http://drmvt.anjero.com/function.require]: failed to open stream: No such file or directory in */storage/websites/test/docs/includes/AutoLoader.php* on line *362
*I played around a bit, and found out that by making $IP global, either in my function or in LocalSettings, I'd get a bit further, but then hit this error:
*Fatal error*: Call to a member function incr() on a non-object in */storage/websites/drmvt/docs/includes/GlobalFunctions.php* on line *1679
*My hypothesis is that MediaWiki relies on many variables being in the global scope, due to their being defined outside of any MW functions (for example, anything defined by LocalSettings). Since I'm running MW from inside my own function, variables not explicitly defined as global inherit my function's variable scope. Thus later references to those same variables, in subroutines where they are explicitly made global, actually reference a different (and empty) variable scope.
1) Does this theory sound correct?
2) Assuming I need to use functions in my site's framework, what's the best way to make this work?
Thanks,
Andy
- Does this theory sound correct?
So it seems.
- Assuming I need to use functions in my site's framework, what's the
best way to make this work?
I suppose you could do some strange trickeries to avoid the function, like
<?Php do_data() render_page(); if ($show_wiki) require("index.php"); ?>
However, i think you're using the wrong approach here. You could allow the users to go to /wiki/ with the wiki having an Skin to resemble your site's skin (you can even callback to your site's code). http://www.mediawiki.org/wiki/Manual:Skinning
Also, if you only want to convert wikitext to html, you can use the Parser class in your code.
I don't know about doing it though any place other than the same directory that MediaWiki is located in, but if you take this code out from index.php: # Initialise common code require_once( 'includes/WebStart.php' );
# Initialize MediaWiki base class require_once( "includes/Wiki.php" ); $mediaWiki = new MediaWiki();
You suddenly gain access to everything in MediaWiki, all the wfMsg, and the database, title, and other methods are available.
~Daniel Friesen(Dantman) of The Gaiapedia, Wikia Graphical Entertainment Project, and Wiki-Tools.com
Platonides wrote:
- Does this theory sound correct?
So it seems.
- Assuming I need to use functions in my site's framework, what's the
best way to make this work?
I suppose you could do some strange trickeries to avoid the function, like
<?Php do_data() render_page(); if ($show_wiki) require("index.php"); ?>
However, i think you're using the wrong approach here. You could allow the users to go to /wiki/ with the wiki having an Skin to resemble your site's skin (you can even callback to your site's code). http://www.mediawiki.org/wiki/Manual:Skinning
Also, if you only want to convert wikitext to html, you can use the Parser class in your code.
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org