Extension:AutoWikiDump
From MediaWiki.org
|
Auto Wiki Dump Release status: beta |
|
|---|---|
| Description | Writes a wiki page to a file when it is updated |
| Author(s) | Thomas Lorentsen (matx Talk) |
| Version | 0.1 (2008-04-18) |
| MediaWiki | 1.11 |
| License | GPL |
| Download | Scroll down |
| Hooks used | |
Contents |
[edit] What can this extension do?
When a page is updated, this extension can write the wiki text to a file. This allows access to the wiki text without logging into mediawiki.
[edit] Usage
Below lets you configure which pages you want saved to a file.
$awd_config = array(); $awd_config["Testwikidump"]["filename"] = 'testfile.txt'; $awd_config["Testwikidump"]["on"] = true;
Make sure the file has write permission set.
chmod a+rw testfile.txt
[edit] Installation
To install this extension, add the following to LocalSettings.php:
$awd_config = array(); $awd_config["Wikipagename"]["filename"] = 'testfile.txt'; $awd_config["Wikipagename"]["on"] = true; require_once("$IP/extensions/autowikidump.php");
[edit] Code
<? /* * Usage * Create file wiki write rights. * chmod a+rw testfile.txt * * * $awd_config = array(); * $awd_config["Testwikidump"]["filename"] = 'testFile.txt'; * $awd_config["Testwikidump"]["on"] = true; * * @author Thomas Lorentsen */ if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die(); } $wgHooks['ArticleSaveComplete'][] = 'fnAutoWikiDump'; function fnAutoWikiDump(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, &$revision){ global $awd_config; $awd_title = $article->getTitle(); if ($awd_config["$awd_title"]["on"]) { if(isset($awd_config["$awd_title"]["filename"]) and $awd_config["$awd_title"]["on"] == true) { $myFile = $awd_config["$awd_title"]["filename"]; $fh = fopen($myFile, 'w'); $stringData = $text; fwrite($fh, $stringData); fclose($fh); } } return true; } /* * Gets the requested wiki page * $page the wiki page * returns the requested wiki page */ function awd_getContent($page) { global $wgOut, $wgTitle, $wgParser; $titleFromText = $wgTitle->newFromText($page); $article = new Article($titleFromText); return $article->getContent(); }

