You are here

function panels_edit_display_settings_form in Panels 7.3

Same name and namespace in other branches
  1. 6.3 includes/display-edit.inc \panels_edit_display_settings_form()

Form for display settings.

1 call to panels_edit_display_settings_form()
panels_edit_display_form in includes/display-edit.inc
Form definition for the panels display editor.

File

includes/display-edit.inc, line 216
Core Panels API include file containing various display-editing functions. This includes all the basic editing forms (content, layout, layout settings) as well as the ajax modal forms associated with them.

Code

function panels_edit_display_settings_form($form, &$form_state) {
  $display =& $form_state['display'];
  $layout = panels_get_layout($display->layout);
  $form_state['layout'] = $layout;
  ctools_include('dependent');
  if ($form_state['display_title']) {
    $form['display_title'] = array(
      '#tree' => TRUE,
    );
    $form['display_title']['hide_title'] = array(
      '#type' => 'select',
      '#title' => t('Title type'),
      '#default_value' => (int) $display->hide_title,
      '#options' => array(
        PANELS_TITLE_NONE => t('No title'),
        PANELS_TITLE_FIXED => t('Manually set'),
        PANELS_TITLE_PANE => t('From pane'),
      ),
    );
    $form['display_title']['title'] = array(
      '#type' => 'textfield',
      '#default_value' => $display->title,
      '#title' => t('Title'),
      '#description' => t('The title of this panel. If left blank, a default title may be used. If you want the title actually to be blank, change the "Title type" dropdown from "Manually Set" to "No Title".'),
      '#process' => array(
        'ctools_dependent_process',
      ),
      '#dependency' => array(
        'edit-display-title-hide-title' => array(
          PANELS_TITLE_FIXED,
        ),
      ),
      '#maxlength' => 255,
    );
    if (!empty($display->context)) {
      $form['display_title']['title']['#description'] .= ' ' . t('You may use substitutions in this title.');

      // We have to create a manual fieldset because fieldsets do not support IDs.
      // Use 'hidden' instead of 'markup' so that the process will run.
      // Add js for collapsible fieldsets manually
      //      drupal_add_js('misc/form.js');
      //      drupal_add_js('misc/collapse.js');
      //      $form['display_title']['contexts_prefix'] = array(
      //        '#type' => 'hidden',
      //        '#id' => 'edit-display-substitutions',
      //        '#prefix' => '<div><fieldset id="edit-display-substitutions" class="collapsed collapsible"><legend>' . t('Substitutions') . '</legend><div class="fieldset-wrapper">',
      //        '#process' => array('ctools_dependent_process'),
      //        '#dependency' => array('edit-display-title-hide-title' => array(PANELS_TITLE_FIXED)),
      //      );
      $rows = array();
      foreach ($display->context as $context) {
        foreach (ctools_context_get_converters('%' . check_plain($context->keyword) . ':', $context) as $keyword => $title) {
          $rows[] = array(
            check_plain($keyword),
            t('@identifier: @title', array(
              '@title' => $title,
              '@identifier' => $context->identifier,
            )),
          );
        }
      }
      $header = array(
        t('Keyword'),
        t('Value'),
      );
      $form['display_title']['contexts'] = array(
        '#type' => 'fieldset',
        '#title' => t('Substitutions'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#value' => theme('table', array(
          'header' => $header,
          'rows' => $rows,
        )),
      );

      // $form['display_title']['contexts_suffix'] = array(      //        '#value' => '</div></fieldset></div>',
      //      );.
    }
  }

  // TODO doc the ability to do this as part of the API.
  if (!empty($layout['settings form']) && function_exists($layout['settings form'])) {
    $form['layout_settings'] = $layout['settings form']($display, $layout, $display->layout_settings);
  }
  $form['layout_settings']['#tree'] = TRUE;
  return $form;
}