function specimens_from_reference($reference_id) { global $db; // delete any existing specimens $sql = 'DELETE FROM rdmp_reference_specimen_joiner WHERE reference_id=' . $reference_id; $result = $db->Execute($sql); if ($result == false) { die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql); } $pages = bhl_retrieve_reference_pages($reference_id); $page_ids = array(); foreach ($pages as $p) { $page_ids[] = $p->PageID; } //echo "PageIDs:\n"; //print_r($page_ids); $text = bhl_fetch_text_for_pages($page_ids); $text = str_replace('\\n', "\n", $text); $text = str_replace("\n ", "\n", $text); $specimens = extract_specimen_codes($text); $extra = array(); foreach ($specimens as $code) { $extra = array_merge($extra, extend_specimens($code, $text)); } $specimens = array_unique(array_merge($specimens, $extra)); sort($specimens); if (count($specimens) == 0) { // none found, insert NULL entry to flag that we've processed this reference $sql = 'INSERT INTO rdmp_reference_specimen_joiner(reference_id,code) VALUES(' . $reference_id . ',NULL)'; } else { foreach ($specimens as $code) { $sql = 'INSERT INTO rdmp_reference_specimen_joiner(reference_id,code) VALUES(' . $reference_id . ',' . $db->qstr($code) . ')'; $result = $db->Execute($sql); if ($result == false) { die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql); } } } /* $nm = bhl_names_in_reference_by_page($reference_id); $nm->names; // Get majority rule taxon (what paper is about) $tags = array(); foreach ($nm->names as $name) { $tags[] = $name->namestring; } $paths = get_paths($tags); $majority_rule = majority_rule_path($paths); $expanded = expand_path($majority_rule); print_r($expanded); */ return $specimens; }
function DisplayText() { $text = ''; if (db_reference_from_bhl($this->id)) { $pages = bhl_retrieve_reference_pages($this->id); $page_ids = array(); foreach ($pages as $p) { $page_ids[] = $p->PageID; } $text = bhl_fetch_text_for_pages($page_ids); $text = str_replace('\\n', "\n", $text); $text = str_replace("\n ", "\n", $text); // wiki experiments /* foreach ($page_ids as $page) { $names = names_in_page($page); print_r($names); } */ } header("Content-type: text/plain; charset=utf-8\n\n"); echo $text; }