start.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. define("FILE_TOOLS_SUBTYPE", "folder");
  3. define("FILE_TOOLS_RELATIONSHIP", "folder_of");
  4. define("FILE_TOOLS_BASEURL", elgg_get_site_url() . "file_tools/");
  5. require_once(dirname(__FILE__) . "/lib/functions.php");
  6. require_once(dirname(__FILE__) . "/lib/events.php");
  7. require_once(dirname(__FILE__) . "/lib/hooks.php");
  8. require_once(dirname(__FILE__) . "/lib/page_handlers.php");
  9. // register default Elgg events
  10. elgg_register_event_handler("init", "system", "file_tools_init");
  11. elgg_register_event_handler("pagesetup", "system", "file_tools_pagesetup");
  12. /**
  13. * Called during system initialization
  14. *
  15. * @return void
  16. */
  17. function file_tools_init() {
  18. // extend CSS
  19. elgg_extend_view("css/elgg", "css/file_tools/site");
  20. $vendors = elgg_get_site_url() . "mod/file_tools/vendors/";
  21. // register JS libraries
  22. elgg_define_js('jquery.uploadify', array(
  23. 'src' => '/mod/file_tools/vendors/uploadify/jquery.uploadify-3.1.min.js',
  24. 'deps' => array('jquery'),
  25. ));
  26. elgg_register_simplecache_view("css/uploadify/uploadify");
  27. elgg_register_css("jquery.uploadify", elgg_get_simplecache_url("css", "uploadify/uploadify"));
  28. elgg_register_css("jquery.tree", $vendors . "jstree/dist/themes/default/style.css");
  29. elgg_define_js('jquery.tree', array(
  30. 'src' => $vendors . 'jstree/dist/jstree.min.js',
  31. 'deps' => array('jquery'),
  32. ));
  33. elgg_define_js('jquery.hashchange', array(
  34. 'src' => '/mod/file_tools/vendors/hashchange/jquery.hashchange.js',
  35. 'exports' => 'jQuery.fn.hashchange',
  36. 'deps' => array('jquery'),
  37. ));
  38. // Make settings file loadable through AMD
  39. elgg_register_simplecache_view('js/file_tools/settings.js');
  40. // extend views
  41. elgg_extend_view("groups/edit", "file_tools/group_settings");
  42. // register page handler for nice URL's
  43. elgg_register_page_handler("file_tools", "file_tools_page_handler");
  44. // make our own URLs for folder icons
  45. elgg_register_plugin_hook_handler("entity:icon:url", "object", "file_tools_folder_icon_hook");
  46. // register group option to allow management of file tree structure
  47. add_group_tool_option("file_tools_structure_management", elgg_echo("file_tools:group_tool_option:structure_management"));
  48. // register widgets
  49. // add folder widget
  50. // need to keep file_tree for the widget name to be compatible with previous filetree plugin users
  51. elgg_register_widget_type("file_tree", elgg_echo("widgets:file_tree:title"), elgg_echo("widgets:file_tree:description"), array("dashboard", "profile", "groups"), true);
  52. // group files
  53. elgg_register_widget_type("group_files", elgg_echo("file:group"), elgg_echo("widgets:group_files:description"), array("groups"));
  54. // index files
  55. elgg_register_widget_type("index_file", elgg_echo("file"), elgg_echo("widgets:index_file:description"), array("index"), true);
  56. // register events
  57. elgg_register_event_handler("create", "object", "file_tools_object_handler");
  58. elgg_register_event_handler("update", "object", "file_tools_object_handler");
  59. elgg_register_event_handler("delete", "object", "file_tools_object_handler_delete");
  60. // register hooks
  61. elgg_register_plugin_hook_handler("register", "menu:entity", "file_tools_entity_menu_hook");
  62. elgg_register_plugin_hook_handler("permissions_check:metadata", "object", "file_tools_can_edit_metadata_hook");
  63. // elgg_register_plugin_hook_handler("access:collections:write", "all", "file_tools_write_acl_plugin_hook", 550);
  64. elgg_register_plugin_hook_handler("route", "file", "file_tools_file_route_hook");
  65. elgg_register_plugin_hook_handler("widget_url", "widget_manager", "file_tools_widget_url_hook");
  66. elgg_register_plugin_hook_handler("entity:url", "object", "file_tools_folder_url_handler");
  67. elgg_register_plugin_hook_handler("register", "menu:file_tools_folder_breadcrumb", "file_tools_folder_breadcrumb_hook");
  68. elgg_register_plugin_hook_handler("register", "menu:file_tools_folder_sidebar_tree", "file_tools_folder_sidebar_tree_hook");
  69. // register actions
  70. elgg_register_action("file_tools/groups/save_sort", dirname(__FILE__) . "/actions/groups/save_sort.php");
  71. elgg_register_action("file_tools/folder/edit", dirname(__FILE__) . "/actions/folder/edit.php");
  72. elgg_register_action("file_tools/folder/delete", dirname(__FILE__) . "/actions/folder/delete.php");
  73. elgg_register_action("file_tools/folder/reorder", dirname(__FILE__) . "/actions/folder/reorder.php");
  74. elgg_register_action("file_tools/upload/zip", dirname(__FILE__) . "/actions/upload/zip.php");
  75. elgg_register_action("file_tools/folder/delete", dirname(__FILE__) . "/actions/folder/delete.php");
  76. elgg_register_action("file_tools/file/hide", dirname(__FILE__) . "/actions/file/hide.php");
  77. elgg_register_action("file/move", dirname(__FILE__) . "/actions/file/move.php");
  78. elgg_register_action("file/bulk_delete", dirname(__FILE__) . "/actions/file/bulk_delete.php");
  79. }
  80. /**
  81. * Called during pagesetup
  82. *
  83. * @return void
  84. */
  85. function file_tools_pagesetup() {
  86. $page_owner = elgg_get_page_owner_entity();
  87. if (empty($page_owner) || !elgg_instanceof($page_owner, "group")) {
  88. return;
  89. }
  90. // check if the group hase files enabled
  91. if ($page_owner->files_enable == "no") {
  92. // no, so remove the widgets
  93. elgg_unregister_widget_type("file_tree");
  94. elgg_unregister_widget_type("group_files");
  95. }
  96. }