summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-12-23 23:05:51 +0400
committerAndrew Dolgov <[email protected]>2012-12-23 23:05:51 +0400
commit8dcb2b47628346226b18940b5cde7849f7a24687 (patch)
treeca3ee70e34095455614f4c2c7f9d69ce9f1ed27c /plugins
parent5cedb389d24861a94c1183d1562900dbe59ee3fb (diff)
implement plugin routing masks, add example plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/example_routing/example_routing.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/example_routing/example_routing.php b/plugins/example_routing/example_routing.php
new file mode 100644
index 000000000..a5c4e6139
--- /dev/null
+++ b/plugins/example_routing/example_routing.php
@@ -0,0 +1,46 @@
+<?php
+class Example_Routing extends Plugin implements IHandler {
+
+ // Demonstrates adding a custom handler and method:
+ // backend.php?op=test&method=example
+ // and masking a system builtin public method:
+ // public.php?op=getUnread
+
+ // Plugin class must implelement IHandler interface and has
+ // a public method of same name as being registered.
+ //
+ // Any system method may be masked by plugins.
+
+ private $link;
+ private $host;
+
+ function __construct($host) {
+ $this->link = $host->get_link();
+ $this->host = $host;
+
+ $host->add_handler("test", "example", $this);
+ $host->add_handler("public", "getunread", $this);
+ }
+
+ function getunread() {
+ print rand(0,100); # yeah right
+ }
+
+ function example() {
+ print "example method called";
+ }
+
+ function csrf_ignore($method) {
+ return true;
+ }
+
+ function before($method) {
+ return true;
+ }
+
+ function after() {
+ return true;
+ }
+
+}
+?>