public function Record::buildOptionsForm in Views OAI-PMH 8
Parameters
$form:
\Drupal\Core\Form\FormStateInterface $form_state:
Throws
\Drupal\Component\Plugin\Exception\PluginException
Overrides StylePluginBase::buildOptionsForm
File
- src/
Plugin/ views/ style/ Record.php, line 111
Class
- Record
- Plugin annotation @ViewsStyle( id = "views_oai_pmh_record", title = @Translation("OAI-PMH"), help = @Translation("Displays rows in OAI-PMH records."), display_types = {"oai_pmh"} )
Namespace
Drupal\views_oai_pmh\Plugin\views\styleCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$handlers = $this->displayHandler
->getHandlers('field');
if (empty($handlers)) {
$form['error_markup'] = [
'#markup' => '<div class="error messages">' . $this
->t('You need at least one field before you can configure your table settings') . '</div>',
];
return;
}
$formats = [];
foreach ($this->metadataPrefix as $prefix_id => $prefix) {
$formats[$prefix_id] = $this
->t($prefix['label']);
}
$form['enabled_formats'] = [
'#type' => 'checkboxes',
'#title' => t('OAI-PMH metadata formats'),
'#description' => t('Select the metadata format(s) that you wish to publish. Note that the Dublin Core format must remain enabled as it is required by the OAI-PMH standard.'),
'#default_value' => $this->options['enabled_formats'],
'#options' => $formats,
];
$form['metadata_prefix'] = [
'#type' => 'fieldset',
'#title' => t('Metadata prefixes'),
];
$field_labels = $this->displayHandler
->getFieldLabels();
foreach ($this->metadataPrefix as $prefix_id => $prefix) {
$form['metadata_prefix'][$prefix_id] = [
'#type' => 'textfield',
'#title' => $prefix['label'],
'#default_value' => $this->options['metadata_prefix'][$prefix_id] ? $this->options['metadata_prefix'][$prefix_id] : $prefix['prefix'],
'#required' => TRUE,
'#size' => 16,
'#maxlength' => 32,
];
$form['field_mappings'][$prefix_id] = [
'#type' => 'fieldset',
'#title' => t('Field mappings for <em>@format</em>', [
'@format' => $prefix['label'],
]),
// '#theme' => 'views_oai_pmh_field_mappings_form',
'#states' => [
'visible' => [
':input[name="style_options[enabled_formats][' . $prefix_id . ']"]' => [
'checked' => TRUE,
],
],
],
];
$prefixPlugin = $this
->getInstancePlugin($prefix_id);
foreach ($this->displayHandler
->getOption('fields') as $field_name => $field) {
$form['field_mappings'][$prefix_id][$field_name] = [
'#type' => 'select',
'#options' => $prefixPlugin
->getElements(),
'#default_value' => !empty($this->options['field_mappings'][$prefix_id][$field_name]) ? $this->options['field_mappings'][$prefix_id][$field_name] : '',
'#title' => $field_labels[$field_name],
];
}
}
}