You are here

function context_reaction_addassets_base::execute in Context Add Assets 6

Same name and namespace in other branches
  1. 7 plugins/context_reaction_addassets_base.inc \context_reaction_addassets_base::execute()

Implementation of the built-in context plugin class execution

File

plugins/context_reaction_addassets_base.inc, line 92
The Context reaction plugin to add asset files

Class

context_reaction_addassets_base
Expose themes as context reactions.

Code

function execute() {
  $contexts = context_active_contexts();
  $classes = array();
  foreach ($contexts as $key => $value) {
    if (!empty($value->reactions[$this->plugin])) {
      foreach ($value->reactions[$this->plugin] as $path_array) {
        if (is_array($path_array)) {
          foreach ($path_array as $path) {
            if ($path) {
              $ext = explode('.', $path);
              $ext = drupal_strtolower($ext[count($ext) - 1]);
              switch ($ext) {
                case 'js':
                  drupal_add_js($path, 'module');
                  break;
                case 'css':
                  drupal_add_css($path, 'theme', 'all', TRUE);
                  break;
              }
            }
          }
        }
      }
    }
  }
}