context_reaction_css_injector.inc 948 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class context_reaction_css_injector extends context_reaction {
  3. function options_form($context) {
  4. $list = array();
  5. foreach (_css_injector_load_rule() as $css_rule) {
  6. $list[$css_rule['crid']] = $css_rule['title'];
  7. }
  8. ksort($list);
  9. return array(
  10. '#title' => $this->title,
  11. '#description' => $this->description,
  12. '#options' => $list,
  13. '#type' => 'checkboxes',
  14. '#default_value' => $this->fetch_from_context($context),
  15. );
  16. }
  17. function execute() {
  18. $contexts = $this->get_contexts();
  19. foreach ($contexts as $context) {
  20. if (!empty($context->reactions[$this->plugin])) {
  21. foreach ($context->reactions[$this->plugin] as $crid => $enabled) {
  22. if ($enabled && $css_rule = _css_injector_load_rule($crid)) {
  23. drupal_add_css(_css_injector_rule_uri($crid), 'module', $css_rule['media'], $css_rule['preprocess']);
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }