X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmodule.php;h=1dbdaff840e64f654af38a08e93440914e8c6221;hb=29bd16dff22ad53c92c51e799a1e68dadf9aeff5;hp=06e5da837c851f88e133db91bc731ecdd869c782;hpb=5f30b30e8b2657ade5c727e98de286386ee002d8;p=platal.git diff --git a/classes/plmodule.php b/classes/plmodule.php index 06e5da8..1dbdaff 100644 --- a/classes/plmodule.php +++ b/classes/plmodule.php @@ -1,6 +1,6 @@ make_hook(...), + * ...); + * @ref make_hook + */ + abstract public function handlers(); /** Register a hook * @param fun name of the handler (the exact name will be handler_$fun) @@ -46,15 +56,36 @@ abstract class PLModule 'type' => $type); } + /** Include a 'module-specific' file. + * Module specific includes must be in the in the path modules/{modulename}. + */ + public function load($file) + { + require_once $this->modIncludePath . $file; + } + /* static functions */ + public static function path($modname) + { + global $globals; + if ($modname == 'core') { + $mod_path = $globals->spoolroot . '/core/modules/' . $modname; + } else { + $mod_path = $globals->spoolroot . '/modules/' . $modname; + } + return $mod_path; + } + public static function factory($modname) { - $mod_path = dirname(__FILE__) . '/../modules/' . $modname . '.php'; + $mod_path = self::path($modname); $class = ucfirst($modname) . 'Module'; - require_once $mod_path; - return new $class(); + require_once $mod_path . '.php'; + $module = new $class(); + $module->modIncludePath = $mod_path . '/'; + return $module; } }