/[pub]/suikawiki/script/misc/plugins/WikiPageRename.wp2
Suika

Contents of /suikawiki/script/misc/plugins/WikiPageRename.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Apr 25 07:06:50 2004 UTC (20 years, 6 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
Changes since 1.1: +5 -4 lines
LeafProp database module added; content_prop implemented; Media type property implemented

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiPageRename
5     @Description:
6     @@@: WikiPage renaming
7     @@lang:en
8     @License: %%Perl%%
9     @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: w@suika.fam.cx
15     @Date.RCS:
16 wakaba 1.2 $Date: 2004/03/10 07:00:32 $
17 wakaba 1.1 @RequiredPlugin[list]:
18     Error
19     InterWikiCore
20     InterWikiText
21     WikiFormCore
22     WikiResource
23     @Use:
24     use Message::Util::Error;
25    
26     PluginConst:
27     @NS_XHTML1:
28     http://www.w3.org/1999/xhtml
29    
30     ViewDefinition:
31     @Mode: pi-wp--rename-
32     @Condition:
33     @@http-method[list]:
34     POST
35     @Description:
36     @@@: Renaming a WikiPage
37     @@lang: en
38     @Use:
39     use Message::Util::Error;
40     @method:
41     @@Name: main
42     @@@:
43     my $wiki = $self->{view}->{wiki};
44     $wiki->{var}->{db}->{read_only}->{'content'} = 0;
45 wakaba 1.2 $wiki->{var}->{db}->{read_only}->{'content_prop'} = 0;
46 wakaba 1.1 $wiki->{var}->{db}->{read_only}->{'lastmodified'} = 0;
47     $self->{view}->init_db;
48     my $from_page = $wiki->{var}->{page};
49     my $to_page = $wiki->name ($wiki->{input}->parameter ('wprn--rename-as')
50     or $from_page);
51    
52     ## Check confliction
53     if ($from_page eq $to_page) {
54     $wiki->view_in_mode (mode => '-wprn--same-name');
55     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
56     }
57     my $check = 1;
58     try {
59 wakaba 1.2 for (qw/content content_prop lastmodified/) {
60 wakaba 1.1 $check = 0, last if $wiki->{db}->exist ($_ => $to_page);
61     }
62     } catch SuikaWiki::DB::Util::Error with {
63     my $err = shift;
64     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
65     $wiki->view_in_mode (mode => '-wdb--fatal-error');
66     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
67     };
68     unless ($check) {
69     $self->{view}->{wiki}->view_in_mode (mode => '-wprn--new-name-exists');
70     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
71     }
72    
73     try {
74 wakaba 1.2 for (qw/content content_prop lastmodified/) {
75 wakaba 1.1 $wiki->{db}->set ($_ => $to_page
76     => $wiki->{db}->get ($_ => $from_page));
77     }
78 wakaba 1.2 for (qw/content content_prop lastmodified/) {
79 wakaba 1.1 $wiki->{db}->delete ($_ => $from_page);
80     }
81     } catch SuikaWiki::DB::Util::Error with {
82     my $err = shift;
83     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
84     $wiki->view_in_mode (mode => '-wdb--fatal-error');
85     throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
86     };
87     $wiki->view_in_mode (mode => '-wprn--renamed');
88    
89     FormattingRule:
90     @Category[list]: view
91     @Name: wp-rename-form
92     @Description:
93     @@@: Renaming form
94     @@lang: en
95     @Parameter:
96     @@Name: page
97     @@Type: WikiName
98     @@Default: (auto)
99     @@Description:
100     @@@@: WikiPage name to be renamed from
101     @@@lang:en
102     @Formatting:
103     __ATTRTEXT:%page__;
104    
105     my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
106     SuikaWiki::Plugin->module_package ('WikiFormCore')
107     ->make_form_in_html
108     ($p->{-parent}, $p->{content},
109     wiki => $o->{wiki}, o => $o,
110     index => -1,
111     output => {
112     mode => 'pi-wp--rename-',
113     page => $page,
114     });
115    
116     FormattingRule:
117     @Category[list]:
118     view
119     view-resource
120     @Name: wp-new-page-name
121     @Formatting:
122     $p->{-parent}->append_text (scalar $o->{wiki}->{input}->parameter
123     ('wprn--rename-as'));
124    
125     ViewFragment:
126     @Template[list]: we--adminedit-body
127     @Order:100
128     @Description:
129     @@@: Renaming WikiName section in adminedit mode
130     @@lang:en
131     @Formatting:
132     %section (
133     title => {%res(name=>{Edit:Rename:Title});}p, heading,
134     content => {
135     %wp-rename-form (
136     content => {
137     %text (
138     id => wprn--rename-as,
139     label => {%res(name=>{Edit:Rename:To=});}p,
140     size => 10,
141     default => {%page-name;}p,
142     );
143     %submit;
144     }p,
145     );
146     }p,
147     );
148    
149     ## See RFC 2518 8.9.4 for HTTP status code use.
150     ##
151     ## 201 Created - Success
152     ## 204 No Content - Success
153     ## 403 Forbidden - Source and destination are same
154     ## 409 Conflict - Can't create destination
155     ## 412 Precondition Failed
156     ## 423 Locked - Source or destination was locked
157     ## 502 Bad Gateway - Destination server refused
158    
159     ViewDefinition:
160     @Mode: -wprn--new-name-exists
161     @Condition:
162     @@http-method[list]:
163     GET
164     HEAD
165     POST
166     @Description:
167     @@@: WikiPage with new WikiName already exists
168     @@lang: en
169     @template:
170     @@http-status-code: 409
171     @@http-status-phrase: Destination WikiName Already Used
172     @@media-type: text/html
173     @@use-media-type-charset: 1
174     @@expires: %%error%%
175     @@body:
176     %template (
177     name => err--general-error,
178     -web-page-title => {%res (name => {WikiPageRename:DestinationExists:WebPageTitle});}p,
179     -section-title => {%res (name => {WikiPageRename:DestinationExists:Title});}p,
180     -content => {%res (name => {WikiPageRename:DestinationExists:Descriptions});}p,
181     );
182    
183     ViewDefinition:
184     @Mode: -wprn--same-name
185     @Condition:
186     @@http-method[list]:
187     GET
188     HEAD
189     POST
190     @Description:
191     @@@: New WikiName is same as current WikiName
192     @@lang: en
193     @template:
194     @@http-status-code: 403
195     @@http-status-phrase: Same Source and Destination WikiNames
196     @@media-type: text/html
197     @@use-media-type-charset: 1
198     @@expires: %%error%%
199     @@body:
200     %template (
201     name => err--general-error,
202     -web-page-title => {%res (name => {WikiPageRename:SameName:WebPageTitle});}p,
203     -section-title => {%res (name => {WikiPageRename:SameName:Title});}p,
204     -content => {%res (name => {WikiPageRename:SameName:Descriptions});}p,
205     );
206    
207     ViewDefinition:
208     @Mode: -wprn--renamed
209     @Condition:
210     @@http-method[list]:
211     GET
212     HEAD
213     POST
214     @Description:
215     @@@: Successfully renamed
216     @@lang: en
217     @template:
218     @@http-status-code: 201
219     @@http-status-phrase: WikiPage Renamed
220     @@media-type: text/html
221     @@use-media-type-charset: 1
222     @@expires: %%error%%
223     @@body:
224     %template (
225     name => err--general-error,
226     -web-page-title => {%res (name => {WikiPageRename:Renamed:WebPageTitle});}p,
227     -section-title => {%res (name => {WikiPageRename:Renamed:Title});}p,
228     -content => {%res (name => {WikiPageRename:Renamed:Descriptions});}p,
229     );
230    
231     Resource:
232     @Edit:Rename:Title:
233     @@@: Change WikiName
234     @@lang: en
235     @Edit:Rename:To=:
236     @@@: New name
237     @@lang: en
238     @WikiPageRename:DestinationExists:Descriptions:
239     @@@:
240     %paragraph (content => {Specified new WikiName
241     %link-to-wikipage (page => {%wp-new-page-name;}p,
242     label => {%link-to-it (label => {%page-name;}p);});
243     is already used for another WikiPage.}p);
244     @@lang: en
245     @WikiPageRename:DestinationExists:Title:
246     @@@: Destination WikiName Already Used
247     @@lang: en
248     @WikiPageRename:DestinationExists:WebPageTitle:
249     @@@: 409 Destination WikiName Already Used (%page-name; => %wp-new-page-name;)
250     @@lang: en
251     @WikiPageRename:Renamed:Descriptions:
252     @@@:
253     %paragraph (content => {WikiPage %page-name; successfully renamed
254     as new WikiName
255     %link-to-wikipage (page => {%wp-new-page-name;}p,
256     label => {%link-to-it (label => {%page-name;}p);});.}p);
257     @@lang: en
258     @WikiPageRename:Renamed:Title:
259     @@@: WikiPage Renamed
260     @@lang: en
261     @WikiPageRename:Renamed:WebPageTitle:
262     @@@: 201 WikiPage Renamed
263     @@lang: en
264     @WikiPageRename:SameName:Descriptions:
265     @@@:
266     %paragraph (content => {Specified new WikiName is exact same as
267     current WikiName.});
268     @@lang: en
269     @WikiPageRename:SameName:Title:
270     @@@: Same Source and Destination WikiNames
271     @@lang: en
272     @WikiPageRename:SameName:WebPageTitle:
273     @@@: 403 Same Source and Destination WikiNames (%page-name;)
274     @@lang: en
275    
276    
277    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24