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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show 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.5: +4 -2 lines
Error occurred while calculating annotation data.
LeafProp database module added; content_prop implemented; Media type property implemented

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: WikiPageRemove
5 @Description:
6 @@@: WikiPage removing
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/18 07:22:11 $
17 @RequiredPlugin[list]:
18 Error
19 WikiEdit
20 WikiFormCore
21 WikiResource
22 @Use:
23 use Message::Util::Error;
24
25 PluginConst:
26 @NS_XHTML1:
27 http://www.w3.org/1999/xhtml
28
29 ViewDefinition:
30 @Mode: wpr--remove
31 @Condition:
32 @@http-method[list]:
33 POST
34 @Description:
35 @@@: Removing a WikiPage
36 @@lang: en
37 @method:
38 @@Name: main
39 @@@:
40 $self->{view}->{wiki}->{var}->{db}->{read_only}->{'content'} = 0;
41 $self->{view}->{wiki}->{var}->{db}->{read_only}->{'content_prop'} = 0;
42 $self->{view}->{wiki}->{var}->{db}->{read_only}->{'lastmodified'} = 0;
43 $self->{view}->init_db;
44 my $page = $self->{view}->{wiki}->{var}->{page};
45
46 ## Check confliction
47 my $current_content;
48 try {
49 $current_content = $self->{view}->{wiki}->{db}->get (content => $page);
50 } catch SuikaWiki::DB::Util::Error with {
51 my $err = shift;
52 $err->throw if $err->{-type} eq 'ERROR_REPORTED';
53 $self->{view}->{wiki}->view_in_mode (mode => '-wdb--fatal-error');
54 throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
55 };
56 if (length $current_content) {
57 my $current_digest = SuikaWiki::Plugin->module_package ('WikiEdit')
58 ->digest ($current_content,
59 normalize => 1);
60 my $prev_digest
61 = $self->{view}->{wiki}->{input}->parameter ('we--digest');
62 if ($current_digest ne $prev_digest) {
63 SuikaWiki::Plugin->module_package ('Error')
64 ->report_error_simple
65 ($self->{view}->{wiki},
66 WikiPageRemove => SuikaWiki::Plugin
67 ->module_package
68 ('WikiResource')
69 ->get_text
70 (name =>
71 'WikiPageRemove:Modified',
72 param => {wiki => $self->{view}->{wiki}},
73 wiki => $self->{view}->{wiki}));
74 $self->{view}->{wiki}->view_in_mode (mode => '-general-error');
75 throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
76 }
77 }
78
79 try {
80 $self->{view}->{wiki}->{db}->delete (content => $page);
81 $self->{view}->{wiki}->{db}->delete (content_prop => $page);
82 $self->{view}->{wiki}->{db}->delete (lastmodified => $page);
83 } catch SuikaWiki::DB::Util::Error with {
84 my $err = shift;
85 $err->throw if $err->{-type} eq 'ERROR_REPORTED';
86 $self->{view}->{wiki}->view_in_mode (mode => '-wdb--fatal-error');
87 throw SuikaWiki::DB::Util::Error -type => 'ERROR_REPORTED';
88 };
89 $self->{view}->{wiki}->view_in_mode (mode => '-deleted');
90
91 FormattingRule:
92 @Category[list]: view
93 @Name: wpr--remove-button
94 @Description:
95 @@@: Removing button
96 @@lang: en
97 @Parameter:
98 @@Name: page
99 @@Type: WikiName
100 @@Default: (auto)
101 @@Description:
102 @@@@: WikiPage that is editing
103 @@@lang:en
104 @Formatting:
105 __ATTRTEXT:%page__;
106
107 my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
108 local $o->{var} = {
109 #content
110 is_admin_mode => 0,
111 is_conflict_mode => 0,
112 #is_new_page_template
113 };
114 $o->{var}->{content} = SuikaWiki::Plugin->module_package ('WikiEdit')
115 ->get_content ($o, $page)->{content};
116 SuikaWiki::Plugin->module_package ('WikiFormCore')
117 ->make_form_in_html
118 ($p->{-parent}, ' ',
119 wiki => $o->{wiki},
120 o => $o,
121 index => -1,
122 output => {
123 mode => 'wpr--remove',
124 page => $page,
125 hidden => sub {
126 my ($hidden, $o) = @_;
127 for ($hidden->append_new_node (type => '#element',
128 namespace_uri => $NS_XHTML1,
129 local_name => 'input')) {
130 $_->set_attribute (type => 'hidden');
131 $_->set_attribute (name => 'we--digest');
132 $_->set_attribute (value => ($o->{var}->{is_new_page_template}?'':
133 SuikaWiki::Plugin->module_package ('WikiEdit')
134 ->digest ($o->{var}->{content},
135 normalize => 1)));
136 $_->option (use_EmptyElemTag => 1);
137 }
138 for ($hidden->append_new_node (type => '#element',
139 namespace_uri => $NS_XHTML1,
140 local_name => 'input')) {
141 $_->set_attribute (type => 'submit');
142 $_->set_attribute (value => SuikaWiki::Plugin
143 ->module_package ('WikiResource')
144 ->append_node
145 (name => 'WikiPageRemove:Remove:Label',
146 param => $o,
147 wiki => $o->{wiki})->inner_text);
148 $_->set_attribute (title => SuikaWiki::Plugin
149 ->module_package ('WikiResource')
150 ->append_node
151 (name =>
152 'WikiPageRemove:Remove:Description',
153 param => $o,
154 wiki => $o->{wiki})->inner_text);
155 $_->option (use_EmptyElemTag => 1);
156 }
157 },
158 });
159
160
161 Resource:
162 @WikiPageRemove:Modified:
163 @@@:
164 WikiPage you are attempting to remove ("%page-name;") has been modified.
165 Please review latest version of the page before removal.
166 @@lang:en
167 @WikiPageRemove:Remove:Description:
168 @@@:Removing WikiPage "%page-name;", w/o any caution nor backup.
169 @@lang:en
170 @WikiPageRemove:Remove:Label:
171 @@@:Remove WikiPage
172 @@lang:en

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24