#?SuikaWikiConfig/2.0 Plugin: @Name: WikiPageRename @Description: @@@: WikiPage renaming @@lang:en @License: %%Perl%% @Author: @@Name: @@@@: Wakaba @@@lang:ja @@@script:Latn @@Mail[list]: w@suika.fam.cx @Date.RCS: $Date: 2004/04/25 07:06:50 $ @RequiredPlugin[list]: Error InterWikiCore InterWikiText WikiFormCore WikiResource @Use: use Message::Util::Error; PluginConst: @NS_XHTML1: http://www.w3.org/1999/xhtml ViewDefinition: @Mode: pi-wp--rename- @Condition: @@http-method[list]: POST @Description: @@@: Renaming a WikiPage @@lang: en @Use: use Message::Util::Error; @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); ## Check confliction 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'); FormattingRule: @Category[list]: view @Name: wp-rename-form @Description: @@@: Renaming form @@lang: en @Parameter: @@Name: page @@Type: WikiName @@Default: (auto) @@Description: @@@@: WikiPage name to be renamed from @@@lang:en @Formatting: __ATTRTEXT:%page__; 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, }); FormattingRule: @Category[list]: view view-resource @Name: wp-new-page-name @Formatting: $p->{-parent}->append_text (scalar $o->{wiki}->{input}->parameter ('wprn--rename-as')); ViewFragment: @Template[list]: we--adminedit-body @Order:100 @Description: @@@: Renaming WikiName section in adminedit mode @@lang:en @Formatting: %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, ); ## See RFC 2518 8.9.4 for HTTP status code use. ## ## 201 Created - Success ## 204 No Content - Success ## 403 Forbidden - Source and destination are same ## 409 Conflict - Can't create destination ## 412 Precondition Failed ## 423 Locked - Source or destination was locked ## 502 Bad Gateway - Destination server refused ViewDefinition: @Mode: -wprn--new-name-exists @Condition: @@http-method[list]: GET HEAD POST @Description: @@@: WikiPage with new WikiName already exists @@lang: en @template: @@http-status-code: 409 @@http-status-phrase: Destination WikiName Already Used @@media-type: text/html @@use-media-type-charset: 1 @@expires: %%error%% @@body: %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, ); ViewDefinition: @Mode: -wprn--same-name @Condition: @@http-method[list]: GET HEAD POST @Description: @@@: New WikiName is same as current WikiName @@lang: en @template: @@http-status-code: 403 @@http-status-phrase: Same Source and Destination WikiNames @@media-type: text/html @@use-media-type-charset: 1 @@expires: %%error%% @@body: %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, ); ViewDefinition: @Mode: -wprn--renamed @Condition: @@http-method[list]: GET HEAD POST @Description: @@@: Successfully renamed @@lang: en @template: @@http-status-code: 201 @@http-status-phrase: WikiPage Renamed @@media-type: text/html @@use-media-type-charset: 1 @@expires: %%error%% @@body: %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, ); Resource: @Edit:Rename:Title: @@@: Change WikiName @@lang: en @Edit:Rename:To=: @@@: New name @@lang: en @WikiPageRename:DestinationExists:Descriptions: @@@: %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); @@lang: en @WikiPageRename:DestinationExists:Title: @@@: Destination WikiName Already Used @@lang: en @WikiPageRename:DestinationExists:WebPageTitle: @@@: 409 Destination WikiName Already Used (%page-name; => %wp-new-page-name;) @@lang: en @WikiPageRename:Renamed:Descriptions: @@@: %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); @@lang: en @WikiPageRename:Renamed:Title: @@@: WikiPage Renamed @@lang: en @WikiPageRename:Renamed:WebPageTitle: @@@: 201 WikiPage Renamed @@lang: en @WikiPageRename:SameName:Descriptions: @@@: %paragraph (content => {Specified new WikiName is exact same as current WikiName.}); @@lang: en @WikiPageRename:SameName:Title: @@@: Same Source and Destination WikiNames @@lang: en @WikiPageRename:SameName:WebPageTitle: @@@: 403 Same Source and Destination WikiNames (%page-name;) @@lang: en