]>
Commit | Line | Data |
---|---|---|
8dcb2b47 AD |
1 | <?php |
2 | class Example_Routing extends Plugin implements IHandler { | |
3 | ||
4 | // Demonstrates adding a custom handler and method: | |
5 | // backend.php?op=test&method=example | |
6 | // and masking a system builtin public method: | |
7 | // public.php?op=getUnread | |
8 | ||
9 | // Plugin class must implelement IHandler interface and has | |
10 | // a public method of same name as being registered. | |
11 | // | |
6cbe53c9 AD |
12 | // Any system method may be masked by plugins. You can mask |
13 | // entire handler by supplying "*" instead of a method name. | |
8dcb2b47 AD |
14 | |
15 | private $link; | |
16 | private $host; | |
17 | ||
18 | function __construct($host) { | |
19 | $this->link = $host->get_link(); | |
20 | $this->host = $host; | |
21 | ||
22 | $host->add_handler("test", "example", $this); | |
23 | $host->add_handler("public", "getunread", $this); | |
24 | } | |
25 | ||
26 | function getunread() { | |
27 | print rand(0,100); # yeah right | |
28 | } | |
29 | ||
30 | function example() { | |
31 | print "example method called"; | |
32 | } | |
33 | ||
34 | function csrf_ignore($method) { | |
35 | return true; | |
36 | } | |
37 | ||
38 | function before($method) { | |
39 | return true; | |
40 | } | |
41 | ||
42 | function after() { | |
43 | return true; | |
44 | } | |
45 | ||
46 | } | |
47 | ?> |