init.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 $host;
  13. function about() {
  14. return array(1.0,
  15. "Example routing plugin",
  16. "fox",
  17. true);
  18. }
  19. function init($host) {
  20. $this->host = $host;
  21. $host->add_handler("test", "example", $this);
  22. $host->add_handler("public", "getunread", $this);
  23. }
  24. function getunread() {
  25. print rand(0,100); # yeah right
  26. }
  27. function example() {
  28. print "example method called";
  29. }
  30. function csrf_ignore($method) {
  31. return true;
  32. }
  33. function before($method) {
  34. return true;
  35. }
  36. function after() {
  37. return true;
  38. }
  39. function api_version() {
  40. return 2;
  41. }
  42. }
  43. ?>