function views_oai_pmh_plugin_row_misc::validate in Views OAI-PMH 7.2
Same name and namespace in other branches
- 6.2 plugins/views_oai_pmh_plugin_row_misc.inc \views_oai_pmh_plugin_row_misc::validate()
Check the values of the Views form.
Return value
array An array of errors; empty if none.
Overrides views_plugin::validate
File
- plugins/
views_oai_pmh_plugin_row_misc.inc, line 82 - Definition of the views_oai_pmh_plugin_row_misc class.
Class
- views_oai_pmh_plugin_row_misc
- @file Definition of the views_oai_pmh_plugin_row_misc class.
Code
function validate() {
// Call the parent class' validation function.
$errors = parent::validate();
$link = $this->display->handler
->option_link('Row options', 'row_options');
$field_handlers = $this->display->handler
->get_handlers('field');
foreach ($field_handlers as $id => $field) {
$ui_label = $field
->ui_name();
$label_string = $field
->label();
// See if the label contains formatting HTML that we need to remove.
if (strpos($label_string, '<span') !== FALSE) {
// Grab the contents of the first 'span' tag in the label.
$label_string = substr($label_string, 0, strpos($label_string, '<span>', 1));
// Strip the span tag, leaving us with just the labels.
$label_string = strip_tags($label_string);
}
// Break the label string into its component labels, which are separated by commas.
$labels[$id] = explode(', ', $label_string);
$found_label = FALSE;
foreach ($labels[$id] as $label) {
// Does this label exist in our array of element names?
if (array_key_exists($label, $GLOBALS['views_oai_pmh'][$this->_metadata_format]->elements)) {
$found_label = TRUE;
break;
}
}
// Check that we found a valid label for this data type.
if (!$found_label) {
$errors[] = t('The field "@title" does not have a @name label associated with it. Go to the !link page to fix it.', array(
'@title' => $ui_label,
'@name' => $GLOBALS['views_oai_pmh'][$this->_metadata_format]->name,
'!link' => $link,
));
}
}
return $errors;
}