start.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace AU\ViewsCounter;
  3. const PLUGIN_ID = 'views_counter';
  4. require_once __DIR__ . '/lib/functions.php';
  5. elgg_register_event_handler('init', 'system', __NAMESPACE__ . '\\init');
  6. /**
  7. * INIT
  8. */
  9. function init() {
  10. // Try to add a views counter for the entities selected through the plugin settings
  11. set_views_counter();
  12. elgg_register_page_handler('views_counter', __NAMESPACE__ . '\\views_counter_page_handler');
  13. elgg_extend_view('css/elgg', 'css/views_counter');
  14. elgg_extend_view('css/admin', 'css/views_counter');
  15. elgg_register_action('views_counter/settings/save', __DIR__ . '/actions/views_counter/settings/save.php', 'admin');
  16. elgg_register_admin_menu_item('administer', 'views_counter', 'statistics');
  17. }
  18. /**
  19. * To control the views_counter pages exhibition
  20. *
  21. * @param $page
  22. */
  23. function views_counter_page_handler($page) {
  24. if (isset($page[0])) {
  25. $return = FALSE;
  26. switch ($page[0]) {
  27. case 'list_entities':
  28. set_input('entity_type', $page[1]);
  29. if (include(elgg_get_plugins_path() . 'views_counter/admin_page.php')) {
  30. $return = TRUE;
  31. }
  32. break;
  33. }
  34. }
  35. return $return;
  36. }