quark.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Grav\Theme;
  3. use Grav\Common\Grav;
  4. use Grav\Common\Theme;
  5. class Quark extends Theme
  6. {
  7. public static function getSubscribedEvents()
  8. {
  9. return [
  10. 'onThemeInitialized' => ['onThemeInitialized', 0],
  11. 'onTwigLoader' => ['onTwigLoader', 0],
  12. 'onTwigInitialized' => ['onTwigInitialized', 0],
  13. ];
  14. }
  15. public function onThemeInitialized()
  16. {
  17. }
  18. // Add images to twig template paths to allow inclusion of SVG files
  19. public function onTwigLoader()
  20. {
  21. $theme_paths = Grav::instance()['locator']->findResources('theme://images');
  22. foreach(array_reverse($theme_paths) as $images_path) {
  23. $this->grav['twig']->addPath($images_path, 'images');
  24. }
  25. }
  26. public function onTwigInitialized()
  27. {
  28. $twig = $this->grav['twig'];
  29. $form_class_variables = [
  30. // 'form_outer_classes' => 'form-horizontal',
  31. 'form_button_outer_classes' => 'button-wrapper',
  32. 'form_button_classes' => 'btn',
  33. 'form_errors_classes' => '',
  34. 'form_field_outer_classes' => 'form-group',
  35. 'form_field_outer_label_classes' => 'form-label-wrapper',
  36. 'form_field_label_classes' => 'form-label',
  37. // 'form_field_outer_data_classes' => 'col-9',
  38. 'form_field_input_classes' => 'form-input',
  39. 'form_field_textarea_classes' => 'form-input',
  40. 'form_field_select_classes' => 'form-select',
  41. 'form_field_radio_classes' => 'form-radio',
  42. 'form_field_checkbox_classes' => 'form-checkbox',
  43. ];
  44. $twig->twig_vars = array_merge($twig->twig_vars, $form_class_variables);
  45. }
  46. }