public function loadTypeSpecificValueFromRow($pa_value_array)
 {
     $this->opn_place_id = $pa_value_array['value_integer1'];
     require_once __CA_MODELS_DIR__ . '/ca_places.php';
     $t_place = new ca_places($this->opn_place_id);
     $this->ops_text = $t_place->getLabelForDisplay() . ($t_place->get("idno") ? " [" . $t_place->get("idno") . "]" : "");
 }
 /**
  *
  */
 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);
 }
    print _t('These results are no longer available. <a href="%1">Click here to restart your browse</a>.', caNavUrl($this->request, $this->request->getModulePath(), $this->request->getController(), 'clearCriteria'));
    ?>
		</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>
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *
 * This source code is free and modifiable under the terms of 
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$va_place_ids = $this->getVar("place_ids");
$t_place = new ca_places();
?>
	<div id="chronologyMapBalloonContainer">
<?php 
foreach ($va_place_ids as $vn_place_id) {
    $t_place->load($vn_place_id);
    # --- display the entities related to the place - this is what we searched up on since that is the curent data available
    print "<H1>" . caNavLink($this->request, $t_place->getLabelForDisplay(), '', 'Detail', 'Place', 'Show', array('place_id' => $t_place->get("ca_places.place_id"))) . "</H1>";
    # --- entities
    $va_entities = $t_place->get("ca_entities", array("returnAsArray" => 1, 'checkAccess' => $va_access_values, 'sort' => 'surname'));
    if (sizeof($va_entities) > 0) {
        foreach ($va_entities as $va_entity) {
            print "<div>" . ($this->request->config->get('allow_detail_for_ca_entities') ? caNavLink($this->request, $va_entity["label"], '', 'Detail', 'Entity', 'Show', array('entity_id' => $va_entity["entity_id"])) : $va_entity["label"]) . " (" . $va_entity['relationship_typename'] . ")</div>";
        }
    }
    print "<p>" . caNavLink($this->request, _t("More") . " &rsaquo;", '', 'Detail', 'Place', 'Show', array('place_id' => $t_place->get("ca_places.place_id"))) . "</p>";
        print $t_rel_collection->getWithTemplate("<b><l>^ca_collections.preferred_labels.name</l></b>");
        if ($vs_brief_description = $t_rel_collection->get("ca_collections.brief_description")) {
            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 {
Beispiel #6
0
 public function insert($pa_options = null)
 {
     if (!$this->inTransaction()) {
         $this->setTransaction(new Transaction());
     }
     if ($this->get('is_default')) {
         $this->getDb()->query("\n\t\t\t\tUPDATE ca_list_items \n\t\t\t\tSET is_default = 0 \n\t\t\t\tWHERE list_id = ?\n\t\t\t", (int) $this->get('list_id'));
     }
     $vn_rc = parent::insert($pa_options);
     if ($this->getPrimaryKey()) {
         $t_list = new ca_lists();
         $o_trans = $this->getTransaction();
         $t_list->setTransaction($o_trans);
         if ($t_list->load($this->get('list_id')) && $t_list->get('list_code') == 'place_hierarchies' && $this->get('parent_id')) {
             // insert root or place hierarchy when creating non-root items in 'place_hierarchies' list
             $t_locale = new ca_locales();
             $va_locales = $this->getAppConfig()->getList('locale_defaults');
             $vn_locale_id = $t_locale->localeCodeToID($va_locales[0]);
             // create root in ca_places
             $t_place = new ca_places();
             $t_place->setTransaction($o_trans);
             $t_place->setMode(ACCESS_WRITE);
             $t_place->set('hierarchy_id', $this->getPrimaryKey());
             $t_place->set('locale_id', $vn_locale_id);
             $t_place->set('type_id', null);
             $t_place->set('parent_id', null);
             $t_place->set('idno', 'Root node for ' . $this->get('idno'));
             $t_place->insert();
             if ($t_place->numErrors()) {
                 $this->delete();
                 $this->errors = array_merge($this->errors, $t_place->errors);
                 return false;
             }
             $t_place->addLabel(array('name' => 'Root node for ' . $this->get('idno')), $vn_locale_id, null, true);
         }
     }
     if ($this->numErrors()) {
         $this->getTransaction()->rollback();
     } else {
         $this->getTransaction()->commit();
         $this->_setSettingsForList();
     }
     return $vn_rc;
 }
            }
            if ($t_occurrence->get("ca_occurrences.pages")) {
                $vs_citation .= ": " . $t_occurrence->get("ca_occurrences.pages");
            }
            $vs_citation .= ".";
            print caDetailLink($this->request, $vs_citation, '', 'ca_occurrences', $va_citation["occurrence_id"], array("subsite" => $this->request->session->getVar("coloradoSubSite")));
        }
        print "</div>";
    }
}
# --- places
$va_locality_list = $t_object->get("ca_places", array('returnAsArray' => true, 'checkAccess' => $va_access_values));
$va_locality_display = array();
$va_place_type_ids_to_exclude = array($t_lists->getItemIDFromList("place_types", "city"), $t_lists->getItemIDFromList("place_types", "basin"), $t_lists->getItemIDFromList("place_types", "other"), $t_lists->getItemIDFromList("place_types", "locality"));
if (sizeof($va_locality_list)) {
    $t_place = new ca_places();
    print "<br><div class='unit'><h2>UCM " . (sizeof($va_places) > 1 ? "Localities" : "Locality") . "</h2>";
    foreach ($va_locality_list as $va_locality) {
        $vs_locality_path = "";
        $va_hierarchy = caExtractValuesByUserLocale($t_place->getHierarchyAncestors($va_locality["place_id"], array("additionalTableToJoin" => "ca_place_labels", "additionalTableSelectFields" => array("name"))));
        $va_hierarchy = array_reverse($va_hierarchy);
        array_shift($va_hierarchy);
        foreach ($va_hierarchy as $va_hier_locality) {
            if (!in_array($va_hier_locality["type_id"], $va_place_type_ids_to_exclude)) {
                $vs_locality_path .= $va_hier_locality["name"] . " / ";
            }
        }
        $vs_locality_path = caDetailLink($this->request, $va_locality["idno"], '', 'ca_places', $va_locality["place_id"], array("subsite" => $this->request->session->getVar("coloradoSubSite"))) . "<br/>" . $vs_locality_path . $va_locality["idno"];
        $va_locality_display[] = $vs_locality_path;
    }
    print join("<br/>", $va_locality_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);
 }
/**
 * 
 *
 * @param string $ps_refinery_name
 * @param string $ps_table
 * @param array $pa_parents 
 * @param array $pa_source_data
 * @param array $pa_item
 * @param int $pn_c
 * @param KLogger $o_log
 * 
 * @return int
 */
function caProcessRefineryParents($ps_refinery_name, $ps_table, $pa_parents, $pa_source_data, $pa_item, $pn_c, $pa_options = null)
{
    global $g_ui_locale_id;
    if (!is_array($pa_options)) {
        $pa_options = array();
    }
    $o_log = caGetOption('log', $pa_options, null);
    $o_reader = caGetOption('reader', $pa_options, null);
    $o_trans = caGetOption('transaction', $pa_options, null);
    $vn_list_id = caGetOption('list_id', $pa_options, null);
    $vb_hierarchy_mode = caGetOption('hierarchyMode', $pa_options, false);
    if (!is_array($pa_parents)) {
        $pa_parents = array($pa_parents);
    }
    $vn_id = null;
    $pa_parents = array_reverse($pa_parents);
    foreach ($pa_parents as $vn_i => $va_parent) {
        if (!is_array($va_parent)) {
            $o_log->logWarn(_t('[%2] Parents options invalid. Did you forget to pass a list? Parents list passed was: %1', print_r($pa_parents, true), $ps_refinery_name));
            break;
        }
        $vs_name = BaseRefinery::parsePlaceholder($va_parent['name'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        $vs_idno = BaseRefinery::parsePlaceholder($va_parent['idno'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        $vs_type = BaseRefinery::parsePlaceholder($va_parent['type'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        if (!$vs_name && !$vs_idno) {
            continue;
        }
        if (!$vs_name) {
            continue;
        }
        //$vs_name = $vs_idno; }
        $va_attributes = isset($va_parent['attributes']) && is_array($va_parent['attributes']) ? $va_parent['attributes'] : array();
        foreach ($va_attributes as $vs_element_code => $va_attrs) {
            if (is_array($va_attrs)) {
                foreach ($va_attrs as $vs_k => $vs_v) {
                    // BaseRefinery::parsePlaceholder may return an array if the input format supports repeated values (as XML does)
                    // DataMigrationUtils::getCollectionID(), which ca_data_importers::importDataFromSource() uses to create related collections
                    // only supports non-repeating attribute values, so we join any values here and call it a day.
                    $va_attributes[$vs_element_code][$vs_k] = BaseRefinery::parsePlaceholder($vs_v, $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
                }
            } else {
                $va_attributes[$vs_element_code] = array($vs_element_code => BaseRefinery::parsePlaceholder($va_attrs, $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' ')));
            }
        }
        $va_attributes['idno'] = $vs_idno;
        $va_attributes['parent_id'] = $vn_id;
        if (isset($va_parent['rules']) && is_array($va_parent['rules'])) {
            foreach ($va_parent['rules'] as $va_rule) {
                $vm_ret = ExpressionParser::evaluate($va_rule['trigger'], $pa_source_data);
                if (!ExpressionParser::hadError() && (bool) $vm_ret) {
                    foreach ($va_rule['actions'] as $va_action) {
                        if (!is_array($va_action) && strtolower($va_action) == 'skip') {
                            $va_action = array('action' => 'skip');
                        }
                        switch ($vs_action_code = strtolower($va_action['action'])) {
                            case 'set':
                                switch ($va_action['target']) {
                                    case 'name':
                                        $vs_name = BaseRefinery::parsePlaceholder($va_action['value'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
                                        break;
                                    case 'type':
                                        $vs_type = BaseRefinery::parsePlaceholder($va_action['value'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
                                        break;
                                    default:
                                        $va_attributes[$va_action['target']] = BaseRefinery::parsePlaceholder($va_action['value'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
                                        break;
                                }
                                break;
                            case 'skip':
                            default:
                                if ($o_log) {
                                    if ($vs_action_code != 'skip') {
                                        $o_log->logInfo(_t('[%3] Parent was skipped using rule "%1" with default action because an invalid action ("%2") was specified', $va_rule['trigger'], $vs_action_code, $ps_refinery_name));
                                    } else {
                                        $o_log->logDebug(_t('[%3] Parent was skipped using rule "%1" with action "%2"', $va_rule['trigger'], $vs_action_code, $ps_refinery_name));
                                    }
                                }
                                continue 4;
                                break;
                        }
                    }
                } elseif (ExpressionParser::hadError() && $o_log) {
                    $o_log->logError(_t('[%3] Error processing rule "%1" as an error occurred. Error number was "%2"', $va_rule['trigger'], ExpressionParser::$s_last_error, $ps_refinery_name));
                }
            }
        }
        $va_match_on = caGetOption("{$ps_refinery_name}_dontMatchOnLabel", $pa_item['settings'], false) ? array('idno') : array('idno', 'label');
        $pa_options = array_merge(array('matchOn' => $va_match_on), $pa_options);
        switch ($ps_table) {
            case 'ca_objects':
                $vn_id = DataMigrationUtils::getObjectID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_entities':
                $vn_id = DataMigrationUtils::getEntityID($va_entity_label = DataMigrationUtils::splitEntityName($vs_name, $pa_options), $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels'] = $va_entity_label;
                $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_places':
                if (!$vn_id) {
                    // get place hierarchy root
                    require_once __CA_MODELS_DIR__ . "/ca_places.php";
                    $t_place = new ca_places();
                    if ($o_trans) {
                        $t_place->setTransaction($o_trans);
                    }
                    $vn_id = $pa_options['defaultParentID'];
                    if (!$vn_id) {
                        $vn_id = $t_place->getHierarchyRootID($pa_options['hierarchyID']);
                    }
                    $va_attributes['parent_id'] = $vn_id;
                }
                $vn_id = DataMigrationUtils::getPlaceID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_occurrences':
                $vn_id = DataMigrationUtils::getOccurrenceID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_collections':
                $vn_id = DataMigrationUtils::getCollectionID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_loans':
                $vn_id = DataMigrationUtils::getLoanID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_movements':
                $vn_id = DataMigrationUtils::getMovementID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            case 'ca_list_items':
                if (!$vn_list_id) {
                    if ($o_log) {
                        $o_log->logDebug(_t('[importHelpers:caProcessRefineryParents] List was not specified'));
                    }
                    return null;
                }
                if (!$vn_id) {
                    // get place hierarchy root
                    require_once __CA_MODELS_DIR__ . "/ca_lists.php";
                    $t_list = new ca_lists();
                    if ($o_trans) {
                        $t_list->setTransaction($o_trans);
                    }
                    $vn_id = $t_list->getRootItemIDForList($vn_list_id);
                    $va_attributes['parent_id'] = $vn_id;
                }
                $vn_id = DataMigrationUtils::getListItemID($vn_list_id, $vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name_singular'] = $va_attributes['preferred_labels']['name_plural'] = $vs_name;
                break;
            case 'ca_storage_locations':
                if (!$vn_id) {
                    // get storage location hierarchy root
                    require_once __CA_MODELS_DIR__ . "/ca_storage_locations.php";
                    $t_loc = new ca_storage_locations();
                    if ($o_trans) {
                        $t_loc->setTransaction($o_trans);
                    }
                    $vn_id = $t_loc->getHierarchyRootID();
                    $va_attributes['parent_id'] = $vn_id;
                }
                $vn_id = DataMigrationUtils::getStorageLocationID($vs_name, $vn_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                $va_attributes['preferred_labels']['name'] = $va_attributes['_preferred_labels'] = $vs_name;
                break;
            default:
                if ($o_log) {
                    $o_log->logDebug(_t('[importHelpers:caProcessRefineryParents] Invalid table %1', $ps_table));
                }
                return null;
                break;
        }
        $va_attributes['locale_id'] = $g_ui_locale_id;
        if ($o_log) {
            $o_log->logDebug(_t('[%6] Got parent %1 (%2) with id %3 and type %4 for %5', $vs_name, $vs_idno, $vn_id, $vs_type, $vs_name, $ps_refinery_name));
        }
    }
    if ($vb_hierarchy_mode) {
        return $va_attributes;
    }
    return $vn_id;
}
 /** 
  * Returns place_id for the place with the specified name, regardless of specified type. If the place does not already 
  * exist then it will be created with the specified name, type and locale, as well as with any specified values in the $pa_values array.
  * $pa_values keys should be either valid place fields or attributes.
  *
  * @param string $ps_place_name Place label name
  * @param int $pn_parent_id The parent_id of the place; must be set to a non-null value
  * @param int $pn_type_id The type_id of the place type to use if the place needs to be created
  * @param int $pn_locale_id The locale_id to use if the place needs to be created (will be used for both the place locale as well as the label locale)
  * @param array $pa_values An optional array of additional values to populate newly created place records with. These values are *only* used for newly created places; they will not be applied if the place named already exists. The array keys should be names of ca_places fields or valid entity attributes. Values should be either a scalar (for single-value attributes) or an array of values for (multi-valued attributes)
  * @param array $pa_options An optional array of options, which include:
  *				outputErrors - if true, errors will be printed to console [default=false]
  *				matchOnIdno - try to match on idno if name match fails [default=false]
  *				dontCreate - if true then new entities will not be created [default=false]
  * 				transaction - if Transaction object is passed, use it for all Db-related tasks [default=null]
  *				returnInstance = return ca_places instance rather than place_id. Default is false. 
  *				generateIdnoWithTemplate = A template to use when setting the idno. The template is a value with automatically-set SERIAL values replaced with % characters. Eg. 2012.% will set the created row's idno value to 2012.121 (assuming that 121 is the next number in the serial sequence.) The template is NOT used if idno is passed explicitly as a value in $pa_values.
  *				importEvent = if ca_data_import_events instance is passed then the insert/update of the place will be logged as part of the import
  *				importEventSource = if importEvent is passed, then the value set for importEventSource is used in the import event log as the data source. If omitted a default value of "?" is used
  *				log = if KLogger instance is passed then actions will be logged
  */
 static function getPlaceID($ps_place_name, $pn_parent_id, $pn_type_id, $pn_locale_id, $pa_values = null, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (!isset($pa_options['outputErrors'])) {
         $pa_options['outputErrors'] = false;
     }
     $pb_match_on_idno = caGetOption('matchOnIdno', $pa_options, false);
     $t_place = new ca_places();
     if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
         $t_place->setTransaction($pa_options['transaction']);
     }
     $o_event = isset($pa_options['importEvent']) && $pa_options['importEvent'] instanceof ca_data_import_events ? $pa_options['importEvent'] : null;
     $vs_event_source = isset($pa_options['importEventSource']) && $pa_options['importEventSource'] ? $pa_options['importEventSource'] : "?";
     $o_log = isset($pa_options['log']) && $pa_options['log'] instanceof KLogger ? $pa_options['log'] : null;
     if (!($vs_idno = isset($pa_values['idno']) ? (string) $pa_values['idno'] : null)) {
         if (isset($pa_options['generateIdnoWithTemplate']) && $pa_options['generateIdnoWithTemplate']) {
             $vs_idno = $t_place->setIdnoTWithTemplate($pa_options['generateIdnoWithTemplate'], array('dontSetValue' => true));
         }
     }
     $va_find_arr = array();
     if ($pn_type_id) {
         $va_find_arr['type_id'] = $pn_type_id;
     }
     if ($pn_parent_id) {
         $va_find_arr['parent_id'] = $pn_parent_id;
     }
     if (!($vn_id = ca_places::find(array_merge(array('preferred_labels' => array('name' => $ps_place_name)), $va_find_arr), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction'])))) {
         if ($pb_match_on_idno && $vs_idno) {
             $va_find_arr['idno'] = $vs_idno;
             $vn_id = ca_places::find($va_find_arr, array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
         }
     }
     if (!$vn_id) {
         if (isset($pa_options['dontCreate']) && $pa_options['dontCreate']) {
             return false;
         }
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_places', 'I');
         }
         $t_place->setMode(ACCESS_WRITE);
         $t_place->set('locale_id', $pn_locale_id);
         $t_place->set('type_id', $pn_type_id);
         $t_place->set('parent_id', $pn_parent_id);
         $t_place->set('source_id', isset($pa_values['source_id']) ? $pa_values['source_id'] : null);
         $t_place->set('access', isset($pa_values['access']) ? $pa_values['access'] : 0);
         $t_place->set('status', isset($pa_values['status']) ? $pa_values['status'] : 0);
         $t_place->set('idno', $vs_idno);
         $t_place->set('lifespan', isset($pa_values['lifespan']) ? $pa_values['lifespan'] : null);
         $t_place->set('hierarchy_id', isset($pa_values['hierarchy_id']) ? $pa_values['hierarchy_id'] : null);
         $t_place->insert();
         if ($t_place->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not insert place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not insert place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
             }
             return null;
         }
         $vb_label_errors = false;
         $t_place->addLabel(array('name' => $ps_place_name), $pn_locale_id, null, true);
         if ($t_place->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not set preferred label for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not set preferred label for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
             }
             $vb_label_errors = true;
         }
         unset($pa_values['access']);
         unset($pa_values['status']);
         unset($pa_values['idno']);
         unset($pa_values['source_id']);
         unset($pa_values['lifespan']);
         unset($pa_values['hierarchy_id']);
         $vb_attr_errors = false;
         if (is_array($pa_values)) {
             foreach ($pa_values as $vs_element => $va_value) {
                 if (is_array($va_value)) {
                     // array of values (complex multi-valued attribute)
                     $t_place->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
                 } else {
                     // scalar value (simple single value attribute)
                     if ($va_value) {
                         $t_place->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                     }
                 }
             }
         }
         $t_place->insert();
         if ($t_place->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not set values for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not set values for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
             }
             $vb_attr_errors = true;
         }
         $vn_place_id = $t_place->getPrimaryKey();
         if ($o_event) {
             if ($vb_attr_errors || $vb_label_errors) {
                 $o_event->endItem($vn_place_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_place->getErrors())));
             } else {
                 $o_event->endItem($vn_place_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
             }
         }
         if ($o_log) {
             $o_log->logInfo(_t("Created new place %1", $ps_place_name));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return $t_place;
         }
     } else {
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_places', 'U');
         }
         $vn_place_id = $vn_id;
         if ($o_event) {
             $o_event->endItem($vn_place_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
         }
         if ($o_log) {
             $o_log->logDebug(_t("Found existing place %1 in DataMigrationUtils::getPlaceID(); total of %2 places were found", $ps_place_name, sizeof($va_place_ids) + 1));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return new ca_places($vn_place_id);
         }
     }
     return $vn_place_id;
 }
 }
 if ($va_primary_venue = $t_occurrence->get('ca_entities', array('restrict_to_relationship_types' => array('primary_venue'), "returnAsArray" => 1, 'checkAccess' => $va_access_values))) {
     $va_primary_venue_name = array();
     foreach ($va_primary_venue as $vn_relation_id => $va_primary_venue_info) {
         $va_entities_output[] = $va_primary_venue_info["relation_id"];
         $va_primary_venue_name[] = $va_primary_venue_info["displayname"];
         $vn_venue_entity_id = $va_primary_venue_info["entity_id"];
     }
     print "<div class='subtitle'>" . implode($va_primary_venue_name, ", ") . "</div><!-- end subtitle -->";
 }
 if ($vn_venue_entity_id) {
     $t_venue = new ca_entities($vn_venue_entity_id);
     if ($va_primary_venue_location = $t_venue->get('ca_places', array('restrict_to_relationship_types' => array('location'), "returnAsArray" => 1, 'checkAccess' => $va_access_values))) {
         $va_primary_venue_location_name = array();
         foreach ($va_primary_venue_location as $vn_relation_id => $va_primary_venue_location_info) {
             $t_place = new ca_places($va_primary_venue_location_info["place_id"]);
             $va_primary_venue_location_name[] = $t_place->getLabelForDisplay();
             if ($t_place->get('ca_places.parent.preferred_labels')) {
                 $va_primary_venue_location_name[] = $t_place->get('ca_places.parent.preferred_labels');
             }
             #$va_primary_venue_location_name[] = $va_primary_venue_location_info["name"];
         }
         print "<div class='subsubtitle'>" . implode($va_primary_venue_location_name, ", ") . "</div><!-- end subsubtitle -->";
     }
 }
 if ($t_occurrence->get("ca_occurrences.date.display_date")) {
     $va_date_info = array_pop($t_occurrence->get("ca_occurrences.date.parsed_date", array("rawDate" => true, "returnAsArray" => true)));
     if (($vn_start_date = intval($va_date_info["start"])) && $vn_start_date >= 1904 && $vn_start_date <= 1988) {
         print "<div class='subsubtitle'>" . caNavLink($this->request, $t_occurrence->get("ca_occurrences.date.display_date"), '', 'Chronology', 'Detail', '', array('year' => $vn_start_date)) . "</div>";
     } else {
         print "<div class='subsubtitle'>" . $t_occurrence->get("ca_occurrences.date.display_date") . "</div>";
 /**
  * Returns place_id for the place with the specified name (and type) or idno (regardless of specified type.) If the place does not already
  * exist then it will be created with the specified name, type and locale, as well as with any specified values in the $pa_values array.
  * $pa_values keys should be either valid place fields or attributes.
  *
  * @param string $ps_place_name Place label name
  * @param int $pn_parent_id The parent_id of the place; must be set to a non-null value
  * @param int $pn_type_id The type_id of the place type to use if the place needs to be created
  * @param int $pn_locale_id The locale_id to use if the place needs to be created (will be used for both the place locale as well as the label locale)
  * @param array $pa_values An optional array of additional values to populate newly created place records with. These values are *only* used for newly created places; they will not be applied if the place named already exists. The array keys should be names of ca_places fields or valid entity attributes. Values should be either a scalar (for single-value attributes) or an array of values for (multi-valued attributes)
  * @param array $pa_options An optional array of options, which include:
  *                outputErrors - if true, errors will be printed to console [default=false]
  *                matchOn = optional list indicating sequence of checks for an existing record; values of array can be "label" and "idno". Ex. array("idno", "label") will first try to match on idno and then label if the first match fails.
  *                dontCreate - if true then new places will not be created [default=false]
  *                transaction - if Transaction object is passed, use it for all Db-related tasks [default=null]
  *                returnInstance = return ca_places instance rather than place_id. Default is false.
  *                generateIdnoWithTemplate = A template to use when setting the idno. The template is a value with automatically-set SERIAL values replaced with % characters. Eg. 2012.% will set the created row's idno value to 2012.121 (assuming that 121 is the next number in the serial sequence.) The template is NOT used if idno is passed explicitly as a value in $pa_values.
  *                importEvent = if ca_data_import_events instance is passed then the insert/update of the place will be logged as part of the import
  *                importEventSource = if importEvent is passed, then the value set for importEventSource is used in the import event log as the data source. If omitted a default value of "?" is used
  *                nonPreferredLabels = an optional array of nonpreferred labels to add to any newly created places. Each label in the array is an array with required place label values.
  *                log = if KLogger instance is passed then actions will be logged
  * @return bool|\ca_places|mixed|null
  */
 static function getPlaceID($ps_place_name, $pn_parent_id, $pn_type_id, $pn_locale_id, $pa_values = null, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (!isset($pa_options['outputErrors'])) {
         $pa_options['outputErrors'] = false;
     }
     $pa_match_on = caGetOption('matchOn', $pa_options, array('label', 'idno'), array('castTo' => "array"));
     /** @var ca_data_import_events $o_event */
     $o_event = isset($pa_options['importEvent']) && $pa_options['importEvent'] instanceof ca_data_import_events ? $pa_options['importEvent'] : null;
     $t_place = new ca_places();
     if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
         $t_place->setTransaction($pa_options['transaction']);
         if ($o_event) {
             $o_event->setTransaction($pa_options['transaction']);
         }
     }
     $vs_event_source = isset($pa_options['importEventSource']) && $pa_options['importEventSource'] ? $pa_options['importEventSource'] : "?";
     /** @var KLogger $o_log */
     $o_log = isset($pa_options['log']) && $pa_options['log'] instanceof KLogger ? $pa_options['log'] : null;
     $vs_idno = isset($pa_values['idno']) ? (string) $pa_values['idno'] : null;
     if (preg_match('!\\%!', $vs_idno)) {
         $pa_options['generateIdnoWithTemplate'] = $vs_idno;
         $vs_idno = null;
     }
     if (!$vs_idno) {
         if (isset($pa_options['generateIdnoWithTemplate']) && $pa_options['generateIdnoWithTemplate']) {
             $vs_idno = $t_place->setIdnoWithTemplate($pa_options['generateIdnoWithTemplate'], array('dontSetValue' => true));
         }
     }
     $vn_id = null;
     foreach ($pa_match_on as $vs_match_on) {
         switch (strtolower($vs_match_on)) {
             case 'label':
             case 'labels':
                 if (trim($ps_place_name)) {
                     if ($vn_id = ca_places::find(array('preferred_labels' => array('name' => $ps_place_name), 'type_id' => $pn_type_id, 'parent_id' => $pn_parent_id), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']))) {
                         break 2;
                     }
                     break;
                 }
             case 'idno':
                 if ($vs_idno == '%') {
                     break;
                 }
                 // don't try to match on an unreplaced idno placeholder
                 if ($vn_id = ca_places::find(array('idno' => $vs_idno ? $vs_idno : $ps_place_name), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']))) {
                     break 2;
                 }
                 break;
         }
     }
     if (!$vn_id) {
         if (isset($pa_options['dontCreate']) && $pa_options['dontCreate']) {
             return false;
         }
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_places', 'I');
         }
         $t_place->setMode(ACCESS_WRITE);
         $t_place->set('locale_id', $pn_locale_id);
         $t_place->set('type_id', $pn_type_id);
         $t_place->set('parent_id', $pn_parent_id);
         $t_place->set('source_id', isset($pa_values['source_id']) ? $pa_values['source_id'] : null);
         $t_place->set('access', isset($pa_values['access']) ? $pa_values['access'] : 0);
         $t_place->set('status', isset($pa_values['status']) ? $pa_values['status'] : 0);
         $t_place->set('idno', $vs_idno);
         $t_place->set('lifespan', isset($pa_values['lifespan']) ? $pa_values['lifespan'] : null);
         $t_place->set('hierarchy_id', isset($pa_values['hierarchy_id']) ? $pa_values['hierarchy_id'] : null);
         $t_place->insert();
         if ($t_place->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not insert place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not insert place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
             }
             return null;
         }
         $vb_label_errors = false;
         $t_place->addLabel(array('name' => $ps_place_name), $pn_locale_id, null, true);
         if ($t_place->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not set preferred label for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not set preferred label for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
             }
             $vb_label_errors = true;
         }
         unset($pa_values['access']);
         unset($pa_values['status']);
         unset($pa_values['idno']);
         unset($pa_values['source_id']);
         unset($pa_values['lifespan']);
         unset($pa_values['hierarchy_id']);
         $vb_attr_errors = false;
         if (is_array($pa_values)) {
             foreach ($pa_values as $vs_element => $va_values) {
                 if (!caIsIndexedArray($va_values)) {
                     $va_values = array($va_values);
                 }
                 foreach ($va_values as $va_value) {
                     if (is_array($va_value)) {
                         // array of values (complex multi-valued attribute)
                         $t_place->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
                     } else {
                         // scalar value (simple single value attribute)
                         if ($va_value) {
                             $t_place->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                         }
                     }
                 }
             }
             $t_place->update();
             if ($t_place->numErrors()) {
                 if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                     print "[Error] " . _t("Could not set values for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
                 }
                 if ($o_log) {
                     $o_log->logError(_t("Could not set values for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
                 }
                 $vb_attr_errors = true;
             }
         }
         /** @var IIDNumbering $o_idno */
         if ($o_idno = $t_place->getIDNoPlugInInstance()) {
             $va_values = $o_idno->htmlFormValuesAsArray('idno', $vs_idno);
             if (!is_array($va_values)) {
                 $va_values = array($va_values);
             }
             if (!($vs_sep = $o_idno->getSeparator())) {
                 $vs_sep = '';
             }
             if (($vs_proc_idno = join($vs_sep, $va_values)) && $vs_proc_idno != $vs_idno) {
                 $t_place->set('idno', $vs_proc_idno);
                 $t_place->update();
                 if ($t_place->numErrors()) {
                     if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                         print "[Error] " . _t("Could not update idno for %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
                     }
                     if ($o_log) {
                         $o_log->logError(_t("Could not idno for %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
                     }
                     return null;
                 }
             }
         }
         if (is_array($va_nonpreferred_labels = caGetOption("nonPreferredLabels", $pa_options, null))) {
             if (caIsAssociativeArray($va_nonpreferred_labels)) {
                 // single non-preferred label
                 $va_labels = array($va_nonpreferred_labels);
             } else {
                 // list of non-preferred labels
                 $va_labels = $va_nonpreferred_labels;
             }
             foreach ($va_labels as $va_label) {
                 $t_place->addLabel($va_label, $pn_locale_id, null, false);
                 if ($t_place->numErrors()) {
                     if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                         print "[Error] " . _t("Could not set non-preferred label for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())) . "\n";
                     }
                     if ($o_log) {
                         $o_log->logError(_t("Could not set non-preferred label for place %1: %2", $ps_place_name, join('; ', $t_place->getErrors())));
                     }
                 }
             }
         }
         $vn_place_id = $t_place->getPrimaryKey();
         if ($o_event) {
             if ($vb_attr_errors || $vb_label_errors) {
                 $o_event->endItem($vn_place_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_place->getErrors())));
             } else {
                 $o_event->endItem($vn_place_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
             }
         }
         if ($o_log) {
             $o_log->logInfo(_t("Created new place %1", $ps_place_name));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return $t_place;
         }
     } else {
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_places', 'U');
         }
         $vn_place_id = $vn_id;
         if ($o_event) {
             $o_event->endItem($vn_place_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
         }
         if ($o_log) {
             $o_log->logDebug(_t("Found existing place %1 in DataMigrationUtils::getPlaceID()", $ps_place_name));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             $t_place = new ca_places($vn_place_id);
             if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
                 $t_place->setTransaction($pa_options['transaction']);
             }
             return $t_place;
         }
     }
     return $vn_place_id;
 }
        $vn_i = 1;
        $va_available_facets = $this->getVar('available_facets');
        foreach ($va_available_facets as $vs_facet_code => $va_facet_info) {
            print "<a href='#' onclick='caUIBrowsePanel.showBrowsePanel(\"{$vs_facet_code}\");' class='facetLink'>" . $va_facet_info['label_plural'] . "</a>";
            if ($vn_i < sizeof($va_available_facets)) {
                print ", ";
            }
            $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') . " &rsaquo;", 'startOver', '', 'Browse', 'clearCriteria', array());
    print "</div><!-- end browseCriteria -->\n";
    print "</div><!-- end browseControls -->";
     $vs_search_text = join(" OR ", $va_search_parts);
     $o_ent_search = new EntitySearch();
     # -- exclude the current entity from list
     $o_ent_search->addResultFilter("ca_entities.entity_id", "!=", $vn_entity_id);
     #print_r($o_ent_search->getResultFilters());
     $qr_entities = $o_ent_search->search($vs_search_text, array("sort" => "ca_entity_labels.lname", "checkAccess" => $va_access_values));
     if ($qr_entities->numHits()) {
         print "<div class='ad_col'><div><span class='listhead caps'>" . _t("Artists from same movement") . "</span><br/><ul>";
         while ($qr_entities->nextHit()) {
             print "<li>" . ($this->request->config->get('allow_detail_for_ca_entities') ? caNavLink($this->request, join(", ", $qr_entities->getDisplayLabels()), '', 'Detail', 'Entity', 'Show', array('entity_id' => $qr_entities->get("ca_entities.entity_id"))) : join(", ", $qr_entities->getDisplayLabels())) . "</li>";
         }
         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>";
         }
Beispiel #15
0
 /**
  * Returns name of hierarchy for currently loaded place or, if specified, place with place_id = to optional $pn_id parameter
  */
 public function getHierarchyName($pn_id = null)
 {
     $t_list = new ca_list_items();
     if ($pn_id) {
         $t_place = new ca_places($pn_id);
         $vn_hierarchy_id = $t_place->get('hierarchy_id');
     } else {
         $vn_hierarchy_id = $this->get('hierarchy_id');
     }
     $t_list->load($vn_hierarchy_id);
     return $t_list->getLabelForDisplay(false);
 }
 /**
  * Import oral histories from specified directory into CollectiveAccess database
  */
 public function commandImportOralHistories()
 {
     $o_conf = $this->getToolConfig();
     // Get locale from config and translate to numeric code
     $t_locale = new ca_locales();
     $pn_locale_id = $t_locale->localeCodeToID($o_conf->get('locale'));
     $o_log = $this->getLogger();
     $o_progress = $this->getProgressBar(0);
     $vs_transcript_dir = $this->getSetting("transcript_directory");
     if (!is_readable($vs_transcript_dir)) {
         if ($o_log) {
             $o_log->logError($vs_err_msg = _t("Transcript directory %1 is not readable", $vs_transcript_dir));
         }
         if ($o_progress) {
             $o_progress->setError($vs_err_msg);
             $o_progress->finish();
         }
         return false;
     }
     $vs_audio_dir = $this->getSetting("audio_directory");
     if (!is_readable($vs_audio_dir)) {
         if ($o_log) {
             $o_log->logError($vs_err_msg = _t("Audio directory %1 is not readable", $vs_audio_dir));
         }
         if ($o_progress) {
             $o_progress->setError($vs_err_msg);
             $o_progress->finish();
         }
         return false;
     }
     if ($o_progress) {
         $o_progress->start("Starting oral history import");
     }
     // ----------------------------------------------------------------------
     // process main data
     $r_dir = opendir($vs_transcript_dir);
     while (($vs_file = readdir($r_dir)) !== false) {
         if ($vs_file[0] == '.') {
             continue;
         }
         // Get markup and fix it up to be valid XML
         $vs_markup = file_get_contents($vs_transcript_dir . $vs_file);
         $vs_markup = preg_replace('!&!', '&amp;', $vs_markup);
         $vs_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><transcript>{$vs_markup}</transcript>";
         try {
             $o_xml = new SimpleXMLElement($vs_xml);
         } catch (Exception $e) {
             $o_log->logError("Could not parse XML transcript for {$vs_transcript_dir}{$vs_file}: " . $e->getMessage());
             continue;
         }
         $vs_idno = (string) $o_xml->identifier;
         if (!file_exists($vs_media_path = "{$vs_audio_dir}{$vs_idno}.mp3")) {
             $o_log->logError("No audio file found for {$vs_idno}. File path was {$vs_media_path}");
             continue;
         }
         $vs_title = (string) $o_xml->title;
         $vs_date_created = (string) $o_xml->datecreated;
         $vs_format = (string) $o_xml->format;
         $vs_medium = (string) $o_xml->medium;
         $vs_place_recorded = (string) $o_xml->placeRecorded;
         $vs_rights = (string) $o_xml->rights;
         $vs_extent = (string) $o_xml->extent;
         $vs_country = (string) $o_xml->countryOfOrigin;
         $va_interviewers = array();
         foreach ($o_xml->interviewer as $o_interviewer) {
             $va_interviewers[(string) $o_interviewer->attributes()->abbreviation] = (string) $o_interviewer;
         }
         $va_participants = array();
         foreach ($o_xml->participant as $o_participant) {
             $va_participants[(string) $o_participant->attributes()->abbreviation] = (string) $o_participant;
         }
         $va_observers = array();
         if ($o_xml->observer) {
             foreach ($o_xml->observer as $o_observer) {
                 $va_observers[] = (string) $o_observer;
             }
         }
         // Create object
         $t_object = new ca_objects();
         $t_object->setMode(ACCESS_WRITE);
         if (!$t_object->load(array('idno' => $vs_idno, 'deleted' => 0))) {
             $t_object->set('type_id', 'oral_history');
             $t_object->set('idno', $vs_idno);
             $t_object->set('status', 0);
             $t_object->set('access', 1);
         }
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'dc_format' => $vs_format), 'dc_format');
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'dates_value' => $vs_date_created, 'dc_dates_types' => 'created'), 'date');
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'medium' => $vs_medium), 'medium');
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'interview_location' => $vs_place_recorded), 'interview_location');
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'rights' => $vs_rights), 'rights');
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'extent' => $vs_extent), 'extent');
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'countryOfOrigin' => $vs_country), 'countryOfOrigin');
         if (!$t_object->getPrimaryKey()) {
             $t_object->insert();
             DataMigrationUtils::postError($t_object, 'While inserting object');
             if ($t_object->numErrors()) {
                 $o_log->logError("While adding object for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
             }
             $t_object->addLabel(array('name' => $vs_title), $pn_locale_id, null, true);
             DataMigrationUtils::postError($t_object, 'While adding object label');
             if ($t_object->numErrors()) {
                 $o_log->logError("While adding object label for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
             }
         } else {
             $t_object->update();
             DataMigrationUtils::postError($t_object, 'While updating object');
             if ($t_object->numErrors()) {
                 $o_log->logError("While updating object for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
             }
         }
         // add entities
         foreach ($va_interviewers as $vs_abbr => $vs_name) {
             $vn_entity_id = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName($vs_name), 'ind', $pn_locale_id);
             $t_object->addRelationship('ca_entities', $vn_entity_id, 'interviewer');
             DataMigrationUtils::postError($t_object, "While adding interviewer {$vs_name} to object");
             if ($t_object->numErrors()) {
                 $o_log->logError("While adding interview {$vs_name} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
             }
         }
         foreach ($va_participants as $vs_abbr => $vs_name) {
             $vn_entity_id = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName($vs_name), 'ind', $pn_locale_id);
             $t_object->addRelationship('ca_entities', $vn_entity_id, 'interviewee');
             DataMigrationUtils::postError($t_object, "While adding interviewee {$vs_name} to object");
             if ($t_object->numErrors()) {
                 $o_log->logError("While adding interviee {$vs_name} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
             }
         }
         foreach ($va_observers as $vn_i => $vs_name) {
             $vn_entity_id = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName($vs_name), 'ind', $pn_locale_id);
             $t_object->addRelationship('ca_entities', $vn_entity_id, 'observer');
             DataMigrationUtils::postError($t_object, "While adding observer {$vs_name} to object");
             if ($t_object->numErrors()) {
                 $o_log->logError("While adding observer {$vs_name} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
             }
         }
         // Add media
         $t_rep = $t_object->addRepresentation($vs_media_path, "front", $pn_locale_id, 0, 1, true, array(), array('returnRepresentation' => true));
         DataMigrationUtils::postError($t_object, "While adding representation {$vs_media_path} to object");
         if ($t_object->numErrors()) {
             $o_log->logError("While adding representation {$vs_media_path} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors()));
         }
         if ($t_object->numErrors()) {
             continue;
         }
         $va_clips = array();
         foreach ($o_xml->clip as $o_clip) {
             $vs_content = nl2br(preg_replace('!^[\\n\\r\\t]+!', '', trim((string) $o_clip->asXML())));
             $vs_start = (string) $o_clip->attributes()->start;
             $va_themes = $va_places = array();
             foreach ($o_clip->children() as $o_node) {
                 $vs_tag = (string) $o_node->getName();
                 switch ($vs_tag) {
                     case 'place':
                         $va_places[] = (string) $o_node;
                         break;
                     default:
                         $va_themes[] = $vs_tag;
                         break;
                 }
             }
             $va_clips[] = array('start' => $vs_start, 'content' => $vs_content, 'themes' => $va_themes, 'places' => $va_places);
         }
         foreach ($va_clips as $vn_i => $va_clip) {
             $vs_start = $va_clip['start'];
             if (!($vs_end = $va_clips[$vn_i + 1]['start'])) {
                 $va_info = $t_rep->getMediaInfo('media', 'original');
                 $vs_end = $va_info['PROPERTIES']['duration'];
             }
             //print "[$vs_start/$vs_end] (".join('/', $va_clip['themes'])."); (".join('/', $va_clip['places']).") ".substr($va_clip['content'], 0, 30)."\n\n\n";
             $t_annotation = $t_rep->addAnnotation("{$vs_start} ... {$vs_end}", $pn_locale_id, 1, array('startTimecode' => $vs_start, 'endTimecode' => $vs_end), 0, 1, array('transcription' => $va_clip['content']), array('returnAnnotation' => true));
             DataMigrationUtils::postError($t_rep, "While adding annotation to representation");
             if ($t_rep->numErrors()) {
                 $o_log->logError("While adding annotation {$vs_start}/{$vs_end} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_rep->getErrors()));
             }
             if ($t_annotation) {
                 foreach ($va_clip['themes'] as $vs_theme) {
                     $t_annotation->addRelationship('ca_list_items', $vs_theme, 'describes');
                     DataMigrationUtils::postError($t_annotation, "While adding theme {$vs_theme} to annotation");
                     if ($t_annotation->numErrors()) {
                         $o_log->logError("While adding theme {$vs_theme} to annotation {$vs_start}/{$vs_end} for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_annotation->getErrors()));
                     }
                 }
                 foreach ($va_clip['places'] as $vs_place) {
                     if ($vn_place_id = ca_places::find(array('preferred_labels' => array('name' => $vs_place)), array('returnAs' => 'firstId'))) {
                         $t_annotation->addRelationship('ca_places', $vn_place_id, 'describes');
                         DataMigrationUtils::postError($t_annotation, "While adding place {$vs_place} to annotation");
                         if ($t_annotation->numErrors()) {
                             $o_log->logError("While adding place {$vs_place} to annotation {$vs_start}/{$vs_end} for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_annotation->getErrors()));
                         }
                     }
                 }
             }
         }
         $o_log->logInfo("Imported {$vs_file}");
     }
     $o_progress->finish("Completed processing");
     if ($o_log) {
         $o_log->logDebug(_t("Ended oral history import"));
     }
     return true;
 }
Beispiel #17
0
                                    }
                                    break;
                                case 'Coordinates':
                                    break 2;
                            }
                        }
                    }
                    break;
                    # ---------------------------
            }
        }
        $o_xml->close();
    }
}
$t_place = new ca_places();
$t_parent = new ca_places();
$t_place->setMode(ACCESS_WRITE);
$vn_tgn_root_id = $t_parent->getHierarchyRootID($vn_tgn_id);
if (true) {
    print "[Notice] LINKING TERMS IN HIERARCHY...\n";
    $vn_last_message_length = 0;
    $va_place_id_cache = array();
    for ($vn_file_index = 1; $vn_file_index <= 15; $vn_file_index++) {
        $o_xml->open("tgn_xml_12/TGN{$vn_file_index}.xml");
        print "[Notice] READING TERMS FROM TGN{$vn_file_index}.xml...\n";
        $va_subject = array();
        while ($o_xml->read()) {
            switch ($o_xml->name) {
                # ---------------------------
                case 'Subject':
                    if ($o_xml->nodeType == XMLReader::END_ELEMENT) {
$vs_facet_name = $this->getVar("facet_name");
$vs_key = $this->getVar("key");
$vs_browse_type = $this->getVar("browse_type");
$vs_link_to = $this->request->getParameter('linkTo', pString);
$va_links = array();
if ($vs_facet_name == "place_facet_hier") {
    $t_lists = new ca_lists();
    $va_place_type_ids_to_exclude = array($t_lists->getItemIDFromList("place_types", "city"), $t_lists->getItemIDFromList("place_types", "basin"), $t_lists->getItemIDFromList("place_types", "other"), $t_lists->getItemIDFromList("place_types", "locality"));
}
foreach ($va_facet_list as $vn_key => $va_facet) {
    if ($vs_facet_name == "place_facet_hier") {
        require_once __CA_MODELS_DIR__ . "/ca_places.php";
        $va_child_ids = array_keys($va_facet);
        array_shift($va_child_ids);
        if (sizeof($va_child_ids) > 0) {
            $q_children = ca_places::createResultSet($va_child_ids);
            $va_children_type_ids = array();
            if ($q_children->numHits()) {
                while ($q_children->nextHit()) {
                    $va_children_type_ids[$q_children->get("place_id")] = $q_children->get("type_id");
                }
            }
        }
    }
    foreach ($va_facet as $vn_id => $va_children) {
        if ($vs_facet_name == "place_facet_hier" && in_array($va_children_type_ids[$vn_id], $va_place_type_ids_to_exclude)) {
            continue;
        }
        if (isset($va_children["name"])) {
            $vs_tmp = "";
            $vs_tmp .= "<div>";
?>
	</div><!-- end leftCol -->
	<div id="rightColMap">
<?php 
# --- map
# --- plot circle based on point for tracks and verts
$o_config = caGetDetailConfig();
$va_types = $o_config->getAssoc('detailTypes');
$va_options = $va_types["place"]["options"];
$vs_map_attribute = caGetOption('map_attribute', $va_options, false);
if ($vs_map_attribute && $t_place->get($vs_map_attribute)) {
    $o_map = new GeographicMap(($vn_width = caGetOption('map_width', $va_options, false)) ? $vn_width : 285, ($vn_height = caGetOption('map_height', $va_options, false)) ? $vn_height : 200, 'map');
    $o_map->mapFrom($t_place, $vs_map_attribute);
    print $o_map->render('HTML', array("obscure" => true, "circle" => true, "radius" => 20000, "fillColor" => "#000000", "pathColor" => "#000000", "zoomLevel" => 5));
} else {
    $qr_hits = ca_places::createResultSet($va_hierarchy_ids);
    if ($qr_hits->numHits()) {
        while ($qr_hits->nextHit()) {
            if ($qr_hits->get($vs_map_attribute)) {
                $t_place->load($qr_hits->get("place_id"));
                $o_map = new GeographicMap(($vn_width = caGetOption('map_width', $va_options, false)) ? $vn_width : 285, ($vn_height = caGetOption('map_height', $va_options, false)) ? $vn_height : 200, 'map');
                $o_map->mapFrom($t_place, $vs_map_attribute);
                print $o_map->render('HTML', array("obscure" => true, "circle" => true, "radius" => 20000, "fillColor" => "#000000", "pathColor" => "#000000", "zoomLevel" => 5));
                break;
            }
        }
    }
}
?>
	</div><!-- end rightColMap -->
</div><!-- end detailBody -->