Cleanup again.
[fa-stable.git] / includes / hooks.inc
index fedbc4c22cf8d4b59eefd209c1d2ffe605aff432..b27fc35501788654afcd15ab69df50d23d5ad73c 100644 (file)
@@ -93,6 +93,19 @@ class hooks {
 //             return array($security_areas, $security_sections);
        }
 
+       //
+       //      Invoked for all modules before page header is displayed
+       //
+       function pre_header($fun_args)
+       {
+       }
+       //
+       //      Invoked for all modules before page footer is displayed
+       //
+       function pre_footer($fun_args)
+       {
+       }
+
        //
        // Price in words. $doc_type is set to document type and can be used to suppress 
        // price in words printing for selected document types.
@@ -252,17 +265,20 @@ function hook_invoke_all($method, &$data, $opts=null)
        global $Hooks;
        
        $return = array();
-       foreach($Hooks as $ext => $hook)
-               if (method_exists($hook, $method)) {
-                       set_ext_domain('modules/'.$ext);
-                       $result = $hook->$method($data, $opts);
-                       if (isset($result) && is_array($result)) {
-                               $return = array_merge_recursive($return, $result);
-                       } else if (isset($result)) {
-                               $return[] = $result;
-                               }
-               }
-       set_ext_domain();
+       if (isset($Hooks))
+       {
+               foreach($Hooks as $ext => $hook)
+                       if (method_exists($hook, $method)) {
+                               set_ext_domain('modules/'.$ext);
+                               $result = $hook->$method($data, $opts);
+                               if (isset($result) && is_array($result)) {
+                                       $return = array_merge_recursive($return, $result);
+                               } else if (isset($result)) {
+                                       $return[] = $result;
+                                       }
+                               set_ext_domain();
+                       }
+       }
        return $return;
 }
 /*
@@ -278,11 +294,11 @@ function hook_invoke_first($method, &$data, $opts=null)
                if (method_exists($hook, $method)) {
                        set_ext_domain('modules/'.$ext);
                        $result = $hook->$method($data, $opts);
+                       set_ext_domain();
                        if (isset($result))
                                break;
                }
        }
-       set_ext_domain();
        return $result;
 }
 /*
@@ -300,11 +316,11 @@ function hook_invoke_last($method, &$data, $opts=null)
                if (method_exists($hook, $method)) {
                        set_ext_domain('modules/'.$ext);
                        $result = $hook->$method($data, $opts);
+                       set_ext_domain();
                        if (isset($result))
                                break;
                }
        }
-       set_ext_domain();
        return $result;
 }
 //------------------------------------------------------------------------------------------