]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
* Add a run_hooks function for the common task of running all hooks of a
[ikiwiki.git] / IkiWiki.pm
index 085953a17220fa50b44bf42892d7f0683f524d21..54ca845501d0396e1893b70ed61e0b98da6a75db 100644 (file)
@@ -61,7 +61,7 @@ sub checkconfig () { #{{{
        if (defined $config{locale}) {
                eval q{use POSIX};
                $ENV{LANG} = $config{locale}
-                       if POSIX::setlocale(&POSIX::LANG, $config{locale});
+                       if POSIX::setlocale(&POSIX::LC_TIME, $config{locale});
        }
 
        if ($config{w3mmode}) {
@@ -93,11 +93,7 @@ sub checkconfig () { #{{{
                require IkiWiki::Rcs::Stub;
        }
 
-       if (exists $hooks{checkconfig}) {
-                foreach my $id (keys %{$hooks{checkconfig}}) {
-                        $hooks{checkconfig}{$id}{call}->();
-                }
-        }
+       run_hooks(checkconfig => sub { shift->() });
 } #}}}
 
 sub loadplugins () { #{{{
@@ -503,4 +499,17 @@ sub hook (@) { # {{{
        $hooks{$param{type}}{$param{id}}=\%param;
 } # }}}
 
+sub run_hooks ($$) { # {{{
+       # Calls the given sub for each hook of the given type,
+       # passing it the hook function to call.
+       my $type=shift;
+       my $sub=shift;
+
+       if (exists $hooks{$type}) {
+               foreach my $id (keys %{$hooks{$type}}) {
+                       $sub->($hooks{$type}{$id}{call});
+               }
+       }
+} #}}}
+
 1