$data = array(); $names = preg_split("/[\r\n;]+/", $str); if (is_array($names)) { foreach ($names as $name) { $tm = new Taxamatch($db); $tm->set('debug_flag', $debug); $tm->set('output_type', strtolower($output)); $tm->set('cache_flag', $authorities[$source]['cache_flag']); $tm->set('cache_path', CACHE_PATH); $tm->set('name_parser', NAME_PARSER); $tm->set('chop_overload', CHOP_OVERLOAD); if ($tm->process($name, $search_mode, $cache)) { $tm->generateResponse($cache); } //$data = array_merge($data, (array)($tm->getData($layout))); $data[] = $tm->getData($layout); } } $debug = $tm->debug; if ($output == 'xml') { $data = $tm->getXML(); } break; case 'tnrs_taxamatch': require_once 'classes/class.taxamatch.php'; require_once 'classes/class.tnrs_aggregator.php'; if ($cache) { $output = 'rest'; } $db = select_source($source, $classification); $data = array();
/** * This is the function that process the input csv file and does the work. * @param string $output_type : output type */ public function process($output_type = 'file') { // Assign File if (file_exists($this->data['input_file'])) { $this->handle_input = fopen($this->data['input_file'], "r"); } else { return false; } $this->handle_output = fopen($this->data['output_file'], "w"); // Build Header $this->build_new_header(); // Writes column header in 1st row of output. $this->write_header(); /** * This will run through the whole data and build the Higer Taxa with * parentID relationship to be used in the final species list. */ $db = select_source($this->data['source']); $search_mode = 'normal'; while (($row = fgetcsv($this->handle_input, 100000, $this->file_delimiter)) !== FALSE) { // Call taxamatch and process row $tm = new Taxamatch($db); if ($tm->process($row[$this->scientificNameIndex], $search_mode)) { $tm->generateResponse($cache); } $data = $tm->getData('flat'); if (is_array($data)) { foreach ($data as $r) { fputcsv($this->handle_output, array_merge($row, $r), $this->file_delimiter); } } } fclose($this->handle_output); fclose($this->handle_input); }
$output = ''; $source = $_REQUEST['source']; $searchtxt = $_REQUEST['search_txt']; $search_mode = 'normal'; $debug = 0; $db = select_source( $source ); $tm = new Taxamatch($db); $tm->set('debug_flag',$debug); $tm->set('output_type',strtolower($output)); if($tm->process($searchtxt , $search_mode, $cache )) { $tm->generateResponse($cache); } $data = $tm->getData(); $debug = $tm->debug; ?> <ul title="Results" class="panel" > <div class="panel" title="Results" id="results" style="left: 0%;" selected="true"> <h2><?=$searchtxt ?></h2> <fieldset class="forceleft"> <div class="row forceleft" style="min-height: 22px; padding-left: 10px"> <b>Source: </b><?=$source?> </div> <?php if($data['genus'] != '') { ?>