# -*- perl -*- =head1 NAME SuikaWiki::Plugin --- SuikaWiki: Plugin manager and the interface to the Wiki database from plugins =cut package SuikaWiki::Plugin; use strict; our $VERSION = do{my @r=(q$Revision: 1.9 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; =head1 PLUGIN INTERFACE =over 4 =item $o->new_index ($index_name) Increments the index number and returns the new index number. =cut {my %Index; sub new_index ($$) { ++$Index{$_[1]} } } ## Obsolete sub magic_and_content ($$) { my ($magic, $page) = ('', $_[1]); $magic = $1 if $page =~ s!^((?:\#\?|/\*|<\?)[^\x02\x0A\x0D]+)[\x02\x0A\x0D]+!!s; ($magic, $page); } {my %Formatter; sub formatter ($$) { my $t = $_[1]; $t =~ tr/-/_/; unless ($Formatter{$t}) { $Formatter{$t} = new SuikaWiki::Plugin::xml_formatter -category_name => $t; } return $Formatter{$t}; }} sub module_package ($$) { my ($self, $module) = @_; my $pack = $SuikaWiki::Plugin::Registry::Info{$module}->{module_name}; if ($pack) { return $pack; } else { ## TODO: throw die "Module $module not loaded"; } } ## Obsolete sub get_data ($$$$;%) { my ($self, $prop, $key, %opt) = @_; ## TODO: common interface to WikiDB ## TODO: error recovering $main::WIKI->{db}->get ($prop => $key); } ## Obsolete sub regist ($@) { } =back =head1 WIKIPLUGIN MANAGER OBJECT This part implements WikiPlugin manager object of SuikaWiki WikiPlugin implementation model, second edition. =over 4 =item $p = SuikaWiki::Plugin->new (wiki => $WIKI) Constructs new instance of WikiPlugin manager =cut sub new ($%) { my $class = shift; my $self = bless {@_}, $class; $self; } sub load_directory ($;@) { shift; for my $dir (@_) { opendir PDIR, $dir; require $dir.'/'.$_ for grep {substr ($_, -3) eq '.pm'} readdir (PDIR); closedir PDIR; } } =item $p->{wiki} Wiki implementation $p is associated with =back =cut package SuikaWiki::Plugin::xml_formatter; require Message::Util::Formatter::Node; our @ISA = 'Message::Util::Formatter::Node'; require Message::Markup::XML::Node; sub rule_def ($) { $SuikaWiki::Plugin::Rule{$_[0]->{-category_name}}; } sub replace_option ($) { return { -class => 'Message::Markup::XML::Node', }; } =head1 SEE ALSO suikawiki.pl, suikawiki-config.ph, =head1 LICENSE Copyright 2002-2003 Wakaba This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # $Date: 2003/12/01 07:43:35 $