context_reaction_theme_html.inc 1008 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Expose themes as context reactions.
  4. */
  5. class context_reaction_theme_html extends context_reaction_theme {
  6. /**
  7. * Allow admins to provide additional body classes.
  8. */
  9. function options_form($context) {
  10. $values = $this->fetch_from_context($context);
  11. $form = array(
  12. 'class' => array(
  13. '#title' => t('Section class'),
  14. '#description' => t('Provides this text as an additional body class (in <strong>$classes</strong> in html.tpl.php) when this section is active.'),
  15. '#type' => 'textfield',
  16. '#maxlength' => 64,
  17. '#default_value' => isset($values['class']) ? $values['class'] : '',
  18. ),
  19. );
  20. return $form;
  21. }
  22. /**
  23. * Set additional classes onto the 'body_classes'.
  24. */
  25. function execute(&$vars) {
  26. $classes = array();
  27. foreach ($this->get_contexts() as $k => $v) {
  28. if (!empty($v->reactions[$this->plugin]['class'])) {
  29. $vars['classes_array'][] = $v->reactions[$this->plugin]['class'];
  30. }
  31. }
  32. }
  33. }