<?php
// $Header: /cvsroot/tikiwiki/tiki/import/mwxml2tikixml.php,v 1.2.2.2 2008-01-06 19:39:40 evanprodromou Exp $

// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

// USAGE: phpmwxml2tikixml.php INPUT OUTPUT

require_once('Text/Wiki.php');
require_once('Text/Wiki/Mediawiki.php');
require_once('Text/Wiki/Tiki.php');

function convertMediaWikiFile($input, $output) {
	$mw = simplexml_load_file($input);
	
	if ($mw === false) {
		// FIXME: Signal error
		print("ERROR: can't load input file '$input'; quitting.\n");
		exit(1);
	}

	$tw = new Text_Wiki_Mediawiki();
	
	foreach ($mw->page as $page) {
		foreach ($page->revision as $revision) {
			$t = htmlspecialchars($revision->text);
			$revision->text = $tw->transform($t, 'Tiki');
		}
	}

	$mw->asXML($output);
	
	if ($result === false) {
		// FIXME: Signal error
		print("ERROR: can't write output file '$output'; quitting.\n");
		exit(1);
	}
}

function printUsage() {
	print "USAGE: phpmwxml2tikixml.php INPUT OUTPUT\n";
}

if (count($argv) != 3) {
	printUsage();
} else {
	convertMediaWikiFile($argv[1], $argv[2]);
}

?>
Add MW import tool (moved from HEAD -- oops!)
Add MW import tool (moved from HEAD -- oops!)


git-svn-id: 98221c33f75d780f3c875f55d1123395aec31ba7@10966 b456876b-0849-0410-b77d-98878d47e9d5
