You are here

function panels_edit_display_form in Panels 6.2

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

Form definition for the panels display editor

No validation function is necessary, as all 'validation' is handled either in the lead-up to form rendering (through the selection of specified content types) or by the validation functions specific to the ajax modals & content types.

See also

panels_edit_display_submit()

1 string reference to 'panels_edit_display_form'
_panels_edit in includes/display-edit.inc
Handle calling and processing of the form for editing display content.

File

includes/display-edit.inc, line 73

Code

function panels_edit_display_form(&$form_state) {
  $display =& $form_state['display'];

  // Annoyingly, theme doesn't have access to form_state so we have to do this.
  $form['#display'] = $display;
  $explanation_text = '<p>';
  $explanation_text .= t('Grab the title bar of any pane to drag-and-drop it into another panel. Click the add pane button (!addicon) in any panel to add more content. Click the configure (!configicon) button on any pane to re-configure that pane. Click the cache (!cacheicon) button to configure caching for that pane specifically. Click the show/hide (!showicon/!hideicon) toggle button to show or hide that pane. Panes hidden in this way will be hidden from <em>everyone</em> until the hidden status is toggled off.', array(
    '!addicon' => '<span class="inline-icon-help">' . theme('image', panels_get_path('images/icon-addcontent.png'), t('Add content to this panel'), t('Add content to this panel')) . '</span>',
    '!configicon' => '<span class="inline-icon-help">' . theme('image', panels_get_path('images/icon-configure.png'), t('Configure this pane'), t('Configure this pane')) . '</span>',
    '!cacheicon' => '<span class="inline-icon-help">' . theme('image', panels_get_path('images/icon-cache.png'), t('Control caching'), t('Control caching')) . '</span>',
    '!showicon' => '<span class="inline-icon-help">' . theme('image', panels_get_path('images/icon-showpane.png'), t('Show this pane'), t('Show this pane')) . '</span>',
    '!hideicon' => '<span class="inline-icon-help">' . theme('image', panels_get_path('images/icon-hidepane.png'), t('Hide this pane'), t('Hide this pane')) . '</span>',
  ));
  $explanation_text .= '</p>';
  $form['explanation'] = array(
    '#value' => $explanation_text,
  );
  $layout = panels_get_layout($display->layout);
  $layout_panels = panels_get_panels($layout, $display);
  $form['panel'] = array(
    '#tree' => TRUE,
  );
  $form['panel']['pane'] = array(
    '#tree' => TRUE,
  );
  foreach ($layout_panels as $panel_id => $title) {

    // Make sure we at least have an empty array for all possible locations.
    if (!isset($display->panels[$panel_id])) {
      $display->panels[$panel_id] = array();
    }
    $form['panel']['pane'][$panel_id] = array(
      // Use 'hidden' instead of 'value' so the js can access it.
      '#type' => 'hidden',
      '#default_value' => implode(',', (array) $display->panels[$panel_id]),
    );
  }
  if (empty($form_state['no buttons'])) {
    $form['buttons']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#id' => 'panels-dnd-save',
      '#submit' => array(
        'panels_edit_display_form_submit',
      ),
      '#save-display' => TRUE,
    );
    $form['buttons']['cancel'] = array(
      '#type' => 'submit',
      '#value' => t('Cancel'),
    );
  }

  /* -- disabled, these buttons aren't useful right now
    $form['hide'] = array(
      '#prefix' => '<span id="panels-js-only">',
      '#suffix' => '</span>',
    );

    $form['hide']['hide-all'] = array(
      '#type' => 'submit',
      '#value' => t('Hide all'),
      '#id' => 'panels-hide-all',
    );

    $form['hide']['show-all'] = array(
      '#type' => 'submit',
      '#value' => t('Show all'),
      '#id' => 'panels-show-all',
    );
  */
  if (user_access('use panels caching features')) {
    $form['hide']['cache-settings-url'] = array(
      '#type' => 'hidden',
      '#value' => url('panels/ajax/cache-method/' . $display->did . '/display', array(
        'absolute' => true,
      )),
      '#attributes' => array(
        'class' => 'panels-cache-settings-url',
      ),
    );
    $form['hide']['cache-settings'] = array(
      '#type' => 'submit',
      '#value' => t('Cache settings'),
      '#id' => 'panels-cache-settings',
      '#attributes' => array(
        'class' => 'panels-ajax-link',
      ),
    );
  }
  panels_modal_js_includes();
  drupal_add_js(panels_get_path('js/display_editor.js'));
  drupal_add_css(panels_get_path('css/panels_dnd.css'));
  drupal_add_css(panels_get_path('css/panels_admin.css'));
  return $form;
}