/** * */ public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null) { $o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null; // Set place hierarchy if ($vs_hierarchy = $pa_item['settings']['placeSplitter_placeHierarchy']) { $vn_hierarchy_id = caGetListItemID('place_hierarchies', $vs_hierarchy); } else { // Default to first place hierarchy $t_list = new ca_lists(); $va_hierarchy_ids = $t_list->getItemsForList('place_hierarchies', array('idsOnly' => true)); $vn_hierarchy_id = array_shift($va_hierarchy_ids); } if (!$vn_hierarchy_id) { if ($o_log) { $o_log->logError(_t('[placeSplitterRefinery] No place hierarchies are defined')); } return array(); } $pa_options['hierarchyID'] = $vn_hierarchy_id; $t_place = new ca_places(); if ($t_place->load(array('parent_id' => null, 'hierarchy_id' => $vn_hierarchy_id))) { $pa_options['defaultParentID'] = $t_place->getPrimaryKey(); } return caGenericImportSplitter('placeSplitter', 'place', 'ca_places', $this, $pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options); }
</div> <?php } else { ?> <!--<span class="listhead"><?php print $vs_facet_name; ?> </span>--> <ul> <?php if ($vs_facet_name == "place_facet") { # --- only show a few places - this list of place ids is configured in the plugin conf file $va_browse_place_ids = $this->getVar("browse_place_ids"); $t_place = new ca_places(); foreach ($va_browse_place_ids as $vn_place_id) { $t_place->load($vn_place_id); if ($t_place->get("place_id")) { print "<li><a href='#' class='abFacetOptionsList' id='abFacetOptionsList" . $t_place->get("place_id") . "' onclick='jQuery(\".abFacetOptionsList\").removeClass(\"selected\"); jQuery(\"#abFacetOptionsList" . $t_place->get("place_id") . "\").addClass(\"selected\"); jQuery(\"#contentBox\").load(\"" . caNavUrl($this->request, 'eastend', 'Map', 'clearAndAddCriteria', array('facet' => $vs_facet_name, 'id' => $t_place->get("place_id"), 'mod_id' => $vm_modify_id)) . "\"); return false;'>" . $t_place->getLabelForDisplay() . "</a></li>"; } } } else { foreach ($va_facet as $vn_i => $va_item) { $vs_label = caGetLabelForDisplay($va_facet, $va_item, $va_facet_info); #print "<div>".caNavLink($this->request, $vs_label, 'browseSelectPanelLink', $this->request->getModulePath(), $this->request->getController(), ((strlen($vm_modify_id)) ? 'modifyCriteria' : 'addCriteria'), array('facet' => $vs_facet_name, 'id' => $va_item['id'], 'mod_id' => $vm_modify_id))."</div>"; print "<li><a href='#' class='abFacetOptionsList' id='abFacetOptionsList" . $va_item['id'] . "' onclick='jQuery(\".abFacetOptionsList\").removeClass(\"selected\"); jQuery(\"#abFacetOptionsList" . $va_item['id'] . "\").addClass(\"selected\"); jQuery(\"#contentBox\").load(\"" . caNavUrl($this->request, 'eastend', 'Map', 'clearAndAddCriteria', array('facet' => $vs_facet_name, 'id' => $va_item['id'], 'mod_id' => $vm_modify_id)) . "\"); return false;'>" . $vs_label . "</a></li>"; } } ?> </ul> <?php }
print "<br/>" . $vs_brief_description; } if ($vs_thumb) { print "</div></div><!-- end row -->"; } else { print "<br/>"; } print "<br/>"; } } $va_places = $t_item->get("ca_places", array("returnAsArray" => true, "checkAccess" => $va_access_values)); if (sizeof($va_places)) { print "<H6>Related place" . (sizeof($va_places) > 1 ? "s" : "") . "</H6>"; $t_rel_place = new ca_places(); foreach ($va_places as $va_place) { $t_rel_place->load($va_place["place_id"]); $t_object_thumb->load($t_rel_place->get("ca_objects.object_id", array("restrictToRelationshipTypes" => array("cover"), "checkAccess" => $va_access_values))); $vs_thumb = $t_object_thumb->get("ca_object_representations.media.icon", array("checkAccess" => $va_access_values)); if ($vs_thumb) { print "<div class='row'><div class='col-sm-3 col-md-3 col-lg-3'>" . $vs_thumb . "</div>\n"; print "<div class='col-sm-9 col-md-9 col-lg-9'>\n"; } print $t_rel_place->getWithTemplate("<b><l>^ca_places.preferred_labels.name</l></b>"); if ($vs_brief_description = $t_rel_place->get("ca_places.brief_description")) { print "<br/>" . $vs_brief_description; } if ($vs_thumb) { print "</div></div><!-- end row -->"; } else { print "<br/>"; }
if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if (!$t_place->load(array('idno' => $vs_child_id))) { print "[Error] could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})\n"; continue; } if ($vs_parent_id == '100000000') { //$t_parent->load($vn_tgn_root_id); // get root_id $vn_parent_id = $vn_tgn_root_id; } else { if (!isset($va_place_id_cache[$vs_parent_id])) { if (!$t_parent->load(array('idno' => $vs_parent_id))) { print "[Error] No list item id for parent_id {$vs_parent_id} (were there previous errors?)\n"; continue; } $vn_parent_id = $va_place_id_cache[$vs_parent_id] = $t_parent->getPrimaryKey(); } else { $vn_parent_id = $va_place_id_cache[$vs_parent_id]; } $t_place->set('parent_id', $vn_parent_id); $t_place->update(array('dontSetHierarchicalIndexing' => true, 'dontCheckCircularReferences' => true)); if ($t_place->numErrors()) { print "[Error] could not set parent_id for {$vs_child_id} (was translated to item_id=" . $t_place->getPrimaryKey() . "): " . join('; ', $t_place->getErrors()) . "\n"; } } } else { $va_subject = array('subject_id' => $o_xml->getAttribute('Subject_ID'));
} $vn_i++; } ?> </div><!-- end refineBrowse --> <?php } $vn_x = 0; print "<div id='browseCriteria'><span class='criteriaHeading'>" . _t("You browsed for: ") . "</span>"; $t_place = new ca_places(); foreach ($va_criteria as $vs_facet_name => $va_row_ids) { $vn_x++; $vn_row_c = 0; foreach ($va_row_ids as $vn_row_id => $vs_label) { if ($vs_facet_name == 'place_facet_hier') { $t_place->load($vn_row_id); $vs_label = $t_place->get('idno'); } print "{$vs_label}" . caNavLink($this->request, 'x', 'close', '', 'Browse', 'removeCriteria', array('facet' => $vs_facet_name, 'id' => $vn_row_id)) . "\n"; $vn_row_c++; } } print caNavLink($this->request, _t('start new search') . " ›", 'startOver', '', 'Browse', 'clearCriteria', array()); print "</div><!-- end browseCriteria -->\n"; print "</div><!-- end browseControls -->"; } else { print $this->render('Browse/browse_intro_text_html.php'); if (sizeof($va_facets)) { print "<div class='startBrowsingBy'>" . _t("Start browsing by:") . "</div>"; print "<div id='facetList'>"; $va_available_facets = $this->getVar('available_facets');
print "</ul></div></div><!--end ad_col 3 -->"; } } # --- places $t_related_place = new ca_places(); $va_places = $t_entity->get("ca_places", array("returnAsArray" => 1, 'checkAccess' => $va_access_values)); if (sizeof($va_places) > 0) { $vs_places_for_display = ""; foreach ($va_places as $va_place) { $vs_effective_date = $va_place["effective_date"]; if (strstr($vs_effective_date, "after")) { $vs_effective_date = str_replace("after", "since", $vs_effective_date); } # --- if this is a street address, load parent so can show town instead if (is_numeric(substr($va_place["label"], 0, 1))) { $t_related_place->load($va_place["place_id"]); $vs_places_for_display .= "<li>" . $t_related_place->get('ca_places.parent.preferred_labels.name') . "<br/>(" . $va_place['relationship_typename'] . ($vs_effective_date ? ", " . $vs_effective_date : "") . ")</li>"; } else { $vs_places_for_display .= "<li>" . ($this->request->config->get('allow_detail_for_ca_places') ? caNavLink($this->request, $va_place["label"], '', 'Detail', 'Place', 'Show', array('place_id' => $va_place["place_id"])) : $va_place["label"]) . "<br/>(" . $va_place['relationship_typename'] . ($vs_effective_date ? ", " . $vs_effective_date : "") . ")</li>"; } } if ($vs_places_for_display) { ?> <div class="ad_col"><div> <span class="listhead caps"><?php print _t("Places"); ?> </span> <ul><?php print $vs_places_for_display; ?>
/** * */ public function get() { if (!is_object($t_entity = $this->_checkEntity())) { return $t_entity; } $vn_id = $t_entity->getPrimaryKey(); $t_list = new ca_lists(); $vn_yes_id = $t_list->getItemIDFromList("yes_no", "yes"); $vn_no_id = $t_list->getItemIDFromList("yes_no", "no"); $vn_male_id = $t_list->getItemIDFromList("genders", "male"); $vn_female_id = $t_list->getItemIDFromList("genders", "female"); // get victim info $va_data = array('id' => $vn_id, 'forename' => $t_entity->get('ca_entities.preferred_labels.forename'), 'other_forenames' => $t_entity->get('ca_entities.preferred_labels.other_forenames'), 'surname' => $t_entity->get('ca_entities.preferred_labels.surname'), 'middlename' => $t_entity->get('ca_entities.preferred_labels.middlename'), 'displayname' => $t_entity->get('ca_entities.preferred_labels.displayname'), 'prefix' => $t_entity->get('ca_entities.preferred_labels.prefix'), 'suffix' => $t_entity->get('ca_entities.preferred_labels.suffix'), 'gender' => $t_entity->get('ca_entities.gender') == $vn_male_id ? "M" : "F", 'pregnant' => $t_entity->get('ca_entities.pregnant') == $vn_yes_id ? 1 : 0, 'final_text_bio' => $t_entity->get('ca_entities.final_text_bio'), 'lifespan' => $t_entity->get('ca_entities.lifespan', array('dateFormat' => 'iso8601')), 'lifespan_as_text' => $t_entity->get('ca_entities.lifetime_text'), 'last_modification' => $t_entity->get('ca_entities.lastModified', array("dateFormat" => 'iso8601'))); $va_nonpreferred_labels = $t_entity->get('ca_entities.nonpreferred_labels', array('returnAsArray' => true, 'assumeDisplayField' => false)); foreach ($va_nonpreferred_labels as $va_label) { $va_data['alternate_names'][] = $va_label; } // add place info $va_places = $t_entity->getRelatedItems('ca_places'); $t_place = new ca_places(); $va_place_type_list = $t_place->getTypeList(); $va_place_type_idnos = array(); foreach ($va_place_type_list as $vn_type_id => $va_type) { if (!$va_type['is_enabled']) { continue; } $va_place_type_idnos[] = $va_type['idno']; } $va_data['place_types'] = $va_place_type_idnos; foreach ($va_places as $vn_relation_id => $va_rel_info) { if ($t_place->load($va_rel_info['place_id'])) { $va_place_ids = $t_place->get('ca_places.hierarchy.place_id', array('returnAsArray' => true)); array_shift($va_place_ids); $vn_i = 0; foreach ($va_place_ids as $vn_id) { if ($t_place->load($vn_id)) { if (!($vs_type_name = $va_place_type_list[$vn_place_type_id = $t_place->get('type_id')]['idno'])) { $vs_type_name = $vn_place_type_id; } $va_data['locations'][$va_rel_info['relationship_type_code']][$vs_type_name] = $t_place->get('ca_places.preferred_labels.name'); $vn_i++; } } } } // add affiliations $va_entities = $t_entity->getRelatedItems('ca_entities', array('restrict_to_relationship_types' => array('employer', 'affiliation'))); $t_rel_entity = new ca_entities(); $va_units = array(); foreach ($va_entities as $vn_relation_id => $va_rel_info) { if ($t_rel_entity->load($va_rel_info['entity_id'])) { $va_display_names = $t_rel_entity->get('ca_entities.hierarchy.preferred_labels.displayname', array('returnAsArray' => true)); if ($va_rel_info['relationship_type_code'] == 'affiliation') { if (sizeof($va_display_names) > 1) { $va_units[] = array_pop($va_display_names); } } else { if (sizeof($va_display_names) > 1) { array_pop($va_display_names); } } $va_data['affiliations'][$va_rel_info['relationship_type_code']][] = array('displayname' => $va_display_names, 'id' => $va_rel_info['entity_id'], 'aliases' => array_values($t_rel_entity->get('ca_entities.nonpreferred_labels.displayname', array('returnAsArray' => true)))); } } // add group $va_data['affiliations']['group'][] = array('displayname' => array($t_entity->get('ca_entities.groupName')), 'id' => -1, 'aliases' => array()); // Map bottom level of two level affiliation to fake "unit" relationship // This let's the Memorial Table CMS easily make the unit value searchable foreach ($va_units as $vs_unit) { $va_data['affiliations']['unit'][] = array('displayname' => array($vs_unit), 'id' => -1, 'aliases' => array()); } return $this->makeResponse($va_data); }