start.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. elgg_register_event_handler('init', 'system', 'gallery_field_init');
  3. function gallery_field_init()
  4. {
  5. // Register library
  6. elgg_register_library('elgg:gallery_field', __DIR__ . '/lib/gallery_field.php');
  7. // Extend CSS
  8. elgg_extend_view('css/elgg', 'gallery_field/css');
  9. // Javascript
  10. elgg_register_js('gallery_field_editor', '/mod/gallery_field/assets/gallery_field_editor.js');
  11. // Page handler for editor
  12. elgg_register_page_handler('gallery_field_image', 'gallery_field_image_page_handler');
  13. //Register actions
  14. $action_path = __DIR__."/actions";
  15. elgg_register_action("gallery_field/upload", "$action_path/upload.php");
  16. if(elgg_get_plugin_setting("enable_blog", "gallery_field") == 'yes')
  17. {
  18. elgg_extend_view('object/blog', 'gallery_field/images_list');
  19. }
  20. if(elgg_get_plugin_setting("enable_pages", "gallery_field") == 'yes')
  21. {
  22. elgg_extend_view('object/page_top', 'gallery_field/images_list');
  23. }
  24. }
  25. function gallery_field_image_page_handler($page)
  26. {
  27. elgg_load_library('elgg:gallery_field');
  28. $image_id = elgg_extract(0, $page);
  29. if($image_id == 'delete')
  30. {
  31. gallery_field_delete_images();
  32. }
  33. elseif($image_id == 'save_sort')
  34. {
  35. gallery_field_save_sort();
  36. }
  37. else
  38. {
  39. $size = elgg_extract(1, $page, "default");
  40. gallery_field_show_image($image_id, $size);
  41. }
  42. return true;
  43. }