1 |
wakaba |
1.1 |
#?SuikaWikiConfig/2.0 |
2 |
|
|
|
3 |
|
|
Plugin: |
4 |
|
|
@Name: WikiEdit |
5 |
|
|
@Description: |
6 |
|
|
@@@: WikiPage editing components |
7 |
|
|
@@lang:en |
8 |
|
|
@License: %%GPL%% |
9 |
|
|
@Author: |
10 |
|
|
@@Name: |
11 |
|
|
@@@@: Wakaba |
12 |
|
|
@@@lang:ja |
13 |
|
|
@@@script:Latn |
14 |
|
|
@@Mail[list]: w@suika.fam.cx |
15 |
|
|
@Date.RCS: $Date:$ |
16 |
|
|
@RequiredModule[list]: |
17 |
|
|
main |
18 |
|
|
Digest::SHA1 |
19 |
|
|
|
20 |
|
|
PluginConst: |
21 |
|
|
@NS_XHTML1: |
22 |
|
|
http://www.w3.org/1999/xhtml |
23 |
|
|
|
24 |
|
|
ViewDefinition: |
25 |
|
|
@Mode: edit |
26 |
|
|
@Condition: |
27 |
|
|
@@http-method[list]: |
28 |
|
|
GET |
29 |
|
|
HEAD |
30 |
|
|
@Description: |
31 |
|
|
@@@: Edit WikiPage content as whole, as a plaintext |
32 |
|
|
@@lang: en |
33 |
|
|
@template: |
34 |
|
|
@@http-status-code: 200 |
35 |
|
|
@@media-type: text/html |
36 |
|
|
@@use-media-type-charset: 1 |
37 |
|
|
@@expires: %%edit%% |
38 |
|
|
@@body: |
39 |
|
|
%html-document ( |
40 |
|
|
title => {%res(name=>{Edit:WebPageTitle});}p, |
41 |
|
|
link-meta => {%predefined-template(name=>links); |
42 |
|
|
%html-meta(name=>ROBOTS,content=>NOINDEX);}p, |
43 |
|
|
content => { |
44 |
|
|
%template ( |
45 |
|
|
name => ws--page, |
46 |
|
|
-content => { |
47 |
|
|
%section (level=>2, |
48 |
|
|
id => edit, |
49 |
|
|
title => {%res (name => {Edit:Title});}p, heading, |
50 |
|
|
content => { |
51 |
|
|
%edit-form; |
52 |
|
|
%section ( |
53 |
|
|
id => edit-help, |
54 |
|
|
add-to-toc => 0, |
55 |
|
|
content => {%read(page=>{Wiki//Edit//Help});}p, |
56 |
|
|
## TODO: customizable |
57 |
|
|
); |
58 |
|
|
}p, |
59 |
|
|
); |
60 |
|
|
}, |
61 |
|
|
); |
62 |
|
|
}p, |
63 |
|
|
); |
64 |
|
|
|
65 |
|
|
ViewDefinition: |
66 |
|
|
@Mode: write |
67 |
|
|
@Condition: |
68 |
|
|
@@http-method[list]: |
69 |
|
|
POST |
70 |
|
|
@Description: |
71 |
|
|
@@@: Saving modified (new) WikiPage content |
72 |
|
|
@@lang: en |
73 |
|
|
@method: |
74 |
|
|
@@@: |
75 |
|
|
my $touch = $self->{view}->{wiki}->{input}->parameter ('we--touch'); |
76 |
|
|
|
77 |
|
|
$self->{view}->{wiki}->{var}->{db}->{read_only}->{'content'} = 0; |
78 |
|
|
$self->{view}->{wiki}->{var}->{db}->{read_only}->{'lastmodified'} = 0 |
79 |
|
|
if $touch; |
80 |
|
|
$self->{view}->init_db; |
81 |
|
|
|
82 |
|
|
my $page = $self->{view}->{wiki}->{var}->{page}; |
83 |
|
|
|
84 |
|
|
## TODO: Implements access control |
85 |
|
|
#if (&frozen_reject()) { |
86 |
|
|
#} |
87 |
|
|
|
88 |
|
|
if (!__FUNCPACK__::page_is_editable ($page)) { |
89 |
|
|
## TODO: Implements this |
90 |
|
|
# &_do_view_msg (-view => '-error', -page => $main::form{mypage}, |
91 |
|
|
# error_message => &Resource ('Error:ThisPageIsUneditable')); |
92 |
|
|
# return; |
93 |
|
|
die "Uneditable!"; |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
## Check confliction |
97 |
|
|
my $current_content = $self->{view}->{wiki}->{db}->get (content => $page); |
98 |
|
|
if (length $current_content) { |
99 |
|
|
require Digest::SHA1; |
100 |
|
|
my $current_digest = Digest::SHA1::sha1_base64 ($current_content); |
101 |
|
|
my $prev_digest |
102 |
|
|
= $self->{view}->{wiki}->{input}->parameter ('we--digest'); |
103 |
|
|
if ($current_digest ne $prev_digest) { |
104 |
|
|
## TODO: Implements this |
105 |
|
|
# _do_view_msg (-view => '-conflict', -page => $page_name); |
106 |
|
|
die "@{[join '//', @$page]}: Conflict : (current) $current_digest [$current_content] vs (prev) $prev_digest"; |
107 |
|
|
} |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
my $new_content |
111 |
|
|
= $self->{view}->{wiki}->{input}->parameter ('we--content'); |
112 |
|
|
if (length $new_content) { |
113 |
|
|
$self->{view}->{wiki}->{db}->set (content => $page => $new_content); |
114 |
|
|
if ($touch) { |
115 |
|
|
$self->{view}->{wiki}->{db}->set (lastmodified => $page => time); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
## TODO: Use SuikaWiki 3 interface |
119 |
|
|
my $new_mode = $self->{view}->{wiki}->{input}->parameter |
120 |
|
|
('we--mode-modified'); |
121 |
|
|
$new_mode =~ s/[^0-9A-Za-z._-]+//g; |
122 |
|
|
my $uri = SuikaWiki::Plugin->_uri_wiki_page (join ('//', @$page), |
123 |
|
|
mode => $new_mode, |
124 |
|
|
with_lm => 1, |
125 |
|
|
absolute => 1); |
126 |
|
|
$uri .= qq<;we--mode-modified=$new_mode>; |
127 |
|
|
|
128 |
|
|
require SuikaWiki::Output::HTTP; |
129 |
|
|
my $output = SuikaWiki::Output::HTTP->new |
130 |
|
|
(wiki => $self->{view}->{wiki}); |
131 |
|
|
$output->set_redirect (uri => $uri, status_code => 303); |
132 |
|
|
$output->output (output => 'http-cgi'); |
133 |
|
|
} else { |
134 |
|
|
die "Delete mode not implemented"; |
135 |
|
|
#delete $main::database{$main::form{mypage}}; |
136 |
|
|
#&_do_view_msg (-view => '-deleted', -page => $main::form{mypage}); |
137 |
|
|
} |
138 |
|
|
@@Name: main |
139 |
|
|
|
140 |
|
|
ViewDefinition: |
141 |
|
|
@Mode: adminedit |
142 |
|
|
@Condition: |
143 |
|
|
@@http-method[list]: |
144 |
|
|
GET |
145 |
|
|
HEAD |
146 |
|
|
@Description: |
147 |
|
|
@@@: Edit WikiPage content as whole, as a plaintext (administrator mode) |
148 |
|
|
@@lang: en |
149 |
|
|
@template: |
150 |
|
|
@@http-status-code: 200 |
151 |
|
|
@@media-type: application/xhtml+xml |
152 |
|
|
@@use-media-type-charset: 1 |
153 |
|
|
@@expires: %%edit%% |
154 |
|
|
@@body: |
155 |
|
|
%html-document(title=>{%res(name=>{Edit:Admin:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);%html-meta(name=>ROBOTS,content=>NOINDEX);}p,content=>{ |
156 |
|
|
%section(level=>1,add-to-toc=>0,type=>body,title=>{%page-name;}p,heading,content=>{ |
157 |
|
|
%section(id=>tools1,class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p); |
158 |
|
|
%section(level=>2,id=>edit,title=>{%res(name=>{Edit:Title});}p,heading,content=>{%edit-form(admin);}p); |
159 |
|
|
%section(level=>2,title=>{%res(name=>{Edit:Rename:Title});}p,heading,content=>{ |
160 |
|
|
%wp-rename-form(content=>{ |
161 |
|
|
%format(context=>form_input,template=>{ |
162 |
|
|
%text(id=>to,label=>{%res(name=>{Edit:Rename:To=});}p,size=>10,default=>{%page-name;}p); |
163 |
|
|
%submit; |
164 |
|
|
}); |
165 |
|
|
}p); |
166 |
|
|
}p); |
167 |
|
|
%section(id=>last-modified,add_to_toc=>0,content=>{%res(name=>{LastModified=});%last-modified;}p); |
168 |
|
|
%section(level=>2,id=>toc,title=>{%res(name=>{TOC:Title});}p,heading,add_to_toc=>0,content=>{%toc(drag);}p); |
169 |
|
|
%section(class=>tools,add_to_toc=>0,content=>{%predefined-template(name=>navbar);}p); |
170 |
|
|
%section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p); |
171 |
|
|
}p); |
172 |
|
|
}p); |
173 |
|
|
|
174 |
|
|
ViewDefinition -- not well-defined yet --: |
175 |
|
|
@Mode: -conflict |
176 |
|
|
@Condition: |
177 |
|
|
@@http-method[list]: |
178 |
|
|
GET |
179 |
|
|
HEAD |
180 |
|
|
@Description: |
181 |
|
|
@@@: Confliction message |
182 |
|
|
@@lang: en |
183 |
|
|
@template: |
184 |
|
|
@@http-status-code: 409 |
185 |
|
|
@@media-type: text/html |
186 |
|
|
@@use-media-type-charset: 1 |
187 |
|
|
@@expires: %%edit%% |
188 |
|
|
@@body: |
189 |
|
|
%html-document(title=>{%res(name=>{Edit:Conflict:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);%html-meta(name=>ROBOTS,content=>NOINDEX);}p,content=>{ |
190 |
|
|
%section(level=>1,add-to-toc=>0,type=>body,title=>{%page-name;}p,heading,content=>{ |
191 |
|
|
%section(id=>tools1,class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p); |
192 |
|
|
%section(level=>2,title=>{%res(name=>{Edit:Conflict:Title});}p,heading,content=>{ |
193 |
|
|
%paragraph(content=>{%res(name=>{Edit:Conflict:Description});}p); |
194 |
|
|
%conflict-form; |
195 |
|
|
%section(level=>3,id=>edit-conflict-diff,title=>{%res(name=>{Edit:Conflict:Diff:Title});}p,heading,content=>{ |
196 |
|
|
%paragraph(content=>{%res(name=>{Edit:Conflict:Diff:Description});}p); |
197 |
|
|
%conflict-diff; |
198 |
|
|
}p); |
199 |
|
|
}p); |
200 |
|
|
%section(level=>2,id=>edit,title=>{%res(name=>{Edit:Title});}p,heading,content=>{ |
201 |
|
|
%paragraph(name=>{%res(name=>{Edit:Conflict:Edit:Description});}p); |
202 |
|
|
%edit-form; |
203 |
|
|
%section(level=>3,id=>edit-help,add-to-toc=>0,content=>{%read(page=>{Wiki//Help//Edit});}p); |
204 |
|
|
}p); |
205 |
|
|
%section(level=>2,id=>toc,title=>{%res(name=>{TOC:Title});}p,heading,add_to_toc=>0,content=>{%toc(drag);}p); |
206 |
|
|
%section(class=>tools,add_to_toc=>0,content=>{%predefined-template(name=>navbar);}p); |
207 |
|
|
%section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p); |
208 |
|
|
}p); |
209 |
|
|
}p); |
210 |
|
|
|
211 |
|
|
Temp: |
212 |
|
|
SuikaWiki::View->definition (-wrote => { |
213 |
|
|
media => {type => 'text/html', charset => 1, expires => 60}, |
214 |
|
|
xmedia => {type => 'application/xhtml+xml', charset => 1, expires => 60}, |
215 |
|
|
template => <<'EOH'}); |
216 |
|
|
%html-document(title=>{%res(name=>{Edit:Wrote:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);%html-meta(name=>ROBOTS,content=>NOINDEX);}p,content=>{ |
217 |
|
|
%section(level=>1,add-to-toc=>0,type=>body,title=>{%page-name;}p,heading,content=>{ |
218 |
|
|
%section(id=>tools1,class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p); |
219 |
|
|
%section(level=>2,add-to-toc=>0,content=>{ |
220 |
|
|
%paragraph(content=>{%res(name=>{Edit:SavedSuccessfully});}p); |
221 |
|
|
}p); |
222 |
|
|
%section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p); |
223 |
|
|
}p); |
224 |
|
|
}p); |
225 |
|
|
EOH |
226 |
|
|
SuikaWiki::View->definition (-deleted => { |
227 |
|
|
media => {type => 'text/html', charset => 1, expires => 60}, |
228 |
|
|
xmedia => {type => 'application/xhtml+xml', charset => 1, expires => 60}, |
229 |
|
|
template => <<'EOH'}); |
230 |
|
|
%html-document(title=>{%res(name=>{Edit:Deleted:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);%html-meta(name=>ROBOTS,content=>NOINDEX);}p,content=>{ |
231 |
|
|
%section(level=>1,add-to-toc=>0,type=>body,title=>{%page-name;}p,heading,content=>{ |
232 |
|
|
%section(id=>tools1,class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p); |
233 |
|
|
%section(level=>2,add-to-toc=>0,content=>{ |
234 |
|
|
%paragraph(content=>{%res(name=>{Edit:PageIsDeletedSuccessfully});}p); |
235 |
|
|
}p); |
236 |
|
|
%section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p); |
237 |
|
|
}p); |
238 |
|
|
}p); |
239 |
|
|
EOH |
240 |
|
|
|
241 |
|
|
ViewFragment: |
242 |
|
|
@Name: links |
243 |
|
|
@Description: |
244 |
|
|
@@@: Link to edit mode of the WikiPage |
245 |
|
|
@@lang:en |
246 |
|
|
@Formatting: |
247 |
|
|
%link-wiki(mode=>edit,rel=>edit,class=>wiki-cmd, |
248 |
|
|
title=>{%res(name=>{Link:Edit:Description});}p,up-to-date); |
249 |
|
|
%link-wiki(mode=>adminedit,rel=>edit,class=>wiki-cmd, |
250 |
|
|
title=>{%res(name=>{Link:AdminEdit:Description});}p,up-to-date); |
251 |
|
|
|
252 |
|
|
ViewFragment: |
253 |
|
|
@Name: navbar |
254 |
|
|
@Description: |
255 |
|
|
@@@: Link to edit mode of the WikiPage |
256 |
|
|
@Order: 10 |
257 |
|
|
@Formatting: |
258 |
|
|
%anchor-wiki(mode=>edit,rel=>edit,class=>wiki-cmd, |
259 |
|
|
label=>{%res(name=>EditThisPage);}p, |
260 |
|
|
title=>{%res(name=>EditThisPageLong);}p, |
261 |
|
|
accesskey=>E,add-param=>{#edit}); |
262 |
|
|
|
263 |
|
|
ViewFragment: |
264 |
|
|
@Name: we--edit |
265 |
|
|
@Description: |
266 |
|
|
@@@: Edit form --- main textarea |
267 |
|
|
@@lang:en |
268 |
|
|
@Order: 0 |
269 |
|
|
@Formatting: |
270 |
|
|
%textarea(id=>we--content,size=>{%res(name=>{Edit:Form:Size});}p, |
271 |
|
|
lines=>{%res(name=>{Edit:Form:Lines});}p); |
272 |
|
|
|
273 |
|
|
ViewFragment: |
274 |
|
|
@Name: we--edit |
275 |
|
|
@Description: |
276 |
|
|
@@@: Submit button |
277 |
|
|
@@lang:en |
278 |
|
|
@Order: 200 |
279 |
|
|
@Formatting: |
280 |
|
|
%submit(label=>{%res(name=>{Edit:Save});}p); |
281 |
|
|
|
282 |
|
|
FormattingRule: |
283 |
|
|
@Category[list]: view |
284 |
|
|
@Name: edit-form |
285 |
|
|
@Description: |
286 |
|
|
@@@: Provides WikiPage editing form |
287 |
|
|
@@lang: en |
288 |
|
|
@Parameter: |
289 |
|
|
@@Name: admin |
290 |
|
|
@@Type: boolean |
291 |
|
|
@@Default: {0} |
292 |
|
|
@@Description: |
293 |
|
|
@@@@: Whether administrator's editing mode or not |
294 |
|
|
@@@lang:en |
295 |
|
|
@Formatting: |
296 |
|
|
if (not __FUNCPACK__::page_is_editable ($o->{wiki}->{var}->{page})) { |
297 |
|
|
$r = '<p>'.$o->resource('Error:ThisPageIsUneditable',escape=>1).'</p>'; |
298 |
|
|
} elsif (!$p->{admin} && &main::is_frozen ($o->{page})) { |
299 |
|
|
$r = '<p>'.$o->resource('Error:ThisPageIsUneditable',escape=>1).'</p>'; |
300 |
|
|
} else { |
301 |
|
|
#$r = '<p>'.$o->resource('Error:PasswordIsNotSpecified',escape=>1).'</p>' if $p->{admin}; |
302 |
|
|
|
303 |
|
|
$r = Message::Markup::XML->new (type => '#element', |
304 |
|
|
namespace_uri => $NS_XHTML1, |
305 |
|
|
local_name => 'form'); |
306 |
|
|
$r->set_attribute (method => 'post'); |
307 |
|
|
## TODO: Use SuikaWiki 3 interface |
308 |
|
|
$r->set_attribute (action => $o->uri ('wiki')); |
309 |
|
|
$r->set_attribute ('accept-charset' => 'iso-2022-jp, utf-8'); |
310 |
|
|
for ($r->append_new_node (type => '#element', |
311 |
|
|
namespace_uri => $NS_XHTML1, |
312 |
|
|
local_name => 'input')) { |
313 |
|
|
$_->set_attribute (type => 'hidden'); |
314 |
|
|
$_->set_attribute (name => 'mypage'); |
315 |
|
|
## TODO: Use SuikaWiki 3 interface |
316 |
|
|
$_->set_attribute (value => join '//', @{$o->{wiki}->{var}->{page}}); |
317 |
|
|
$_->option (use_EmptyElemTag => 1); |
318 |
|
|
} |
319 |
|
|
for ($r->append_new_node (type => '#element', |
320 |
|
|
namespace_uri => $NS_XHTML1, |
321 |
|
|
local_name => 'input')) { |
322 |
|
|
$_->set_attribute (type => 'hidden'); |
323 |
|
|
$_->set_attribute (name => 'mode'); |
324 |
|
|
$_->set_attribute (value => 'write'); |
325 |
|
|
$_->option (use_EmptyElemTag => 1); |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
my $ovar_orig = $o->{var}; |
329 |
|
|
$o->{var} = { |
330 |
|
|
#content |
331 |
|
|
is_admin_mode => $p->{admin}, |
332 |
|
|
is_conflict_mode => 0, |
333 |
|
|
#is_new_page_template |
334 |
|
|
}; |
335 |
|
|
$o->{var}->{content} = __FUNCPACK__::get_content |
336 |
|
|
($o, $o->{wiki}->{var}->{page}); |
337 |
|
|
for ($r->append_new_node (type => '#element', |
338 |
|
|
namespace_uri => $NS_XHTML1, |
339 |
|
|
local_name => 'input')) { |
340 |
|
|
$_->set_attribute (type => 'hidden'); |
341 |
|
|
$_->set_attribute (name => 'we--digest'); |
342 |
|
|
$_->set_attribute (value => ($o->{var}->{is_new_page_template}?'': do { |
343 |
|
|
require Digest::SHA1; |
344 |
|
|
Digest::SHA1::sha1_base64 ($o->{var}->{content}); |
345 |
|
|
})); |
346 |
|
|
$_->option (use_EmptyElemTag => 1); |
347 |
|
|
} |
348 |
|
|
|
349 |
|
|
my $formatter = $o->formatter ('we__edit'); |
350 |
|
|
$r->append_node ($formatter->replace |
351 |
|
|
($o->{wiki}->{view}->assemble_template |
352 |
|
|
('we__edit'), |
353 |
|
|
$o, {formatter => $formatter}), |
354 |
|
|
node_or_text => 1); |
355 |
|
|
$o->{var} = $ovar_orig; |
356 |
|
|
} |
357 |
|
|
|
358 |
|
|
FormattingRule: |
359 |
|
|
@Category[list]: view |
360 |
|
|
@Name: conflict-form |
361 |
|
|
@Description: |
362 |
|
|
@@@: |
363 |
|
|
Provides editing WikiPage form, with confliction indication |
364 |
|
|
@@lang:en |
365 |
|
|
@Formatting: |
366 |
|
|
$r = &main::editform (page => $o->{page}, content => $o->{param}->{mymsg}, last_modified => $o->{param}->{myLastModified}, frozen=>0, conflict=>1); |
367 |
|
|
|
368 |
|
|
FormattingRule: |
369 |
|
|
@Category[list]:view |
370 |
|
|
@Name: conflict-diff |
371 |
|
|
@Description: |
372 |
|
|
@@@: |
373 |
|
|
Provides marked diff between latest WikiPage content and |
374 |
|
|
submitted one |
375 |
|
|
@@lang:en |
376 |
|
|
@Formatting: |
377 |
|
|
require Algorithm::Diff; |
378 |
|
|
for (Algorithm::Diff::diff([split /\x0D?\x0A/, $o->{param}->{mymsg}],[split /\x0D?\x0A/, $main::database{$o->{page}}])){ |
379 |
|
|
for (@{$_}) { |
380 |
|
|
my ($sign, $lineno, $text) = @{$_}; |
381 |
|
|
my $ename = $sign eq '+' ? 'ins' : $sign eq '-' ? 'del' : 'span'; |
382 |
|
|
$r .= qq(<$ename class="line"><span class="lineno">@{[$o->escape($lineno)]}</span> <span class="sign">@{[$o->escape($sign)]}</span> <span class="content">@{[$o->escape($text)]}</span></$ename>\n); |
383 |
|
|
} |
384 |
|
|
$r .= "\n"; |
385 |
|
|
} |
386 |
|
|
$r =~ s/\n+$/\n/; |
387 |
|
|
$r = qq(<pre class="diff">$r</pre>); |
388 |
|
|
|
389 |
|
|
FormattingRule: |
390 |
|
|
@Name:mode-after-edit-selection |
391 |
|
|
@Category[list]:we--edit |
392 |
|
|
@Parameter: |
393 |
|
|
@@Name: name |
394 |
|
|
@@Type: html4:name |
395 |
|
|
@@Default:"we--mode-modified" |
396 |
|
|
@@Description: |
397 |
|
|
@@@@:Form control name for the selection |
398 |
|
|
@@@lang:en |
399 |
|
|
@Formatting: |
400 |
|
|
my $magic = ''; |
401 |
|
|
$magic = $1 if $o->{var}->{content} =~ m/^([^\x0A\x0D]+)/s; |
402 |
|
|
|
403 |
|
|
my $name = $p->{name} || 'we--mode-modified'; |
404 |
|
|
my $selected_mode = $o->{wiki}->{input}->parameter ($name); |
405 |
|
|
unless ($selected_mode) { |
406 |
|
|
if ($magic =~ /C(?:on(?:fig|st)|SS)/) { |
407 |
|
|
$selected_mode = 'edit'; |
408 |
|
|
} else { |
409 |
|
|
$selected_mode = 'default'; |
410 |
|
|
} |
411 |
|
|
} |
412 |
|
|
|
413 |
|
|
my $SELECT = Message::Markup::XML->new (type => '#element', |
414 |
|
|
namespace_uri => $NS_XHTML1, |
415 |
|
|
local_name => 'select'); |
416 |
|
|
$SELECT->set_attribute (name => $name); |
417 |
|
|
for (qw/default read edit/) { |
418 |
|
|
for my $OPTION ($SELECT->append_new_node (type => '#element', |
419 |
|
|
namespace_uri => $NS_XHTML1, |
420 |
|
|
local_name => 'option')) { |
421 |
|
|
$OPTION->set_attribute (value => $_); |
422 |
|
|
my $label = $o->resource ('Edit:SaveAnd:'.$_.':Label'); |
423 |
|
|
$OPTION->set_attribute (label => $label); |
424 |
|
|
$OPTION->append_text ($label); |
425 |
|
|
$OPTION->set_attribute |
426 |
|
|
(title => $o->resource ('Edit:SaveAnd:'.$_.':Description')); |
427 |
|
|
$OPTION->set_attribute (selected => 'selected') |
428 |
|
|
if $selected_mode eq $_; |
429 |
|
|
} |
430 |
|
|
} |
431 |
|
|
$SELECT; |
432 |
|
|
|
433 |
|
|
Resource: |
434 |
|
|
@Edit:Form:Lines:15 |
435 |
|
|
@Edit:Form:Size:18 |
436 |
|
|
@Edit:Save: |
437 |
|
|
@@@:Save |
438 |
|
|
@@lang:en |
439 |
|
|
@Edit:SaveAnd:default:Description: |
440 |
|
|
@@@: Save modified content and show content with your default view mode |
441 |
|
|
@@lang:en |
442 |
|
|
@Edit:SaveAnd:default:Label: |
443 |
|
|
@@@: Default view |
444 |
|
|
@@lang:en |
445 |
|
|
@Edit:SaveAnd:edit:Description: |
446 |
|
|
@@@: Save modified content and show content in the edit mode again |
447 |
|
|
@@lang:en |
448 |
|
|
@Edit:SaveAnd:edit:Label: |
449 |
|
|
@@@: Edit again |
450 |
|
|
@@lang:en |
451 |
|
|
@Edit:SaveAnd:read:Description: |
452 |
|
|
@@@: Save modified content and show content in the read mode |
453 |
|
|
@@lang:en |
454 |
|
|
@Edit:SaveAnd:read:Label: |
455 |
|
|
@@@: Show content |
456 |
|
|
@@lang:en |
457 |
|
|
@EditThisPage: |
458 |
|
|
@@@: Edit |
459 |
|
|
@@lang:en |
460 |
|
|
@EditThisPageLong: |
461 |
|
|
@@@: Edit this WikiPage |
462 |
|
|
@@lang:en |
463 |
|
|
@Edit:WebPageTitle: |
464 |
|
|
@@@: %page-name; (Modification) |
465 |
|
|
@@lang:en |
466 |
|
|
@Edit:Title: |
467 |
|
|
@@@: Modification of the WikiPage |
468 |
|
|
@@lang:en |
469 |
|
|
@Link:AdminEdit:Description: |
470 |
|
|
@@@: Edit this WikiPage (administrator's mode) |
471 |
|
|
@@lang:en |
472 |
|
|
@Link:Edit:Description: |
473 |
|
|
@@@: Edit this WikiPage |
474 |
|
|
@@lang:en |
475 |
|
|
|
476 |
|
|
Function: |
477 |
|
|
@Name:get_content |
478 |
|
|
@Description: |
479 |
|
|
@@@:Get WikiPage content to be modified. For new (currently not exist) |
480 |
|
|
WikiPage, new page template content is returned. |
481 |
|
|
@@lang:en |
482 |
|
|
@Main: |
483 |
|
|
my ($o, $page) = @_; |
484 |
|
|
my $content; |
485 |
|
|
$content = $o->{wiki}->{db}->get (content => $page); |
486 |
|
|
|
487 |
|
|
unless (length $content) { |
488 |
|
|
## TODO: use namespaced template page |
489 |
|
|
$content = $o->{wiki}->{db}->get |
490 |
|
|
(content => $o->{wiki}->{config}->{page}->{NewPageTemplate}); |
491 |
|
|
$o->{var}->{is_new_page_template} = 1; |
492 |
|
|
} |
493 |
|
|
$content; |
494 |
|
|
|
495 |
|
|
Temp: |
496 |
|
|
my $frozen = &main::is_frozen ($wiki->{var}->{page}); |
497 |
|
|
|
498 |
|
|
=pod |
499 |
|
|
|
500 |
|
|
my $f = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'form'); |
501 |
|
|
$f->set_attribute (action => SuikaWiki::Plugin->uri ('wiki'); |
502 |
|
|
$f->set_attribute (method => 'post'); |
503 |
|
|
if (!$option{conflict}) { |
504 |
|
|
for ($f->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'label')) { |
505 |
|
|
for ($_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'input')) { |
506 |
|
|
$f->set_attribute (type => 'submit'); |
507 |
|
|
$f->set_attribute (value => SuikaWiki::Plugin->resource ('Edit:Save')); |
508 |
|
|
} |
509 |
|
|
#<input type=hidden name=mycmd value=write/> |
510 |
|
|
$_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'kbd', value => 'S'); |
511 |
|
|
} |
512 |
|
|
} |
513 |
|
|
|
514 |
|
|
=cut |
515 |
|
|
|
516 |
|
|
my $f = <<"EOD"; |
517 |
|
|
<form action="@{[SuikaWiki::Plugin->uri ('wiki')]}" method="post"> |
518 |
|
|
@{[ $option{conflict} ? '' : qq(<label><input type="submit" value="@{[SuikaWiki::Plugin->resource('Edit:Save',escape=>1)]}" /><kbd>S</kbd></label>) ]} |
519 |
|
|
@{[ $option{admin} ? qq(<label>@{[SuikaWiki::Plugin->resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10" /></label>) : "" ]} [@{[&get_new_anchor_index($option{content})]}]<br /> |
520 |
|
|
<input type="hidden" name="myLastModified" value="$option{last_modified}" /> |
521 |
|
|
<input type="hidden" name="mycmd" value="write" /> |
522 |
|
|
<input type="hidden" name="mypage" value="@{[SuikaWiki::Plugin->escape($main::form{mypage})]}" /> |
523 |
|
|
<textarea cols="@{[SuikaWiki::Plugin->resource('Edit:Form:Cols')+0||35]}" rows="@{[SuikaWiki::Plugin->resource('Edit:Form:Rows')+0||15]}" name="mymsg" tabindex="1"@{[$main::UA =~ m{Mozilla/[0-4]\.} ? ' wrap="virtual"':'']}>@{[SuikaWiki::Plugin->escape($option{content})]}</textarea><br /> |
524 |
|
|
@{[ |
525 |
|
|
$option{admin} ? |
526 |
|
|
qq( |
527 |
|
|
<label><input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]} />@{[SuikaWiki::Plugin->resource('Edit:Freeze',escape=>1)]}</label> |
528 |
|
|
<label><input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]} />@{[SuikaWiki::Plugin->resource('Edit:DontFreeze',escape=>1)]}</label><br />) |
529 |
|
|
: "" |
530 |
|
|
]} |
531 |
|
|
@{[ |
532 |
|
|
$option{conflict} ? "" : |
533 |
|
|
qq( |
534 |
|
|
<label><input type="checkbox" name="mytouch" value="on" checked="checked" />@{[SuikaWiki::Plugin->resource('Edit:UpdateTimeStamp',escape=>1)]}</label><br /> |
535 |
|
|
<label><input type="submit" value="@{[SuikaWiki::Plugin->resource('Edit:Save',escape=>1)]}" accesskey="S" /><kbd>S</kbd></label> |
536 |
|
|
$afteredit |
537 |
|
|
) |
538 |
|
|
]} |
539 |
|
|
</form> |
540 |
|
|
EOD |
541 |
|
|
$f; |
542 |
|
|
} |
543 |
|
|
|
544 |
|
|
Function: |
545 |
|
|
@Name:page_is_editable |
546 |
|
|
@Description: |
547 |
|
|
@@@: |
548 |
|
|
Returns whether the WikiPage is editable or not. |
549 |
|
|
Note that this function is temporary. |
550 |
|
|
@@lang:en |
551 |
|
|
@Main: |
552 |
|
|
my ($page) = @_; |
553 |
|
|
$page = join '//', $page; |
554 |
|
|
return 0 unless SuikaWiki::Name::Space::validate_name ($page); |
555 |
|
|
return 0 if $page =~ /[\x00-\x20\[\]\x7F]/; |
556 |
|
|
1; |
557 |
|
|
|
558 |
|
|
Parameter: |
559 |
|
|
@Name: we--digest |
560 |
|
|
@Type: "Base64ed SHA1" |
561 |
|
|
@Default: {undef} |
562 |
|
|
@Description: |
563 |
|
|
@@@: |
564 |
|
|
SHA1 digest value of the WikiPage content before the modification. |
565 |
|
|
This value is used to detect confliction of modifying. |
566 |
|
|
Empty value (undef or length-zero-string) means that |
567 |
|
|
there were no WikiPage content. |
568 |
|
|
@@lang:en |
569 |
|
|
|
570 |
|
|
Parameter: |
571 |
|
|
@Name: we--touch |
572 |
|
|
@Type: form:checkbox-value |
573 |
|
|
@Default: "off" |
574 |
|
|
@Description: |
575 |
|
|
@@@: |
576 |
|
|
Whether last-modified date-time of the WikiPage should be updated or not |
577 |
|
|
when the WikiPage is modified. |
578 |
|
|
@@lang:en |