From d54ac87747635038aaaf9b4c7a2df7a8a0cd450d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 6 Jun 2011 16:20:29 +0200 Subject: Use autoloading for plugin classes --- inc/plugincontroller.class.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'inc/plugincontroller.class.php') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index cec5c73a9..ea5725d47 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -72,32 +72,21 @@ class Doku_Plugin_Controller { return null; } + $class = $type.'_plugin_'.$name; + //plugin already loaded? if(!empty($DOKU_PLUGINS[$type][$name])){ if ($new || !$DOKU_PLUGINS[$type][$name]->isSingleton()) { - $class = $type.'_plugin_'.$name; - return class_exists($class) ? new $class : null; + return class_exists($class, true) ? new $class : null; } else { return $DOKU_PLUGINS[$type][$name]; } } - //try to load the wanted plugin file - $dir = $this->get_directory($plugin); - $file = $component ? "$type/$component.php" : "$type.php"; - - if(!is_file(DOKU_PLUGIN."$dir/$file")){ - return null; - } - - if (!include_once(DOKU_PLUGIN."$dir/$file")) { - return null; - } - //construct class and instantiate - $class = $type.'_plugin_'.$name; - if (!class_exists($class)){ + if (!class_exists($class, true)) { # the plugin might be in the wrong directory + $dir = $this->get_directory($plugin); $inf = confToHash(DOKU_PLUGIN."$dir/plugin.info.txt"); if($inf['base'] && $inf['base'] != $plugin){ msg("Plugin installed incorrectly. Rename plugin directory '". -- cgit v1.2.3