本文整理汇总了PHP中Rank::find_or_create_by_translated_label方法的典型用法代码示例。如果您正苦于以下问题:PHP Rank::find_or_create_by_translated_label方法的具体用法?PHP Rank::find_or_create_by_translated_label怎么用?PHP Rank::find_or_create_by_translated_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rank
的用法示例。
在下文中一共展示了Rank::find_or_create_by_translated_label方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_hierarchy_entry
function add_hierarchy_entry(&$row, $parent_hierarchy_entry_id, $ancestry, $branch_kingdom)
{
self::debug_iterations("Inserting taxon");
self::commit_iterations("Taxa", 500);
if ($this->archive_validator->has_error_by_line('http://rs.tdwg.org/dwc/terms/taxon', $row['archive_file_location'], $row['archive_line_number'])) {
write_to_resource_harvesting_log("ERROR: add_hierarchy_entry: has_error_by_line" . ",file_location:" . $row['archive_file_location'] . ",line_number:" . $row['archive_line_number']);
return false;
}
// make sure this taxon has a name, otherwise skip this branch
$scientific_name = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/scientificName']);
$authorship = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/scientificNameAuthorship']);
$kingdom = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/kingdom']);
$genus = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/genus']);
$rank_label = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/taxonRank']);
// COL exception
if (strtolower($kingdom) == 'viruses') {
if (substr($scientific_name, -1) == ":") {
$scientific_name = substr($scientific_name, 0, -1);
}
if (preg_match("/^(.*) ICTV\$/i", $scientific_name, $arr)) {
$scientific_name = $arr[1];
}
}
// COL exception
if (strtolower($kingdom) == 'viruses' && $genus && strtolower($rank_label) != 'genus') {
if (stripos($scientific_name, $genus) == 0) {
$scientific_name = ucfirst(trim(substr($scientific_name, strlen($genus))));
}
} else {
if ($authorship && stripos($scientific_name, $authorship) === false) {
$scientific_name = trim($scientific_name . " " . $authorship);
}
}
if (!$scientific_name) {
return false;
}
$taxon_id = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/taxonID']);
if (!$taxon_id) {
$taxon_id = @self::field_decode($row['http://purl.org/dc/terms/identifier']);
}
if (!$taxon_id) {
debug("ERROR - no taxon ID for {$scientific_name}, skipping");
return false;
}
if (isset($this->taxon_ids_inserted[$taxon_id])) {
// this taxon_id has already been inserted meaning this tree has a loop in it - so stop
debug("ERROR - taxon ID ({$taxon_id}) for {$scientific_name} already inserted; LOOP?");
return false;
}
$scientific_name = ucfirst($scientific_name);
$name = Name::find_or_create_by_string($scientific_name);
if (@(!$name->id)) {
debug("ERROR - Failed to insert name: {$scientific_name}");
return false;
}
$phylum = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/phylum']);
$class = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/class']);
$order = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/order']);
$family = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/family']);
$rank = Rank::find_or_create_by_translated_label($rank_label);
$dataset_id = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/datasetID']);
$taxonomic_status = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/taxonomicStatus']);
$source_url = @self::field_decode($row['http://rs.tdwg.org/ac/terms/furtherInformationURL']);
if (!$source_url) {
$source_url = @self::field_decode($row['http://purl.org/dc/terms/source']);
}
if (!$source_url) {
$source_url = @self::field_decode($row['http://purl.org/dc/terms/references']);
}
if (!$source_url) {
$source_url = @self::field_decode($row['http://purl.org/dc/terms/isReferencedBy']);
}
if (isset($row['http://rs.tdwg.org/dwc/terms/taxonRemarks'])) {
$taxon_remarks = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/taxonRemarks']);
} else {
$taxon_remarks = NULL;
}
if (!$taxon_remarks && strtolower($taxonomic_status) == 'provisionally accepted name') {
$taxon_remarks = "provisionally accepted name";
}
// TODO: This block is somewhat confusing. Clearly, it's clearing the
// rank that's currently being read, but shouldn't it also clear all of
// the ranks below that?
if (strtolower($rank_label) == 'kingdom') {
$kingdom = null;
}
if (strtolower($rank_label) == 'phylum') {
$phylum = null;
}
if (strtolower($rank_label) == 'class') {
$class = null;
}
if (strtolower($rank_label) == 'order') {
$order = null;
}
if (strtolower($rank_label) == 'family') {
$family = null;
}
if (strtolower($rank_label) == 'genus') {
$genus = null;
//.........这里部分代码省略.........
示例2: read_taxon_xml
public static function read_taxon_xml($t, $resource)
{
$t_dc = $t->children("http://purl.org/dc/elements/1.1/");
$t_dcterms = $t->children("http://purl.org/dc/terms/");
$t_dwc = $t->children("http://rs.tdwg.org/dwc/dwcore/");
$taxon_parameters = array();
$taxon_parameters["identifier"] = Functions::import_decode($t_dc->identifier);
$taxon_parameters["source_url"] = Functions::import_decode($t_dc->source);
$taxon_parameters["kingdom"] = Functions::import_decode($t_dwc->Kingdom);
$taxon_parameters["phylum"] = Functions::import_decode($t_dwc->Phylum);
$taxon_parameters["class"] = Functions::import_decode($t_dwc->Class);
$taxon_parameters["order"] = Functions::import_decode($t_dwc->Order);
$taxon_parameters["family"] = Functions::import_decode($t_dwc->Family);
$taxon_parameters["genus"] = Functions::import_decode($t_dwc->Genus);
$taxon_parameters["scientific_name"] = Functions::import_decode($t_dwc->ScientificName);
$taxon_parameters["rank"] = Rank::find_or_create_by_translated_label(Functions::import_decode($t->rank));
$taxon_parameters["taxon_created_at"] = trim($t_dcterms->created);
$taxon_parameters["taxon_modified_at"] = trim($t_dcterms->modified);
if ($taxon_parameters["scientific_name"]) {
$taxon_parameters["name"] = Name::find_or_create_by_string($taxon_parameters["scientific_name"]);
} else {
if ($name = $taxon_parameters["genus"]) {
$taxon_parameters["scientific_name"] = $name;
$taxon_parameters["name"] = Name::find_or_create_by_string($name);
$taxon_parameters["genus"] = "";
} elseif ($name = $taxon_parameters["family"]) {
$taxon_parameters["scientific_name"] = $name;
$taxon_parameters["name"] = Name::find_or_create_by_string($name);
$taxon_parameters["family"] = "";
} elseif ($name = $taxon_parameters["order"]) {
$taxon_parameters["scientific_name"] = $name;
$taxon_parameters["name"] = Name::find_or_create_by_string($name);
$taxon_parameters["order"] = "";
} elseif ($name = $taxon_parameters["class"]) {
$taxon_parameters["scientific_name"] = $name;
$taxon_parameters["name"] = Name::find_or_create_by_string($name);
$taxon_parameters["class"] = "";
} elseif ($name = $taxon_parameters["phylum"]) {
$taxon_parameters["scientific_name"] = $name;
$taxon_parameters["name"] = Name::find_or_create_by_string($name);
$taxon_parameters["phylum"] = "";
} elseif ($name = $taxon_parameters["kingdom"]) {
$taxon_parameters["scientific_name"] = $name;
$taxon_parameters["name"] = Name::find_or_create_by_string($name);
$taxon_parameters["kingdom"] = "";
} else {
return;
}
}
$taxon_parameters["common_names"] = array();
foreach ($t->commonName as $c) {
$common_name = Functions::import_decode((string) $c);
if (!$common_name) {
continue;
}
$xml_attr = $c->attributes("http://www.w3.org/XML/1998/namespace");
$params = array("name" => $common_name, "language" => Language::find_or_create_for_parser(@Functions::import_decode($xml_attr["lang"])));
$taxon_parameters["common_names"][] = $params;
}
$taxon_parameters["synonyms"] = array();
foreach ($t->synonym as $s) {
$synonym = Functions::import_decode((string) $s);
if (!$synonym) {
continue;
}
$attr = $s->attributes();
if (!@$attr["relationship"]) {
$attr["relationship"] = 'synonym';
}
$params = array("name" => Name::find_or_create_by_string($synonym), "synonym_relation" => SynonymRelation::find_or_create_by_translated_label(trim($attr["relationship"])));
$taxon_parameters["synonyms"][] = $params;
}
$taxon_parameters["agents"] = array();
foreach ($t->agent as $a) {
$agent_name = Functions::import_decode((string) $a);
if (!$agent_name) {
continue;
}
$attr = $a->attributes();
$params = array("full_name" => Functions::import_decode((string) $a, 0, 0), "homepage" => @Functions::import_decode($attr["homepage"]), "logo_url" => @Functions::import_decode($attr["logoURL"]), "agent_role" => AgentRole::find_or_create_by_translated_label(@trim($attr["role"])));
$taxon_parameters["agents"][] = $params;
unset($params);
}
$taxon_parameters["refs"] = array();
foreach ($t->reference as $r) {
$reference = Functions::import_decode((string) $r, 0, 0);
if (!$reference) {
continue;
}
$ref = Reference::find_or_create_by_full_reference($reference);
$taxon_parameters["refs"][] = $ref;
$id_labels = array("bici", "coden", "doi", "eissn", "handle", "issn", "isbn", "lsid", "oclc", "sici", "url", "urn");
$attr = $r->attributes();
foreach ($id_labels as $label) {
if ($id = @Functions::import_decode($attr[$label], 0, 0)) {
$type = RefIdentifierType::find_or_create_by_label($label);
$ref->add_ref_identifier(@$type->id ?: 0, $id);
}
}
}
//.........这里部分代码省略.........