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