X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmodule.php;h=33de3709e97b8f52c44361a493977a90d9d8715e;hb=bfb9093b94f6403150200e3081c895cf5e48f563;hp=9d5dc9b5240994e286f48f613c04c4e2ab42389d;hpb=ba63661ce2f38974002c7e4113320e9d06010853;p=platal.git diff --git a/classes/plmodule.php b/classes/plmodule.php index 9d5dc9b..33de370 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,20 +56,43 @@ abstract class PLModule 'type' => $type); } + /** Register a hook that points to a wiki page. + */ + public function make_wiki_hook($auth = AUTH_PUBLIC, $perms = 'user', $type = DO_AUTH) + { + return Platal::wiki_hook($auth, $perms, $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 factory($modname) + public static function path($modname) { global $globals; if ($modname == 'core') { - $mod_path = $globals->spoolroot . '/core/modules/' . $modname . '.php'; + $mod_path = $globals->spoolroot . '/core/modules/' . $modname; } else { - $mod_path = $globals->spoolroot . '/modules/' . $modname . '.php'; + $mod_path = $globals->spoolroot . '/modules/' . $modname; } + return $mod_path; + } + + public static function factory($modname) + { + $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; } }