public function getFeaturedArtistSlideshow()
 {
     $va_featured_ids = array();
     $t_featured = new ca_sets();
     # --- featured artists set - set name assigned in eastend.conf - plugin conf file
     $t_featured->load(array('set_code' => $this->opo_plugin_config->get('featured_artists_set_name')));
     # Enforce access control on set
     if (sizeof($this->opa_access_values) == 0 || sizeof($this->opa_access_values) && in_array($t_featured->get("access"), $this->opa_access_values)) {
         $this->view->setVar('featured_set_id', $t_featured->get("set_id"));
         $va_featured_ids = array_keys(is_array($va_tmp = $t_featured->getItemRowIDs(array('checkAccess' => $this->opa_access_values, 'shuffle' => 1))) ? $va_tmp : array());
         // These are the entity ids in the set
     }
     if (!is_array($va_featured_ids) || sizeof($va_featured_ids) == 0) {
         # put random entities in the features variable
         $o_db = new Db();
         $q_entities = $o_db->query("SELECT e.entity_id from ca_entities e WHERE e.access IN (" . implode($this->opa_access_values, ", ") . ") ORDER BY RAND() LIMIT 10");
         if ($q_entities->numRows() > 0) {
             while ($q_entities->nextRow()) {
                 $va_featured_ids[] = $q_entities->get("entity_id");
             }
         }
     }
     # --- loop through featured ids and grab the entity's name, portrait, lifespan -lifespans_date, indexing_notes (brief description abouthow they relate to the east end)
     $t_entity = new ca_entities();
     $t_object = new ca_objects();
     $va_featured_artists = array();
     foreach ($va_featured_ids as $vn_featured_entity_id) {
         $va_tmp = array();
         $t_entity->load($vn_featured_entity_id);
         $va_tmp["entity_id"] = $vn_featured_entity_id;
         $va_tmp["lifespan"] = $t_entity->get("lifespans_date");
         $va_tmp["indexing_notes"] = $t_entity->get("indexing_notes");
         $va_tmp["name"] = $t_entity->getLabelForDisplay();
         $va_objects = $t_entity->get("ca_objects", array("returnAsArray" => 1, 'checkAccess' => $this->opa_access_values, 'restrict_to_relationship_types' => array('portrait')));
         $va_object = array_shift($va_objects);
         $t_object->load($va_object["object_id"]);
         $va_portrait = $t_object->getPrimaryRepresentation(array("abSlideShow"));
         # --- don't show records with status ars/vaga don't show image
         if ($t_object->get("ca_objects.object_status") != 348) {
             if ($t_object->get("ca_objects.object_status") == 349) {
                 $va_tmp["vaga_class"] = "vagaDisclaimer";
             }
             $va_tmp["image"] = $va_portrait["tags"]["abSlideShow"];
             $va_tmp["caption"] = $t_object->get("ca_objects.caption");
         }
         $va_featured_artists[$vn_featured_entity_id] = $va_tmp;
     }
     $this->view->setVar("featured_artists", $va_featured_artists);
     $this->render('featured_artists_html.php');
 }
 * 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_entity_ids = $this->getVar("entity_ids");
$t_entity = new ca_entities();
?>
	<div id="memberMapBalloonContainer">
<?php 
foreach ($va_entity_ids as $vn_entity_id) {
    $t_entity->load($vn_entity_id);
    print "<H1>" . $t_entity->getLabelForDisplay() . "</H1>";
    if ($t_entity->get("biography")) {
        print "<p>";
        print $t_entity->get("biography");
        print "</p>";
    }
    if ($t_entity->get("ca_entities.external_link.url_entry")) {
        print "<p>";
        print "<a href='" . $t_entity->get("ca_entities.external_link.url_entry") . "' target='_blank'>" . $t_entity->get("ca_entities.external_link.url_entry") . "</a>";
        print "</p>";
Exemplo n.º 3
0
 /** 
  * Returns entity_id for the entity with the specified name, regardless of specified type. If the entity 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 entity fields or attributes.
  *
  * @param array $pa_entity_name Array with values for entity label
  * @param int $pn_type_id The type_id of the entity type to use if the entity needs to be created
  * @param int $pn_locale_id The locale_id to use if the entity needs to be created (will be used for both the entity locale as well as the label locale)
  * @param array $pa_values An optional array of additional values to populate newly created entity records with. These values are *only* used for newly created entities; they will not be applied if the entity named already exists. The array keys should be names of ca_entities 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]
  *				dontCreate - if true then new entities will not be created [default=false]
  *				matchOnIdno - try to match on idno if name match fails [default=false]
  *				matchOnDisplayName  if true then entities are looked up exclusively using displayname, otherwise forename and surname fields are used [default=false]
  * 				transaction - if Transaction instance is passed, use it for all Db-related tasks [default=null]
  *				returnInstance = return ca_entities instance rather than entity_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 entity 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 getEntityID($pa_entity_name, $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_displayname = caGetOption('matchOnDisplayName', $pa_options, false);
     $pb_match_on_idno = caGetOption('matchOnIdno', $pa_options, false);
     $t_entity = new ca_entities();
     if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
         $t_entity->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;
     $va_find_arr = array();
     if ($pn_type_id) {
         $va_find_arr['type_id'] = $pn_type_id;
     }
     if (!($vs_idno = isset($pa_values['idno']) ? (string) $pa_values['idno'] : null)) {
         if (isset($pa_options['generateIdnoWithTemplate']) && $pa_options['generateIdnoWithTemplate']) {
             $vs_idno = $t_entity->setIdnoTWithTemplate($pa_options['generateIdnoWithTemplate'], array('dontSetValue' => true));
         }
     }
     if ($pb_match_on_displayname) {
         $vn_id = ca_entities::find(array_merge(array('preferred_labels' => array('displayname' => $pa_entity_name['displayname']), $va_find_arr)), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
     } else {
         $vn_id = ca_entities::find(array_merge(array('preferred_labels' => array('forename' => $pa_entity_name['forename'], 'surname' => $pa_entity_name['surname']), $va_find_arr)), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
     }
     if (!$vn_id && $pb_match_on_idno) {
         $va_find_arr['idno'] = $vs_idno;
         $vn_id = ca_entities::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_entities', 'I');
         }
         $t_entity->setMode(ACCESS_WRITE);
         $t_entity->set('locale_id', $pn_locale_id);
         $t_entity->set('type_id', $pn_type_id);
         $t_entity->set('source_id', isset($pa_values['source_id']) ? $pa_values['source_id'] : null);
         $t_entity->set('access', isset($pa_values['access']) ? $pa_values['access'] : 0);
         $t_entity->set('status', isset($pa_values['status']) ? $pa_values['status'] : 0);
         $t_entity->set('idno', $vs_idno);
         $t_entity->set('lifespan', isset($pa_values['lifespan']) ? $pa_values['lifespan'] : null);
         $t_entity->set('parent_id', isset($pa_values['parent_id']) ? $pa_values['parent_id'] : null);
         unset($pa_values['access']);
         unset($pa_values['status']);
         unset($pa_values['idno']);
         unset($pa_values['source_id']);
         unset($pa_values['lifespan']);
         unset($pa_values['_interstitial']);
         $t_entity->insert();
         if ($t_entity->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not insert entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not insert entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())));
             }
             return null;
         }
         $vb_label_errors = false;
         $t_entity->addLabel($pa_entity_name, $pn_locale_id, null, true);
         if ($t_entity->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not set preferred label for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not set preferred label for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())));
             }
             $vb_label_errors = true;
         }
         $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_entity->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
                 } else {
                     // scalar value (simple single value attribute)
                     if ($va_value) {
                         $t_entity->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                     }
                 }
             }
             $t_entity->update();
             if ($t_entity->numErrors()) {
                 if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                     print "[Error] " . _t("Could not set values for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())) . "\n";
                 }
                 if ($o_log) {
                     $o_log->logError(_t("Could not set values for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())));
                 }
                 $vb_attr_errors = true;
             }
         }
         $vn_entity_id = $t_entity->getPrimaryKey();
         if ($o_event) {
             if ($vb_attr_errors || $vb_label_errors) {
                 $o_event->endItem($vn_entity_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_entity->getErrors())));
             } else {
                 $o_event->endItem($vn_entity_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
             }
         }
         if ($o_log) {
             $o_log->logInfo(_t("Created new entity %1", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname']));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return $t_entity;
         }
     } else {
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_entities', 'U');
         }
         $vn_entity_id = $vn_id;
         if ($o_event) {
             $o_event->endItem($vn_entity_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
         }
         if ($o_log) {
             $o_log->logDebug(_t("Found existing entity %1 in DataMigrationUtils::getEntityID(); total of %2 entities were found", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], sizeof($va_entity_ids) + 1));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return new ca_entities($vn_entity_id);
         }
     }
     return $vn_entity_id;
 }
 while ($qr_res->nextHit()) {
     if ($vs_media = $qr_res->getWithTemplate('<l>^ca_object_representations.media.large</l>', array("checkAccess" => $va_access_values))) {
         print "<li><div class='frontSlide'>" . $vs_media;
         print "<div class='frontSlideCaption'>";
         print $qr_res->getWithTemplate("<l><i>^ca_objects.preferred_labels.name</i></l>");
         if ($qr_res->get("ca_objects.creation_date")) {
             print ", ";
             if (strtolower($qr_res->get("ca_objects.creation_date")) == "unknown") {
                 print "Date " . $qr_res->get("ca_objects.creation_date");
             } else {
                 print $qr_res->get("ca_objects.creation_date");
             }
         }
         $va_entities = $qr_res->get("ca_entities", array("returnAsArray" => true, "restrictToRelationshipTypes" => array("creator"), "checkAccess" => $va_access_values));
         if (sizeof($va_entities)) {
             $t_entity = new ca_entities();
             print "<br/>";
             $i = 0;
             foreach ($va_entities as $va_entity) {
                 $t_entity->load($va_entity["entity_id"]);
                 print caDetailLink($this->request, $t_entity->getLabelForDisplay(), "", "ca_entities", $t_entity->get("entity_id"));
                 $vs_nationality = trim($t_entity->get("nationality", array("delimiter" => "; ", "convertCodesToDisplayText" => true)));
                 $vs_dob = $t_entity->get("dob_dod");
                 if (strtolower($vs_dob) == "unknown") {
                     $vs_dob = "";
                 }
                 if ($vs_nationality || $vs_dob) {
                     print " (" . $vs_nationality;
                     if ($vs_nationality && $vs_dob) {
                         print ", ";
                     }
Exemplo n.º 5
0
 function RefineSearch()
 {
     $vs_refine = "";
     $pn_entity_id = $this->request->getParameter('entity_id', pInteger);
     $this->view->setVar('entity_id', $pn_entity_id);
     $t_entity = new ca_entities($pn_entity_id);
     $this->view->setVar('entity_name', $t_entity->getLabelForDisplay());
     if ($pn_entity_id) {
         $vs_refine = " AND ca_entities.entity_id:" . $pn_entity_id;
     }
     $pn_occurrence_id = $this->request->getParameter('occurrence_id', pInteger);
     $this->view->setVar('occurrence_id', $pn_occurrence_id);
     $t_occurrence = new ca_occurrences($pn_occurrence_id);
     $this->view->setVar('occurrence_name', $t_occurrence->getLabelForDisplay());
     if ($pn_occurrence_id) {
         $vs_refine = " AND ca_occurrences.occurrence_id:" . $pn_occurrence_id;
     }
     # --- style school
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $this->view->setVar('item_id', $pn_item_id);
     $t_list_item = new ca_list_items($pn_item_id);
     $this->view->setVar('style_school_name', $t_list_item->getLabelForDisplay());
     if ($pn_item_id) {
         $vs_refine = " AND ca_objects.style_school:" . $pn_item_id;
     }
     $vn_y = $this->ops_date_range;
     $va_period_data = array();
     $o_obj_search_refine = new ObjectSearch();
     $qr_objects_refine = $o_obj_search_refine->search("ca_objects.creation_date:\"" . $vn_y . "\" AND (ca_object.object_status:349 OR ca_object.object_status:347 OR ca_object.object_status:193)" . $vs_refine, array("sort" => "ca_objects.creation_date", "no_cache" => !$this->opb_cache_searches, "checkAccess" => $this->opa_access_values));
     $va_object_ids = array();
     while ($qr_objects_refine->nextHit()) {
         $va_object_ids[] = $qr_objects_refine->get("ca_objects.object_id");
     }
     $qr_objects_refine->seek(0);
     $this->opo_result_context->setAsLastFind();
     $this->opo_result_context->setResultList($va_object_ids);
     $this->opo_result_context->setParameter("period", $this->opn_period);
     $this->opo_result_context->saveContext();
     $va_period_data["objects"] = $qr_objects_refine;
     $this->view->setVar('period_data', $va_period_data);
     $this->render('chronology_object_results_html.php');
 }
 /**
  * Remove all likes from object (for one user)
  * @param array $pa_data
  * @return bool
  */
 protected function unlike($pa_data)
 {
     if (!is_array($pa_data) || !isset($pa_data['object_id']) || !isset($pa_data['entity_id'])) {
         $this->addError("Malformed request body");
         return false;
     }
     $vn_object_id = (int) $pa_data['object_id'];
     $t_object = new ca_objects($vn_object_id);
     if (!$t_object->getPrimaryKey()) {
         $this->addError("Invalid object id");
         return false;
     }
     $vn_entity_id = (int) $pa_data['entity_id'];
     $t_entity = new ca_entities($vn_entity_id);
     if (!$t_entity->getPrimaryKey()) {
         $this->addError("Invalid entity id");
         return false;
     }
     $o_db = new Db();
     $qr_likes = $o_db->query("\n\t\t\tDELETE FROM ca_item_comments WHERE name = ? AND table_num = ? AND row_id = ?\n\t\t", $vn_entity_id, $t_object->tableNum(), $t_object->getPrimaryKey());
     if (!$qr_likes) {
         $this->addError('something may have went wrong');
         return false;
     }
     return array('msg' => 'like(s) successfully removed');
 }
    $vs_buf .= $qr_rels->get("ca_objects_x_entities.date_in");
    $vs_buf .= "</div>";
    $vs_buf .= "<div class='col-xs-2 col-sm-2 col-md-2 col-lg-2'>";
    $vs_buf .= $qr_rels->get("ca_objects_x_entities.representative");
    $vs_buf .= "</div>";
    $vs_buf .= "<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'>";
    $vs_buf .= $qr_rels->get("ca_objects_x_entities.fine");
    $vs_buf .= "</div>";
    $vs_buf .= "<div class='col-xs-2 col-sm-2 col-md-2 col-lg-2'>";
    $vs_buf .= $va_parents[$qr_rels->get("ca_objects_x_entities.see_original_link", array('idsOnly' => true))] . " " . $qr_rels->get("ca_objects_x_entities.see_original_link", array('returnAsLink' => true));
    $vs_buf .= "</div>";
    $vs_buf .= "</div>";
    # Reader Count
    $vn_entity_id = $qr_rels->get("ca_entities.entity_id");
    $va_readers[$vn_entity_id] = $qr_rels->get("ca_entities.preferred_labels.displayname");
    $t_entity = new ca_entities($vn_entity_id);
    $va_reading_list = $t_entity->get('ca_objects.object_id', array('returnAsArray' => true, 'restrictToRelationshipTypes' => array('reader')));
    $va_volume_list = $t_object->get('ca_objects.children.object_id', array('returnAsArray' => true));
    foreach ($va_volume_list as $va_volume_key => $va_volume_list_id) {
        $vn_read_volume = false;
        foreach ($va_reading_list as $va_reading_key => $va_reading_id) {
            if ($va_reading_id == $va_volume_list_id) {
                $vn_read_volume = true;
            }
        }
    }
    if ($vn_read_volume == true) {
        $va_full_set_readers[$vn_entity_id] = $qr_rels->get("ca_entities.preferred_labels.displayname");
    }
    $vn_i++;
}
Exemplo n.º 8
0
                } else {
                    if ($va_entity['relationship_typename'] == "creator - web") {
                        $this->setVar('tooltip_relationship', "Creator");
                    }
                }
            }
            if ($t_object->get("ca_entities.lifespan")) {
                $this->setVar('tooltip_lifespan', $t_object->get("ca_entities.lifespan"));
            }
            if ($t_object->get("ca_entities.residence")) {
                $this->setVar('tooltip_residence', $t_object->get("ca_entities.residence"));
            }
            if ($t_object->get("ca_entities.birthplace")) {
                $this->setVar('tooltip_birthplace', $t_object->get("ca_entities.birthplace"));
            }
            $t_entity = new ca_entities($va_entity["entity_id"]);
            if ($t_entity->get("ca_entities", array('restrict_to_relationship_types' => array('employer')))) {
                $this->setVar('tooltip_employer', $t_entity->get("ca_entities", array('restrict_to_relationship_types' => array('employer'))));
            }
            if ($t_object->get("ca_entities.occupation")) {
                $this->setVar('tooltip_occupation', $t_object->get("ca_entities.occupation"));
            }
            if ($t_entity->get("ca_places.preferred_labels.name", array('restrict_to_relationship_types' => array('residence')))) {
                $this->setVar('tooltip_floor', $t_entity->get("ca_places.preferred_labels.name", array('restrict_to_relationship_types' => array('workplace'))));
            }
            TooltipManager::add("#item{$va_entity['idno']}", $this->render('tooltip_html.php'));
        }
    }
    ?>
				</div><!-- end unit -->
<?php 
Exemplo n.º 9
0
 /**
  *
  */
 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? true : (bool) $pa_element_info['settings']['requireValue'];
     if (preg_match('![^\\d]+!', $ps_value)) {
         // try to convert idno to entity_id
         if ($vn_id = ca_entities::find(array('idno' => $ps_value), array('returnAs' => 'firstId'))) {
             $ps_value = $vn_id;
         }
     }
     if (!$vb_require_value && !(int) $ps_value) {
         return array('value_longtext1' => null, 'value_integer1' => null);
     }
     if (strlen($ps_value) && !is_numeric($ps_value)) {
         $this->postError(1970, _t('Item_id %2 is not valid for element %1', $pa_element_info["element_code"], $ps_value), 'EntitiesAttributeValue->parseValue()');
         return false;
     }
     $t_item = new ca_entities((int) $ps_value);
     if (!$t_item->getPrimaryKey()) {
         if ($ps_value) {
             $this->postError(1970, _t('%1 is not a valid entity_id for %2 [%3]', $ps_value, $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'EntitiesAttributeValue->parseValue()');
         } else {
             return null;
         }
         return false;
     }
     return array('value_longtext1' => $ps_value, 'value_integer1' => (int) $ps_value);
 }
 * 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
 *
 * ----------------------------------------------------------------------
 */
$vo_result = $this->getVar('result');
$vn_items_per_page = $this->getVar('current_items_per_page');
$va_access_values = $this->getVar('access_values');
$va_entity_results = array();
?>
	
	<div id="rightcol_featured"></div><!-- rightcol_featured -->	
<?php 
if ($vo_result) {
    $t_entity = new ca_entities();
    while ($vo_result->nextHit()) {
        $vn_entity_id = $vo_result->get('ca_entities.entity_id');
        $va_labels = $vo_result->getDisplayLabels($this->request);
        $vs_surname = $vo_result->get("ca_entity_labels.surname");
        $vs_letter = mb_strtoupper(mb_substr($vs_surname, 0, 1));
        $va_entity_results[$vs_letter]["entities"][] = caNavLink($this->request, join($va_labels, "; "), '', 'Detail', 'Entity', 'Show', array('entity_id' => $vn_entity_id));
        if (!$va_entity_results[$vs_letter]["image"]) {
            $t_entity->load($vn_entity_id);
            $va_portraits = $t_entity->get("ca_objects", array("restrictToRelationshipTypes" => array("portrait"), "returnAsArray" => 1, 'checkAccess' => $va_access_values));
            foreach ($va_portraits as $va_portrait) {
                $t_object = new ca_objects($va_portrait["object_id"]);
                if ($t_object->get("object_status") != 348) {
                    if ($va_portrait = $t_object->getPrimaryRepresentation(array('abHeadShot'), null, array('return_with_access' => $va_access_values))) {
                        $vs_vaga_class = "";
                        if ($t_object->get("object_status") == 349) {
Exemplo n.º 11
0
 /**
  * Returns entity_id for the entity with the specified name (and type) or idno (regardless of specified type.) If the entity 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 entity fields or attributes.
  *
  * @param array $pa_entity_name Array with values for entity label
  * @param int $pn_type_id The type_id of the entity type to use if the entity needs to be created
  * @param int $pn_locale_id The locale_id to use if the entity needs to be created (will be used for both the entity locale as well as the label locale)
  * @param array $pa_values An optional array of additional values to populate newly created entity records with. These values are *only* used for newly created entities; they will not be applied if the entity named already exists. The array keys should be names of ca_entities 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]
  *                dontCreate - if true then new entities will not be created [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.
  *                matchOnDisplayName  if true then entities are looked up exclusively using displayname, otherwise forename and surname fields are used [default=false]
  *                transaction - if Transaction instance is passed, use it for all Db-related tasks [default=null]
  *                returnInstance = return ca_entities instance rather than entity_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 entity 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 entities. Each label in the array is an array with required entity label values.
  *                log = if KLogger instance is passed then actions will be logged
  * @return bool|\ca_entities|mixed|null
  */
 static function getEntityID($pa_entity_name, $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_displayname = caGetOption('matchOnDisplayName', $pa_options, 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_entity = new ca_entities();
     if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
         $t_entity->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;
     $vn_parent_id = isset($pa_values['parent_id']) && $pa_values['parent_id'] ? $pa_values['parent_id'] : 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_entity->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 ($pb_match_on_displayname && strlen(trim($pa_entity_name['displayname'])) > 0) {
                     $vn_id = ca_entities::find(array('preferred_labels' => array('displayname' => $pa_entity_name['displayname']), 'type_id' => $pn_type_id, 'parent_id' => $vn_parent_id), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
                 } else {
                     $vn_id = ca_entities::find(array('preferred_labels' => array('forename' => $pa_entity_name['forename'], 'surname' => $pa_entity_name['surname']), 'type_id' => $pn_type_id, 'parent_id' => $vn_parent_id), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
                 }
                 if ($vn_id) {
                     break 2;
                 }
                 break;
             case 'surname':
                 $vn_id = ca_entities::find(array('preferred_labels' => array('surname' => $pa_entity_name['surname']), 'type_id' => $pn_type_id, 'parent_id' => $vn_parent_id), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
                 if ($vn_id) {
                     break 2;
                 }
                 break;
             case 'forename':
                 $vn_id = ca_entities::find(array('preferred_labels' => array('forename' => $pa_entity_name['forename']), 'type_id' => $pn_type_id, 'parent_id' => $vn_parent_id), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
                 if ($vn_id) {
                     break 2;
                 }
                 break;
             case 'displayname':
                 $vn_id = ca_entities::find(array('preferred_labels' => array('displayname' => $pa_entity_name['displayname']), 'type_id' => $pn_type_id, 'parent_id' => $vn_parent_id), array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
                 if ($vn_id) {
                     break 2;
                 }
                 break;
             case 'idno':
                 if ($vs_idno == '%') {
                     break;
                 }
                 // don't try to match on an unreplaced idno placeholder
                 if (($vs_idno || trim($pa_entity_name['_originalText'])) && ($vn_id = ca_entities::find(array('idno' => $vs_idno ? $vs_idno : $pa_entity_name['_originalText']), 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_entities', 'I');
         }
         $t_entity->setMode(ACCESS_WRITE);
         $t_entity->set('locale_id', $pn_locale_id);
         $t_entity->set('type_id', $pn_type_id);
         $t_entity->set('source_id', isset($pa_values['source_id']) ? $pa_values['source_id'] : null);
         $t_entity->set('access', isset($pa_values['access']) ? $pa_values['access'] : 0);
         $t_entity->set('status', isset($pa_values['status']) ? $pa_values['status'] : 0);
         $t_entity->set('idno', $vs_idno);
         $t_entity->set('lifespan', isset($pa_values['lifespan']) ? $pa_values['lifespan'] : null);
         $t_entity->set('parent_id', isset($pa_values['parent_id']) ? $pa_values['parent_id'] : null);
         unset($pa_values['access']);
         unset($pa_values['status']);
         unset($pa_values['idno']);
         unset($pa_values['source_id']);
         unset($pa_values['lifespan']);
         unset($pa_values['_interstitial']);
         $t_entity->insert();
         if ($t_entity->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not insert entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not insert entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())));
             }
             return null;
         }
         $vb_label_errors = false;
         $t_entity->addLabel($pa_entity_name, $pn_locale_id, null, true);
         if ($t_entity->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not set preferred label for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not set preferred label for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())));
             }
             $vb_label_errors = true;
         }
         /** @var IIDNumbering $o_idno */
         if ($o_idno = $t_entity->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_entity->set('idno', $vs_proc_idno);
                 $t_entity->update();
                 if ($t_entity->numErrors()) {
                     if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                         print "[Error] " . _t("Could not update idno for %1: %2", join("/", $pa_entity_name), join('; ', $t_entity->getErrors())) . "\n";
                     }
                     if ($o_log) {
                         $o_log->logError(_t("Could not update idno for %1: %2", join("/", $pa_entity_name), join('; ', $t_entity->getErrors())));
                     }
                     return null;
                 }
             }
         }
         $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_entity->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
                     } else {
                         // scalar value (simple single value attribute)
                         if ($va_value) {
                             $t_entity->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                         }
                     }
                 }
             }
             $t_entity->update();
             if ($t_entity->numErrors()) {
                 if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                     print "[Error] " . _t("Could not set values for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())) . "\n";
                 }
                 if ($o_log) {
                     $o_log->logError(_t("Could not set values for entity %1: %2", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname'], join('; ', $t_entity->getErrors())));
                 }
                 $vb_attr_errors = true;
             }
         }
         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_entity->addLabel($va_label, $pn_locale_id, null, false);
                 if ($t_entity->numErrors()) {
                     if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                         print "[Error] " . _t("Could not set non-preferred label for entity %1: %2", $va_label['forename'] . "/" . $va_label['surname'], join('; ', $t_entity->getErrors())) . "\n";
                     }
                     if ($o_log) {
                         $o_log->logError(_t("Could not set non-preferred label for entity %1: %2", $va_label['forename'] . "/" . $va_label['surname'], join('; ', $t_entity->getErrors())));
                     }
                 }
             }
         }
         $vn_entity_id = $t_entity->getPrimaryKey();
         if ($o_event) {
             if ($vb_attr_errors || $vb_label_errors) {
                 $o_event->endItem($vn_entity_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_entity->getErrors())));
             } else {
                 $o_event->endItem($vn_entity_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
             }
         }
         if ($o_log) {
             $o_log->logInfo(_t("Created new entity %1", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname']));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return $t_entity;
         }
     } else {
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_entities', 'U');
         }
         $vn_entity_id = $vn_id;
         if ($o_event) {
             $o_event->endItem($vn_entity_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
         }
         if ($o_log) {
             $o_log->logDebug(_t("Found existing entity %1 in DataMigrationUtils::getEntityID()", $pa_entity_name['forename'] . "/" . $pa_entity_name['surname']));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             $t_entity = new ca_entities($vn_entity_id);
             if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
                 $t_entity->setTransaction($pa_options['transaction']);
             }
             return $t_entity;
         }
     }
     return $vn_entity_id;
 }
Exemplo n.º 12
0
<?php 
    # --- increase width of art_detail_info if the image is less than 580 px wide
    $vn_info_width = 200;
    if ($va_media_info["WIDTH"] < 580) {
        $vn_info_width = $vn_info_width + (580 - $va_media_info["WIDTH"]);
    }
}
?>
		<div id="art_detail_info" <?php 
print $vn_info_width ? "style='width:" . $vn_info_width . "px;'" : "";
?>
>	
<?php 
# --- creator
$va_creator = $t_object->get("ca_entities", array("restrictToRelationshipTypes" => array("maker", "artist"), "returnAsArray" => 1, 'checkAccess' => $va_access_values, 'sort' => 'surname'));
$t_creator = new ca_entities();
if (sizeof($va_creator) > 0) {
    foreach ($va_creator as $va_entity) {
        $vs_creator = $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"];
        # --- load the entity record for the creator so can grab the portrait
        $t_creator->load($va_entity["entity_id"]);
    }
    # --- get the portrait of the creator
    // 			$va_portraits = $t_creator->get("ca_objects", array("restrictToRelationshipTypes" => array("portrait"), "returnAsArray" => 1, 'checkAccess' => $va_access_values));
    // 			foreach($va_portraits as $va_portrait){
    // 				$t_object = new ca_objects($va_portrait["object_id"]);
    // 				if($va_portrait = $t_object->getPrimaryRepresentation(array('tiny'), null, array('return_with_access' => $va_access_values))){
    // 					print "<div id='portrait'>".$va_portrait['tags']['tiny']."</div><!-- end portrait -->";
    // 					break;
    // 				}
    // 			}
 /**
  *
  */
 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;
     $va_group_dest = explode(".", $pa_group['destination']);
     $vs_terminal = array_pop($va_group_dest);
     $pm_value = $pa_source_data[$pa_item['source']];
     if (is_array($pm_value)) {
         $va_entities = $pm_value;
         // for input formats that support repeating values
     } else {
         $va_entities = array($pm_value);
     }
     $va_vals = array();
     $vn_c = 0;
     $t_entity = new ca_entities();
     foreach ($va_entities as $pm_value) {
         if (!($vs_entity = trim($pm_value))) {
             return array();
         }
         if (is_array($va_skip_values = $pa_item['settings']['entityJoiner_skipIfValue']) && in_array($vs_entity, $va_skip_values)) {
             return array();
         }
         $va_name = array();
         foreach ($t_entity->getLabelUIFields() as $vs_fld) {
             $va_name[$vs_fld] = BaseRefinery::parsePlaceholder($pa_item['settings']['entityJoiner_' . $vs_fld], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '));
         }
         if (isset($va_name[$vs_terminal])) {
             return $va_name[$vs_terminal];
         }
         if (in_array($vs_terminal, array('preferred_labels', 'nonpreferred_labels'))) {
             return $va_name;
         }
         // Set label
         $va_val = array('preferred_labels' => $va_name);
         // Set relationship type
         if ($vs_rel_type_opt = $pa_item['settings']['entityJoiner_relationshipType']) {
             $va_val['_relationship_type'] = BaseRefinery::parsePlaceholder($vs_rel_type_opt, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '));
         }
         if ((!isset($va_val['_relationship_type']) || !$va_val['_relationship_type']) && ($vs_rel_type_opt = $pa_item['settings']['entityJoiner_relationshipTypeDefault'])) {
             $va_val['_relationship_type'] = BaseRefinery::parsePlaceholder($vs_rel_type_opt, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '));
         }
         if ((!isset($va_val['_relationship_type']) || !$va_val['_relationship_type']) && $o_log) {
             $o_log->logWarn(_t('[entityJoinerRefinery] No relationship type is set for entity %1', $vs_entity));
         }
         // Set entity_type
         if ($vs_type_opt = $pa_item['settings']['entityJoiner_entityType']) {
             $va_val['_type'] = BaseRefinery::parsePlaceholder($vs_type_opt, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '));
         }
         if ((!isset($va_val['_type']) || !$va_val['_type']) && ($vs_type_opt = $pa_item['settings']['entityJoiner_entityTypeDefault'])) {
             $va_val['_type'] = BaseRefinery::parsePlaceholder($vs_type_opt, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '));
         }
         if ((!isset($va_val['_type']) || !$va_val['_type']) && $o_log) {
             $o_log->logWarn(_t('[entityJoinerRefinery] No entity type is set for entity %1', $vs_entity));
         }
         // Set attributes
         if (is_array($va_attr_vals = caProcessRefineryAttributes($pa_item['settings']['entityJoiner_attributes'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'log' => $o_log)))) {
             $va_val = array_merge($va_val, $va_attr_vals);
         }
         // Set interstitials
         if (isset($pa_options['mapping']) && is_array($va_attr_vals = caProcessInterstitialAttributes('entityJoiner', $pa_options['mapping']->get('table_num'), 'ca_entities', $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'log' => $o_log)))) {
             $va_val = array_merge($va_val, $va_attr_vals);
         }
         caProcessRefineryRelatedMultiple($this, $pa_item, $pa_source_data, $vn_c, $o_log, caGetOption('reader', $pa_options, null), $va_val, $va_vals);
         // nonpreferred labels
         if (is_array($pa_item['settings']['entityJoiner_nonpreferred_labels'])) {
             $va_non_preferred_labels = array();
             foreach ($pa_item['settings']['entityJoiner_nonpreferred_labels'] as $vn_index => $va_elements) {
                 if (is_array($va_elements)) {
                     $vb_non_pref_label_was_set = false;
                     foreach ($va_elements as $vs_k => $vs_v) {
                         if (!trim($vs_v)) {
                             continue;
                         }
                         if ($vs_k == 'split') {
                             if (!is_array($va_non_preferred_labels[$vn_index])) {
                                 $va_non_preferred_labels[$vn_index] = array();
                             }
                             if ($vs_name = BaseRefinery::parsePlaceholder($vs_v, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '))) {
                                 $va_non_preferred_labels[$vn_index] = array_merge($va_non_preferred_labels[$vn_index], DataMigrationUtils::splitEntityName($vs_name));
                                 $vb_non_pref_label_was_set = true;
                             }
                         } else {
                             if ($va_non_preferred_labels[$vn_index][$vs_k] = trim(BaseRefinery::parsePlaceholder($vs_v, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                                 $vb_non_pref_label_was_set = true;
                             }
                         }
                     }
                 }
                 if (!$vb_non_pref_label_was_set) {
                     unset($va_non_preferred_labels[$vn_index]);
                 }
             }
             if (sizeof($va_non_preferred_labels)) {
                 $va_val['nonpreferred_labels'] = $va_non_preferred_labels;
             }
         }
         $va_vals[] = $va_val;
         $vn_c++;
     }
     return $va_vals;
 }
Exemplo n.º 14
0
}
$t_object_share = new ca_objects($va_featured_share_ids[0]);
$va_rep = $t_object_share->getPrimaryRepresentation(array('frontpage'), null, array('return_with_access' => $va_access_values));
$vn_featured_share_id = $va_featured_share_ids[0];
$vs_featured_share_image = $va_rep["tags"]["frontpage"];
$vs_featured_share_label = $t_object->getLabelForDisplay();
# --- set for featured member - set name assigned in app.conf - featured_member_set_name - this is an ENTITY set
$t_featured_member = new ca_sets();
$t_featured_member->load(array('set_code' => $this->request->config->get('featured_member_set_name')));
# Enforce access control on set
if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_featured_member->get("access"), $va_access_values)) {
    $vn_featured_member_set_id = $t_featured_member->get("set_id");
    $va_featured_member_ids = array_keys(is_array($va_tmp = $t_featured_member->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array());
    // These are the entity ids in the set
}
$t_entity = new ca_entities($va_featured_member_ids[0]);
$vn_featured_member_id = $va_featured_member_ids[0];
$vs_featured_member_image = $t_entity->get("mem_inst_image", array("version" => "frontpage", "return" => "tag"));
$vs_featured_member_name = $t_entity->getLabelForDisplay();
# --- canned browses
$va_browse_codes = $this->request->config->get('hp_category_browse_codes');
$t_list_item = new ca_list_items();
$va_browses = array();
if (is_array($va_browse_codes) && sizeof($va_browse_codes)) {
    foreach ($va_browse_codes as $vs_item_code) {
        $t_list_item->load(array('idno' => $vs_item_code));
        $va_browses[$t_list_item->get("item_id")] = array("idno" => $vs_item_code, "name" => $t_list_item->getLabelForDisplay());
    }
}
if ($this->getVar("featured_set_id")) {
    $t_featured_set = new ca_sets($this->getVar("featured_set_id"));
Exemplo n.º 15
0
 /**
  * Returns name of hierarchy for currently loaded row or, if specified, row identified by optional $pn_id parameter
  */
 public function getHierarchyName($pn_id = null)
 {
     if (!$pn_id) {
         $pn_id = $this->getPrimaryKey();
     }
     $va_ancestors = $this->getHierarchyAncestors($pn_id, array('idsOnly' => true));
     if (is_array($va_ancestors) && sizeof($va_ancestors)) {
         $vn_parent_id = array_pop($va_ancestors);
         $t_entity = new ca_entities($vn_parent_id);
         return $t_entity->getLabelForDisplay(false);
     } else {
         if ($pn_id == $this->getPrimaryKey()) {
             return $this->getLabelForDisplay(true);
         } else {
             $t_entity = new ca_entities($pn_id);
             return $t_entity->getLabelForDisplay(false);
         }
     }
 }
Exemplo n.º 16
0
					
				</div><!-- end col -->
				<div class='col-md-6 col-lg-6'>
					<H4>{{{^ca_places.preferred_labels.name}}}</H4>
					{{{<ifdef code="ca_places.description"><br/>^ca_places.description<br/></ifdef>}}}<br/>
<?php 
print "<p>" . caNavLink($this->request, _t("View all related objects"), "btn btn-default", "", "Browse", "objects", array("facet" => "place_facet", "id" => $t_item->get("place_id"))) . "</p>";
$t_object_thumb = new ca_objects();
$va_entities = $t_item->get("ca_entities", array("returnAsArray" => true, "checkAccess" => $va_access_values));
if (sizeof($va_entities)) {
    if (sizeof($va_entities) == 1) {
        print "<H6>Related person/organisation</H6>";
    } else {
        print "<H6>Related people/organisations</H6>";
    }
    $t_rel_entity = new ca_entities();
    foreach ($va_entities as $va_entity) {
        $t_rel_entity->load($va_entity["entity_id"]);
        $t_object_thumb->load($t_rel_entity->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_entity->getWithTemplate("<b><l>^ca_entities.preferred_labels.displayname</l></b>");
        if ($vs_brief_description = $t_rel_entity->get("ca_entities.brief_description")) {
            print "<br/>" . $vs_brief_description;
        }
        if ($vs_thumb) {
            print "</div></div><!-- end row -->";
        } else {
Exemplo n.º 17
0
 $va_entities_output = array();
 print "<H2>";
 if ($this->getVar('label')) {
     print $this->getVar('label');
 }
 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)));
Exemplo n.º 18
0
/**
 * Process relationships on the refinery
 *
 * @param $ps_related_table
 * @param $pa_related_option_list
 * @param array $pa_source_data
 * @param array $pa_item
 * @param int $pn_c
 * @param null $pa_options
 *
 * @return array
 */
function caProcessRefineryRelated($ps_related_table, $pa_related_option_list, $pa_source_data, $pa_item, $pn_c, $pa_options = null)
{
    $o_reader = caGetOption('reader', $pa_options, null);
    $o_log = caGetOption('log', $pa_options, null);
    $o_trans = caGetOption('transaction', $pa_options, null);
    global $g_ui_locale_id;
    $va_attr_vals = array();
    if (!$pa_related_option_list || !is_array($pa_related_option_list)) {
        return $va_attr_vals;
    }
    foreach ($pa_related_option_list as $vn_i => $pa_related_options) {
        $vn_id = null;
        $va_name = null;
        $vs_name = caGetOption('name', $pa_related_options, null);
        $vs_name = BaseRefinery::parsePlaceholder($pa_related_options['name'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        $vs_idno = BaseRefinery::parsePlaceholder($pa_related_options['idno'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        $vs_type = BaseRefinery::parsePlaceholder($pa_related_options['type'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        $vn_parent_id = BaseRefinery::parsePlaceholder($pa_related_options['parent_id'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        if (!$vs_name) {
            $vs_name = $vs_idno;
        }
        if ($ps_related_table == 'ca_entities') {
            $t_entity = new ca_entities();
            if ($o_trans) {
                $t_entity->setTransaction($o_trans);
            }
            if (!$vs_name) {
                $va_name = array();
                foreach ($t_entity->getLabelUIFields() as $vs_label_fld) {
                    if (!isset($pa_related_options[$vs_label_fld])) {
                        $pa_related_options[$vs_label_fld] = '';
                    }
                    $va_name[$vs_label_fld] = BaseRefinery::parsePlaceholder($pa_related_options[$vs_label_fld], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader));
                }
            } else {
                $va_name = DataMigrationUtils::splitEntityName($vs_name, $pa_options);
            }
            if (!is_array($va_name) || !$va_name) {
                if ($o_log) {
                    $o_log->logDebug(_t('[importHelpers:caProcessRefineryRelated] No name specified for table %1', $ps_related_table));
                }
                return null;
            }
        }
        if (!$vs_name) {
            if ($o_log) {
                $o_log->logDebug(_t('[importHelpers:caProcessRefineryRelated] No name specified for table %1', $ps_related_table));
            }
            return null;
        }
        $vs_name = BaseRefinery::parsePlaceholder($vs_name, $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader));
        $va_attributes = isset($pa_related_options['attributes']) && is_array($pa_related_options['attributes']) ? $pa_related_options['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' => ' ')));
            }
        }
        if ($ps_related_table != 'ca_object_lots') {
            $va_attributes['idno'] = $vs_idno;
            $va_attributes['parent_id'] = $vn_parent_id;
        } else {
            $vs_idno_stub = BaseRefinery::parsePlaceholder($pa_related_options['idno_stub'], $pa_source_data, $pa_item, $pn_c, array('reader' => $o_reader, 'returnAsString' => true, 'delimiter' => ' '));
        }
        $pa_options = array_merge(array('matchOn' => array('idno', 'label'), $pa_options));
        switch ($ps_related_table) {
            case 'ca_objects':
                $vn_id = DataMigrationUtils::getObjectID($vs_name, $vn_parent_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_object_lots':
                $vn_id = DataMigrationUtils::getObjectLotID($vs_idno_stub, $vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_entities':
                $vn_id = DataMigrationUtils::getEntityID($va_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_places':
                $vn_id = DataMigrationUtils::getPlaceID($vs_name, $vn_parent_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_occurrences':
                $vn_id = DataMigrationUtils::getOccurrenceID($vs_name, $vn_parent_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_collections':
                $vn_id = DataMigrationUtils::getCollectionID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_loans':
                $vn_id = DataMigrationUtils::getLoanID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_movements':
                $vn_id = DataMigrationUtils::getMovementID($vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_list_items':
                if (!($vn_list_id = caGetOption('list_id', $pa_options, null))) {
                    if ($o_log) {
                        $o_log->logDebug(_t('[importHelpers:caProcessRefineryRelated] List was not specified'));
                    }
                    return null;
                }
                $vn_id = DataMigrationUtils::getListItemID($vn_list_id, $vs_name, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            case 'ca_storage_locations':
                $vn_id = DataMigrationUtils::getStorageLocationID($vs_name, $vn_parent_id, $vs_type, $g_ui_locale_id, $va_attributes, $pa_options);
                break;
            default:
                if ($o_log) {
                    $o_log->logDebug(_t('[importHelpers:caProcessRefineryRelated] Invalid table %1', $ps_related_table));
                }
                return null;
                break;
        }
        if ($vn_id) {
            $va_attr_vals['_related_related'][$ps_related_table][] = array('id' => $vn_id, '_relationship_type' => $pa_related_options['relationshipType']);
        }
    }
    return $va_attr_vals;
}
Exemplo n.º 19
0
 /**
  * 
  */
 private function _checkEntity()
 {
     $t_entity = new ca_entities($vn_id = $this->opo_request->getParameter('id', pInteger));
     if (!$t_entity->getPrimaryKey()) {
         return $this->makeResponse(array(), 500, 'Victim ID is invalid');
     }
     // is the entity a victim?
     if ($t_entity->getTypeID() != $this->opn_victim_type_id) {
         return $this->makeResponse(array(), 500, 'Entity is not of type "victim"; expected ' . $this->opn_victim_type_id . '; got ' . $t_entity->getTypeID());
     }
     return $t_entity;
 }