X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmodule.php;h=55de69f15af7c817105a20594d4bd208608ebcda;hb=2e11cb87effddefdaed6da3e1951c935096ab361;hp=697b4efec8ef47e4a4ab429c9f073f405e6d6263;hpb=8fc4efa394721853bca6ee0e4f2028f33ed0867d;p=platal.git diff --git a/classes/plmodule.php b/classes/plmodule.php index 697b4ef..55de69f 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) @@ -40,21 +50,47 @@ abstract class PLModule */ public function make_hook($fun, $auth, $perms = 'user', $type = DO_AUTH) { - return array('hook' => array($this, 'handler_'.$fun), - 'auth' => $auth, - 'perms' => $perms, - 'type' => $type); + return new PlStdHook(array($this, 'handler_' . $fun), + $auth, $perms, $type); + } + + /** Register a hook that points to a wiki page. + */ + public function make_wiki_hook($auth = AUTH_PUBLIC, $perms = 'user', $type = DO_AUTH) + { + return new PlWikiHook($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 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; } }