From ac2f544d3ee0cfe67fc61759f0f6f72dec7e1cc9 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 23 Aug 2008 14:39:28 +0200 Subject: [PATCH] Add Platal::load(module, include_file = null) to load a module or an include of this module. Signed-off-by: Florent Bruneau --- classes/platal.php | 18 ++++++++++++++++++ classes/plmodule.php | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/classes/platal.php b/classes/platal.php index 858ab98..97b2e42 100644 --- a/classes/platal.php +++ b/classes/platal.php @@ -336,6 +336,24 @@ abstract class Platal } } + public static function load($modname, $include = null) + { + global $platal; + $modname = strtolower($modname); + if (isset($platal->__mods[$modname])) { + if (is_null($include)) { + return; + } + $platal->__mods[$modname]->load($include); + } else { + if (is_null($include)) { + require_once PLModule::path($modname) . '.php'; + } else { + require_once PLModule::path($modname) . '/' . $include; + } + } + } + static public function &page() { global $platal; diff --git a/classes/plmodule.php b/classes/plmodule.php index ec1e5f0..4e1229b 100644 --- a/classes/plmodule.php +++ b/classes/plmodule.php @@ -66,7 +66,7 @@ abstract class PLModule /* static functions */ - public static function factory($modname) + public static function path($modname) { global $globals; if ($modname == 'core') { @@ -74,6 +74,12 @@ abstract class PLModule } else { $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 . '.php'; -- 2.1.4