function panels_common_allowed_layouts_form in Panels 7.3
Same name and namespace in other branches
- 6.3 includes/common.inc \panels_common_allowed_layouts_form()
The FAPI code for generating an 'allowed layouts' selection form.
NOTE: Because the Panels API does not guarantee a particular method of storing the data on allowed layouts, it is not_possible for the Panels API to implement any checks that determine whether reductions in the set of allowed layouts conflict with pre-existing layout selections. $displays in that category will continue to function with their current layout as normal until the user/owner/admin attempts to change layouts on that display, at which point they will have to select from the new set of allowed layouts. If this is not the desired behavior for your client module, it's up to you to write a validation routine that determines what should be done with conflicting layouts.
Remember that changing layouts where panes have already been created can result in data loss; consult panels_change_layout() to see how the Panels API handles that process. Running drupal_execute('panels_change_layout', ...) is one possible starting point.
Parameters
array $allowed_layouts: The set of allowed layouts that should be used as the default values for this form. If none is provided, then by default no layouts will be restricted.
1 call to panels_common_allowed_layouts_form()
- panels_common_settings in includes/
common.inc - A common settings page for Panels modules, because this code is relevant to any modules that don't already have special requirements.
File
- includes/
common.inc, line 417 - Functions used by more than one panels client module.
Code
function panels_common_allowed_layouts_form(&$form, &$form_state, $module_name) {
// Fetch our allowed layouts from variables.
$allowed_layouts = panels_common_get_allowed_layout_object($module_name);
$layouts = panels_get_layouts();
foreach ($layouts as $id => $layout) {
$options[$id] = panels_print_layout_icon($id, $layout, check_plain($layout['title']));
}
$form_state['allowed_layouts'] =& $allowed_layouts;
ctools_add_js('panels-base', 'panels');
ctools_add_js('layout', 'panels');
$form['layout_selection'] = array(
'#type' => 'fieldset',
'#title' => t('Select allowed layouts'),
'#group' => 'additional_settings',
'#weight' => 10,
);
$form['layout_selection']['layouts'] = array(
'#type' => 'checkboxes',
'#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)),
'#prefix' => '<div class="clearfix panels-layouts-checkboxes">',
'#suffix' => '</div>',
'#checkall' => TRUE,
);
return $form;
}