function views_oai_pmh_plugin_row_auto::options_submit in Views OAI-PMH 7.2
Same name and namespace in other branches
- 6.2 plugins/views_oai_pmh_plugin_row_auto.inc \views_oai_pmh_plugin_row_auto::options_submit()
Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.
Overrides views_plugin_row::options_submit
File
- plugins/
views_oai_pmh_plugin_row_auto.inc, line 150 - Definition of the views_oai_pmh_plugin_row_auto class.
Class
Code
function options_submit(&$form, &$form_state) {
if ($this
->_check_row_objects()) {
// Pass the $form and $form_state variables to each row style object's form submission handler.
$all_form_item_options = array();
foreach ($this->_row_objects as $obj) {
// "Submit" the form and store the resulting set of options in an array.
$all_form_item_options[] = $obj
->options_submit($form, $form_state, FALSE);
}
// Combine the options arrays for each "form" into one merged array which we can process later.
$merged_form_item_options = array();
foreach ($all_form_item_options as $form_item_options) {
foreach ($form_item_options as $form_item => $form_item_option) {
foreach ($form_item_option as $field => $value) {
if ($field == 'label' && $merged_form_item_options[$form_item][$field] != '') {
// Join the item labels for each field.
if ($value != '') {
$merged_form_item_options[$form_item][$field] .= ', ' . $value;
}
}
else {
// Use whatever value we're given; apart from the label, which we're handling above, they'll all be the same.
$merged_form_item_options[$form_item][$field] = $value;
}
}
}
}
// Process each merged set of options for each field.
foreach ($merged_form_item_options as $id => $options) {
// The mappings can look really ugly if they are output alongside the
// field names. To combat this, we wrap them in HTML with display:none.
// We can pick them up later by removing the HTML code.
if ($options['label'] != '') {
$options['label'] = '<span class="js-hide">' . $options['label'] . '</span><span>' . format_plural(substr_count($options['label'], ', ') + 1, '1 mapping', '@count mappings') . '</span>';
}
// Save the field info in the view.
$form_state['view']
->set_item($form_state['display_id'], 'field', $id, $options);
}
}
return NULL;
}