filter_admin_format_form
- Versions
- 4.7 – 5
filter_admin_format_form($format = NULL)- 6
filter_admin_format_form(&$form_state, $format)- 7
filter_admin_format_form($form, &$form_state, $format)
Generate a text format form.
See also
filter_admin_format_form_validate()
@see filter_admin_format_form_submit()
Related topics
Code
modules/filter/filter.admin.inc, line 105
<?php
function filter_admin_format_form($form, &$form_state, $format) {
$is_fallback = ($format->format == filter_fallback_format());
if ($is_fallback) {
$help = t('All roles for this text format must be enabled and cannot be changed.');
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $format->name,
'#description' => t('Specify a unique name for this text format.'),
'#required' => TRUE,
);
// Add a row of checkboxes for form group.
$form['roles'] = array('#type' => 'fieldset',
'#title' => t('Roles'),
'#description' => $is_fallback ? $help : t('Choose which roles may use this text format. Note that roles with the "administer filters" permission can always use all text formats.'),
'#tree' => TRUE,
);
$checked = filter_get_roles_by_format($format);
foreach (user_roles() as $rid => $name) {
$form['roles'][$rid] = array('#type' => 'checkbox',
'#title' => $name,
'#default_value' => ($is_fallback || isset($checked[$rid])),
);
if ($is_fallback) {
$form['roles'][$rid]['#disabled'] = TRUE;
}
}
// Table with filters
$filter_info = filter_get_filters();
$filters = filter_list_format($format->format);
$form['filters'] = array('#type' => 'fieldset',
'#title' => t('Filters'),
'#description' => t('Choose the filters that will be used in this text format.'),
'#tree' => TRUE,
);
foreach ($filter_info as $name => $filter) {
$form['filters'][$name]['status'] = array(
'#type' => 'checkbox',
'#title' => $filter['title'],
'#default_value' => !empty($filters[$name]->status),
'#description' => $filter['description'],
);
}
if (!empty($format->format)) {
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
// Composition tips (guidelines)
$tips = _filter_tips($format->format, FALSE);
$tiplist = theme('filter_tips', array('tips' => $tips, 'long' => FALSE));
if (!$tiplist) {
$tiplist = '<p>' . t('No guidelines available.') . '</p>';
}
else {
$tiplist .= theme('filter_tips_more_info');
}
$group = '<p>' . t('These are the guidelines that users will see for posting in this text format. They are automatically generated from the filter settings.') . '</p>';
$group .= $tiplist;
$form['tips'] = array('#markup' => '<h2>' . t('Formatting guidelines') . '</h2>' . $group);
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
return $form;
}
?>Login or register to post comments 