You are here

function panels_content_config_form in Panels 6.2

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

Master FAPI definition for all pane add/edit configuration forms.

Parameters

object $cache: The $cache object for the panels $display currently being edited.

object $pane: The $pane object currently being added/edited.

bool $add: A boolean indicating whether we are adding a new pane ($add === TRUE) operation in this operation, or editing an existing pane ($add === FALSE).

Return value

array $form A structured FAPI form definition, having been passed through all the appropriate content-type specific callbacks.

Related topics

2 string references to 'panels_content_config_form'
panels_ajax_add_pane_config in includes/display-edit.inc
AJAX entry point for to configure a pane that has just been added.
panels_ajax_configure_pane in includes/display-edit.inc
AJAX entry point for to configure a pane that has just been added.

File

includes/display-edit.inc, line 572

Code

function panels_content_config_form(&$form_state) {
  $display =& $form_state['display'];
  $pane =& $form_state['pane'];
  $type = $form_state['type'];
  $subtype = $form_state['subtype'];
  $op = $form_state['op'];
  $form['configuration'] = panels_ct_conf_form($type, $subtype, $display->context, $pane->configuration);
  if (is_array($form_additions = panels_ct_pane_config_form($pane, $display->context, array(
    'configuration',
  ), $op))) {
    $form['configuration'] += $form_additions;
  }
  $form['configuration']['#tree'] = TRUE;
  $ignore_roles = empty($type['role-based access']);
  if ($visibility_function = panels_plugin_get_function('content_types', $type, 'visibility control')) {
    $ignore_roles = TRUE;
    if (isset($type['roles and visibility']) && $type['roles and visibility'] === TRUE) {
      $ignore_roles = FALSE;
    }
  }
  if (!$ignore_roles) {
    if (user_access('administer pane access')) {
      $form['access'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Access'),
        '#default_value' => $pane->access,
        '#options' => user_roles(TRUE),
        '#description' => t('Only the checked roles will be able to see this pane; if no roles are checked, access will not be restricted.'),
      );
    }
    else {
      $form['access'] = array(
        '#type' => 'value',
        '#value' => isset($pane->access) ? $pane->access : array(),
      );
    }
  }
  if (isset($visibility_function)) {
    $form['visibility'] = $visibility_function($display->context, $pane->subtype, $pane->configuration, $form_state['op'] == 'add');
  }
  $form['next'] = array(
    '#type' => 'submit',
    '#value' => $op == 'add' ? t('Add pane') : t('Save'),
  );

  // Allows content types that define this callback to have full control over the pane config form.

  /* @todo -- make this work
    if (isset($cc['form_controller'])) {
      call_user_func_array($cc['form_controller'], array(&$form, &$cache->content_config[$pane->pid], &$cache->display, $add));
    }
  */
  return $form;
}