当前位置: 首页>>代码示例>>PHP>>正文


PHP License::find_or_create_for_parser方法代码示例

本文整理汇总了PHP中License::find_or_create_for_parser方法的典型用法代码示例。如果您正苦于以下问题:PHP License::find_or_create_for_parser方法的具体用法?PHP License::find_or_create_for_parser怎么用?PHP License::find_or_create_for_parser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在License的用法示例。


在下文中一共展示了License::find_or_create_for_parser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert_data_object

 public function insert_data_object($row, $parameters)
 {
     self::debug_iterations("Inserting DataObject");
     $this->commit_iterations("DataObject", 20);
     if ($this->archive_validator->has_error_by_line('http://eol.org/schema/media/document', $parameters['archive_table_definition']->location, $parameters['archive_line_number'])) {
         write_to_resource_harvesting_log("ERROR: insert_data_object: has_error_by_line" . ",file_location:" . $parameters['archive_table_definition']->location . ",line_number:" . $parameters['archive_line_number']);
         return false;
     }
     $object_taxon_ids = self::get_foreign_keys_from_row($row, 'http://rs.tdwg.org/dwc/terms/taxonID');
     $object_taxon_info = array();
     if ($object_taxon_ids) {
         foreach ($object_taxon_ids as $taxon_id) {
             if ($taxon_info = @$this->taxon_ids_inserted[$taxon_id]) {
                 self::uncompress_array($taxon_info);
                 $object_taxon_info[] = $taxon_info;
             }
         }
     }
     if (!$object_taxon_info) {
         return false;
     }
     if ($this->harvest_event->resource->is_eol_flickr_group() && self::is_this_flickr_image_in_inaturalist($row)) {
         return false;
     }
     $data_object = new DataObject();
     $data_object->identifier = @self::field_decode($row['http://purl.org/dc/terms/identifier']);
     if (isset($this->media_ids_inserted[$data_object->identifier])) {
         return false;
     }
     $data_object->data_type = DataType::find_or_create_by_schema_value(@self::field_decode($row['http://purl.org/dc/terms/type']));
     if ($dt = DataType::find_or_create_by_schema_value(@self::field_decode($row['http://rs.tdwg.org/audubon_core/subtype']))) {
         $data_object->data_subtype_id = $dt->id;
     }
     $data_object->mime_type = MimeType::find_or_create_by_translated_label(@self::field_decode($row['http://purl.org/dc/terms/format']));
     $data_object->object_created_at = @self::field_decode($row['http://ns.adobe.com/xap/1.0/CreateDate']);
     $data_object->object_modified_at = @self::field_decode($row['http://purl.org/dc/terms/modified']);
     $data_object->available_at = @self::field_decode($row['http://purl.org/dc/terms/available']);
     $data_object->object_title = @self::field_decode($row['http://purl.org/dc/terms/title']);
     $data_object->language = Language::find_or_create_for_parser(@self::field_decode($row['http://purl.org/dc/terms/language']));
     // check multiple fields for a value of license
     if (isset($row['http://purl.org/dc/terms/license'])) {
         $license_string = @self::field_decode($row['http://purl.org/dc/terms/license']);
     } else {
         $license_string = @self::field_decode($row['http://ns.adobe.com/xap/1.0/rights/UsageTerms']);
     }
     // convert British licences to American licenses
     $license_string = str_replace("creativecommons.org/licences/", "creativecommons.org/licenses/", $license_string);
     if (!$license_string && $this->harvest_event->resource->license && $this->harvest_event->resource->license->source_url) {
         $license_string = $this->harvest_event->resource->license->source_url;
     }
     if (!$license_string || !\eol_schema\MediaResource::valid_license($license_string)) {
         return false;
     }
     $data_object->license = License::find_or_create_for_parser($license_string);
     $data_object->rights_statement = @self::field_decode($row['http://purl.org/dc/terms/rights']);
     $data_object->rights_holder = @self::field_decode($row['http://ns.adobe.com/xap/1.0/rights/Owner']);
     $data_object->bibliographic_citation = @self::field_decode($row['http://purl.org/dc/terms/bibliographicCitation']);
     $data_object->source_url = @self::field_decode($row['http://rs.tdwg.org/ac/terms/furtherInformationURL']);
     $data_object->derived_from = @self::field_decode($row['http://rs.tdwg.org/ac/terms/derivedFrom']);
     $data_object->description = @self::field_decode($row['http://purl.org/dc/terms/description']);
     // Turn newlines into paragraphs
     $data_object->description = str_replace("\n", "</p><p>", $data_object->description);
     $data_object->object_url = @self::field_decode($row['http://rs.tdwg.org/ac/terms/accessURI']);
     $data_object->thumbnail_url = @self::field_decode($row['http://eol.org/schema/media/thumbnailURL']);
     $data_object->location = @self::field_decode($row['http://iptc.org/std/Iptc4xmpExt/1.0/xmlns/LocationCreated']);
     $data_object->spatial_location = @self::field_decode($row['http://purl.org/dc/terms/spatial']);
     $data_object->latitude = @self::field_decode($row['http://www.w3.org/2003/01/geo/wgs84_pos#lat']);
     $data_object->longitude = @self::field_decode($row['http://www.w3.org/2003/01/geo/wgs84_pos#long']);
     $data_object->altitude = @self::field_decode($row['http://www.w3.org/2003/01/geo/wgs84_pos#alt']);
     $rating = @self::field_decode($row['http://ns.adobe.com/xap/1.0/Rating']);
     // ratings may be 0 to 5
     // TODO: technically 0 means untrusted, and then anywhere from 1-5 is OK.
     // 0.5 for example isn't really valid acording to the schema
     if (is_numeric($rating) && $rating > 0 && $rating <= 5) {
         $data_object->data_rating = $rating;
     }
     //TODO - update this
     if ($data_object->mime_type && $data_object->mime_type->equals(MimeType::flash()) && $data_object->is_video()) {
         $data_object->data_type = DataType::youtube();
         $data_object->data_type_id = DataType::youtube()->id;
     }
     // //take the first available source_url of one of this object's taxa
     if (!@$data_object->source_url && @$taxon_parameters["source_url"]) {
         foreach ($object_taxon_info as $taxon_info) {
             if ($source_url = $taxon_info['source_url']) {
                 $data_object->source_url = $source_url;
                 break;
             }
         }
     }
     /* Checking requirements */
     // if text: must have description
     if ($data_object->data_type->equals(DataType::text()) && !$data_object->description) {
         return false;
     }
     // if image, movie or sound: must have object_url
     if (($data_object->data_type->equals(DataType::video()) || $data_object->data_type->equals(DataType::sound()) || $data_object->data_type->equals(DataType::image())) && !$data_object->object_url) {
         return false;
     }
     /* ADDING THE DATA OBJECT */
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:maps_test,代码行数:101,代码来源:ArchiveDataIngester.php

示例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);
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:maps_test,代码行数:101,代码来源:SchemaParser.php


注:本文中的License::find_or_create_for_parser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。