function block_class_styles_admin_settings in Block Class Styles 7.2
Same name and namespace in other branches
- 7 block_class_styles.admin.inc \block_class_styles_admin_settings()
Form builder. Configure my_module.
See also
Related topics
1 string reference to 'block_class_styles_admin_settings'
- block_class_styles_menu in ./
block_class_styles.module - Implements hook_menu().
File
- ./
block_class_styles.admin.inc, line 17 - Administration page callbacks for the block_class_styles module.
Code
function block_class_styles_admin_settings() {
$form = array();
$default = $presets = block_class_styles_info(TRUE);
$temp = '';
foreach ($default as $key => $value) {
$temp .= "{$key}|{$value}\n";
}
$default = $temp;
$form['block_class_styles_presets'] = array(
'#type' => 'textarea',
'#title' => t('Style definitions'),
'#description' => t('Enter class/style presets one per line like this: <code>css-class|Style Name</code>. You may combine multiple classes in one style by separating classes with a space, e.g. <code>some-class another-class|Combo Style</code>'),
'#default_value' => $default,
'#rows' => 10,
'#resizable' => TRUE,
);
$suggestions = array();
foreach ($presets as $css => $style) {
$hooks = _block_class_styles_theme_hook_suggestion($style);
foreach ($hooks as &$hook) {
$hook = str_replace('_', '-', $hook) . '.tpl.php';
}
$suggestions[] = $style . " <code>(" . implode(', ', $hooks) . ")</code>";
}
if ($suggestions) {
$form['suggestions'] = array(
'#type' => 'fieldset',
'#title' => t('Template suggestions list'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
0 => array(
'#theme' => 'item_list',
'#items' => $suggestions,
'#prefix' => '<h3></h3>',
),
);
}
$options = array(
NULL => t('- system default -'),
);
foreach (filter_formats() as $format) {
$options[$format->format] = $format->name;
}
$form['block_class_styles_title_format'] = array(
'#type' => 'select',
'#title' => t('Block titles format'),
'#description' => t('In Drupal core, custom block titles must be plain text. You may override this by selecting a global format for block titles. This affects the title you enter when editing a block, not the titles automatically generated by modules.'),
'#default_value' => variable_get('block_class_styles_title_format', BLOCK_CLASS_STYLES_TITLE_FORMAT),
'#options' => $options,
);
$form['form_text_overrides'] = array(
'#type' => 'fieldset',
'#title' => t('Block Edit Form Settings'),
'#collapsible' => FALSE,
);
// @todo Find a way to make this work; it is incompatible with the storage mechanism of block_class
//$form['block_class_styles_allow_multiple'] = array(
// '#type' => 'checkboxes',
// '#title' => t('Single or Multiple?'),
// '#options' => array(TRUE => t('Allow more than one style definition per block?')),
// '#default_value' => variable_get('block_class_styles_allow_multiple', BLOCK_CLASS_STYLES_ALLOW_MULTIPLE),
//);
$form['form_text_overrides']['block_class_styles_fs_title'] = array(
'#type' => 'textfield',
'#title' => t('Fieldset title'),
'#required' => TRUE,
'#default_value' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
);
$form['form_text_overrides']['block_class_styles_fs_description'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('Fieldset instructions'),
'#default_value' => variable_get('block_class_styles_fs_description', BLOCK_CLASS_STYLES_FS_DESCRIPTION),
);
$form['form_text_overrides']['block_class_styles_form_collapsed'] = array(
'#type' => 'checkbox',
'#title' => t('Check to open the %title fieldset by default', array(
'%title' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
)),
'#default_value' => variable_get('block_class_styles_form_collapsed', FALSE),
);
$form['form_text_overrides']['block_class_styles_form_weight'] = array(
'#type' => 'weight',
'#title' => t('Position in form'),
'#description' => t('To position the fieldset higher in the form, choose a lower number.'),
'#default_value' => variable_get('block_class_styles_form_weight', 0),
'#delta' => 20,
);
$form['form_text_overrides']['block_class_styles_title'] = array(
'#type' => 'textfield',
'#required' => TRUE,
'#title' => t('%title select list title', array(
'%title' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
)),
'#default_value' => variable_get('block_class_styles_title', BLOCK_CLASS_STYLES_TITLE),
);
$form['form_text_overrides']['block_class_styles_description'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('%title select list description', array(
'%title' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
)),
'#description' => t('Optional text to appear below the selector on the block edit pages.'),
'#default_value' => variable_get('block_class_styles_description', BLOCK_CLASS_STYLES_DESCRIPTION),
);
$default = variable_get('block_class_styles_hidden', array());
$default = array_keys(array_diff_key($presets, $default));
$form['form_text_overrides']['block_class_styles_hidden'] = array(
'#type' => 'checkboxes',
'#title' => t("%title select list options", array(
'%title' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
)),
'#description' => t('Uncheck any style you wish to be hidden on block edit forms'),
'#options' => $presets,
'#default_value' => $default,
);
if (module_exists('bean') && ($info = entity_get_info('bean')) && count($info['bundles'])) {
$form['bean'] = array(
'#type' => 'fieldset',
'#title' => t('Bean module'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$options = array();
foreach ($info['bundles'] as $bundle_type => $bundle_info) {
$options[$bundle_type] = $bundle_info['label'];
}
$form['bean']['block_class_styles_beans'] = array(
'#type' => 'checkboxes',
'#title' => t('Active bundles'),
'#description' => t('Add %title to each of these Bean bundles:', array(
'%title' => variable_get('block_class_styles_fs_title', BLOCK_CLASS_STYLES_FS_TITLE),
)),
'#options' => $options,
'#default_value' => _block_class_styles_bean_bundles(),
);
}
//$form['form_text_overrides']['block_class_styles_hide_classes'] = array(
// '#type' => 'checkbox',
// '#title' => t('Check this box to hide the <strong>CSS class(es)</strong> textfield created by the Block Class module.'),
// '#default_value' => variable_get('block_class_styles_hide_classes', BLOCK_CLASS_STYLES_HIDE_CLASSES),
//);
$form['#validate'][] = 'block_class_styles_admin_settings_validate';
return system_settings_form($form);
}