NAME

CMS::MediaWiki - Perl extension for creating and updating MediaWiki pages

SYNOPSIS

  use CMS::MediaWiki;

  my $mw = CMS::MediaWiki->new(
	# protocol => 'https',  # optional, default is http
	host  => 'localhost',
	path  => 'wiki' ,     #  Can be empty on 3rd-level domain Wikis
	debug => 0            #  0=no debug msgs, 1=some msgs, 2=more msgs
  );

DESCRIPTION

Create or update MediaWiki pages. An update of a MediaWiki page can also be reduced to a specific page section. You may update many pages with the same object handle ($mw in the shown example).

You could change the login name between an update. This might be necessary if you would like to update a public page *and* a protected page by the WikiSysop user in just one cycle.

Login example

  if ($mw->login(user => 'Reto', pass => 'yourpass')) {
	print STDERR "Could not login\n";
	exit;
  }
  else {
	# Logged in, do stuff ...
  }

Another login example

  $rc = $mw->login(
	protocol => 'https',       # optional, default is http
	host     => 'localhost' ,  # optional here, but wins if (re-)set here
	path     => 'wiki',        # optional here, but wins
	user     => 'Reto' ,
	pass     => 'yourpass' ,
  );

Edit a Wiki page or section

  $rc = $mw->editPage(
	title   => 'Online_Directory:Computers:Software:Internet:Authoring' ,

    	section => '' ,	#  2 means edit second section etc.
       	                # '' = no section means edit the full page

       	text    => "== Your Section Title ==\nbar foo\n\n",

	summary => "Your summary." , # optional
  );

Get a Wiki page or a section of a Wiki page

$lines_ref = $mw->getPage(title => 'Perl_driven', section => 1); # omit section to get full page

# Process Wiki lines ...
print sprintf('%08d ', ++$i), " $_\n" foreach @$lines_ref;

In general, $rc returns 0 on success unequal 0 on failure.

Tip

After a successful call of the *editPage* function you had the following information available:

print "Edit time (before) was ", $mw->get('EDIT_TIME_BEFORE'), "\n";
print "Page title was "        , $mw->get('PAGE_TITLE')      , "\n";
print "The Wiki name was "     , $mw->get('WIKI_NAME')       , "\n";

EXPORT

None by default.

SEE ALSO

http://www.infocopter.com/perl/modules/

http://www.infocopter.com/know-how/cms.html

http://www.infocopter.com/know-how/mediawiki-reference/Perl-CMS-MediaWiki.html

AUTHOR

Reto Schaer, <retoh@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2005-2006 by Reto Schaer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

http://www.infocopter.com/perl/licencing.html