From 2b74984974b8363aa2bf197fb1d3950f7425a878 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sun, 8 Jan 2012 13:48:20 +0100 Subject: Improved Plugin API. --- ratatoeskr/sys/plugin_api.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'ratatoeskr') diff --git a/ratatoeskr/sys/plugin_api.php b/ratatoeskr/sys/plugin_api.php index e8f1a2c..797f42d 100644 --- a/ratatoeskr/sys/plugin_api.php +++ b/ratatoeskr/sys/plugin_api.php @@ -15,15 +15,15 @@ require_once(dirname(__FILE__) . "/../frontend.php"); /* * Constant: APIVERSION - * The current API version (3). + * The current API version (4). */ -define("APIVERSION", 3); +define("APIVERSION", 4); /* * Array: $api_compat * Array of API versions, this version is compatible to (including itself). */ -$api_compat = array(3); +$api_compat = array(3, 4); $url_handlers = array(); /* @@ -158,6 +158,8 @@ abstract class RatatoeskrPlugin * * Your $fx should output output the result of a STE template, which should load "/systemtemplates/master.html" and overwrite the "content" section. * + * If you need a URL to your pluginpage, you can use and the STE variable $rel_path_to_pluginpage. + * * See also: * */ @@ -167,7 +169,28 @@ abstract class RatatoeskrPlugin $this->ste->vars["pluginpages"][$this->id] = $label; sort($this->ste->vars["pluginpages"]); - $pluginpages_handlers["p{$this->id}"] = $fx; + $pluginid = $this->id; + $pluginpages_handlers["p{$this->id}"] = function(&$data, $url_now, &$url_next) use($pluginid, $fx) + { + global $ste, $rel_path_to_root; + $ste->vars["rel_path_to_pluginpage"] = "$rel_path_to_root/backend/pluginpages/p$pluginid"; + $rv = $fx($data, $url_now, $url_next); + unset($ste->vars["rel_path_to_pluginpage"]); + return $rv; + }; + } + + /* + * Function: get_backend_pluginpage_url + * Get the URL to your backend plugin page. + * + * Returns: + * The URL to your backend plugin page. + */ + final protected function get_backend_pluginpage_url() + { + global $rel_path_to_root; + return "$rel_path_to_root/backend/pluginpages/p{$this->id}"; } /* -- cgit v1.2.3-54-g00ecf