You are here

function _cache_actions_load_panes in Cache Actions 7

Same name and namespace in other branches
  1. 6.2 cache_actions.rules.inc \_cache_actions_load_panes()
  2. 7.2 cache_actions.rules.inc \_cache_actions_load_panes()
1 call to _cache_actions_load_panes()
_cache_actions_get_panels_handlers in ./cache_actions.rules.inc
Get all existing handlers from page manager. This is the ugliest function in the whole module =)

File

./cache_actions.rules.inc, line 310
This file provides the rules integration for this module.

Code

function _cache_actions_load_panes($handler, $handler_title, $js = FALSE) {
  ctools_include('plugins', 'panels');
  $available_panes = array();
  $js_panes = array();
  if (isset($handler->did)) {
    $display = panels_load_display($handler->did);
  }
  else {
    $display = $handler->conf['display'];
  }
  if (isset($display->content)) {
    foreach ($display->content as $pane) {
      if ($pane->cache['method'] == 'rules') {

        // We can't satisfy a context here, so we only get the title if no context is set.
        if (empty($pane->configuration['context'])) {
          $pane_title = panels_get_pane_title($pane);
        }
        else {
          $pane_title = $pane->subtype;
        }
        $available_panes[$handler_title][$pane->pid] = $pane_title;
        if (isset($handler->did)) {
          $js_panes[$handler->did][$pane->pid] = $pane_title;
        }
        else {
          $js_panes[$handler->name . ':' . $handler->task . (!empty($handler->subtask) ? ':' . $handler->subtask : '')][$pane->pid] = $pane_title;
        }
      }
    }
  }
  if ($js) {
    return array(
      $available_panes,
      $js_panes,
    );
  }
  return $available_panes;
}