Page callback: Form constructor for a form to list and reorder text formats.
filter_admin_overview_submit()
function filter_admin_overview($form) {
// Overview of all formats.
$formats = filter_formats();
$fallback_format = filter_fallback_format();
$form['#tree'] = TRUE;
$form['formats'] = array(
'#type' => 'table',
'#header' => array(
t('Name'),
t('Roles'),
t('Weight'),
t('Operations'),
),
'#tabledrag' => array(
array(
'order',
'sibling',
'text-format-order-weight',
),
),
);
foreach ($formats as $id => $format) {
$form['formats'][$id]['#attributes']['class'][] = 'draggable';
$form['formats'][$id]['#weight'] = $format->weight;
$links = array();
$links['configure'] = array(
'title' => t('configure'),
'href' => "admin/config/content/formats/{$id}",
);
// 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']) {
$form['formats'][$id]['name'] = array(
'#markup' => drupal_placeholder($format->name),
);
if (config('filter.settings')
->get('always_show_fallback_choice')) {
$roles_markup = drupal_placeholder(t('All roles may use this format'));
}
else {
$roles_markup = drupal_placeholder(t('This format is shown when no other formats are available'));
}
}
else {
$form['formats'][$id]['name'] = array(
'#markup' => check_plain($format->name),
);
$roles = array_map('check_plain', filter_get_roles_by_format($format));
$roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format');
$links['disable'] = array(
'title' => t('disable'),
'href' => "admin/config/content/formats/{$id}/disable",
);
}
$form['formats'][$id]['roles'] = array(
'#markup' => $roles_markup,
);
$form['formats'][$id]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array(
'@title' => $format->name,
)),
'#title_display' => 'invisible',
'#default_value' => $format->weight,
'#attributes' => array(
'class' => array(
'text-format-order-weight',
),
),
);
$form['formats'][$id]['operations'] = array(
'#type' => 'operations',
'#links' => $links,
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save changes'),
);
return $form;
}