init.php 1.0 KB

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