1 filter.admin.inc | filter_admin_overview($form) |
Page callback: Form constructor for a form to list and reorder text formats.
See also
filter_admin_overview_submit()
Related topics
File
- core/
modules/ filter/ filter.admin.inc, line 14 - Admin page callbacks for the Filter module.
Code
function filter_admin_overview($form) {
// Overview of all formats.
$formats = filter_formats(NULL, TRUE);
$fallback_format = filter_fallback_format();
$editors = filter_get_editors();
$form['help'] = array(
'#type' => 'help',
'#markup' => t('The order of the text formats below determines the order in which they will appear in the <em>Editor</em> selector when creating content (depending on permissions for the text formats).'),
);
$form['#tree'] = TRUE;
foreach ($formats as $id => $format) {
$links = array();
$links['configure'] = array(
'title' => t('Configure'),
'href' => "admin/config/content/formats/$id",
'weight' => 0,
);
if (module_exists('config') && user_access('synchronize configuration')) {
$links['export'] = array(
'title' => t('Export'),
'href' => 'admin/config/development/configuration/single/export',
'query' => array(
'group' => 'Text formats',
'name' => 'filter.format.' . $id,
),
'weight' => 5,
);
}
// Add status so we can group by enabled/disabled. If disabled, add 100
// to weight to push it down to the bottom of the list.
$form['formats'][$id]['#status'] = $format->status;
$form['formats'][$id]['#weight'] = $format->weight;
if (!$format->status) {
$form['formats'][$id]['#weight'] += 100;
}
// Check whether this is the fallback text format. This format is available
// to all roles and cannot be disabled via the admin interface.
$form['formats'][$id]['#is_fallback'] = ($id == $fallback_format);
if ($form['formats'][$id]['#is_fallback']) {
$label = theme('label_machine_name__filter', array(
'label' => $format->name,
'machine_name' => $id,
));
$form['formats'][$id]['name'] = array('#markup' => $label);
$roles_markup = t('Fallback format. Used if a role has access to no other formats.');
}
else {
if ($form['formats'][$id]['#status']) {
$links['disable'] = array(
'title' => t('Disable'),
'href' => 'admin/config/content/formats/' . $id . '/disable',
'query' => array(
'token' => backdrop_get_token('format-' . $format->format)
),
'weight' => 10,
);
}
else {
$links['enable'] = array(
'title' => t('Enable'),
'href' => 'admin/config/content/formats/' . $id . '/enable',
'query' => array(
'token' => backdrop_get_token('format-' . $format->format)
),
'weight' => -10,
);
}
$label = theme('label_machine_name__filter', array(
'label' => $format->name,
'machine_name' => $id,
));
$form['formats'][$id]['name'] = array('#markup' => $label);
$roles = array();
foreach (filter_get_roles_by_format($format) as $role_name) {
$role = user_role_load($role_name);
$roles[] = check_plain($role->label);
}
$roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format');
}
$form['formats'][$id]['editor'] = array(
'#markup' => isset($editors[$format->editor]) ? check_plain($editors[$format->editor]['label']) : t('None'),
);
$form['formats'][$id]['roles'] = array(
'#markup' => $roles_markup,
);
backdrop_sort($links, array('weight'));
$form['formats'][$id]['operations'] = array(
'#type' => 'operations',
'#links' => $links,
);
$form['formats'][$id]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array('@title' => $format->name)),
'#title_display' => 'invisible',
'#default_value' => $format->weight,
);
}
backdrop_sort($form['formats'], array('#weight'));
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save changes'));
return $form;
}