예제 #1
0
 public function postAudience()
 {
     $audience = new Audience();
     $audience->name = Input::get('name');
     $audience->save();
     return Response::json($audience);
 }
예제 #2
0
 /**
  * Populates the Category object from the request
  * @return bean Category
  */
 protected function getBeanFromRequest()
 {
     global $logger;
     $logger->debug(get_class($this) . "::getBeanFromRequest()");
     $cat = new Audience($_REQUEST);
     $cat->setScope($_REQUEST['catscope']);
     $logger->debug("Auto fill of Category bean has name of: " . $cat->getName());
     // TODO add events and gallery if linked
     return $cat;
 }
예제 #3
0
 /**
  * A temporary method of generating test data.  Will be
  * refactored out once all services have been implemented.
  * @param bean the EventSUmmaryPage bean
  * @return bean the EventSUmmaryPage bean w/ stubbed data
  */
 private function loadDemoSummaryData($model)
 {
     global $logger;
     $logger->debug(get_class($this) . '::loadTestSummaryData()');
     // Test Venues
     require_once WEB_INF . '/beans/Venue.php';
     $v1 = new Venue();
     $v1->setName('Hurd Gallery');
     $v1->setOid(48);
     $v2 = new Venue();
     $v2->setName('Taube Courtyard');
     $v2->setOid(24);
     $v3 = new venue();
     $v3->setName('Main Lobby');
     $v3->setOid(17);
     $venues = array($v1, $v2, $v3);
     // Test Audience
     require_once WEB_INF . '/beans/Audience.php';
     $a1 = new Audience();
     $a1->setName('All Age Groups');
     $a2 = new Audience();
     $a2->setName('Adults');
     $a3 = new Audience();
     $a3->setName('Toddlers');
     $audiences = array($a1, $a2, $a3);
     $list = $model->getList();
     foreach ($list as $event) {
         $event->setFamily($this->randomizeTestBoolean());
         $event->setAudience($this->randomizeTestArray($audiences, 1, 1));
     }
     $model->setEvents($list);
     // Page Announcement
     $msg = "<strong>This is some introductory text about this section of " . "the web site if needed.</strong>  Otherwise this would not be " . "here and everything below would move up so that there isn't a " . "big blank space.";
     $model->setAnnouncement($msg);
     return $model;
 }
예제 #4
0
 /**
  * Populates the Venue object from the request
  * @return bean Venue
  */
 protected function getBeanFromRequest()
 {
     global $logger;
     $prgm = new Program($_REQUEST);
     $genre = new Genre();
     $genre->setOid($_REQUEST['primaryGenre']);
     $prgm->setPrimaryGenre($genre);
     if (isset($_REQUEST['defaultVenue'])) {
         $venue = new Venue();
         $venue->setOid($_REQUEST['defaultVenue']);
         $prgm->setDefaultVenue($venue);
         $prgm->setVenues(array($venue));
     }
     // categories
     $cats = array();
     if (isset($_REQUEST['audience'])) {
         foreach ($_REQUEST['audience'] as $oid) {
             $category = new Audience();
             $category->setOid($oid);
             $cats['audience'][] = $category;
         }
     }
     if (isset($_REQUEST['genre'])) {
         foreach ($_REQUEST['genre'] as $oid) {
             $category = new Genre();
             $category->setOid($oid);
             $cats['genre'][] = $category;
         }
     }
     if (isset($_REQUEST['series'])) {
         foreach ($_REQUEST['series'] as $oid) {
             $category = new Series();
             $category->setOid($oid);
             $cats['series'][] = $category;
         }
     }
     if (isset($cats['audience'])) {
         $logger->debug("Number of audience categories in the form: " . count($cats['audience']));
     }
     if (isset($cats['genre'])) {
         $logger->debug("Number of genre categories in the form: " . count($cats['genre']));
     }
     if (isset($cats['series'])) {
         $logger->debug("Number of series categories in the form: " . count($cats['series']));
     }
     if (isset($cats['audience']) || isset($cats['genre']) || isset($cats['series'])) {
         $prgm->setCategories($cats);
     }
     // related events
     $events = array();
     if (isset($_REQUEST['exhibition'])) {
         foreach ($_REQUEST['exhibition'] as $oid) {
             $exhibition = new Exhibition();
             $exhibition->setOid($oid);
             $events[] = $exhibition;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related exhibitions in the form: " . count($events));
         $prgm->setExhibitions($events);
     }
     $events = array();
     if (isset($_REQUEST['course'])) {
         foreach ($_REQUEST['course'] as $oid) {
             $course = new Course();
             $course->setOid($oid);
             $events[] = $course;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related courses in the form: " . count($events));
         $prgm->setCourses($events);
     }
     $activities = array();
     if (isset($_REQUEST['activityChanged']) && $_REQUEST['activityChanged']) {
         // parse delimited attributes as pipe-delimited '|' string
         $startTimes = explode('|', $_REQUEST['activityStartTime']);
         $endTimes = explode('|', $_REQUEST['activityEndTime']);
         $venues = explode('|', $_REQUEST['activityVenueList']);
         $status = explode('|', $_REQUEST['activityStatusList']);
         $tickets = explode('|', $_REQUEST['activityTicketList']);
         for ($index = 0; $index < count($venues); $index++) {
             $schedule = new Schedule();
             $stint = strtotime($startTimes[$index]);
             $etint = strtotime($endTimes[$index]);
             $schedule->setStartTime($stint);
             $schedule->setEndTime($etint);
             $venue = new Venue();
             $venue->setOid($venues[$index]);
             $activity = new Performance();
             $activity->setSchedule($schedule);
             $activity->setVenue($venue);
             $activity->setActivityStatus($status[$index]);
             $activity->setTicketCode($tickets[$index]);
             $activities[] = $activity;
         }
     }
     if (isset($activities)) {
         $logger->debug("Number of related performances in the form: " . count($activities));
         $prgm->setChildren($activities);
     }
     return $prgm;
 }
예제 #5
0
 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 */
     list($data_object, $status) = DataObject::find_and_compare($this->harvest_event->resource, $data_object, $this->content_manager);
     if (@(!$data_object->id)) {
         return false;
     }
     $this->media_ids_inserted[$data_object->identifier] = $data_object->id;
     $this->harvest_event->add_data_object($data_object, $status);
     $data_object->delete_hierarchy_entries();
     $vetted_id = Vetted::unknown()->id;
     $visibility_id = Visibility::preview()->id;
     foreach ($object_taxon_info as $taxon_info) {
         $he_id = $taxon_info['hierarchy_entry_id'];
         $tc_id = $taxon_info['taxon_concept_id'];
         $this->mysqli->insert("INSERT IGNORE INTO data_objects_hierarchy_entries (hierarchy_entry_id, data_object_id, vetted_id, visibility_id) VALUES ({$he_id}, {$data_object->id}, {$vetted_id}, {$visibility_id})");
         $this->mysqli->insert("INSERT IGNORE INTO data_objects_taxon_concepts (taxon_concept_id, data_object_id) VALUES ({$tc_id}, {$data_object->id})");
     }
     // a few things to add after the DataObject is inserted
     // keep track of reference foreign keys
     self::append_foreign_keys_from_row($row, 'http://eol.org/schema/reference/referenceID', $this->media_reference_ids, $data_object->id, $data_object->guid);
     // keep track of agent foreign keys
     self::append_foreign_keys_from_row($row, 'http://eol.org/schema/agent/agentID', $this->media_agent_ids, $data_object->id);
     $data_object->delete_info_items();
     $data_object->delete_table_of_contents();
     if ($s = @self::field_decode($row['http://iptc.org/std/Iptc4xmpExt/1.0/xmlns/CVterm'])) {
         $ii = InfoItem::find_or_create_by_schema_value($s);
         $data_object->add_info_item($ii->id);
         unset($ii);
     }
     if ($a = @self::field_decode($row['http://purl.org/dc/terms/audience'])) {
         $a = Audience::find_or_create_by_translated_label(trim((string) $a));
         $data_object->add_audience($a->id);
         unset($a);
     }
     $data_object_parameters["agents"] = array();
     self::append_agents($row, $data_object_parameters, 'http://purl.org/dc/terms/creator', 'Creator');
     self::append_agents($row, $data_object_parameters, 'http://purl.org/dc/terms/publisher', 'Publisher');
     self::append_agents($row, $data_object_parameters, 'http://purl.org/dc/terms/contributor', 'Contributor');
     $data_object->delete_agents();
     $i = 0;
     foreach ($data_object_parameters['agents'] as &$a) {
         $agent = Agent::find_or_create($a);
         if ($agent->logo_url && !$agent->logo_cache_url) {
             if ($logo_cache_url = $this->content_manager->grab_file($agent->logo_url, "partner")) {
                 $agent->logo_cache_url = $logo_cache_url;
                 $agent->save();
             }
         }
         $data_object->add_agent($agent->id, @$a['agent_role']->id ?: 0, $i);
         unset($a);
         $i++;
     }
     if (!isset($this->object_references_deleted[$data_object->id])) {
         $data_object->delete_refs();
         $this->object_references_deleted[$data_object->id] = true;
     }
     // add data object info to resource contribution
     if ($status != "Unchanged") {
         $result = $this->mysqli->query("SELECT id, source_url, taxon_concept_id, hierarchy_id, identifier FROM hierarchy_entries inner join  data_objects_hierarchy_entries on hierarchy_entries.id = data_objects_hierarchy_entries.hierarchy_entry_id where data_object_id =" . $data_object->id);
         if ($result && ($row = $result->fetch_assoc())) {
             $hierarchy_entry_id = $row["id"];
             $source = "'" . $this->get_hierarchy_entry_outlink($row["hierarchy_id"], $row["identifier"], preg_replace('/\'/', "\\'", $row["source_url"])) . "'";
             $identifier = "'" . $row["identifier"] . "'";
             $taxon_concept_id = $row["taxon_concept_id"];
         }
         $resource_id = $this->harvest_event->resource_id;
         $this->mysqli->insert("INSERT IGNORE INTO resource_contributions (resource_id, data_object_id, data_point_uri_id, hierarchy_entry_id, taxon_concept_id, source, object_type, identifier, data_object_type) VALUES ({$resource_id}, {$data_object->id}, NULL, {$hierarchy_entry_id}, {$taxon_concept_id}, {$source}, 'data_object', {$identifier}, {$data_object->data_type_id})");
     }
 }
예제 #6
0
 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);
             }
         }
     }
     $taxon_parameters["data_objects"] = array();
     foreach ($t->dataObject as $d) {
         $d_dc = $d->children("http://purl.org/dc/elements/1.1/");
         $d_dcterms = $d->children("http://purl.org/dc/terms/");
         $d_geo = $d->children("http://www.w3.org/2003/01/geo/wgs84_pos#");
         $data_object = new DataObject();
         $data_object->identifier = Functions::import_decode($d_dc->identifier);
         $data_object->data_type = DataType::find_or_create_by_schema_value(Functions::import_decode($d->dataType));
         $data_object->mime_type = MimeType::find_or_create_by_translated_label(Functions::import_decode($d->mimeType));
         $data_object->object_created_at = Functions::import_decode($d_dcterms->created);
         $data_object->object_modified_at = Functions::import_decode($d_dcterms->modified);
         $data_object->object_title = Functions::import_decode($d_dc->title, 0, 0);
         $data_object->language = Language::find_or_create_for_parser(Functions::import_decode($d_dc->language));
         $data_object->license = License::find_or_create_for_parser(Functions::import_decode($d->license));
         $data_object->rights_statement = Functions::import_decode($d_dc->rights, 0, 0);
         $data_object->rights_holder = Functions::import_decode($d_dcterms->rightsHolder, 0, 0);
         $data_object->bibliographic_citation = Functions::import_decode($d_dcterms->bibliographicCitation, 0, 0);
         $data_object->source_url = Functions::import_decode($d_dc->source);
         $data_object->description = Functions::import_decode($d_dc->description, 0, 0);
         $data_object->object_url = Functions::import_decode($d->mediaURL);
         $data_object->thumbnail_url = Functions::import_decode($d->thumbnailURL);
         $data_object->location = Functions::import_decode($d->location, 0, 0);
         if (@$d->additionalInformation) {
             $data_object->additional_information = (array) $d->additionalInformation;
         }
         if ($r = (string) @$d->additionalInformation->rating) {
             if (is_numeric($r) && $r > 0 && $r <= 5) {
                 $data_object->data_rating = $r;
             }
         }
         if ($subtype = @$d->additionalInformation->subtype) {
             if ($dt = DataType::find_or_create_by_schema_value(Functions::import_decode($subtype))) {
                 $data_object->data_subtype_id = $dt->id;
             }
         }
         $data_object_parameters = array();
         if (!$data_object->language) {
             $xml_attr = $d_dc->description->attributes("http://www.w3.org/XML/1998/namespace");
             $data_object->language = Language::find_or_create_for_parser(@Functions::import_decode($xml_attr["lang"]));
         }
         if (!$data_object->language && $resource->language) {
             $data_object->language = $resource->language;
         }
         //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 taxon's source_url if none present
         if (!@$data_object->source_url && @$taxon_parameters["source_url"]) {
             $data_object->source_url = $taxon_parameters["source_url"];
         }
         // Turn newlines into paragraphs
         $data_object->description = str_replace("\n", "</p><p>", $data_object->description);
         /* Checking requirements*/
         //if text: must have description
         if ($data_object->data_type->equals(DataType::text()) && !$data_object->description) {
             continue;
         }
         //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) {
             continue;
         }
         $data_object->latitude = 0;
         $data_object->longitude = 0;
         $data_object->altitude = 0;
         foreach ($d_geo->Point as $p) {
             $p_geo = $p->children("http://www.w3.org/2003/01/geo/wgs84_pos#");
             $data_object->latitude = Functions::import_decode($p_geo->lat);
             $data_object->longitude = Functions::import_decode($p_geo->long);
             $data_object->altitude = Functions::import_decode($p_geo->alt);
         }
         $data_object_parameters["agents"] = array();
         foreach ($d->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"])));
             $data_object_parameters["agents"][] = $params;
             unset($params);
         }
         $data_object_parameters["audiences"] = array();
         foreach ($d->audience as $a) {
             $data_object_parameters["audiences"][] = Audience::find_or_create_by_translated_label(trim((string) $a));
         }
         $data_object_parameters["info_items"] = array();
         foreach ($d->subject as $s) {
             $data_object_parameters["info_items"][] = InfoItem::find_or_create_by_schema_value(trim((string) $s));
         }
         if ($subject = @$d->additionalInformation->subject) {
             if ($ii = InfoItem::find_or_create_by_schema_value(trim((string) $subject))) {
                 $data_object_parameters["info_items"] = array($ii);
             }
         }
         // EXCEPTIONS
         if ($data_object->is_text()) {
             if ($resource->title == "BOLD Systems Resource") {
                 // EXCEPTION - overriding the subject for BOLD
                 $data_object_parameters["info_items"] = array(InfoItem::find_or_create_by_schema_value('http://www.eol.org/voc/table_of_contents#Barcode'));
             } elseif ($resource->title == "Wikipedia") {
                 // EXCEPTION - overriding the subject for Wikipedia
                 $data_object_parameters["info_items"] = array(InfoItem::find_or_create_by_schema_value('http://www.eol.org/voc/table_of_contents#Wikipedia'));
             } elseif ($resource->title == "IUCN Red List") {
                 if ($data_object->object_title == "IUCNConservationStatus") {
                     // EXCEPTION - overriding the data type for IUCN text
                     $data_object->data_type_id = DataType::iucn()->id;
                     $data_object->data_type = DataType::iucn();
                 }
             }
         }
         $data_object_parameters["refs"] = array();
         foreach ($d->reference as $r) {
             $reference = Functions::import_decode((string) $r, 0, 0);
             if (!$reference) {
                 continue;
             }
             $ref = Reference::find_or_create_by_full_reference($reference);
             $data_object_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);
                 }
             }
         }
         $taxon_parameters["data_objects"][] = array($data_object, $data_object_parameters);
         unset($data_object);
     }
     return $taxon_parameters;
 }
예제 #7
0
 /**
  * Instantiates an Exhibition bean object and copies all
  * valid incoming form elements to the bean object
  * @return The valid Exhibition bean
  */
 protected function getBeanFromRequest()
 {
     global $logger;
     $logger->debug(get_class($this) . "::getBeanFromRequest()");
     $service = $this->getEventService();
     // TODO: Add validator here
     $exhibit = new Exhibition($_REQUEST);
     $logger->debug("exhibition object: {$exhibit}");
     if (isset($_REQUEST['displayOrder']) && intval($_REQUEST['displayOrder']) > 0) {
         $exhibit->setDisplayOrder($_REQUEST['displayOrder']);
     }
     // Format the times
     $logger->debug("Start Time: " . $_REQUEST['startMonth'] . "," . $_REQUEST['startDay'] . "," . $_REQUEST['startYear']);
     $startTime = mktime(0, 0, 0, $_REQUEST['startMonth'], $_REQUEST['startDay'], $_REQUEST['startYear']);
     $logger->debug("Start Time (mktime)" . $startTime);
     // find out if this is a recurring event
     $endTime = mktime(0, 0, 0, $_REQUEST['endMonth'], $_REQUEST['endDay'], $_REQUEST['endYear']);
     if ($_REQUEST['close_type'] == 'ongoing') {
         $endTime = 0;
     }
     // load the schedule
     $schedule = new Schedule();
     if (isset($_REQUEST['scheduleOid'])) {
         $schedule->setOid(intval($_REQUEST['scheduleOid']));
     }
     $schedule->setStartTime($startTime);
     $schedule->setEndTime($endTime);
     $exhibit->setSchedule($schedule);
     // venues
     if (isset($_REQUEST['venue'])) {
         $venues = array();
         foreach ($_REQUEST['venue'] as $oid) {
             $venue = new Venue();
             $venue->setOid($oid);
             $venues[] = $venue;
         }
         $logger->debug("Number of venues in the form: " . count($venues));
         $exhibit->setVenues($venues);
     }
     // categories
     $cats = array();
     if (isset($_REQUEST['audience'])) {
         foreach ($_REQUEST['audience'] as $oid) {
             $category = new Audience();
             $category->setOid($oid);
             $cats['audience'][] = $category;
         }
     }
     if (isset($_REQUEST['genre'])) {
         foreach ($_REQUEST['genre'] as $oid) {
             $category = new Genre();
             $category->setOid($oid);
             $cats['genre'][] = $category;
         }
     }
     if (isset($cats['audience'])) {
         $logger->debug("Number of audience categories in the form: " . count($cats['audience']));
     }
     if (isset($cats['genre'])) {
         $logger->debug("Number of genre categories in the form: " . count($cats['genre']));
     }
     if (isset($cats['audience']) || isset($cats['genre'])) {
         $exhibit->setCategories($cats);
     }
     // related events
     $events = array();
     if (isset($_REQUEST['program'])) {
         foreach ($_REQUEST['program'] as $oid) {
             $program = new Program();
             $program->setOid($oid);
             $events[] = $program;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related programs in the form: " . count($events));
         $exhibit->setPrograms($events);
     }
     $events = array();
     if (isset($_REQUEST['course'])) {
         foreach ($_REQUEST['course'] as $oid) {
             $course = new Course();
             $course->setOid($oid);
             $events[] = $course;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related courses in the form: " . count($events));
         $exhibit->setCourses($events);
     }
     // gallery
     if (isset($_REQUEST['gallery'])) {
         $exhibit->setGallery($_REQUEST['gallery']);
     }
     // artists
     if (isset($_REQUEST['person'])) {
         $persons = array();
         foreach ($_REQUEST['person'] as $oid) {
             $person = new Artist();
             $person->setOid($oid);
             $persons[] = $person;
         }
         $logger->debug("Number of persons in the form: " . count($persons));
         $exhibit->setArtists($persons);
     }
     // artifacts
     if (isset($_REQUEST['artifact'])) {
         $artifacts = array();
         foreach ($_REQUEST['artifact'] as $id) {
             $artifacts[] = $id;
         }
         $artlist = implode(",", $artifacts);
         $logger->debug("Number of persons in the form: " . count($artifacts));
         $exhibit->setArtifacts($artlist);
     }
     return $exhibit;
 }
예제 #8
0
 public function testArrayValue()
 {
     $this->claim->setValue([self::$value]);
     $this->assertSame([self::$value], $this->claim->getValue());
 }