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 * Display the given template.
39 function display_plugin_template($template, $with_headers = true) {
40 $name = 'plugins/'. $this->get_name() .'/templates/'. $template .'.php';
41 $this->display_template($name, $with_headers);
45 * Return the name of this plugin, for example: "hello".
48 $name = get_class($this);
49 return strtolower(str_replace('Plugin', '', $name));
53 * Called when a registered hook is triggered.
56 * header - before closing the head tag
57 * summary - add to summary page
58 * page_start - after body is opened
59 * footer - before closing the body tag
60 * pagenav - $page['links'] can be modified to add more pagenav links, see templates/header.php
62 function hook($type) {}
65 * Can be used to output xhtml.
67 function output($xhtml) {
72 * Registers the given action for this plugin.
74 function register_action($action) {
75 self
::$plugin_actions[$action] = $this;
78 function register_hook($type) {
79 self
::$plugin_hooks[$type][] = $this;
82 // Static members + methods
84 public static $plugin_actions = array();
85 public static $plugin_hooks = array();
88 * Call plugin hooks of given type.
89 * @see VGPlugin::register_hook()
91 static function call_hooks($type) {
92 if (in_array($type, array_keys(self
::$plugin_hooks))) {
93 foreach (self
::$plugin_hooks[$type] as $class) {