Extension talk:Wiki2xml

From MediaWiki.org
Jump to navigation Jump to search

Installation[edit]

I find this extension very useful, especially the ODT export. I use it via the URL : http://tools.wikimedia.de/~magnus/wiki2xml/w2x.php but it is currently out of service. I tried to install it on my Linux MediaWiki installation, but I didn't managed to activate the ODT export, even after two hours spent to analyze the PHP code... This extension seems to have been made for Windows and doesn't work well with Linux.

Could somebody solve this problem, please ?

Best regards. Peter17 19:53, 6 April 2008 (UTC)

It is a bit late to answer. However the corresponding README file provides the following instructions (slightly modified). Put this into your local.php
On a Unix/Linux server the following can be used as a starting point:

        # Base url of your site
        # e.g. "example.com" or "wiki.example.com"
        $xmlg["site_base_url"] = "" ;

	# Directory for temporary files:
        # subdirectory of the path of your wiki installation
	$xmlg["temp_dir"] = "/tmp";

 	# Path to the zip/unzip programs; can be omitted if in default
	# executable path:
	#$xmlg["zip_odt_path"] = "";

	# Command to zip directory $1 to file $2:
	$xmlg["zip_odt"] = 'zip -r9 $1 $2';

	# Command to unzip file $1 to directory $2:
	$xmlg["unzip_odt"] = 'unzip -x $1 -d $2';


It worked for me. Cheers --kgh 22:47, 19 March 2010 (UTC)
Hi, kgh!
Thanks for your help! I tried that and its now working! Peter17 07:21, 21 April 2010 (UTC)

Not for Linux?[edit]

In the README file of this extension you can read:

On a Unix/Linux server the following can be used as a starting point:

In the local.php file (which can be copied from sample_local.php) you can set the following:

# On Windows, set
# $xmlg['is_windows'] = true ;

So my conclusion would be that it is designed to work on linux.

I said I thought it was not, because of some lines in sample_local.php
$xmlg["docbook"] = array (
 "command_pdf" => "C:/docbook/bat/docbook_pdf.bat %1" ,
 "command_html" => "C:/docbook/bat/docbook_html.bat %1" ,
 "temp_dir" => "C:/docbook/repository" ,
 "out_dir" => "C:/docbook/output" ,
 "dtd" => "file:/c:/docbook/dtd/docbookx.dtd"
) ;
I didn't know how to adapt them for Linux. But I didn't notice I could just ignore them and add the lines suggested by the README file. Sorry for my mistake, it's working correctly now. Peter17 07:21, 21 April 2010 (UTC)

Fix it on Linux - ToDo list[edit]

Create new file local.php

  1. cp sample_local.php local.php
  2. change zip_odt and unzip_odt to the syntax of the zip program installed on the server(It can be: zip/unzip, 7z, etc...(

Fix w2xml.php

  1. add line @mkdir($dir)

Fix image converting

  1. enable cURL php extension on the server

I need to make this more clear. --Power Boots 16:20, 14 July 2009 (UTC)

Hi Power Boots! Thanks for your help. Is there a way to enable images export without modifying the server configuration? Peter17 07:21, 21 April 2010 (UTC)


Syntax error[edit]

In the file "mediawiki_converter.php" (in the extension/wiki2xml/ -directory) on line 45 you find:

$xml .= ' title="' . htmlspecialchars( $title ) '"' ;

When I add a point (".") the extension seems to work. So I changed the line in:

$xml .= ' title="' . htmlspecialchars( $title ) . '"' ;

Hope That Helps

Patch[edit]

--- mediawiki_converter.php	Wed Nov 26 15:03:51 2008
+++ mediawiki_converter.php	Wed Nov 26 15:02:59 2008
@@ -42,7 +42,7 @@
 		}
 		$xml = '<article' ;
 		if ( $title != "" ) {
-			$xml .= ' title="' . htmlspecialchars( $title ) '"' ;
+			$xml .= ' title="' . htmlspecialchars( $title ) . '"' ;
 			$content_provider->add_article ( urldecode ( $ot ) ) ;
 		}
 		$xml .= '>' ;

--rhododendronbusch 14:20, 26 November 2008 (UTC)

This fix is now incorporated to the files at subversion. Cheers --kgh 22:47, 19 March 2010 (UTC)

Source Code not available[edit]

all links to the source code on wikimedia servers (SVN) are not available anymore :(

where can i get the latest version? thank you --Fsc ay 10:52, 22 December 2010 (UTC)

Found: http://svn.wikimedia.org/viewvc/mediawiki/trunk/parsers/wiki2xml/php/

The repository has been moved again, this time here. --Tim Landscheidt 23:07, 26 June 2011 (UTC)