/[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.5 - (hide annotations) (download)
Wed Feb 18 07:22:11 2004 UTC (20 years, 8 months ago) by wakaba
Branch: MAIN
Changes since 1.4: +5 -1 lines
WikiDB error reporting bug fixed

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24