function panels_choose_layout in Panels 6.3
Same name and namespace in other branches
- 5.2 includes/display_edit.inc \panels_choose_layout()
- 6.2 includes/display-layout.inc \panels_choose_layout()
- 7.3 includes/display-layout.inc \panels_choose_layout()
Form definition for the display layout editor.
4 calls to panels_choose_layout()
- panels_mini_ui::edit_form_layout in panels_mini/
plugins/ export_ui/ panels_mini_ui.class.php - panels_page_wizard_add_layout in includes/
page-wizard.inc - @file Contains helper functions for the Panels page wizards.
- panels_panel_context_edit_choose in plugins/
task_handlers/ panel_context.inc - Choose a layout for this panel.
- panels_panel_context_edit_layout in plugins/
task_handlers/ panel_context.inc - Change the layout for this panel.
1 string reference to 'panels_choose_layout'
- _panels_edit_layout in includes/
display-layout.inc - Handle calling and processing of the form for editing display layouts.
File
- includes/
display-layout.inc, line 74 - Handle the forms for changing a display's layout.
Code
function panels_choose_layout(&$form_state) {
$display =& $form_state['display'];
ctools_include('common', 'panels');
ctools_include('cleanstring');
$layouts = panels_common_get_allowed_layouts($form_state['allowed_layouts']);
$categories = array();
$current = '';
foreach ($layouts as $id => $layout) {
$category = ctools_cleanstring($layout['category']);
// Default category to first in case layout doesn't exist or there isn't one.
if (empty($current)) {
$current = $category;
}
$categories[$category] = $layout['category'];
$options[$category][$id] = panels_print_layout_icon($id, $layout, check_plain($layout['title']));
// Set current category to what is chosen.
if ($id == $display->layout) {
$current = $category;
}
}
ctools_add_js('layout', 'panels');
$form['categories'] = array(
'#title' => t('Category'),
'#type' => 'select',
'#options' => $categories,
'#default_value' => $current,
);
$form['layout'] = array(
'#prefix' => '<div class="panels-choose-layout panels-layouts-checkboxes clear-block">',
'#suffix' => '</div>',
);
// We set up the dependencies manually because these aren't really form
// items. It's possible there's a simpler way to do this, but I could not
// think of one at the time.
$dependencies = array();
foreach ($options as $category => $radios) {
$dependencies['panels-layout-category-' . $category] = array(
'values' => array(
'edit-categories' => array(
$category,
),
),
'num' => 1,
'type' => 'hide',
);
$form['layout'][$category] = array(
'#prefix' => '<div id="panels-layout-category-' . $category . '-wrapper"><div id="panels-layout-category-' . $category . '" class="form-checkboxes clear-block"><div class="panels-layouts-category">' . $categories[$category] . '</div>',
'#suffix' => '</div></div>',
);
foreach ($radios as $key => $choice) {
// Generate the parents as the autogenerator does, so we will have a
// unique id for each radio button.
$form['layout'][$category][$key] = array(
'#type' => 'radio',
'#title' => $choice,
'#parents' => array(
'layout',
),
'#id' => form_clean_id('edit-layout-' . $key),
'#return_value' => check_plain($key),
'#default_value' => in_array($display->layout, array_keys($layouts)) ? $display->layout : NULL,
);
}
}
ctools_add_js('dependent');
$js['CTools']['dependent'] = $dependencies;
drupal_add_js($js, 'setting');
if (empty($form_state['no buttons'])) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
}
return $form;
}