function panels_flexible_settings_form in Panels 5.2
Same name and namespace in other branches
- 6.2 layouts/flexible/flexible.inc \panels_flexible_settings_form()
1 string reference to 'panels_flexible_settings_form'
- panels_flexible_panels_layouts in layouts/
flexible.inc - implementation of hook_panels_layouts
File
- layouts/
flexible.inc, line 54
Code
function panels_flexible_settings_form($display, $layout, $settings) {
if (empty($settings)) {
// default for a new flexible layout
$settings = panels_flexible_default_panels();
}
// Special check for updating:
if (empty($settings['width_type'])) {
$settings['width_type'] = '%';
$settings['percent_width'] = 100;
$settings['sidebars']['left'] = FALSE;
$settings['sidebars']['left_width'] = 200;
$settings['sidebars']['right'] = FALSE;
$settings['sidebars']['right_width'] = 200;
$settings['sidebars']['width_type'] = 'px';
}
$form['instructions'] = array(
'#value' => t('<p>Here you may determine the number of rows and columns your layout may have. Each row can have its own number of columns, and each column can have its width set independently. When changing the number of rows or columns, click Save to update the form so you can set the widths for new cells properly.</p><p><strong>Note: Removing cells which contain panes will cause those panes to be disappear. Please move any content you wish to keep.</strong></p>'),
);
$form['width_type'] = array(
'#type' => 'select',
'#title' => t('Width unit type'),
'#options' => array(
'%' => t('% (percentage)'),
'px' => t('px (pixels)'),
'em' => t('em (current)'),
),
'#description' => t('The width unit type this layout can have: %, px or em. When using percentage, your layout will be fluid; when using px or em, your layout will be fixed.'),
'#default_value' => $settings['width_type'],
);
$form['percent_width'] = array(
'#type' => 'textfield',
'#size' => 2,
'#width' => 10,
'#title' => t('Total width'),
'#description' => t('If using the percentage width, choose the total width that this layout must add up to; if you are having problems with your flexible layout having columns fall off, try lowering this number and adjusting the width of individual columns to match.'),
'#default_value' => $settings['percent_width'],
);
$form['rows'] = array(
'#type' => 'textfield',
'#size' => 2,
'#width' => 10,
'#title' => t('Rows'),
'#description' => t('The number of rows this layout can have.'),
'#default_value' => $settings['rows'],
);
for ($row = 1; $row <= intval($settings['rows']); $row++) {
$form["row_{$row}"] = array(
'#type' => 'fieldset',
'#title' => t('Row @d', array(
'@d' => $row,
)),
);
$form["row_{$row}"]["columns"] = array(
'#prefix' => '<div style="float: left; padding-right: 2em">',
'#suffix' => '</div>',
'#type' => 'textfield',
'#size' => 2,
'#width' => 10,
'#title' => t('Columns'),
// '#description' => t('The number of columns in row @d.', array('@d' => $row)),
'#default_value' => $settings["row_{$row}"]["columns"],
);
for ($col = 1; $col <= intval($settings["row_{$row}"]["columns"]); $col++) {
$form["row_{$row}"]["width_{$row_}{$col}"] = array(
'#prefix' => '<div style="float: left; padding-right: 2em">',
'#suffix' => '</div>',
'#type' => 'textfield',
'#size' => 2,
'#width' => 10,
'#title' => t('Width @d', array(
'@d' => $col,
)),
'#default_value' => $settings["row_{$row}"]["width_{$col}"],
);
}
if (is_array($settings["row_{$row}"]["names"])) {
$names = implode(', ', $settings["row_{$row}"]["names"]);
}
else {
$names = '';
}
$form["row_{$row}"]['names'] = array(
'#prefix' => '<div style="float: left;">',
'#suffix' => '</div>',
'#type' => 'textfield',
'#title' => t('Column titles, separated by commas'),
'#default_value' => $names,
);
}
$form['sidebars'] = array(
'#type' => 'fieldset',
'#title' => t('Sidebars'),
);
$form['sidebars']['left_aligner_start'] = array(
'#value' => '<div class="option-text-aligner">',
'#tree' => TRUE,
);
$form['sidebars']['left'] = array(
'#type' => 'checkbox',
'#id' => 'sidebar-left-checkbox',
'#title' => t('Sidebar left'),
'#default_value' => $settings['sidebars']['left'],
);
$form['sidebars']['left_width'] = array(
'#type' => 'textfield',
'#id' => 'sidebar-left-width',
'#size' => 2,
'#width' => 10,
'#default_value' => $settings['sidebars']['left_width'],
);
$form['sidebars']['right'] = array(
'#type' => 'checkbox',
'#id' => 'sidebar-right-checkbox',
'#title' => t('Sidebar right'),
'#default_value' => $settings['sidebars']['right'],
);
$form['sidebars']['right_width'] = array(
'#type' => 'textfield',
'#id' => 'sidebar-right-width',
'#size' => 2,
'#width' => 10,
'#default_value' => $settings['sidebars']['right_width'],
);
$form['sidebars']['left_aligner_stop'] = array(
'#value' => '</div><div style="clear: both; padding: 0; margin: 0"></div>',
);
$form['sidebars']['left_title_markup'] = array(
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
'#value' => t('If a sidebar is selected, enter the width of the sidebar.'),
);
$form['sidebars']['width_type'] = array(
'#type' => 'select',
'#title' => t('Width unit type'),
'#options' => array(
'%' => t('% (percentage)'),
'px' => t('px (pixels)'),
'em' => t('em (current)'),
),
'#description' => t('The width unit type activated sidebars will have: %, px or em. When using percentage, your sidebars will be fluid; when using px or em, your sidebars will be fixed.'),
'#default_value' => $settings['sidebars']['width_type'],
);
$js_settings = array(
'panels' => array(
'checkboxes' => array(
'#sidebar-left-checkbox' => array(
'#sidebar-left-width',
),
'#sidebar-right-checkbox' => array(
'#sidebar-right-width',
),
),
),
);
drupal_add_js(panels_get_path('js/checkboxes.js'));
drupal_add_js($js_settings, 'setting');
return $form;
}