/[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.4 - (hide annotations) (download)
Sat Feb 14 10:53:04 2004 UTC (20 years, 8 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +4 -4 lines
Use SuikaWiki 3 WikiName interface

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24