start.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Start file for the plugin, is loaded when all active plugins are loaded
  4. *
  5. * @package tag_tools
  6. */
  7. require_once(dirname(__FILE__) . "/lib/hooks.php");
  8. require_once(dirname(__FILE__) . "/lib/functions.php");
  9. require_once(dirname(__FILE__) . "/lib/events.php");
  10. // register default Elgg events
  11. elgg_register_event_handler("init", "system", "tag_tools_init");
  12. /**
  13. * This function is called during the "init" event
  14. *
  15. * @return void
  16. */
  17. function tag_tools_init() {
  18. elgg_register_event_handler("pagesetup", "system", "tag_tools_pagesetup");
  19. // register js/ss lib
  20. elgg_define_js("jquery.tag-it", array("src" => "mod/tag_tools/vendors/jquery/tag_it/js/tag-it.min.js"));
  21. elgg_extend_view("css/elgg", "css/tag_tools/jquery.tagit.css");
  22. elgg_extend_view("css/elgg", "css/tag_tools/follow");
  23. elgg_extend_view("js/elgg", "js/tag_tools/follow");
  24. // extend views
  25. elgg_extend_view("input/tags", "tag_tools/extend_tags");
  26. // register events
  27. elgg_register_event_handler("create", "metadata", "tag_tools_create_metadata_event_handler");
  28. // plugin hooks
  29. elgg_register_plugin_hook_handler("route", "tags", "tag_tools_route_tags_hook");
  30. elgg_register_plugin_hook_handler("route", "activity", "tag_tools_route_activity_hook");
  31. elgg_register_plugin_hook_handler("route", "notifications", "tag_tools_route_notifications_hook");
  32. elgg_register_plugin_hook_handler("register", "menu:filter", "tag_tools_activity_filter_menu_hook_handler");
  33. // widgets
  34. elgg_register_widget_type("follow_tags", elgg_echo("tag_tools:widgets:follow_tags:title"), elgg_echo("tag_tools:widgets:follow_tags:description"), array("profile", "dashboard"));
  35. // actions
  36. elgg_register_action("tag_tools/follow_tag", dirname(__FILE__) . "/actions/follow_tag.php");
  37. elgg_register_action("tag_tools/notifications/edit", dirname(__FILE__) . "/actions/notifications/edit.php");
  38. }
  39. /**
  40. * This function is called during the "pagesetup" event
  41. *
  42. * @return void
  43. */
  44. function tag_tools_pagesetup() {
  45. if (!elgg_is_logged_in() || !elgg_in_context("settings")) {
  46. return;
  47. }
  48. $user = elgg_get_page_owner_entity();
  49. if (!$user) {
  50. $user = elgg_get_logged_in_user_entity();
  51. }
  52. $params = array(
  53. "name" => "tag_notifications",
  54. "text" => elgg_echo("tag_tools:notifications:menu"),
  55. "href" => "notifications/tag/" . $user->username,
  56. "section" => "notifications",
  57. );
  58. elgg_register_menu_item("page", $params);
  59. }