]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
rename: implemented new canrename hook
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index 77439a3ca1fc1504d6c4f0151ec939711e74f8a6..5670f3608ef3a5bb8424fffb4c6c3898f72a868f 100644 (file)
@@ -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 () {
@@ -483,7 +494,9 @@ sub myurlto ($$;$) {
        # avoid, i.e. when po_link_to = negotiated
        if ($config{po_link_to} eq "negotiated") {
                my @caller = caller(1);
-               my $run_by_editpage = ($caller[3] eq "IkiWiki::cgi_editpage");
+               my $run_by_editpage = 0;
+               $run_by_editpage = 1 if (exists $caller[3] && defined $caller[3]
+                                        && $caller[3] eq "IkiWiki::cgi_editpage");
                inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'})
                        if $run_by_editpage;
                my $res = $origsubs{'urlto'}->($to,$from,$absolute);