splash.module 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. use OSInet\Splash\SettingsForm;
  3. use OSInet\Splash\SplashBlock;
  4. /**
  5. * This module provides a splash screen and associated block.
  6. *
  7. * Settings:
  8. * - An image file to display
  9. * - An initial jQuery selector on which to display the splash: can be full
  10. * screen or not
  11. * - An optional later jQuery selector on which to display the image after it
  12. * stopped being displayed on the element targeted by the initial selector
  13. * - A list of pages on which to display the splash, as used by block.module
  14. */
  15. function splash_menu() {
  16. $ret = [];
  17. $ret['admin/structure/block/splash'] = [
  18. 'title' => 'Splash',
  19. 'description' => 'Configure Splash block',
  20. 'page callback' => 'drupal_get_form',
  21. 'page arguments' => ['splash_settings_form'],
  22. 'access arguments' => ['administer blocks'],
  23. 'type' => MENU_LOCAL_ACTION,
  24. ];
  25. return $ret;
  26. }
  27. function splash_block_info() {
  28. $ret = [
  29. SplashBlock::DELTA => SplashBlock::info(),
  30. ];
  31. return $ret;
  32. }
  33. /**
  34. * Implements hook_block_view().
  35. */
  36. function splash_block_view($delta = '') {
  37. if ($delta != SplashBlock::DELTA) {
  38. watchdog('splash', 'Incorrect block delta for display: @delta', ['@delta' => $delta], WATCHDOG_ERROR);
  39. return;
  40. }
  41. return (new SplashBlock())->build();
  42. }
  43. /**
  44. * Form builder for Splash settings.
  45. *
  46. * @param array $form
  47. * @param array $form_state
  48. */
  49. function splash_settings_form(array $form, array &$form_state) {
  50. $form = new SettingsForm($form, $form_state);
  51. $ret = $form->build();
  52. return $ret;
  53. }
  54. /**
  55. * Implements hook_xautoload().
  56. */
  57. function splash_xautoload($api) {
  58. $api->absolute()->addPsr4('OSInet\Splash\\', __DIR__ . '/lib/OSInet/Splash');
  59. }