MediaWiki/archive/embedding/1.16/index.php

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< MediaWiki‎ | archive‎ | embedding
Revision as of 23:32, 17 March 2011 by Woozle (talk | contribs) (bug fix for restricted wikis)
Jump to navigation Jump to search

About

This works with MediaWiki v1.16.x.

Instructions

  • Set $wpWikiBase to the folder containing your MediaWiki installation
  • Change YOUR SITE TITLE to whatever you want to show up as the title in the brower's titlebar
  • Put this file (index.php) in the folder where you want the pages to appear. (I've only tested this in "/", however.)
  • Modify Apache/.htaccess -- see /.htaccess
  • Whatever is in [[project:Transclude/]] will appear (without the wiki skin) at http://yourdomain.com, [[project:Transclude/a page]] will appear at http://yourdomain.com/a_page, and so on.

Future

  • It should be simple enough to have a base title plus the page title, or even a title defined within the wikitext.
  • I haven't tested to see if a trailing "/" brings up a different page or not; if it does, then trimming off trailing "/"s from the request should fix that.

History

  • 2011-03-17 changed $wgArticle creation method -- other method returns fully-skinned error page when user does not have read access to the requested page
    • also added some debug code in case of other unanticipated problems

Code

<php><?php $wpWikiBase = '/wiki'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> YOUR SITE NAME

GetText('title'); $action = 'view'; $wgTitle = $mediaWiki->checkInitialQueries( $title, $action ); $wgArticle = MediaWiki::articleFromTitle( $wgTitle ); //$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest ); //$mediaWiki->performRequestForTitle( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest ); require_once( "$preIP/includes/Article.php" ); if (is_object($wgArticle)) { $txtPage = $wgArticle->getContent(); //$out = $wgParser->recursiveTagParse($txtPage); $objOptions = new ParserOptions(); $objPOut = $wgParser->parse( $txtPage, $wgTitle, $objOptions ); $out = $objPOut->getText(); } else { $out = "internal error"; } echo $out; echo '

';</php>