$cache = false;
$source = explode(",", $source);
$db = select_source($source, $classification);
$header = TnrsAggregator::$field;
if (isset($count)) {
    array_unshift($header, "ID");
}
$outfh = fopen($outfile, 'w') or die("can't open outputfile");
fputcsv($outfh, $header);
$handle = fopen($file, "r");
while (($field = fgetcsv($handle, 1000, ",")) !== FALSE) {
    if (!isset($field[0]) || $field[0] == '') {
        continue;
    }
    $ta = new TnrsAggregator($db);
    $tm = new Taxamatch($db);
    $tm->set('debug_flag', '');
    $tm->set('output_type', '');
    $tm->set('cache_flag', false);
    $tm->set('cache_path', CACHE_PATH);
    $tm->set('name_parser', NAME_PARSER);
    $tm->set('chop_overload', CHOP_OVERLOAD);
    $tm->set('parse_only', $parse_only);
    $name = escapeshellarg($field[0]);
    if ($tm->process($name, $search_mode, $cache) && !$parse_only) {
        $tm->generateResponse($cache);
    }
    $ta->aggregate($tm);
    $result = $ta->getData();
    foreach ($result as $re) {
        if (isset($count)) {
Esempio n. 2
0
     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();
     $names = preg_split("/[\r\n;]+/u", $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);
             $tm->set('parse_only', $parse_only);
             if ($tm->process($name, $search_mode, $cache)) {
                 $tm->generateResponse($cache);
             }
             $ta = new TnrsAggregator($db);
             $ta->aggregate($tm);
             $data[] = $ta->getData();
         }
     }
Esempio n. 3
0
 /**
  * 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);
 }
Esempio n. 4
0
		$cmd = $_REQUEST['cmd'];
	} else {
		$cmd = 'search';
	}
	
	switch($cmd) {
		case 'search_results':
	
			$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>