HelloPlugin works now.
[viewgit.git] / inc / plugins.php
blobc1e22ff54ee5cfd4cb572a7ab920615149a369f1
1 <?php
3 $plugin_actions = array(); // action -> plugin object
4 $plugin_hooks = array();
6 function call_hooks($type) {
7 global $plugin_hooks;
8 foreach ($plugin_hooks as $type => $classes) {
9 foreach ($classes as $class) {
10 $class->hook($type);
15 /**
16 * Base class plugins should extend. This defines the public, hopefully
17 * somewhat static API plugins should be able to rely on.
19 * Plugins go to plugins/name/main.php and must contain a NamePlugin class.
21 class VGPlugin
23 /**
24 * Actions, hooks and other things must be initialized/registered here.
26 function __construct() {
30 /**
31 * Called when a registered action is triggered.
33 function action($action) {}
35 /**
36 * Called when a registered hook is triggered.
38 function hook($type) {}
40 /**
41 * Can be used to output xhtml.
43 function output($xhtml) {
44 echo($xhtml);
47 /**
48 * Registers the given action for this plugin.
50 function register_action($action) {
51 global $plugin_actions;
52 $plugin_actions[$action] = $this;
55 function register_hook($type) {
56 global $plugin_hooks;
57 $plugin_hooks[$type][] = $this;