You are here

function panels_cache_object::cache in Panels 6.3

Same name and namespace in other branches
  1. 5.2 includes/plugins.inc \panels_cache_object::cache()
  2. 6.2 includes/plugins.inc \panels_cache_object::cache()
  3. 7.3 includes/plugins.inc \panels_cache_object::cache()

Set the object for storing. This overwrites.

File

includes/plugins.inc, line 151
Contains helper code for plugins and contexts.

Class

panels_cache_object
An object to hold caching information while it is happening.

Code

function cache() {
  if ($this->ready) {
    return;
  }
  $this->ready = TRUE;

  // Simple replacement for head
  $this->head = str_replace($this->head, '', drupal_set_html_head());

  // Slightly less simple for CSS:
  $css = drupal_add_css();
  $start = $this->css;
  $this->css = array();
  foreach ($css as $media => $medias) {
    foreach ($medias as $type => $types) {
      foreach ($types as $path => $preprocess) {
        if (!isset($start[$media][$type][$path])) {
          $this->css[] = array(
            $path,
            $type,
            $media,
            $preprocess,
          );
        }
      }
    }
  }
  $js = array();

  // A little less simple for js
  foreach (array(
    'header',
    'footer',
  ) as $scope) {
    $js[$scope] = drupal_add_js(NULL, NULL, $scope);
  }
  $start = $this->js;
  $this->js = array();
  foreach ($js as $scope => $scopes) {
    foreach ($scopes as $type => $types) {
      foreach ($types as $id => $info) {
        if (!isset($start[$scope][$type][$id])) {
          switch ($type) {
            case 'setting':
              $this->js[] = array(
                $info,
                $type,
                $scope,
              );
              break;
            case 'inline':
              $this->js[] = array(
                $info['code'],
                $type,
                $scope,
                $info['defer'],
              );
              break;
            default:
              $this->js[] = array(
                $id,
                $type,
                $scope,
                $info['defer'],
                $info['cache'],
              );
          }
        }
      }
    }
  }

  // And for tokens:
  $tokens = ctools_set_page_token();
  foreach ($this->tokens as $token => $argument) {
    if (isset($tokens[$token])) {
      unset($tokens);
    }
  }
  $this->tokens = $tokens;
}