function ds_extras_field_ui_alter in Display Suite 7
Same name and namespace in other branches
- 7.2 modules/ds_extras/includes/ds_extras.admin.inc \ds_extras_field_ui_alter()
Alter Manage display screen.
1 call to ds_extras_field_ui_alter()
- ds_extras_form_field_ui_display_overview_form_alter in modules/
ds_extras/ ds_extras.module - Implements hook_form_FORM_ID_alter().
File
- modules/
ds_extras/ ds_extras.admin.inc, line 260 - Display Suite Extras administrative functions.
Code
function ds_extras_field_ui_alter(&$form, &$form_state) {
// Field Template.
if (variable_get('ds_extras_field_template', FALSE) && isset($form['#ds_layout'])) {
$field_settings = $form['#field_settings'];
$field_styles = _ds_styles('ds_styles_fields');
$functions = module_invoke_all('ds_field_theme_functions_info');
$default_field_function = variable_get('ft-default', 'theme_field');
$i = 1;
foreach (element_children($form['fields']) as $key) {
// Check if the label is overridden - add the original too.
if (isset($form['fields'][$key]['human_name'])) {
$form['fields'][$key]['human_name']['#prefix'] = '<div class="field-label-row"><input type="hidden" class="original-label" value="' . $form['fields'][$key]['human_name']['#markup'] . '">';
$form['fields'][$key]['human_name']['#suffix'] = '</div>';
if (isset($field_settings[$key]['ft']['lb'])) {
$form['fields'][$key]['human_name']['#markup'] = t('@label (Original: @original)', array(
'@label' => $field_settings[$key]['ft']['lb'],
'@original' => $form['fields'][$key]['human_name']['#markup'],
));
}
}
// Skip those settings for DS views.
if ($form['#entity_type'] == 'ds_views') {
continue;
}
// Link to open settings.
$form['fields'][$key]['format']['ft'] = array(
'#prefix' => '<a href="" class="ft-link">' . t('Field display') . '</a><div class="field-template" id="ft-' . $i . '">',
'#suffix' => '</div>',
'#weight' => 50,
);
$i++;
$field_function = isset($field_settings[$key]['ft']['func']) ? $field_settings[$key]['ft']['func'] : $default_field_function;
// Functions.
$form['fields'][$key]['format']['ft']['function'] = array(
'#title' => t('Choose a Field Template'),
'#type' => 'select',
'#options' => $functions,
'#default_value' => $field_function,
'#attributes' => array(
'class' => array(
'ds-extras-field-template',
),
),
);
// Field styles.
if (!empty($field_styles)) {
$field_styles_select = array(
'#type' => 'select',
'#multiple' => TRUE,
'#options' => $field_styles,
'#title' => t('Choose a field style'),
'#default_value' => isset($field_settings[$key]['ft']['styles']) ? explode(' ', $field_settings[$key]['ft']['styles']) : array(),
'#prefix' => '<div class="field-styles">',
'#suffix' => '</div>',
);
$form['fields'][$key]['format']['ft']['styles'] = $field_styles_select;
}
else {
$form['fields'][$key]['format']['ft']['styles'] = array(
'#type' => 'value',
'#value' => array(
'',
),
);
}
// Wrappers and label.
$wrappers = array(
'lb' => array(
'title' => t('Label'),
),
'ow' => array(
'title' => t('Outer wrapper'),
),
'fis' => array(
'title' => t('Field items'),
),
'fi' => array(
'title' => t('Field item'),
),
);
$colon_checkbox = FALSE;
foreach ($wrappers as $wrapper_key => $value) {
// Hide colon.
if (!$colon_checkbox) {
$form['fields'][$key]['format']['ft']['lb-col'] = array(
'#type' => 'checkbox',
'#title' => t('Hide colon'),
'#default_value' => isset($field_settings[$key]['ft']['lb-col']) ? $field_settings[$key]['ft']['lb-col'] : FALSE,
'#attributes' => array(
'class' => array(
'colon-checkbox',
),
),
);
$colon_checkbox = TRUE;
}
$form['fields'][$key]['format']['ft'][$wrapper_key] = array(
'#type' => 'checkbox',
'#title' => $value['title'],
'#prefix' => '<div class="ft-group ' . $wrapper_key . '">',
'#default_value' => isset($field_settings[$key]['ft'][$wrapper_key]) ? TRUE : FALSE,
);
$form['fields'][$key]['format']['ft'][$wrapper_key . '-el'] = array(
'#type' => 'textfield',
'#title' => t('Element'),
'#size' => '10',
'#description' => t('E.g. div, span, h2 etc.'),
'#default_value' => isset($field_settings[$key]['ft'][$wrapper_key . '-el']) ? $field_settings[$key]['ft'][$wrapper_key . '-el'] : '',
);
$classes = array(
'field-name-' . strtr($key, '_', '-'),
);
$form['fields'][$key]['format']['ft'][$wrapper_key . '-cl'] = array(
'#type' => 'textfield',
'#title' => t('Classes'),
'#size' => '10',
'#suffix' => '</div><div class="clearfix"></div>',
'#default_value' => isset($field_settings[$key]['ft'][$wrapper_key . '-cl']) ? $field_settings[$key]['ft'][$wrapper_key . '-cl'] : '',
'#description' => t('Classes: !classes', array(
'!classes' => implode(', ', $classes),
)),
);
}
$form['fields'][$key]['format']['ft']['update'] = array(
'#type' => 'button',
'#value' => t('Update'),
'#attributes' => array(
'class' => array(
'ft-update',
),
),
);
// Another label needs some other stuff.
unset($form['fields'][$key]['format']['ft']['lb']['#description']);
$form['fields'][$key]['format']['ft']['lb']['#type'] = 'textfield';
$form['fields'][$key]['format']['ft']['lb']['#size'] = '10';
$form['fields'][$key]['format']['ft']['lb']['#attributes'] = array(
'class' => array(
'label-change',
),
);
$form['fields'][$key]['format']['ft']['lb']['#default_value'] = isset($field_settings[$key]['ft']['lb']) ? $field_settings[$key]['ft']['lb'] : '';
}
}
// Views displays.
if ($form['#entity_type'] == 'ds_views') {
// Add an additional submit callback so we can ditch the extra title
// which is added by ds_extras_field_extra_fields().
$form['#submit'] = array_merge(array(
'ds_extras_vd_field_ui_submit',
), $form['#submit']);
}
// Page title functionality, currently only works on nodes, users and taxonomy terms.
if (variable_get('ds_extras_hide_page_title', FALSE) && isset($form['#ds_layout']) && in_array($form['#entity_type'], array(
'node',
'user',
'taxonomy_term',
)) && ($form['#view_mode'] == 'full' || $form['#view_mode'] == 'revision' || variable_get('ds_extras_switch_view_mode', FALSE) && $form['#entity_type'] == 'node')) {
$form['additional_settings']['ds_layouts']['ds_page_title_options'] = _ds_extras_page_title_options($form['#ds_layout']->settings, $form['#entity_type']);
}
// Region to block only fires if there is a layout and we're working on the
// a view mode which is not equal to default.
if (isset($form['#ds_layout']) && $form['#view_mode'] != 'default' && variable_get('ds_extras_region_to_block', FALSE)) {
$layout = $form['#ds_layout'];
// Get the entity_type, bundle and view mode.
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$view_mode = $form['#view_mode'];
$region_blocks_options = array();
$region_blocks = variable_get('ds_extras_region_blocks', array());
foreach ($region_blocks as $key => $block) {
if ($block['info'] == "{$entity_type}_{$bundle}_{$view_mode}") {
$region_blocks_options[$key] = t('Remove') . ' ' . $block['title'];
}
}
$form['additional_settings']['region_to_block'] = array(
'#type' => 'fieldset',
'#title' => t('Block regions'),
'#description' => t('Create additional regions in this layout which will be exposed as blocks.'),
);
$form['additional_settings']['region_to_block']['new_block_region'] = array(
'#type' => 'textfield',
'#title' => t('Region name'),
'#description' => t('Enter a name to create a new region.'),
);
$form['additional_settings']['region_to_block']['new_block_region_key'] = array(
'#title' => t('Machine name'),
'#type' => 'machine_name',
'#default_value' => '',
'#maxlength' => 32,
'#required' => FALSE,
'#description' => t('The machine-readable name of this block region. This name must contain only lowercase letters and underscores. This name must be unique.'),
'#disabled' => FALSE,
'#machine_name' => array(
'exists' => 'ds_extras_region_to_block_unique',
'source' => array(
'additional_settings',
'region_to_block',
'new_block_region',
),
),
);
if (!empty($region_blocks_options)) {
$form['additional_settings']['region_to_block']['remove_block_region'] = array(
'#type' => 'checkboxes',
'#title' => t('Existing block regions'),
'#options' => $region_blocks_options,
'#description' => t('Check the regions you want to remove.'),
);
}
$form['#submit'][] = 'ds_extras_block_submit';
}
// Editor switch.
if (variable_get('ds_extras_editor_switch') && variable_get('ds_extras_panel_view_modes')) {
// Get the entity_type, bundle and view mode.
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$view_mode = $form['#view_mode'];
$form['additional_settings']['editor_switch'] = array(
'#type' => 'fieldset',
'#group' => 'tabs',
'#title' => t('Switch editor'),
'#weight' => 10,
);
$query = array(
'switch' => 'panels',
);
$switch_link = l(t('Switch to Panels'), $_GET['q'], array(
'query' => $query,
));
$content = array(
'#markup' => '<p>' . t('Click on the link underneath to switch to Panels') . '</p><p>' . $switch_link . '</p>',
);
$form['additional_settings']['editor_switch']['content'] = array(
'#markup' => drupal_render($content),
);
}
}