SettingsForm.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @file
  4. * SettingsForm.php
  5. *
  6. * @author: Frédéric G. MARAND <fgm@osinet.fr>
  7. *
  8. * @copyright (c) 2015 Ouest Systèmes Informatiques (OSInet).
  9. *
  10. * @license General Public License version 2 or later
  11. */
  12. namespace OSInet\Splash;
  13. class SettingsForm {
  14. /**
  15. * @var array
  16. */
  17. public $form;
  18. /**
  19. * @var array
  20. */
  21. public $state;
  22. public function __construct(array $form, array &$form_state) {
  23. $this->form = $form;
  24. $this->state = $form_state;
  25. }
  26. public function build() {
  27. $form = $this->form;
  28. $form['splash-source'] = [
  29. '#title' => t('Source selector'),
  30. '#description' => t('The jQuery selector for the source container'),
  31. '#type' => 'textfield',
  32. '#default_value' => variable_get('splash-source', 'body'),
  33. ];
  34. $form['splash-destination'] = [
  35. '#title' => t('Destination selector'),
  36. '#description' => t('The jQuery selector for the destination container. If empty, the splash will just disappear after the timeout.'),
  37. '#type' => 'textfield',
  38. '#default_value' => variable_get('splash-destination', ''),
  39. ];
  40. $form['splash-timeout'] = [
  41. '#title' => t('Timeout'),
  42. '#description' => t('The number of milliseconds during which to display the splash.'),
  43. '#type' => 'textfield',
  44. '#size' => 5,
  45. '#default_value' => variable_get('splash-timeout', 3),
  46. ];
  47. $form['splash-body'] = [
  48. '#title' => t('Splash content'),
  49. '#description' => t('The content inserted as the splash. This is raw text, so be cautious. It will typically be something like &lt;img src="somepath.png" /&gt;'),
  50. '#type' => 'textarea',
  51. '#rows' => 5,
  52. '#cols' => 80,
  53. '#default_value' => variable_get('splash-body', ''),
  54. ];
  55. $form = system_settings_form($form);
  56. return $form;
  57. }
  58. }