function views_ui_rearrange_form
Form to rearrange items in the views UI.
1 string reference to 'views_ui_rearrange_form'
- views_ui_ajax_forms in includes/
admin.inc - Various subforms for editing the pieces of a view.
File
-
includes/
admin.inc, line 3538
Code
function views_ui_rearrange_form($form, &$form_state) {
$view =& $form_state['view'];
$display_id = $form_state['display_id'];
$type = $form_state['type'];
$types = views_object_types();
if (!$view->set_display($display_id)) {
views_ajax_error(t('Invalid display id @display', array(
'@display' => $display_id,
)));
}
$display =& $view->display[$display_id];
$form['#title'] = t('Rearrange @type', array(
'@type' => $types[$type]['ltitle'],
));
$form['#section'] = $display_id . 'rearrange-item';
if ($display->handler
->defaultable_sections($types[$type]['plural'])) {
$form_state['section'] = $types[$type]['plural'];
views_ui_standard_display_dropdown($form, $form_state, $form_state['section']);
}
$count = 0;
// Get relationship labels.
$relationships = array();
foreach ($display->handler
->get_handlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->label();
$handlers = $display->handler
->get_option('relationships');
if ($handlers) {
foreach ($handlers as $id => $info) {
$handler = $display->handler
->get_handler('relationship', $id);
$relationships[$id] = $handler->label();
}
}
}
foreach ($display->handler
->get_option($types[$type]['plural']) as $id => $field) {
$form['fields'][$id] = array(
'#tree' => TRUE,
);
$form['fields'][$id]['weight'] = array(
'#type' => 'textfield',
'#default_value' => ++$count,
);
$handler = $display->handler
->get_handler($type, $id);
if ($handler) {
$name = $handler->ui_name() . ' ' . $handler->admin_summary();
if (!empty($field['relationship']) && !empty($relationships[$field['relationship']])) {
$name = '(' . $relationships[$field['relationship']] . ') ' . $name;
}
$form['fields'][$id]['name'] = array(
'#markup' => $name,
);
}
else {
$form['fields'][$id]['name'] = array(
'#markup' => t('Broken field @id', array(
'@id' => $id,
)),
);
}
$form['fields'][$id]['removed'] = array(
'#type' => 'checkbox',
'#id' => 'views-removed-' . $id,
'#attributes' => array(
'class' => array(
'views-remove-checkbox',
),
),
'#default_value' => 0,
);
}
// Add JavaScript settings that will be added via $.extend for tabledragging.
$form['#js']['tableDrag']['arrange']['weight'][0] = array(
'target' => 'weight',
'source' => NULL,
'relationship' => 'sibling',
'action' => 'order',
'hidden' => TRUE,
'limit' => 0,
);
$name = NULL;
if (isset($form_state['update_name'])) {
$name = $form_state['update_name'];
}
views_ui_standard_form_buttons($form, $form_state, 'views_ui_rearrange_form');
return $form;
}