4 * Base class plugins should extend. This defines the public, hopefully
5 * somewhat static API plugins should be able to rely on.
7 * Plugins go to plugins/name/main.php and must contain a NamePlugin class.
12 * Actions, hooks and other things must be initialized/registered here.
14 function __construct() {
19 * Called when a registered action is triggered.
21 function action($action) {}
24 * Display the given template.
26 function display_template($template, $with_headers = true) {
28 require 'templates/header.php';
32 require 'templates/footer.php';
37 * Called when a registered hook is triggered.
40 * header - before closing the head tag
41 * page_start - after body is opened
42 * footer - before closing the body tag
43 * pagenav - output() can be used to insert content into pagenav.
45 function hook($type) {}
48 * Can be used to output xhtml.
50 function output($xhtml) {
55 * Registers the given action for this plugin.
57 function register_action($action) {
58 self
::$plugin_actions[$action] = $this;
61 function register_hook($type) {
62 self
::$plugin_hooks[$type][] = $this;
65 // Static members + methods
67 public static $plugin_actions = array();
68 public static $plugin_hooks = array();
71 * Call plugin hooks of given type.
72 * @see VGPlugin::register_hook()
74 static function call_hooks($type) {
75 if (in_array($type, array_keys(self
::$plugin_hooks))) {
76 foreach (self
::$plugin_hooks[$type] as $class) {