X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmodule.php;h=1dbdaff840e64f654af38a08e93440914e8c6221;hb=446937eeaa89b10d24f6503ad99e0259a4d8c1b9;hp=06e5da837c851f88e133db91bc731ecdd869c782;hpb=179afa7fa79902e11498314d37fe4dbf452b3617;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; } }