diff options
author | intrigeri <intrigeri@boum.org> | 2009-01-01 16:38:16 +0100 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2009-01-01 16:44:39 +0100 |
commit | 741b26aa176b34d0359a2b89dd6d8293fcdf2b3d (patch) | |
tree | a11600b8035bba15841272347eae72f2f68ac9df /IkiWiki/Plugin | |
parent | 5852f03efacb391f97d3d68e98ec8888cd09dc84 (diff) |
remove: implemented a new canremove hook; use it in the po plugin
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/po.pm | 11 | ||||
-rw-r--r-- | IkiWiki/Plugin/remove.pm | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 205066341..5670f3608 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -39,6 +39,7 @@ sub import { hook(type => "rename", id => "po", call => \&renamepages); hook(type => "delete", id => "po", call => \&mydelete); hook(type => "change", id => "po", call => \&change); + hook(type => "canremove", id => "po", call => \&canremove); hook(type => "editcontent", id => "po", call => \&editcontent); $origsubs{'bestlink'}=\&IkiWiki::bestlink; @@ -406,6 +407,16 @@ sub change(@) { } } +sub canremove ($$$) { + my ($page, $cgi, $session) = (shift, shift, shift); + + if (istranslation($page)) { + return gettext("Can not remove a translation. Removing the master page,". + "though, removes its translations as well."); + } + return undef; +} + # As we're previewing or saving a page, the content may have # changed, so tell the next filter() invocation it must not be lazy. sub editcontent () { diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 21989aff3..2e3614cca 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -54,6 +54,26 @@ sub check_canremove ($$$) { error("renaming of attachments is not allowed"); } } + + my $canremove; + IkiWiki::run_hooks(canremove => sub { + return if defined $canremove; + my $ret=shift->($page, $q, $session); + if (defined $ret) { + if ($ret eq "") { + $canremove=1; + } + elsif (ref $ret eq 'CODE') { + $ret->(); + $canremove=0; + } + elsif (defined $ret) { + error($ret); + $canremove=0; + } + } + }); + return $canremove; } sub formbuilder_setup (@) { |