Last modified: 2008-12-05 12:02:01 UTC
When trying to get parsedContent of Pages via the API along the lines of: $title = Title::newFromText($titleText); $article = new Article($title); $wikitext = $article->getContent(); $content = $wgOut->parse($wikitext); I run into trouble when trying to prepare for being able to use the above code snippet. The code: $preIP="/srv/www/intern/mediawiki-1.13.0"; putenv ("MW_INSTALL_PATH=$preIP"); require_once( "$preIP/includes/WebStart.php" ); # Initialize MediaWiki base class require_once( "$preIP/includes/Wiki.php" ); require_once( "$preIP/includes/Title.php" ); require_once( "$preIP/includes/Article.php" ); only works if no autoloader is running. E.g. in WebRequest.php /** * Some entry points may use this file without first enabling the * autoloader. */ if ( !function_exists( '__autoload' ) ) { require_once( dirname(__FILE__) . '/normal/UtfNormal.php' ); } Does check whether __autoload exist - but doesn not check whether it is the autoloader of Mediawiki. It would be great if there'd be some simple function that allows to retrieve the Mediawiki page content for use in other applications (even if this means some limits on what the page can contain e.g. obviously to follow links would be tricky if no other measures are taken).
After looking into the details of this I think the handling of global variables should not assume that the initialization is done in the global space. I tried to autoload a Class that does than initialize Wikimedia and it doesn't work since e.g. DefaultSettings.php does not declare the variables to be global - it is simply assumed that the current scope is global. It would be great if on initial declaration of global variable content the global $... declaration would be used to avoid this problem. e.g. global $wgLegalTitleChars; $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+"; and so on ...
You're probably better off using the /actual/ API, at http://en.wikipedia.org/w/api.php . Docs are at [[mw:API]], you'll be particularly interested in [[mw:API:Expanding_templates_and_rendering]] and [[mw:API:Calling_internally]].
(In reply to comment #2) > You're probably better off using the /actual/ API, at > http://en.wikipedia.org/w/api.php . Docs are at [[mw:API]], you'll be > particularly interested in [[mw:API:Expanding_templates_and_rendering]] and > [[mw:API:Calling_internally]]. > Oops, those links don't really work. Try http://www.mediawiki.org/wiki/API