start.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. require_once(dirname(__FILE__) . "/lib/functions.php");
  3. elgg_register_event_handler('init', 'system', 'follow_tags_init');
  4. function follow_tags_init() {
  5. // Load follow-tags configuration
  6. if(elgg_get_plugin_setting("followTags", "follow_tags") == "true") {
  7. // Register Cache-Clear hook after change admin settig
  8. elgg_register_plugin_hook_handler("setting", "plugin", "follow_tags_setting");
  9. //Register Save Action for saving and changing FollowTags
  10. elgg_register_action("follow_tags/save", dirname(__FILE__) . '/action/save_notify.php');
  11. elgg_register_action("follow_tags/activity", dirname(__FILE__) . '/action/save.php');
  12. //Register a River Tab
  13. if (elgg_is_logged_in()) {
  14. $user = elgg_get_logged_in_user_entity();
  15. elgg_register_menu_item('filter', array(
  16. 'name' => 'tags',
  17. 'href' => "/activity/tags",
  18. 'text' => elgg_echo("follow_tags:tab:title"),
  19. 'priority' => 500,
  20. 'contexts' => array('activity'),
  21. ));
  22. //Register a Sidebar Item for Usersettings
  23. elgg_register_menu_item('page', array(
  24. 'name' => "follow_tags",
  25. 'text' => elgg_echo("follow_tags:sidebar:title"),
  26. 'href' => "follow_tags/settings/" . $user->username,
  27. 'context' => "settings",
  28. ));
  29. }
  30. elgg_register_plugin_hook_handler("route", "activity", "follow_tags_route_activity_hook");
  31. //Register Pagehandlers
  32. elgg_register_page_handler('follow_tags', 'follow_tags_page_handler');
  33. }
  34. //Register Pagehandlers
  35. elgg_register_page_handler('follow_tags_data', 'follow_tags_data_page_handler');
  36. //Register JS and CSS for custom taginput field
  37. $js_url = 'mod/follow_tags/vendors/tag-it.min.js';
  38. elgg_register_js('jquery.tagsinput', $js_url);
  39. // Register CSS for TagInput
  40. $css_url = 'mod/follow_tags/vendors/tag-it.css';
  41. elgg_register_css('jquery.tagsinput', $css_url);
  42. // extend tags to include js/css just in time
  43. elgg_extend_view("input/tags", "follow_tags/extends/tags");
  44. // Add a JavaScript Initialization
  45. elgg_extend_view('js/elgg','js/follow_tags/site');
  46. // Run the followtags_notofy function in event is triggerd
  47. elgg_register_event_handler('create', 'object', 'follow_tags_notify', 501);
  48. }
  49. function follow_tags_data_page_handler() {
  50. echo follow_tags_get_all_tags(50);
  51. return true;
  52. }
  53. function follow_tags_route_activity_hook($hook, $type, $return_value, $params) {
  54. $result = $return_value;
  55. if ($page = elgg_extract("segments", $return_value)){
  56. if (elgg_extract(0, $page) == "tags") {
  57. include(dirname(__FILE__) . '/pages/activity/follow_tags.php');
  58. $result = false; // block other page handlers
  59. }
  60. }
  61. return $result;
  62. }
  63. function follow_tags_page_handler($page){
  64. require_once dirname(__FILE__) . '/pages/follow_tags/settings.php';
  65. return true;
  66. }