You are here

function panels_ajax_toggle_shown in Panels 5.2

Same name and namespace in other branches
  1. 6.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.

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

File

includes/display_edit.inc, line 844

Code

function panels_ajax_toggle_shown($did = NULL, $pid = NULL, $op = NULL) {
  if ((is_numeric($did) || $did == 'new') && ($cache = panels_cache_get($did))) {
    $ajax_vars = new stdClass();
    list($ajax_vars->type, $ajax_vars->id, $ajax_vars->old_op) = array(
      'toggle-shown',
      $pid,
      drupal_strtolower($op),
    );
    if ($op == 'Show') {
      list($cache->display->content[$pid]->shown, $ajax_vars->output, $ajax_vars->new_op) = array(
        1,
        'Hide',
        'hide',
      );
    }
    elseif ($op == 'Hide') {
      list($cache->display->content[$pid]->shown, $ajax_vars->output, $ajax_vars->new_op) = array(
        0,
        'Show',
        'show',
      );
    }
    else {

      // bad args, error out.
      panels_ajax_render();
    }
    panels_cache_set($cache->display->did, $cache);
    panels_ajax_render($ajax_vars);
  }
  panels_ajax_render();
}