public function GFF3Importer::formValidate
3.x GFF3Importer.inc | public GFF3Importer::formValidate($form, &$form_state) |
Overrides TripalImporter::formValidate
See also
TripalImporter::formValidate()
File
- tripal_chado/
includes/ TripalImporter/ GFF3Importer.inc, line 248
Class
Code
public function formValidate($form, &$form_state) {
$organism_id = $form_state['values']['organism_id'];
$target_organism_id = $form_state['values']['target_organism_id'];
$target_type = trim($form_state['values']['target_type']);
$create_target = $form_state['values']['create_target'];
$create_organism = $form_state['values']['create_organism'];
$add_only = $form_state['values']['add_only'];
$update = $form_state['values']['update'];
$refresh = 0; //$form_state['values']['refresh'];
$remove = 0; //$form_state['values']['remove'];
$use_transaction = $form_state['values']['use_transaction'];
$line_number = trim($form_state['values']['line_number']);
$landmark_type = trim($form_state['values']['landmark_type']);
$alt_id_attr = trim($form_state['values']['alt_id_attr']);
$re_mrna = trim($form_state['values']['re_mrna']);
$re_protein = trim($form_state['values']['re_protein']);
// @coder-ignore: there are no functions being called here
if (($add_only AND ($update OR $refresh OR $remove)) OR
($update AND ($add_only OR $refresh OR $remove)) OR
($refresh AND ($update OR $add_only OR $remove)) OR
($remove AND ($update OR $refresh OR $add_only))) {
form_set_error('add_only', t("Please select only one checkbox from the import options section"));
}
if ($line_number and !is_numeric($line_number) or $line_number < 0) {
form_set_error('line_number', t("Please provide an integer line number greater than zero."));
}
if (!($re_mrna and $re_protein) and ($re_mrna or $re_protein)) {
form_set_error('re_uname', t("You must provide both a regular expression for mRNA and a replacement string for protein"));
}
// check the regular expression to make sure it is valid
set_error_handler(function() {
}, E_WARNING);
$result_re = preg_match("/" . $re_mrna . "/", null);
$result = preg_replace("/" . $re_mrna . "/", $re_protein, null);
restore_error_handler();
if ($result_re === FALSE) {
form_set_error('re_mrna', 'Invalid regular expression.');
}
else if ($result === FALSE) {
form_set_error('re_protein', 'Invalid replacement string.');
}
}