use warnings;
use strict;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "rename", call => \&getsetup);
IkiWiki::Plugin::attachment::check_canattach($session, $dest, $srcfile);
}
}
+
+ my $canrename;
+ IkiWiki::run_hooks(canrename => sub {
+ return if defined $canrename;
+ my $ret=shift->($q, $session, src => $src, srcfile => $srcfile,
+ dest => $dest, destfile => $destfile);
+ if (defined $ret) {
+ if ($ret eq "") {
+ $canrename=1;
+ }
+ elsif (ref $ret eq 'CODE') {
+ $ret->();
+ $canrename=0;
+ }
+ elsif (defined $ret) {
+ error($ret);
+ $canrename=0;
+ }
+ }
+ });
+ return $canrename;
}
sub rename_form ($$$) {
required => 1,
};
+ IkiWiki::run_hooks(rename => sub { shift->(\@torename, $q, $session); });
+
# See if any subpages need to be renamed.
if ($q->param("subpages") && $src ne $dest) {
foreach my $p (keys %pagesources) {
sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
$session->param("name"), $ENV{REMOTE_ADDR}) if $config{rcs};
+ # Then link fixups.
foreach my $rename (@torename) {
next if $rename->{src} eq $rename->{dest};
next if $rename->{error};
- IkiWiki::run_hooks(rename => sub {
- shift->(
- oldpage => $src,
- newpage => $dest,
- );
- });
- # Then link fixups.
foreach my $p (fixlinks($rename, $session)) {
# map old page names to new
foreach my $r (@torename) {