| 1 |
use strict; |
| 2 |
package SuikaWiki::Plugin::Registry; |
| 3 |
|
| 4 |
|
| 5 |
our %Info; |
| 6 |
$Info{q#WikiPageRename#}->{Name} = q#WikiPageRename#; |
| 7 |
$Info{q#WikiPageRename#}->{q#Version#} = q#2004.0831.0328#; |
| 8 |
$Info{q#WikiPageRename#}->{q#InterfaceVersion#} = q#2.9.1#; |
| 9 |
$Info{q#WikiPageRename#}->{q#mkpluginVersion#} = q#2.1.19#; |
| 10 |
$Info{q#WikiPageRename#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a#; |
| 11 |
$Info{q#WikiPageRename#}->{q#Date.RCS#} = q#$Date: 2004/04/25 07:06:50 $#; |
| 12 |
$Info{q#WikiPageRename#}->{RequiredPlugin} = [q#Error#, q#InterWikiCore#, q#InterWikiText#, q#WikiFormCore#, q#WikiResource#]; |
| 13 |
$Info{q#WikiPageRename#}->{Description} = [[q#WikiPage renaming#, q#en#, q##]]; |
| 14 |
$Info{q#WikiPageRename#}->{License} = [[q#%%Perl%%#, q##, q##]]; |
| 15 |
$Info{q#WikiPageRename#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]]; |
| 16 |
package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a; |
| 17 |
|
| 18 |
|
| 19 |
#line 1 "(WikiPlugin module source WikiPageRename.wp2, block Plugin/Use)" |
| 20 |
use Message::Util::Error; |
| 21 |
#line 1 "(WikiPlugin module WikiPageRename, chunk 1)" |
| 22 |
|
| 23 |
push @SuikaWiki::View::Implementation::CommonViewDefs, { |
| 24 |
condition => {q#mode#, q#pi_wp__rename_#, q#http_method#, [q#POST#]}, |
| 25 |
object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::pi_wp__rename_1040731032806rcfh#, |
| 26 |
}; |
| 27 |
package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::pi_wp__rename_1040731032806rcfh; |
| 28 |
|
| 29 |
|
| 30 |
our @ISA = q#SuikaWiki::View::template#; |
| 31 |
|
| 32 |
#line 1 "(WikiPlugin module source WikiPageRename.wp2, block ViewDefinition[Mode='pi_wp__rename_']/Use)" |
| 33 |
use Message::Util::Error; |
| 34 |
|
| 35 |
sub main ($$) { |
| 36 |
my ($self, $opt, $opt2) = @_; |
| 37 |
|
| 38 |
#line 1 "(WikiPlugin module source WikiPageRename.wp2, block ViewDefinition[Mode='pi_wp__rename_']/method[Name='main'])" |
| 39 |
my $wiki = $self->{view}->{wiki}; |
| 40 |
$wiki->{var}->{db}->{read_only}->{'content'} = 0; |
| 41 |
$wiki->{var}->{db}->{read_only}->{'content_prop'} = 0; |
| 42 |
$wiki->{var}->{db}->{read_only}->{'lastmodified'} = 0; |
| 43 |
$self->{view}->init_db; |
| 44 |
my $from_page = $wiki->{var}->{page}; |
| 45 |
my $to_page = $wiki->name ($wiki->{input}->parameter ('wprn--rename-as') |
| 46 |
or $from_page); |
| 47 |
if ($from_page eq $to_page) { |
| 48 |
$wiki->view_in_mode (mode => '-wprn--same-name'); |
| 49 |
throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; |
| 50 |
} |
| 51 |
my $check = 1; |
| 52 |
try { |
| 53 |
for (qw/content content_prop lastmodified/) { |
| 54 |
$check = 0, last if $wiki->{db}->exist ($_ => $to_page); |
| 55 |
} |
| 56 |
} catch SuikaWiki::DB::Util::Error with { |
| 57 |
my $err = shift; |
| 58 |
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
| 59 |
$wiki->view_in_mode (mode => '-wdb--fatal-error'); |
| 60 |
throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; |
| 61 |
}; |
| 62 |
unless ($check) { |
| 63 |
$self->{view}->{wiki}->view_in_mode (mode => '-wprn--new-name-exists'); |
| 64 |
throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; |
| 65 |
} |
| 66 |
try { |
| 67 |
for (qw/content content_prop lastmodified/) { |
| 68 |
$wiki->{db}->set ($_ => $to_page |
| 69 |
=> $wiki->{db}->get ($_ => $from_page)); |
| 70 |
} |
| 71 |
for (qw/content content_prop lastmodified/) { |
| 72 |
$wiki->{db}->delete ($_ => $from_page); |
| 73 |
} |
| 74 |
} catch SuikaWiki::DB::Util::Error with { |
| 75 |
my $err = shift; |
| 76 |
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
| 77 |
$wiki->view_in_mode (mode => '-wdb--fatal-error'); |
| 78 |
throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED'; |
| 79 |
}; |
| 80 |
$wiki->view_in_mode (mode => '-wprn--renamed');} |
| 81 |
|
| 82 |
#line 1 "(WikiPlugin module WikiPageRename, chunk 2)" |
| 83 |
|
| 84 |
package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a; |
| 85 |
|
| 86 |
$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) = @_; |
| 87 |
|
| 88 |
#line 1 "(WikiPlugin module source WikiPageRename.wp2, block FormattingRule[name()='[q#view#]/wp_rename_form']/Formatting)" |
| 89 |
$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}; |
| 90 |
my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page}); |
| 91 |
SuikaWiki::Plugin->module_package ('WikiFormCore') |
| 92 |
->make_form_in_html |
| 93 |
($p->{-parent}, $p->{content}, |
| 94 |
wiki => $o->{wiki}, o => $o, |
| 95 |
index => -1, |
| 96 |
output => { |
| 97 |
mode => 'pi-wp--rename-', |
| 98 |
page => $page, |
| 99 |
});}} |
| 100 |
#line 1 "(WikiPlugin module WikiPageRename, chunk 3)" |
| 101 |
; |
| 102 |
|
| 103 |
{my $def = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
| 104 |
|
| 105 |
#line 1 "(WikiPlugin module source WikiPageRename.wp2, block FormattingRule[name()='[q#view#, q#view-resource#]/wp_new_page_name']/Formatting)" |
| 106 |
$p->{-parent}->append_text (scalar $o->{wiki}->{input}->parameter |
| 107 |
('wprn--rename-as'));}} |
| 108 |
#line 1 "(WikiPlugin module WikiPageRename, chunk 5)" |
| 109 |
; |
| 110 |
$SuikaWiki::Plugin::Rule{view}->{wp_new_page_name} = $def; |
| 111 |
$SuikaWiki::Plugin::Rule{view_resource}->{wp_new_page_name} = $def; |
| 112 |
}; |
| 113 |
|
| 114 |
push @{$SuikaWiki::View::Implementation::TemplateFragment{q#we__adminedit_body#}}, { |
| 115 |
Main => q#%section ( |
| 116 |
title => {%res(name=>{Edit:Rename:Title});}p, heading, |
| 117 |
content => { |
| 118 |
%wp-rename-form ( |
| 119 |
content => { |
| 120 |
%text ( |
| 121 |
id => wprn--rename-as, |
| 122 |
label => {%res(name=>{Edit:Rename:To=});}p, |
| 123 |
size => 10, |
| 124 |
default => {%page-name;}p, |
| 125 |
); |
| 126 |
%submit; |
| 127 |
}p, |
| 128 |
); |
| 129 |
}p, |
| 130 |
);#, |
| 131 |
Order => 100, |
| 132 |
Description => [[q#Renaming WikiName section in adminedit mode#, q#en#, q##]], |
| 133 |
}; |
| 134 |
|
| 135 |
push @SuikaWiki::View::Implementation::CommonViewDefs, { |
| 136 |
condition => {q#mode#, q#-wprn__new_name_exists#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, |
| 137 |
object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__new_name_exists1040731032806b0CC#, |
| 138 |
}; |
| 139 |
package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__new_name_exists1040731032806b0CC; |
| 140 |
|
| 141 |
|
| 142 |
our @ISA = q#SuikaWiki::View::template#; |
| 143 |
|
| 144 |
sub main ($$$) { |
| 145 |
my ($self, $opt, $opt2) = @_; |
| 146 |
require SuikaWiki::Output::HTTP; |
| 147 |
$opt2->{output} = SuikaWiki::Output::HTTP->new |
| 148 |
(wiki => $self->{view}->{wiki}, |
| 149 |
view => $self->{view}, viewobj => $self); |
| 150 |
for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, |
| 151 |
'Accept-Language') { |
| 152 |
$opt2->{output}->add_negotiate_header_field ($_); |
| 153 |
} |
| 154 |
|
| 155 |
$opt2->{template} = q#%template ( |
| 156 |
name => err--general-error, |
| 157 |
-web-page-title => {%res (name => {WikiPageRename:DestinationExists:WebPageTitle});}p, |
| 158 |
-section-title => {%res (name => {WikiPageRename:DestinationExists:Title});}p, |
| 159 |
-content => {%res (name => {WikiPageRename:DestinationExists:Descriptions});}p, |
| 160 |
);#; |
| 161 |
$opt2->{o} = bless { |
| 162 |
## SuikaWiki 3 WikiPlugin interface |
| 163 |
wiki => $self->{view}->{wiki}, |
| 164 |
plugin => $self->{view}->{wiki}->{plugin}, |
| 165 |
var => {}, |
| 166 |
}, 'SuikaWiki::Plugin'; |
| 167 |
$opt2->{output}->{status_code} = 409; |
| 168 |
$opt2->{output}->{status_phrase} = q#Destination WikiName Already Used#; |
| 169 |
$opt2->{output}->{entity}->{media_type} = q#text/html#; |
| 170 |
|
| 171 |
$opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; |
| 172 |
$opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); |
| 173 |
$opt2->{output}->{entity}->{body_is_octet_stream} = 0; |
| 174 |
|
| 175 |
$self->{view}->{wiki}->init_db; |
| 176 |
$self->main_pre ($opt, $opt2); |
| 177 |
|
| 178 |
require Message::Markup::XML::Serialize::HTML; |
| 179 |
use Message::Util::Error; |
| 180 |
try { |
| 181 |
$opt2->{output}->{entity}->{body} |
| 182 |
= Message::Markup::XML::Serialize::HTML::html_simple |
| 183 |
(SuikaWiki::Plugin->formatter ('view') |
| 184 |
->replace ($opt2->{template}, param => $opt2->{o})); |
| 185 |
} $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; |
| 186 |
$opt2->{output}->output (output => 'http-cgi'); |
| 187 |
|
| 188 |
$self->main_post ($opt, $opt2); |
| 189 |
} |
| 190 |
|
| 191 |
push @SuikaWiki::View::Implementation::CommonViewDefs, { |
| 192 |
condition => {q#mode#, q#-wprn__same_name#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, |
| 193 |
object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__same_name10407310328069drd#, |
| 194 |
}; |
| 195 |
package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__same_name10407310328069drd; |
| 196 |
|
| 197 |
|
| 198 |
our @ISA = q#SuikaWiki::View::template#; |
| 199 |
|
| 200 |
sub main ($$$) { |
| 201 |
my ($self, $opt, $opt2) = @_; |
| 202 |
require SuikaWiki::Output::HTTP; |
| 203 |
$opt2->{output} = SuikaWiki::Output::HTTP->new |
| 204 |
(wiki => $self->{view}->{wiki}, |
| 205 |
view => $self->{view}, viewobj => $self); |
| 206 |
for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, |
| 207 |
'Accept-Language') { |
| 208 |
$opt2->{output}->add_negotiate_header_field ($_); |
| 209 |
} |
| 210 |
|
| 211 |
$opt2->{template} = q#%template ( |
| 212 |
name => err--general-error, |
| 213 |
-web-page-title => {%res (name => {WikiPageRename:SameName:WebPageTitle});}p, |
| 214 |
-section-title => {%res (name => {WikiPageRename:SameName:Title});}p, |
| 215 |
-content => {%res (name => {WikiPageRename:SameName:Descriptions});}p, |
| 216 |
);#; |
| 217 |
$opt2->{o} = bless { |
| 218 |
## SuikaWiki 3 WikiPlugin interface |
| 219 |
wiki => $self->{view}->{wiki}, |
| 220 |
plugin => $self->{view}->{wiki}->{plugin}, |
| 221 |
var => {}, |
| 222 |
}, 'SuikaWiki::Plugin'; |
| 223 |
$opt2->{output}->{status_code} = 403; |
| 224 |
$opt2->{output}->{status_phrase} = q#Same Source and Destination WikiNames#; |
| 225 |
$opt2->{output}->{entity}->{media_type} = q#text/html#; |
| 226 |
|
| 227 |
$opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; |
| 228 |
$opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); |
| 229 |
$opt2->{output}->{entity}->{body_is_octet_stream} = 0; |
| 230 |
|
| 231 |
$self->{view}->{wiki}->init_db; |
| 232 |
$self->main_pre ($opt, $opt2); |
| 233 |
|
| 234 |
require Message::Markup::XML::Serialize::HTML; |
| 235 |
use Message::Util::Error; |
| 236 |
try { |
| 237 |
$opt2->{output}->{entity}->{body} |
| 238 |
= Message::Markup::XML::Serialize::HTML::html_simple |
| 239 |
(SuikaWiki::Plugin->formatter ('view') |
| 240 |
->replace ($opt2->{template}, param => $opt2->{o})); |
| 241 |
} $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; |
| 242 |
$opt2->{output}->output (output => 'http-cgi'); |
| 243 |
|
| 244 |
$self->main_post ($opt, $opt2); |
| 245 |
} |
| 246 |
|
| 247 |
push @SuikaWiki::View::Implementation::CommonViewDefs, { |
| 248 |
condition => {q#mode#, q#-wprn__renamed#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, |
| 249 |
object_class => q#SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__renamed1040731032806stTo#, |
| 250 |
}; |
| 251 |
package SuikaWiki::Plugin::plugin::WikiPageRename1040731032806qG6a::wprn__renamed1040731032806stTo; |
| 252 |
|
| 253 |
|
| 254 |
our @ISA = q#SuikaWiki::View::template#; |
| 255 |
|
| 256 |
sub main ($$$) { |
| 257 |
my ($self, $opt, $opt2) = @_; |
| 258 |
require SuikaWiki::Output::HTTP; |
| 259 |
$opt2->{output} = SuikaWiki::Output::HTTP->new |
| 260 |
(wiki => $self->{view}->{wiki}, |
| 261 |
view => $self->{view}, viewobj => $self); |
| 262 |
for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, |
| 263 |
'Accept-Language') { |
| 264 |
$opt2->{output}->add_negotiate_header_field ($_); |
| 265 |
} |
| 266 |
|
| 267 |
$opt2->{template} = q#%template ( |
| 268 |
name => err--general-error, |
| 269 |
-web-page-title => {%res (name => {WikiPageRename:Renamed:WebPageTitle});}p, |
| 270 |
-section-title => {%res (name => {WikiPageRename:Renamed:Title});}p, |
| 271 |
-content => {%res (name => {WikiPageRename:Renamed:Descriptions});}p, |
| 272 |
);#; |
| 273 |
$opt2->{o} = bless { |
| 274 |
## SuikaWiki 3 WikiPlugin interface |
| 275 |
wiki => $self->{view}->{wiki}, |
| 276 |
plugin => $self->{view}->{wiki}->{plugin}, |
| 277 |
var => {}, |
| 278 |
}, 'SuikaWiki::Plugin'; |
| 279 |
$opt2->{output}->{status_code} = 201; |
| 280 |
$opt2->{output}->{status_phrase} = q#WikiPage Renamed#; |
| 281 |
$opt2->{output}->{entity}->{media_type} = q#text/html#; |
| 282 |
|
| 283 |
$opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; |
| 284 |
$opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); |
| 285 |
$opt2->{output}->{entity}->{body_is_octet_stream} = 0; |
| 286 |
|
| 287 |
$self->{view}->{wiki}->init_db; |
| 288 |
$self->main_pre ($opt, $opt2); |
| 289 |
|
| 290 |
require Message::Markup::XML::Serialize::HTML; |
| 291 |
use Message::Util::Error; |
| 292 |
try { |
| 293 |
$opt2->{output}->{entity}->{body} |
| 294 |
= Message::Markup::XML::Serialize::HTML::html_simple |
| 295 |
(SuikaWiki::Plugin->formatter ('view') |
| 296 |
->replace ($opt2->{template}, param => $opt2->{o})); |
| 297 |
} $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; |
| 298 |
$opt2->{output}->output (output => 'http-cgi'); |
| 299 |
|
| 300 |
$self->main_post ($opt, $opt2); |
| 301 |
} |
| 302 |
|
| 303 |
package SuikaWiki::Plugin::Resource; |
| 304 |
|
| 305 |
our $BaseResource; |
| 306 |
$BaseResource->{q#en#}->{q##}->{q#Edit:Rename:Title#} = q#Change WikiName#; |
| 307 |
$BaseResource->{q#en#}->{q##}->{q#Edit:Rename:To=#} = q#New name#; |
| 308 |
$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);#; |
| 309 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:DestinationExists:Title#} = q#Destination WikiName Already Used#; |
| 310 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:DestinationExists:WebPageTitle#} = q#409 Destination WikiName Already Used (%page-name; => %wp-new-page-name;)#; |
| 311 |
$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);#; |
| 312 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:Renamed:Title#} = q#WikiPage Renamed#; |
| 313 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:Renamed:WebPageTitle#} = q#201 WikiPage Renamed#; |
| 314 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:SameName:Descriptions#} = q#%paragraph (content => {Specified new WikiName is exact same as current WikiName.});#; |
| 315 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:SameName:Title#} = q#Same Source and Destination WikiNames#; |
| 316 |
$BaseResource->{q#en#}->{q##}->{q#WikiPageRename:SameName:WebPageTitle#} = q#403 Same Source and Destination WikiNames (%page-name;)#; |
| 317 |
package SuikaWiki::Plugin::Registry; |
| 318 |
|
| 319 |
$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#}]}; |
| 320 |
|
| 321 |
1; |