00001 <?php
00002
00003 class context_reaction_css_injector extends context_reaction {
00004
00005 function options_form($context) {
00006 $list = array();
00007 foreach (_css_injector_load_rule() as $css_rule) {
00008 $list[$css_rule['crid']] = $css_rule['title'];
00009 }
00010 ksort($list);
00011
00012 return array(
00013 '#title' => $this->title,
00014 '#description' => $this->description,
00015 '#options' => $list,
00016 '#type' => 'checkboxes',
00017 '#default_value' => $this->fetch_from_context($context),
00018 );
00019 }
00020
00021 function execute() {
00022 $contexts = $this->get_contexts();
00023 foreach ($contexts as $context) {
00024 if (!empty($context->reactions[$this->plugin])) {
00025 foreach ($context->reactions[$this->plugin] as $crid => $enabled) {
00026 if ($enabled && $css_rule = _css_injector_load_rule($crid)) {
00027 drupal_add_css(_css_injector_rule_uri($crid), 'module', $css_rule['media'], $css_rule['preprocess']);
00028 }
00029 }
00030 }
00031 }
00032 }
00033 }