function _taxonomy_display_admin_form_build_plugin_form in Taxonomy display 7
Helper function; build the admin form for plugins.
Parameters
string $type: Either 'term', 'associated', or 'breadcrumb'.
array $fieldset: Form array that we will modify.
array|null $form_state: The form state array.
$stored_settings: Object from taxonomy_display_fetch_taxonomy_display().
Return value
void
See also
1 call to _taxonomy_display_admin_form_build_plugin_form()
- taxonomy_display_admin_form in ./
taxonomy_display.admin.inc - Helper callback; perform form alterations for taxonomy display admin form.
File
- ./
taxonomy_display.admin.inc, line 213 - Administration form functions for taxonomy display configuration.
Code
function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$form_state, $stored_settings) {
$plugin_types = _taxonomy_display_plugin_types();
if (!isset($plugin_types[$type])) {
return;
}
// Set variables needed based on type
$select_field_title = t($plugin_types[$type]['long']);
$select_field_description = t("Select which plugin you would like to display the term's %plugin_types_description.", array(
'%plugin_types_description' => $plugin_types[$type]['description'],
));
$values = NULL;
if (isset($form_state['values']['additional_settings']['taxonomy_display'])) {
$values =& $form_state['values']['additional_settings']['taxonomy_display'];
}
// Populate $options with plugins that are available.
$options = taxonomy_display_plugins($type);
// Add support for missing plugins.
if (isset($stored_settings->{$type . '_plugin_missing'})) {
$options = array_merge(array(
'missing' => t('- Missing plugin -'),
), $options);
}
// Discover which option should be selected from the display plugins.
if (isset($values[$type . '_display_select']) && $values[$type . '_display_select'] != 'missing' && array_key_exists($values[$type . '_display_select'], $options)) {
$selected = $values[$type . '_display_select'];
}
elseif (isset($options['missing'])) {
$selected = 'missing';
}
else {
$selected = $stored_settings->{$type . '_display_plugin'};
}
$fieldset[$type . '_display_select'] = array(
'#ajax' => array(
'callback' => 'taxonomy_display_ajax_' . $type . '_display_callback',
'wrapper' => 'replace-' . $type . '-display-form',
),
'#default_value' => $selected,
'#description' => $select_field_description,
'#options' => $options,
'#title' => $select_field_title,
'#type' => 'select',
);
if (isset($form_state['taxonomy_display'][$type . '_display_handler'])) {
$last_handler = $form_state['taxonomy_display'][$type . '_display_handler'];
}
$form_state['taxonomy_display'][$type . '_display_handler'] = $selected;
if ($selected == 'missing') {
$fieldset[$type . '_display_form'] = array(
'#description' => t('The selected display plugin is missing. Either restore the plugin or select one that is available to configure.'),
'#prefix' => '<div id="replace-' . $type . '-display-form">',
'#suffix' => '</div>',
'#type' => 'fieldset',
);
return;
}
$fieldset[$type . '_display_form'] = array(
'#prefix' => '<div id="replace-' . $type . '-display-form">',
'#suffix' => '</div>',
'#title' => t('@label display options', array(
'@label' => $options[$selected],
)),
'#type' => 'fieldset',
);
// Get the fieldset from the selected handler.
$plugin_class = new $selected();
// Set $options as null
$display_options = NULL;
if (!isset($stored_settings->no_record)) {
$display_options = $stored_settings->{$type . '_display_options'};
}
// If the handler wasn't the one used on the last form build then reset the
// $form_state values for it.
if (!isset($last_handler) || $last_handler != $selected) {
$values[$type . '_display_form'] = array();
}
$plugin_class
->formFieldset($fieldset[$type . '_display_form'], $values[$type . '_display_form'], $display_options);
}