/** * Get the control for species input, either a grid or a single species input control. */ protected static function get_control_species($auth, $args, $tabAlias, $options) { $gridmode = call_user_func(array(self::$called_class, 'getGridMode'), $args); if (!isset($args['cache_lookup']) || $args['species_ctrl'] !== 'autocomplete' && !$gridmode) { $args['cache_lookup'] = false; } // default for old form configurations or when not using an autocomplete //The filter can be a URL or on the edit tab, so do the processing to work out the filter to use $filterLines = self::get_species_filter($args); // store in the argument so that it can be used elsewhere $args['taxon_filter'] = implode("\n", $filterLines); //Single species mode only ever applies if we have supplied only one filter species and we aren't in taxon group mode if ($args['taxon_filter_field'] !== 'taxon_group' && count($filterLines) === 1 && $args['multiple_occurrence_mode'] !== 'multi') { $response = self::get_single_species_data($auth, $args, $filterLines); //Optional message to display the single species on the page if ($args['single_species_message']) { self::$singleSpeciesName = $response[0]['taxon']; } if (count($response) == 0) { //if the response is empty there is no matching taxon, so clear the filter as we can try and display the checklist with all data $args['taxon_filter'] = ''; } elseif (count($response) == 1) { //Keep the id of the single species in a hidden field for processing if in single species mode return '<input type="hidden" name="occurrence:taxa_taxon_list_id" value="' . $response[0]['id'] . "\"/>\n"; } } $extraParams = $auth['read']; if ($gridmode) { return self::get_control_species_checklist($auth, $args, $extraParams, $options); } else { return self::get_control_species_single($auth, $args, $extraParams, $options); } }