You are here

function panels_ajax_toggle_shown in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/display_edit.inc \panels_ajax_toggle_shown()

Entry point for AJAX: toggle pane show/hide status.

Parameters

int $did: The display id for the display object currently being edited. Errors out silently if absent.

int $pid: The pane id for the pane object whose show/hide state we're toggling.

string $op: The operation - showing or hiding - that this should perform. This could be calculated from cached values, but given that this is a toggle button and people may click it too fast, it's better to leave the decision on which $op to use up to the js than to calculate it here.

Related topics

1 string reference to 'panels_ajax_toggle_shown'
panels_menu in ./panels.module
Implementation of hook_menu

File

includes/display-edit.inc, line 688

Code

function panels_ajax_toggle_shown($op, $did = NULL, $pid = NULL) {
  panels_load_include('plugins');
  panels_load_include('ajax');
  if (!is_numeric($did) && $did != 'new' || !($cache = panels_cache_get('display', $did))) {
    panels_ajax_render(t('Invalid display id.'));
  }
  if (empty($cache->display->content[$pid])) {
    panels_ajax_render(t('Invalid pane id.'));
  }
  $pane =& $cache->display->content[$pid];
  $pane->shown = $op == 'show';
  panels_cache_set('display', $did, $cache);
  $output = new stdClass();
  $output->type = 'replace';
  $output->id = "#panel-pane-{$pane->pid}";
  $output->output = panels_show_pane($cache->display, $pane, TRUE);
  panels_ajax_render($output);
}