use strict; package SuikaWiki::Plugin::Registry; our %Info; $Info{q#WikiPageRename#}->{Name} = q#WikiPageRename#; $Info{q#WikiPageRename#}->{q#Version#} = q#2004.0831.0328#; $Info{q#WikiPageRename#}->{q#InterfaceVersion#} = q#2.9.1#; $Info{q#WikiPageRename#}->{q#mkpluginVersion#} = q#2.1.19#; $Info{q#WikiPageRename#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a#; $Info{q#WikiPageRename#}->{q#Date.RCS#} = q#$Date: 2010/05/16 23:05:49 $#; $Info{q#WikiPageRename#}->{RequiredPlugin} = [q#Error#, q#InterWikiCore#, q#InterWikiText#, q#WikiFormCore#, q#WikiResource#]; $Info{q#WikiPageRename#}->{Description} = [[q#WikiPage renaming#, q#en#, q##]]; $Info{q#WikiPageRename#}->{License} = [[q#%%Perl%%#, q##, q##]]; $Info{q#WikiPageRename#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]]; package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a; #line 1 "(WikiPlugin module source WikiPageRename.wp2, block Plugin/Use)" use Message::Util::Error; #line 1 "(WikiPlugin module WikiPageRename, chunk 1)" push @SuikaWiki::View::Implementation::CommonViewDefs, { condition => {q#mode#, q#pi_wp__rename_#, q#http_method#, [q#POST#]}, object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::pi_wp__rename_1040731032806rcfh#, }; package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::pi_wp__rename_1040731032806rcfh; our @ISA = q#SuikaWiki::View::template#; #line 1 "(WikiPlugin module source WikiPageRename.wp2, block ViewDefinition[Mode='pi_wp__rename_']/Use)" use Message::Util::Error; sub main ($$) { my ($self, $opt, $opt2) = @_; #line 1 "(WikiPlugin module source WikiPageRename.wp2, block ViewDefinition[Mode='pi_wp__rename_']/method[Name='main'])" my $wiki = $self->{view}->{wiki}; $wiki->{var}->{db}->{read_only}->{'content'} = 0; $wiki->{var}->{db}->{read_only}->{'content_prop'} = 0; $wiki->{var}->{db}->{read_only}->{'lastmodified'} = 0; $self->{view}->init_db; my $from_page = $wiki->{var}->{page}; my $to_page = $wiki->name ($wiki->{input}->parameter ('wprn--rename-as') or $from_page); if ($from_page eq $to_page) { $wiki->view_in_mode (mode => '-wprn--same-name'); throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; } my $check = 1; try { for (qw/content content_prop lastmodified/) { $check = 0, last if $wiki->{db}->exist ($_ => $to_page); } } catch SuikaWiki::DB::Util::Error with { my $err = shift; $err->throw if $err->{-type} eq 'ERROR_REPORTED'; $wiki->view_in_mode (mode => '-wdb--fatal-error'); throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; }; unless ($check) { $self->{view}->{wiki}->view_in_mode (mode => '-wprn--new-name-exists'); throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; } try { for (qw/content content_prop lastmodified/) { $wiki->{db}->set ($_ => $to_page => $wiki->{db}->get ($_ => $from_page)); } for (qw/content content_prop lastmodified/) { $wiki->{db}->delete ($_ => $from_page); } } catch SuikaWiki::DB::Util::Error with { my $err = shift; $err->throw if $err->{-type} eq 'ERROR_REPORTED'; $wiki->view_in_mode (mode => '-wdb--fatal-error'); throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; }; $wiki->view_in_mode (mode => '-wprn--renamed');} #line 1 "(WikiPlugin module WikiPageRename, chunk 2)" package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a; $SuikaWiki::Plugin::Rule{view}->{wp_rename_form} = {q#Parameter#, {q#page#, {q#Type#, q#WikiName#, q#Default#, q#(auto)#, q#Description#, [[q#WikiPage name to be renamed from#, q#en#, q##]]}}, q#Description#, [[q#Renaming form#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source WikiPageRename.wp2, block FormattingRule[name()='[q#view#]/wp_rename_form']/Formatting)" $p->{q#page#} = do { my $r = $f->parse_attr ($p=>q#page#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page}); SuikaWiki::Plugin->module_package ('WikiFormCore') ->make_form_in_html ($p->{-parent}, $p->{content}, wiki => $o->{wiki}, o => $o, index => -1, output => { mode => 'pi-wp--rename-', page => $page, });}} #line 1 "(WikiPlugin module WikiPageRename, chunk 3)" ; {my $def = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source WikiPageRename.wp2, block FormattingRule[name()='[q#view#, q#view-resource#]/wp_new_page_name']/Formatting)" $p->{-parent}->append_text (scalar $o->{wiki}->{input}->parameter ('wprn--rename-as'));}} #line 1 "(WikiPlugin module WikiPageRename, chunk 5)" ; $SuikaWiki::Plugin::Rule{view}->{wp_new_page_name} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{wp_new_page_name} = $def; }; push @{$SuikaWiki::View::Implementation::TemplateFragment{q#we__adminedit_body#}}, { Main => q#%section ( title => {%res(name=>{Edit:Rename:Title});}p, heading, content => { %wp-rename-form ( content => { %text ( id => wprn--rename-as, label => {%res(name=>{Edit:Rename:To=});}p, size => 10, default => {%page-name;}p, ); %submit; }p, ); }p, );#, Order => 100, Description => [[q#Renaming WikiName section in adminedit mode#, q#en#, q##]], }; push @SuikaWiki::View::Implementation::CommonViewDefs, { condition => {q#mode#, q#-wprn__new_name_exists#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__new_name_exists1040731032806b0CC#, }; package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__new_name_exists1040731032806b0CC; our @ISA = q#SuikaWiki::View::template#; sub main ($$$) { my ($self, $opt, $opt2) = @_; require SuikaWiki::Output::HTTP; $opt2->{output} = SuikaWiki::Output::HTTP->new (wiki => $self->{view}->{wiki}, view => $self->{view}, viewobj => $self); for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, 'Accept-Language') { $opt2->{output}->add_negotiate_header_field ($_); } $opt2->{template} = q#%template ( name => err--general-error, -web-page-title => {%res (name => {WikiPageRename:DestinationExists:WebPageTitle});}p, -section-title => {%res (name => {WikiPageRename:DestinationExists:Title});}p, -content => {%res (name => {WikiPageRename:DestinationExists:Descriptions});}p, );#; $opt2->{o} = bless { ## SuikaWiki 3 WikiPlugin interface wiki => $self->{view}->{wiki}, plugin => $self->{view}->{wiki}->{plugin}, var => {}, }, 'SuikaWiki::Plugin'; $opt2->{output}->{status_code} = 409; $opt2->{output}->{status_phrase} = q#Destination WikiName Already Used#; $opt2->{output}->{entity}->{media_type} = q#text/html#; $opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; $opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); $opt2->{output}->{entity}->{body_is_octet_stream} = 0; $self->{view}->{wiki}->init_db; $self->main_pre ($opt, $opt2); require Message::Markup::XML::Serialize::HTML; use Message::Util::Error; try { $opt2->{output}->{entity}->{body} = Message::Markup::XML::Serialize::HTML::html_simple (SuikaWiki::Plugin->formatter ('view') ->replace ($opt2->{template}, param => $opt2->{o})); } $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; $opt2->{output}->output (output => 'http-cgi'); $self->main_post ($opt, $opt2); } push @SuikaWiki::View::Implementation::CommonViewDefs, { condition => {q#mode#, q#-wprn__same_name#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__same_name10407310328069drd#, }; package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__same_name10407310328069drd; our @ISA = q#SuikaWiki::View::template#; sub main ($$$) { my ($self, $opt, $opt2) = @_; require SuikaWiki::Output::HTTP; $opt2->{output} = SuikaWiki::Output::HTTP->new (wiki => $self->{view}->{wiki}, view => $self->{view}, viewobj => $self); for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, 'Accept-Language') { $opt2->{output}->add_negotiate_header_field ($_); } $opt2->{template} = q#%template ( name => err--general-error, -web-page-title => {%res (name => {WikiPageRename:SameName:WebPageTitle});}p, -section-title => {%res (name => {WikiPageRename:SameName:Title});}p, -content => {%res (name => {WikiPageRename:SameName:Descriptions});}p, );#; $opt2->{o} = bless { ## SuikaWiki 3 WikiPlugin interface wiki => $self->{view}->{wiki}, plugin => $self->{view}->{wiki}->{plugin}, var => {}, }, 'SuikaWiki::Plugin'; $opt2->{output}->{status_code} = 403; $opt2->{output}->{status_phrase} = q#Same Source and Destination WikiNames#; $opt2->{output}->{entity}->{media_type} = q#text/html#; $opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; $opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); $opt2->{output}->{entity}->{body_is_octet_stream} = 0; $self->{view}->{wiki}->init_db; $self->main_pre ($opt, $opt2); require Message::Markup::XML::Serialize::HTML; use Message::Util::Error; try { $opt2->{output}->{entity}->{body} = Message::Markup::XML::Serialize::HTML::html_simple (SuikaWiki::Plugin->formatter ('view') ->replace ($opt2->{template}, param => $opt2->{o})); } $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; $opt2->{output}->output (output => 'http-cgi'); $self->main_post ($opt, $opt2); } push @SuikaWiki::View::Implementation::CommonViewDefs, { condition => {q#mode#, q#-wprn__renamed#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__renamed1040731032806stTo#, }; package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__renamed1040731032806stTo; our @ISA = q#SuikaWiki::View::template#; sub main ($$$) { my ($self, $opt, $opt2) = @_; require SuikaWiki::Output::HTTP; $opt2->{output} = SuikaWiki::Output::HTTP->new (wiki => $self->{view}->{wiki}, view => $self->{view}, viewobj => $self); for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, 'Accept-Language') { $opt2->{output}->add_negotiate_header_field ($_); } $opt2->{template} = q#%template ( name => err--general-error, -web-page-title => {%res (name => {WikiPageRename:Renamed:WebPageTitle});}p, -section-title => {%res (name => {WikiPageRename:Renamed:Title});}p, -content => {%res (name => {WikiPageRename:Renamed:Descriptions});}p, );#; $opt2->{o} = bless { ## SuikaWiki 3 WikiPlugin interface wiki => $self->{view}->{wiki}, plugin => $self->{view}->{wiki}->{plugin}, var => {}, }, 'SuikaWiki::Plugin'; $opt2->{output}->{status_code} = 201; $opt2->{output}->{status_phrase} = q#WikiPage Renamed#; $opt2->{output}->{entity}->{media_type} = q#text/html#; $opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; $opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); $opt2->{output}->{entity}->{body_is_octet_stream} = 0; $self->{view}->{wiki}->init_db; $self->main_pre ($opt, $opt2); require Message::Markup::XML::Serialize::HTML; use Message::Util::Error; try { $opt2->{output}->{entity}->{body} = Message::Markup::XML::Serialize::HTML::html_simple (SuikaWiki::Plugin->formatter ('view') ->replace ($opt2->{template}, param => $opt2->{o})); } $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; $opt2->{output}->output (output => 'http-cgi'); $self->main_post ($opt, $opt2); } package SuikaWiki::Plugin::Resource; our $BaseResource; $BaseResource->{q#en#}->{q##}->{q#Edit:Rename:Title#} = q#Change WikiName#; $BaseResource->{q#en#}->{q##}->{q#Edit:Rename:To=#} = q#New name#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:DestinationExists:Descriptions#} = q#%paragraph (content => {Specified new WikiName %link-to-wikipage (page => {%wp-new-page-name;}p, label => {%link-to-it (label => {%page-name;}p);}); is already used for another WikiPage.}p);#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:DestinationExists:Title#} = q#Destination WikiName Already Used#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:DestinationExists:WebPageTitle#} = q#409 Destination WikiName Already Used (%page-name; => %wp-new-page-name;)#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:Renamed:Descriptions#} = q#%paragraph (content => {WikiPage %page-name; successfully renamed as new WikiName %link-to-wikipage (page => {%wp-new-page-name;}p, label => {%link-to-it (label => {%page-name;}p);});.}p);#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:Renamed:Title#} = q#WikiPage Renamed#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:Renamed:WebPageTitle#} = q#201 WikiPage Renamed#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:SameName:Descriptions#} = q#%paragraph (content => {Specified new WikiName is exact same as current WikiName.});#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:SameName:Title#} = q#Same Source and Destination WikiNames#; $BaseResource->{q#en#}->{q##}->{q#WikiPageRename:SameName:WebPageTitle#} = q#403 Same Source and Destination WikiNames (%page-name;)#; package SuikaWiki::Plugin::Registry; $Info{q#WikiPageRename#}->{provide} = {q#rule#, {q#view#, [q#wp_rename_form#, q#wp_new_page_name#], q#view_resource#, [q#wp_new_page_name#]}, q#viewfragment#, [{q#Name#, q#we__adminedit_body#}], q#viewdef#, [{q#Description#, [q#Renaming a WikiPage#, q#en#, q##], q#Name#, q#pi_wp__rename_#}, {q#Description#, [q#WikiPage with new WikiName already exists#, q#en#, q##], q#Name#, q#-wprn__new_name_exists#}, {q#Description#, [q#New WikiName is same as current WikiName#, q#en#, q##], q#Name#, q#-wprn__same_name#}, {q#Description#, [q#Successfully renamed#, q#en#, q##], q#Name#, q#-wprn__renamed#}]}; 1;