website_jukni/tools/docu-export.php
2017-12-29 15:51:59 +01:00

113 lines
3.5 KiB
PHP

<?php
if($_GET['showsource']) highlight_file($_SERVER['SCRIPT_FILENAME']) && die();
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dokuwiki Khaganat Tutorial to RyzomForge Mediawiki Helper</title>
<style>
<!--
body, input{
font-family:"Tahoma","Verdana",sans;
}
div{
background-color: sandybrown;
}
textarea{
height:300px;
width:500px;
}
table{display:none;}
div.advertising{ color: none; display:none }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="Mediawiki, converter, dokuwiki, wiki, syntax" />
<meta name="description" content="Mediawiki to dokuwiki syntax converter, online." />
</head>
<body>
<h1>Dokuwiki Khaganat Tutorial to RyzomForge Mediawiki Helper</h1>
This is a php script to convert Docuwiki text to the Mediawiki syntax. This script has been made to help the ryzomforge project and transfert somes tuto from the khaganat project to the ryzomforge wiki. The script is based on the "mediawiki to docuwiki" converter from <a href="http://johbuc6.coconia.net/doku.php?id=mediawiki_to_dokuwiki_converter">Johannes Buchner</a>.
<div class="advertising">Dokuwiki Khaganat Tutorial to RyzomForge Mediawiki Helper, Dokuwiki Khaganat Tutorial to RyzomForge Mediawiki Helper, converting Wiki Text from Docuwiki to Mediawiki.</div>
<?php
$replacements = array(
'^[ ]*=([^=])'=>'<h1> ${1}',
'([^=])=[ ]*$'=>'${1} </h1>',
'^[ ]*==([^=])'=>'<h2> ${1}',
'([^=])==[ ]*$'=>'${1} </h2>',
'^[ ]*===([^=])'=>'<h3> ${1}',
'([^=])===[ ]*$'=>'${1} </h3>',
'^[ ]*====([^=])'=>'<h4> ${1}',
'([^=])====[ ]*$'=>'${1} </h4>',
'^[ ]*=====([^=])'=>'<h5> ${1}',
'([^=])=====[ ]*$'=>'${1} </h5>',
'^[ ]*======([^=])'=>'<h6> ${1}',
'([^=])======[ ]*$'=>'${1} </h6>',
'<\/?h1>'=>'======',
'<\/?h2>'=>'=====',
'<\/?h3>'=>'====',
'<\/?h4>'=>'===',
'<\/?h5>'=>'==',
'<\/?h6>'=>'=',
'^ \* '=> '***** ' ,
'^ \* '=>'**** ',
'^ \* '=>'*** ',
'^ \* '=>'** ',
'^ \* '=>'* ',
'^ \- '=>'#### ',
'^ \- '=>'### ',
'^ \- '=>'## ',
'^ \- '=>'# ',
'(.)\*\*'=>'${1}\'\'\'',
'\/\/'=>'\'\'',
'<code>'=>'<pre>',
'<\/code>'=>"<\/pre>"
);
$_POST['docuwiki'] = stripslashes($_POST['docuwiki']);
//echo "\"'" . $_POST['docuwiki'] . "\"'" ;
$mediawiki = split("\r\n",stripslashes($_POST['docuwiki']));
//print_r($mediawiki) ;
if(!empty($mediawiki)) foreach($replacements as $k=>$v){
for($i=0;$i<count($mediawiki);$i++)
$mediawiki = preg_replace('/'.$k.'/',$v,$mediawiki);
//echo (++$j)." " . $i . "\r\n";
//echo $mediawiki."\r\n";
}
$mediawiki = join("\r\n",$mediawiki);
//echo "\"".$mediawiki."\"" ;
?>
<h2>Docuwiki:</h2>
<form action="" method="post">
<textarea name="docuwiki"><?php echo $_POST['docuwiki'] ?></textarea>
<input type="submit" value="convert">
</form>
<h2>Mediawiki:</h2>
<textarea name="mediawiki"><?php echo $mediawiki; ?></textarea>
<div class="advertising">Dokuwiki Khaganat Tutorial to RyzomForge Mediawiki Helper, Dokuwiki Khaganat Tutorial to RyzomForge Mediawiki Helper, converting Wiki Text from Docuwiki to Mediawiki.</div>
</body>
</html>