You are here

function panels_ajax_add_config in Panels 5.2

Entry point for AJAX: Add pane configuration.

After updating the $cache data and equipping a new $pane object with basic values, the general-purpose ajax form handler, panels_ajax_form(), is called and pushes the configuration form to the screen.

Once form submission is completed, data is pushed back into js by panels_ajax_render().

Parameters

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

string $pane_info: A string generated by the following code in panels_add_content(): \n

$output .= l($link_text, 'javascript: void()', array(
  'class' => 'panels-modal-add-config',
  'id' => $type_name . '-' . $panel_id . '-' . $subtype_name,
), NULL, NULL, NULL, TRUE);

\n $type_name contains the name of the content type, $panel_id the name of the panel region to which the pane will be added, and $subtype_name is the name of the content subtype.

See also

panels_content_config_form()

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

File

includes/display_edit.inc, line 889

Code

function panels_ajax_add_config($did = NULL, $pane_info = NULL) {
  if ((is_numeric($did) || $did == 'new') && ($cache = panels_cache_get($did))) {
    if (!isset($_POST['form_id'])) {
      $pid = $cache->display
        ->next_new_pid();
      $pane = new stdClass();
      $pane->pid = "new-{$pid}";

      // Ensure there's no data relics.
      unset($cache->content_config[$pane->pid], $cache->pane);
      $cc =& $cache->content_config[$pane->pid];
      list($cc['content_type'], $cc['panel_id'], $cc['content_subtype']) = explode('-', $pane_info, 3);
      list($pane->type, $pane->subtype, $pane->configuration, $pane->access) = array(
        $cc['content_type'],
        $cc['content_subtype'],
        array(),
        array(),
      );
      _panels_ajax_ct_preconfigure($cache, $pane);
      $cache->pane = drupal_clone($pane);
      panels_cache_set($did, $cache);
    }
    else {

      // Not the render passthrough, so the above data has been cached; we retrieve $pane from $cache.
      $pane = $cache->pane;
      unset($cache->pane);
    }
    $ajax_vars = panels_ajax_form('panels_content_config_form', t('Configure !subtype_title', array(
      '!subtype_title' => $cache->content_config[$pane->pid]['ct_data']['subtype']['title'],
    )), url($_GET['q'], NULL, NULL, TRUE), $cache, $pane, TRUE);
    panels_ajax_render($ajax_vars);
  }
  panels_ajax_render();
}