function panels_common_settings in Panels 6.2
Same name and namespace in other branches
- 5.2 includes/common.inc \panels_common_settings()
- 6.3 includes/common.inc \panels_common_settings()
- 7.3 includes/common.inc \panels_common_settings()
A common settings page for Panels modules, because this code is relevant to any modules that don't already have special requirements.
3 string references to 'panels_common_settings'
- panels_mini_settings in panels_mini/
panels_mini.admin.inc - Settings for mini panels.
- panels_node_settings in panels_node/
panels_node.module - Settings for panel nodes.
- panels_page_settings in panels_page/
panels_page.admin.inc - General settings configuration page for panel pages.
File
- includes/
common.inc, line 226 - Functions used by more than one panels client module.
Code
function panels_common_settings(&$form_state, $module_name = 'panels_common') {
panels_load_include('plugins');
$content_types = panels_get_content_types();
$default_types = variable_get($module_name . '_default', NULL);
if (!isset($default_types)) {
$default_types = array(
'block' => TRUE,
'views' => TRUE,
'other' => TRUE,
);
$skip = TRUE;
}
foreach ($content_types as $id => $info) {
if (empty($info['single'])) {
$default_options[$id] = t('New @s', array(
'@s' => $info['title'],
));
}
}
$default_options['other'] = t('New content of other types');
$form['panels_common_default'] = array(
'#type' => 'checkboxes',
'#title' => t('New content behavior'),
'#description' => t('Select the default behavior of new content added to the system. If checked, new content will automatically be immediately available to be added to Panels pages. If not checked, new content will not be available until specifically allowed here.'),
'#options' => $default_options,
'#default_value' => array_keys(array_filter($default_types)),
);
if ($skip) {
$form['markup'] = array(
'#value' => t('<p>Click Submit to be presented with a complete list of available content types set to the defaults you selected.</p>'),
);
$form['skip'] = array(
'#type' => 'value',
'#value' => TRUE,
);
}
else {
// Rebuild the entire list, setting appropriately from defaults. Give
// each type its own checkboxes set unless it's 'single' in which
// case it can go into our fake other set.
$available_content_types = panels_get_all_content_types();
$allowed_content_types = variable_get($module_name . '_allowed_types', array());
foreach ($available_content_types as $id => $types) {
foreach ($types as $type => $info) {
$key = $id . '-' . $type;
$checkboxes = empty($content_types[$id]['single']) ? $id : 'other';
$options[$checkboxes][$key] = $info['title'];
if (!isset($allowed_content_types[$key])) {
$allowed[$checkboxes][$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other'];
}
else {
$allowed[$checkboxes][$key] = $allowed_content_types[$key];
}
}
}
$form['content_types'] = array(
'#tree' => TRUE,
'#prefix' => '<div class="clear-block">',
'#suffix' => '</div>',
);
// cheat a bit
$content_types['other'] = array(
'title' => t('Other'),
'weight' => 10,
);
foreach ($content_types as $id => $info) {
if (isset($allowed[$id])) {
$form['content_types'][$id] = array(
'#prefix' => '<div class="panels-page-type-container">',
'#suffix' => '</div>',
'#type' => 'checkboxes',
'#title' => t('Allowed @s content', array(
'@s' => $info['title'],
)),
'#options' => $options[$id],
'#default_value' => array_keys(array_filter($allowed[$id])),
);
}
}
}
$form['module_name'] = array(
'#type' => 'value',
'#value' => $module_name,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
drupal_add_css(panels_get_path('css/panels_page.css'));
return $form;
}