3 require_once "config.php";
5 require_once "common.php";
7 require_once "Classes/class-message.php";
10 /** Check for plugins and load them.
12 * This expects your plugin folder to be located in `plugins/` and that the directory name,
13 * constructor file name and class name are identical.
15 * You must have a file structure like this: plugins/myplugin/myplugin.php
16 * Which contains a class like this:
19 * $name = "My plugin";
20 * $author = "Joe Bloggs";
22 * $desc = "This is my plugin and it does stuff";
24 * // rest of code here...
27 * Your plugin class must be constructable and contain the following public variables:
28 * $name The name or title of your plugin.
29 * $author The name of the author
30 * $version The version of the plugin
31 * $description A short description of the plugin
37 static function load($modname)
39 $plugin = new Plugin($modname);
42 Message
::Fail("Warning: Plugin \"$modname\" failed to load: $plugin->error");
46 self
::$list[] = $plugin;
60 function __construct($handle)
62 if (!is_dir("plugins/$handle"))
63 $this->error = "Plugin directory \"plugins
/$handle\" doesn
't exist";
65 else if (!is_file("plugins/$handle/$handle.php"))
66 $this->error = "Plugin file \"plugins/$handle/$handle.php\" doesn't exist
";
70 require_once "plugins
/$handle/$handle.php
";
72 if (!class_exists($handle))
73 $this->error = "Class \"$handle\" doesn
't exist";
77 $plugin = new $handle();
79 if (!isset($plugin->name))
80 $this->error = "Plugin name not defined";
81 elseif (!isset($plugin->author))
82 $this->error = "Plugin author not defined";
83 elseif (!isset($plugin->version))
84 $this->error = "Plugin version not defined";
85 elseif (!isset($plugin->description))
86 $this->error = "Plugin description not defined";
89 $this->handle = $handle;
90 $this->name = $plugin->name;
91 $this->author = $plugin->author;
92 $this->version = $plugin->version;
93 $this->description = $plugin->description;
100 if (defined('PLUGINS
'))
102 foreach(PLUGINS as $plugin)
103 Plugins::load($plugin);