You are here

function panels_common_set_allowed_layouts in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/common.inc \panels_common_set_allowed_layouts()
1 string reference to 'panels_common_set_allowed_layouts'
panels_allowed_layouts::set_allowed in includes/common.inc
Manage panels_common_set_allowed_layouts(), the FAPI code for selecting allowed layouts.

File

includes/common.inc, line 370
Functions used by more than one panels client module.

Code

function panels_common_set_allowed_layouts(&$form_state, $allowed_layouts, $title) {
  $layouts = panels_get_layouts();
  foreach ($layouts as $id => $layout) {
    $options[$id] = panels_print_layout_icon($id, $layout, check_plain($layout['title']));
  }
  drupal_set_title($title);
  $form_state['allowed_layouts'] =& $allowed_layouts;
  $form['variables'] = array(
    '#type' => 'value',
    '#value' => array(
      $allowed_layouts,
    ),
  );
  drupal_add_js(panels_get_path('js/layout.js'));
  $form['layouts'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select allowed layouts'),
    '#options' => $options,
    '#description' => t('Check the boxes for all layouts you want to allow users choose from when picking a layout. You must allow at least one layout.'),
    '#default_value' => array_keys(array_filter($allowed_layouts->allowed_layout_settings)),
  );
  $form['clearer'] = array(
    // TODO: Fix this to use clear-block instead
    '#value' => '<div style="clear: both;"></div>',
  );
  $form['#redirect'] = FALSE;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['#token'] = FALSE;
  return $form;
}