Пример #1
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);
 }
Пример #2
0
 /**
  * Returns a display label for a given criterion and facet.
  *
  * @param string $ps_facet_name Name of facet 
  * @param mixed $pm_criterion 
  * @return string
  */
 public function getCriterionLabel($ps_facet_name, $pn_row_id)
 {
     if (!($va_facet_info = $this->getInfoForFacet($ps_facet_name))) {
         return null;
     }
     switch ($va_facet_info['type']) {
         # -----------------------------------------------------
         case 'has':
             $vs_yes_text = isset($va_facet_info['label_yes']) && $va_facet_info['label_yes'] ? $va_facet_info['label_yes'] : _t('Yes');
             $vs_no_text = isset($va_facet_info['label_no']) && $va_facet_info['label_no'] ? $va_facet_info['label_no'] : _t('No');
             return (bool) $pn_row_id ? $vs_yes_text : $vs_no_text;
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'label':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName(isset($va_facet_info['relative_to']) && $va_facet_info['relative_to'] ? $va_facet_info['relative_to'] : $this->ops_browse_table_name, true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'authority':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table'], true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'attribute':
             $t_element = new ca_metadata_elements();
             if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
                 return urldecode($pn_row_id);
             }
             $vn_element_id = $t_element->getPrimaryKey();
             switch ($vn_element_type = $t_element->get('datatype')) {
                 case __CA_ATTRIBUTE_VALUE_LIST__:
                     $t_list = new ca_lists();
                     return $t_list->getItemFromListForDisplayByItemID($t_element->get('list_id'), $pn_row_id, true);
                     break;
                 case __CA_ATTRIBUTE_VALUE_OBJECTS__:
                 case __CA_ATTRIBUTE_VALUE_ENTITIES__:
                 case __CA_ATTRIBUTE_VALUE_PLACES__:
                 case __CA_ATTRIBUTE_VALUE_OCCURRENCES__:
                 case __CA_ATTRIBUTE_VALUE_COLLECTIONS__:
                 case __CA_ATTRIBUTE_VALUE_LOANS__:
                 case __CA_ATTRIBUTE_VALUE_MOVEMENTS__:
                 case __CA_ATTRIBUTE_VALUE_STORAGELOCATIONS__:
                 case __CA_ATTRIBUTE_VALUE_OBJECTLOTS__:
                     if ($t_rel_item = AuthorityAttributeValue::elementTypeToInstance($vn_element_type)) {
                         return $t_rel_item->load($pn_row_id) ? $t_rel_item->getLabelForDisplay() : "???";
                     }
                     break;
                 default:
                     return urldecode($pn_row_id);
                     break;
             }
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'field':
             if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
                 break;
             }
             if ($vb_is_bit = $t_item->getFieldInfo($va_facet_info['field'], 'FIELD_TYPE') == FT_BIT) {
                 return (bool) $pn_row_id ? caGetOption('label_yes', $va_facet_info, _t('Yes')) : caGetOption('label_no', $va_facet_info, _t('No'));
             }
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'violations':
             if (!($t_rule = $this->opo_datamodel->getInstanceByTableName('ca_metadata_dictionary_rules', true))) {
                 break;
             }
             if ($t_rule->load(array('rule_code' => $pn_row_id))) {
                 return $t_rule->getSetting('label');
             }
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'checkouts':
             $vs_status_text = null;
             $vs_status_code = isset($va_facet_info['status']) && $va_facet_info['status'] ? $va_facet_info['status'] : $pn_row_id;
             switch ($vs_status_code) {
                 case 'overdue':
                     $vs_status_text = _t('Overdue');
                     break;
                 case 'reserved':
                     $vs_status_text = _t('Reserved');
                     break;
                 case 'available':
                     $vs_status_text = _t('Available');
                     break;
                 default:
                 case 'out':
                     $vs_status_text = _t('Out');
                     break;
             }
             $va_params = array();
             switch ($va_facet_info['mode']) {
                 case 'user':
                     $vs_name = null;
                     $t_user = new ca_users($pn_row_id);
                     if ($t_user->getPrimaryKey()) {
                         $vs_name = $t_user->get('fname') . ' ' . $t_user->get('lname') . (($vs_email = $t_user->get('email')) ? " ({$vs_email})" : "");
                         return _t('%1 for %2', $vs_status_text, $vs_name);
                     }
                     break;
                 default:
                 case 'all':
                     return $vs_status_text;
                     break;
             }
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'location':
             $va_tmp = explode(":", urldecode($pn_row_id));
             $vs_loc_table_name = $this->opo_datamodel->getTableName($va_tmp[0]);
             $va_collapse_map = $this->getCollapseMapForLocationFacet($va_facet_info);
             $t_instance = $this->opo_datamodel->getInstanceByTableName($vs_loc_table_name, true);
             if (($vs_table_name = $vs_loc_table_name) == 'ca_objects_x_storage_locations') {
                 $vs_table_name = 'ca_storage_locations';
             }
             if (isset($va_collapse_map[$vs_table_name][$va_tmp[1]])) {
                 // Class/subclass is collapsable
                 return $va_collapse_map[$vs_table_name][$va_tmp[1]];
             } elseif (isset($va_collapse_map[$vs_table_name]['*'])) {
                 // Class is collapsable
                 return $va_collapse_map[$vs_table_name]['*'];
             } elseif ($va_tmp[2] && ($qr_res = caMakeSearchResult($vs_table_name, array($va_tmp[2]))) && $qr_res->nextHit()) {
                 // Return label for id
                 $va_config = ca_objects::getConfigurationForCurrentLocationType($vs_table_name, $va_tmp[1]);
                 $vs_template = isset($va_config['template']) ? $va_config['template'] : "^{$vs_table_name}.preferred_labels";
                 return caTruncateStringWithEllipsis($qr_res->getWithTemplate($vs_template), 30, 'end');
             }
             return '???';
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'normalizedLength':
             $vn_start = urldecode($pn_row_id);
             if (!($vs_output_units = caGetLengthUnitType($vs_units = caGetOption('units', $va_facet_info, 'm')))) {
                 $vs_output_units = Zend_Measure_Length::METER;
             }
             $vs_increment = caGetOption('increment', $va_facet_info, '1 m');
             $vo_increment = caParseLengthDimension($vs_increment);
             $vn_increment_in_current_units = (double) $vo_increment->convertTo($vs_output_units, 6, 'en_US');
             $vn_end = $vn_start + $vn_increment_in_current_units;
             return "{$vn_start} {$vs_units} - {$vn_end} {$vs_units}";
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'normalizedDates':
             return $pn_row_id === 'null' ? _t('Date unknown') : urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'fieldList':
             if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
                 break;
             }
             $vs_field_name = $va_facet_info['field'];
             $va_field_info = $t_item->getFieldInfo($vs_field_name);
             $t_list = new ca_lists();
             if ($vs_list_name = $va_field_info['LIST_CODE']) {
                 $t_list_item = new ca_list_items($pn_row_id);
                 if ($vs_tmp = $t_list_item->getLabelForDisplay()) {
                     return $vs_tmp;
                 }
                 return '???';
             } else {
                 if ($vs_list_name = $va_field_info['LIST']) {
                     if (is_array($va_list_items = $t_list->getItemsForList($vs_list_name))) {
                         $va_list_items = caExtractValuesByUserLocale($va_list_items);
                         foreach ($va_list_items as $vn_id => $va_list_item) {
                             if ($va_list_item['item_value'] == $pn_row_id) {
                                 return $va_list_item['name_plural'];
                             }
                         }
                     }
                 }
             }
             if (isset($va_field_info['BOUNDS_CHOICE_LIST'])) {
                 $va_choice_list = $va_field_info['BOUNDS_CHOICE_LIST'];
                 if (is_array($va_choice_list)) {
                     foreach ($va_choice_list as $vs_val => $vn_id) {
                         if ($vn_id == $pn_row_id) {
                             return $vs_val;
                         }
                     }
                 }
             }
             if ($va_facet_info['table'] && ($t_browse_table = $this->opo_datamodel->getInstanceByTableName($vs_facet_table = $va_facet_info['table'], true))) {
                 if (!($app = AppController::getInstance())) {
                     return '???';
                 }
                 if ($t_browse_table->load($pn_row_id) && $t_browse_table->isReadable($app->getRequest(), 'preferred_labels')) {
                     return $t_browse_table->get("{$vs_facet_table}.preferred_labels");
                 }
             }
             return '???';
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         default:
             if ($ps_facet_name == '_search') {
                 return $pn_row_id;
             }
             return 'Invalid type';
             break;
             # -----------------------------------------------------
     }
 }
Пример #3
0
 /**
  *
  */
 private function _getChangeLogFromRawData($pa_data, $pn_table_num, $pa_options = null)
 {
     //print "<pre>".print_r($pa_data, true)."</pre>\n";
     $va_log_output = array();
     $vs_blank_placeholder = '&lt;' . _t('BLANK') . '&gt;';
     if (!$pa_options) {
         $pa_options = array();
     }
     if (sizeof($pa_data)) {
         //
         // Init
         //
         $o_datamodel = Datamodel::load();
         $va_change_types = array('I' => _t('Added'), 'U' => _t('Edited'), 'D' => _t('Deleted'));
         $vs_label_table_name = $vs_label_display_name = '';
         $t_item = $o_datamodel->getInstanceByTableNum($pn_table_num, true);
         $vs_label_table_name = $vn_label_table_num = $vs_label_display_name = null;
         if (method_exists($t_item, 'getLabelTableName')) {
             $t_item_label = $t_item->getLabelTableInstance();
             $vs_label_table_name = $t_item->getLabelTableName();
             $vn_label_table_num = $t_item_label->tableNum();
             $vs_label_display_name = $t_item_label->getProperty('NAME_SINGULAR');
         }
         //
         // Group data by unit
         //
         $va_grouped_data = array();
         foreach ($pa_data as $va_log_entry) {
             $va_grouped_data[$va_log_entry['unit_id']]['ca_table_num_' . $va_log_entry['logged_table_num']][] = $va_log_entry;
         }
         //
         // Process units
         //
         $va_attributes = array();
         foreach ($va_grouped_data as $vn_unit_id => $va_log_entries_by_table) {
             foreach ($va_log_entries_by_table as $vs_table_key => $va_log_entries) {
                 foreach ($va_log_entries as $va_log_entry) {
                     $va_changes = array();
                     if (!is_array($va_log_entry['snapshot'])) {
                         $va_log_entry['snapshot'] = array();
                     }
                     //
                     // Get date/time stamp for display
                     //
                     $vs_datetime = date("n/d/Y@g:i:sa T", $va_log_entry['log_datetime']);
                     //
                     // Get user name
                     //
                     $vs_user = $va_log_entry['fname'] . ' ' . $va_log_entry['lname'];
                     $vs_email = $va_log_entry['email'];
                     // The "logged" table/row is the row to which the change was actually applied
                     // The "subject" table/row is the row to which the change is considered to have been made for workflow purposes.
                     //
                     // For example: if an entity is related to an object, strictly speaking the logging occurs on the ca_objects_x_entities
                     // row (ca_objects_x_entities is the "logged" table), but the subject is ca_objects since it's only in the context of the
                     // object (and probably the ca_entities row as well) that you can about the change.
                     //
                     $t_obj = $o_datamodel->getInstanceByTableNum($va_log_entry['logged_table_num'], true);
                     // get instance for logged table
                     if (!$t_obj) {
                         continue;
                     }
                     $vs_subject_display_name = '???';
                     $vn_subject_row_id = null;
                     $vn_subject_table_num = null;
                     if (isset($pa_options['return_item_names']) && $pa_options['return_item_names']) {
                         if (!($vn_subject_table_num = $va_log_entry['subject_table_num'])) {
                             $vn_subject_table_num = $va_log_entry['logged_table_num'];
                             $vn_subject_row_id = $va_log_entry['logged_row_id'];
                         } else {
                             $vn_subject_row_id = $va_log_entry['subject_row_id'];
                         }
                         if ($t_subject = $o_datamodel->getInstanceByTableNum($vn_subject_table_num, true)) {
                             if ($t_subject->load($vn_subject_row_id)) {
                                 if (method_exists($t_subject, 'getLabelForDisplay')) {
                                     $vs_subject_display_name = $t_subject->getLabelForDisplay(false);
                                 } else {
                                     if ($vs_idno_field = $t_subject->getProperty('ID_NUMBERING_ID_FIELD')) {
                                         $vs_subject_display_name = $t_subject->getProperty('NAME_SINGULAR') . ' [' . $t_subject->get($vs_idno_field) . ']';
                                     } else {
                                         $vs_subject_display_name = $t_subject->getProperty('NAME_SINGULAR') . ' [' . $vn_subject_row_id . ']';
                                     }
                                 }
                             }
                         }
                     }
                     //
                     // Get item changes
                     //
                     // ---------------------------------------------------------------
                     // is this an intrinsic field?
                     if ($pn_table_num == $va_log_entry['logged_table_num']) {
                         foreach ($va_log_entry['snapshot'] as $vs_field => $vs_value) {
                             $va_field_info = $t_obj->getFieldInfo($vs_field);
                             if (isset($va_field_info['IDENTITY']) && $va_field_info['IDENTITY']) {
                                 continue;
                             }
                             if (isset($va_field_info['DISPLAY_TYPE']) && $va_field_info['DISPLAY_TYPE'] == DT_OMIT) {
                                 continue;
                             }
                             if (isset($va_field_info['DISPLAY_FIELD']) && is_array($va_field_info['DISPLAY_FIELD']) && ($va_disp_fields = $va_field_info['DISPLAY_FIELD'])) {
                                 //
                                 // Lookup value in related table
                                 //
                                 if (!$vs_value) {
                                     continue;
                                 }
                                 if (sizeof($va_disp_fields)) {
                                     $va_rel = $o_datamodel->getManyToOneRelations($t_obj->tableName(), $vs_field);
                                     $va_rel_values = array();
                                     if ($t_rel_obj = $o_datamodel->getTableInstance($va_rel['one_table'], true)) {
                                         $t_rel_obj->load($vs_value);
                                         foreach ($va_disp_fields as $vs_display_field) {
                                             $va_tmp = explode('.', $vs_display_field);
                                             if (($vs_tmp = $t_rel_obj->get($va_tmp[1])) !== '') {
                                                 $va_rel_values[] = $vs_tmp;
                                             }
                                         }
                                     }
                                     $vs_proc_val = join(', ', $va_rel_values);
                                 }
                             } else {
                                 // Is field a foreign key?
                                 $va_keys = $o_datamodel->getManyToOneRelations($t_obj->tableName(), $vs_field);
                                 if (sizeof($va_keys)) {
                                     // yep, it's a foreign key
                                     $va_rel_values = array();
                                     if ($t_rel_obj = $o_datamodel->getTableInstance($va_keys['one_table'], true)) {
                                         if ($t_rel_obj->load($vs_value)) {
                                             if (method_exists($t_rel_obj, 'getLabelForDisplay')) {
                                                 $vs_proc_val = $t_rel_obj->getLabelForDisplay(false);
                                             } else {
                                                 $va_disp_fields = $t_rel_obj->getProperty('LIST_FIELDS');
                                                 foreach ($va_disp_fields as $vs_display_field) {
                                                     if (($vs_tmp = $t_rel_obj->get($vs_display_field)) !== '') {
                                                         $va_rel_values[] = $vs_tmp;
                                                     }
                                                 }
                                                 $vs_proc_val = join(' ', $va_rel_values);
                                             }
                                             if (!$vs_proc_val) {
                                                 $vs_proc_val = '???';
                                             }
                                         } else {
                                             $vs_proc_val = _t("Not set");
                                         }
                                     } else {
                                         $vs_proc_val = _t('Non-existent');
                                     }
                                 } else {
                                     // Adjust display of value for different field types
                                     switch ($va_field_info['FIELD_TYPE']) {
                                         case FT_BIT:
                                             $vs_proc_val = $vs_value ? 'Yes' : 'No';
                                             break;
                                         default:
                                             $vs_proc_val = $vs_value;
                                             break;
                                     }
                                     // Adjust display of value for lists
                                     if ($va_field_info['LIST']) {
                                         $t_list = new ca_lists();
                                         if ($t_list->load(array('list_code' => $va_field_info['LIST']))) {
                                             $vn_list_id = $t_list->getPrimaryKey();
                                             $t_list_item = new ca_list_items();
                                             if ($t_list_item->load(array('list_id' => $vn_list_id, 'item_value' => $vs_value))) {
                                                 $vs_proc_val = $t_list_item->getLabelForDisplay();
                                             }
                                         }
                                     } else {
                                         if ($va_field_info['BOUNDS_CHOICE_LIST']) {
                                             // TODO
                                         }
                                     }
                                 }
                             }
                             $va_changes[] = array('label' => $va_field_info['LABEL'], 'description' => strlen((string) $vs_proc_val) ? $vs_proc_val : $vs_blank_placeholder, 'value' => $vs_value);
                         }
                     }
                     // ---------------------------------------------------------------
                     // is this a label row?
                     if ($va_log_entry['logged_table_num'] == $vn_label_table_num) {
                         foreach ($va_log_entry['snapshot'] as $vs_field => $vs_value) {
                             $va_changes[] = array('label' => $t_item_label->getFieldInfo($vs_field, 'LABEL'), 'description' => $vs_value);
                         }
                     }
                     // ---------------------------------------------------------------
                     // is this an attribute?
                     if ($va_log_entry['logged_table_num'] == 3) {
                         // attribute_values
                         if ($t_element = ca_attributes::getElementInstance($va_log_entry['snapshot']['element_id'])) {
                             if ($o_attr_val = Attribute::getValueInstance($t_element->get('datatype'))) {
                                 $o_attr_val->loadValueFromRow($va_log_entry['snapshot']);
                                 $vs_attr_val = $o_attr_val->getDisplayValue();
                             } else {
                                 $vs_attr_val = '?';
                             }
                             // Convert list-based attributes to text
                             if ($vn_list_id = $t_element->get('list_id')) {
                                 $t_list = new ca_lists();
                                 $vs_attr_val = $t_list->getItemFromListForDisplayByItemID($vn_list_id, $vs_attr_val, true);
                             }
                             if (!$vs_attr_val) {
                                 $vs_attr_val = $vs_blank_placeholder;
                             }
                             $vs_label = $t_element->getLabelForDisplay();
                             $va_attributes[$va_log_entry['snapshot']['attribute_id']]['values'][] = array('label' => $vs_label, 'value' => $vs_attr_val);
                             $va_changes[] = array('label' => $vs_label, 'description' => $vs_attr_val);
                         }
                     }
                     // ---------------------------------------------------------------
                     // is this a related (many-many) row?
                     $va_keys = $o_datamodel->getOneToManyRelations($t_item->tableName(), $t_obj->tableName());
                     if (sizeof($va_keys) > 0) {
                         if (method_exists($t_obj, 'getLeftTableNum')) {
                             if ($t_obj->getLeftTableNum() == $t_item->tableNum()) {
                                 // other side of rel is on right
                                 $t_related_table = $o_datamodel->getInstanceByTableNum($t_obj->getRightTableNum(), true);
                                 $t_related_table->load($va_log_entry['snapshot'][$t_obj->getRightTableFieldName()]);
                             } else {
                                 // other side of rel is on left
                                 $t_related_table = $o_datamodel->getInstanceByTableNum($t_obj->getLeftTableNum(), true);
                                 $t_related_table->load($va_log_entry['snapshot'][$t_obj->getLeftTableFieldName()]);
                             }
                             $t_rel = $o_datamodel->getInstanceByTableNum($t_obj->tableNum(), true);
                             $va_changes[] = array('label' => caUcFirstUTF8Safe($t_related_table->getProperty('NAME_SINGULAR')), 'idno' => ($vs_idno_field = $t_related_table->getProperty('ID_NUMBERING_ID_FIELD')) ? $t_related_table->get($vs_idno_field) : null, 'description' => $t_related_table->getLabelForDisplay(), 'table_name' => $t_related_table->tableName(), 'table_num' => $t_related_table->tableNum(), 'row_id' => $t_related_table->getPrimaryKey(), 'rel_type_id' => $va_log_entry['snapshot']['type_id'], 'rel_typename' => $t_rel->getRelationshipTypename('ltor', $va_log_entry['snapshot']['type_id']));
                         }
                     }
                     // ---------------------------------------------------------------
                     // record log line
                     if (sizeof($va_changes)) {
                         $va_log_output[$vn_unit_id][] = array('datetime' => $vs_datetime, 'user_fullname' => $vs_user, 'user_email' => $vs_email, 'user' => $vs_user . ' (' . $vs_email . ')', 'changetype_display' => $va_change_types[$va_log_entry['changetype']], 'changetype' => $va_log_entry['changetype'], 'changes' => $va_changes, 'subject' => $vs_subject_display_name, 'subject_id' => $vn_subject_row_id, 'subject_table_num' => $vn_subject_table_num, 'logged_table_num' => $va_log_entry['logged_table_num'], 'logged_table' => $t_obj->tableName(), 'logged_row_id' => $va_log_entry['logged_row_id']);
                     }
                 }
             }
         }
     }
     return $va_log_output;
 }
Пример #4
0
    $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"));
    ?>
		<div id="contentcontainer">
			<div id="objectcontainerHP">
				<div class="homeIntro">Navigate through some of the collections of Nova Scotia's community museums to learn about the province's past, and share your own stories and information about what is important to you.</div><!-- end home intro -->
				<div id="objectslidesContainerHP">
<?php 
    # --- featured objects
    foreach ($va_item_media as $vn_object_id => $va_media) {
        if ($va_media['urls']['frontpage']) {
            $vs_image_tag = $va_media["tags"]["frontpage"];
            $t_title_object = new ca_objects($vn_object_id);
Пример #5
0
 /**
  *
  */
 public function getCriterionLabel($ps_facet_name, $pn_row_id)
 {
     if (!($va_facet_info = $this->getInfoForFacet($ps_facet_name))) {
         return null;
     }
     switch ($va_facet_info['type']) {
         # -----------------------------------------------------
         case 'has':
             $vs_yes_text = isset($va_facet_info['label_yes']) && $va_facet_info['label_yes'] ? $va_facet_info['label_yes'] : _t('Yes');
             $vs_no_text = isset($va_facet_info['label_no']) && $va_facet_info['label_no'] ? $va_facet_info['label_no'] : _t('No');
             return (bool) $pn_row_id ? $vs_yes_text : $vs_no_text;
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'label':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName(isset($va_facet_info['relative_to']) && $va_facet_info['relative_to'] ? $va_facet_info['relative_to'] : $this->ops_browse_table_name, true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'authority':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table'], true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'attribute':
             $t_element = new ca_metadata_elements();
             if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
                 return urldecode($pn_row_id);
             }
             $vn_element_id = $t_element->getPrimaryKey();
             switch ($t_element->get('datatype')) {
                 case 3:
                     // list
                     $t_list = new ca_lists();
                     return $t_list->getItemFromListForDisplayByItemID($t_element->get('list_id'), $pn_row_id, true);
                     break;
                 default:
                     return urldecode($pn_row_id);
                     break;
             }
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'field':
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'normalizedDates':
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'fieldList':
             if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
                 break;
             }
             $vs_field_name = $va_facet_info['field'];
             $va_field_info = $t_item->getFieldInfo($vs_field_name);
             $t_list = new ca_lists();
             if ($vs_list_name = $va_field_info['LIST_CODE']) {
                 $t_list_item = new ca_list_items($pn_row_id);
                 if ($vs_tmp = $t_list_item->getLabelForDisplay()) {
                     return $vs_tmp;
                 }
                 return '???';
             } else {
                 if ($vs_list_name = $va_field_info['LIST']) {
                     if (is_array($va_list_items = $t_list->getItemsForList($vs_list_name))) {
                         $va_list_items = caExtractValuesByUserLocale($va_list_items);
                         foreach ($va_list_items as $vn_id => $va_list_item) {
                             if ($va_list_item['item_value'] == $pn_row_id) {
                                 return $va_list_item['name_plural'];
                             }
                         }
                     }
                 }
             }
             if (isset($va_field_info['BOUNDS_CHOICE_LIST'])) {
                 $va_choice_list = $va_field_info['BOUNDS_CHOICE_LIST'];
                 if (is_array($va_choice_list)) {
                     foreach ($va_choice_list as $vs_val => $vn_id) {
                         if ($vn_id == $pn_row_id) {
                             return $vs_val;
                         }
                     }
                 }
             }
             return '???';
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         default:
             if ($ps_facet_name == '_search') {
                 return $pn_row_id;
             }
             return 'Invalid type';
             break;
             # -----------------------------------------------------
     }
 }
Пример #6
0
$t_object = $this->getVar('t_item');
$vn_object_id = $t_object->get('object_id');
$vs_title = $this->getVar('label');
$va_access_values = $this->getVar('access_values');
$t_rep = $this->getVar('t_primary_rep');
$vn_num_reps = $t_object->getRepresentationCount(array("return_with_access" => $va_access_values));
$vs_display_version = $this->getVar('primary_rep_display_version');
$va_display_options = $this->getVar('primary_rep_display_options');
$va_theme_info = array();
$va_themes = caExtractValuesByUserLocale($t_object->get("novastory_category", array("returnAsArray" => true)));
$vs_placeholder = "";
if (sizeof($va_themes)) {
    $t_list_item = new ca_list_items();
    foreach ($va_themes as $k => $vs_list_item_id) {
        $t_list_item->load($vs_list_item_id);
        $va_theme_info["name"] = $t_list_item->getLabelForDisplay();
        if (file_exists($this->request->getThemeDirectoryPath() . "/graphics/novamuse/" . $t_list_item->get("idno") . ".png")) {
            $va_theme_info["icon"] = $this->request->getThemeUrlPath() . "/graphics/novamuse/" . $t_list_item->get("idno") . ".png";
        }
        if (file_exists($this->request->getThemeDirectoryPath() . "/graphics/novamuse/placeholders/" . $t_list_item->get("idno") . ".png")) {
            $vs_placeholder = $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/" . $t_list_item->get("idno") . ".png";
        }
        $va_theme_info["id"] = $t_list_item->get("item_id");
        $va_themes_info[] = $va_theme_info;
    }
}
if (!$vs_placeholder) {
    $vs_placeholder = $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/placeholder.png";
}
# --- get similar items by category
$va_categories = explode(",", $t_object->get('ns_category'));
Пример #7
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');
 }
Пример #8
0
 /**
  * Returns a display label for a given criterion and facet.
  *
  * @param string $ps_facet_name Name of facet 
  * @param mixed $pm_criterion 
  * @return string
  */
 public function getCriterionLabel($ps_facet_name, $pn_row_id)
 {
     if (!($va_facet_info = $this->getInfoForFacet($ps_facet_name))) {
         return null;
     }
     switch ($va_facet_info['type']) {
         # -----------------------------------------------------
         case 'has':
             $vs_yes_text = isset($va_facet_info['label_yes']) && $va_facet_info['label_yes'] ? $va_facet_info['label_yes'] : _t('Yes');
             $vs_no_text = isset($va_facet_info['label_no']) && $va_facet_info['label_no'] ? $va_facet_info['label_no'] : _t('No');
             return (bool) $pn_row_id ? $vs_yes_text : $vs_no_text;
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'label':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName(isset($va_facet_info['relative_to']) && $va_facet_info['relative_to'] ? $va_facet_info['relative_to'] : $this->ops_browse_table_name, true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'authority':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table'], true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'attribute':
             $t_element = new ca_metadata_elements();
             if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
                 return urldecode($pn_row_id);
             }
             $vn_element_id = $t_element->getPrimaryKey();
             switch ($vn_element_type = $t_element->get('datatype')) {
                 case __CA_ATTRIBUTE_VALUE_LIST__:
                     $t_list = new ca_lists();
                     return $t_list->getItemFromListForDisplayByItemID($t_element->get('list_id'), $pn_row_id, true);
                     break;
                 case __CA_ATTRIBUTE_VALUE_OBJECTS__:
                 case __CA_ATTRIBUTE_VALUE_ENTITIES__:
                 case __CA_ATTRIBUTE_VALUE_PLACES__:
                 case __CA_ATTRIBUTE_VALUE_OCCURRENCES__:
                 case __CA_ATTRIBUTE_VALUE_COLLECTIONS__:
                 case __CA_ATTRIBUTE_VALUE_LOANS__:
                 case __CA_ATTRIBUTE_VALUE_MOVEMENTS__:
                 case __CA_ATTRIBUTE_VALUE_STORAGELOCATIONS__:
                 case __CA_ATTRIBUTE_VALUE_OBJECTLOTS__:
                     if ($t_rel_item = AuthorityAttributeValue::elementTypeToInstance($vn_element_type)) {
                         return $t_rel_item->load($pn_row_id) ? $t_rel_item->getLabelForDisplay() : "???";
                     }
                     break;
                 default:
                     return urldecode($pn_row_id);
                     break;
             }
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'field':
             if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
                 break;
             }
             if ($vb_is_bit = $t_item->getFieldInfo($va_facet_info['field'], 'FIELD_TYPE') == FT_BIT) {
                 return (bool) $pn_row_id ? caGetOption('label_yes', $va_facet_info, _t('Yes')) : caGetOption('label_no', $va_facet_info, _t('No'));
             }
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'location':
             $va_tmp = explode(":", urldecode($pn_row_id));
             $vs_loc_table_name = $this->opo_datamodel->getTableName($va_tmp[0]);
             $va_collapse_map = $this->getCollapseMapForLocationFacet($va_facet_info);
             $t_instance = $this->opo_datamodel->getInstanceByTableName($vs_loc_table_name, true);
             if (($vs_table_name = $vs_loc_table_name) == 'ca_objects_x_storage_locations') {
                 $vs_table_name = 'ca_storage_locations';
             }
             if (isset($va_collapse_map[$vs_table_name][$va_tmp[1]])) {
                 // Class/subclass is collapsable
                 return $va_collapse_map[$vs_table_name][$va_tmp[1]];
             } elseif (isset($va_collapse_map[$vs_table_name]['*'])) {
                 // Class is collapsable
                 return $va_collapse_map[$vs_table_name]['*'];
             } elseif ($va_tmp[2] && ($qr_res = caMakeSearchResult($vs_table_name, array($va_tmp[2]))) && $qr_res->nextHit()) {
                 // Return label for id
                 $va_config = ca_objects::getConfigurationForCurrentLocationType($vs_table_name, $va_tmp[1]);
                 $vs_template = isset($va_config['template']) ? $va_config['template'] : "^{$vs_table_name}.preferred_labels";
                 return caTruncateStringWithEllipsis($qr_res->getWithTemplate($vs_template), 30, 'end');
             }
             return '???';
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'normalizedDates':
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'fieldList':
             if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
                 break;
             }
             $vs_field_name = $va_facet_info['field'];
             $va_field_info = $t_item->getFieldInfo($vs_field_name);
             $t_list = new ca_lists();
             if ($vs_list_name = $va_field_info['LIST_CODE']) {
                 $t_list_item = new ca_list_items($pn_row_id);
                 if ($vs_tmp = $t_list_item->getLabelForDisplay()) {
                     return $vs_tmp;
                 }
                 return '???';
             } else {
                 if ($vs_list_name = $va_field_info['LIST']) {
                     if (is_array($va_list_items = $t_list->getItemsForList($vs_list_name))) {
                         $va_list_items = caExtractValuesByUserLocale($va_list_items);
                         foreach ($va_list_items as $vn_id => $va_list_item) {
                             if ($va_list_item['item_value'] == $pn_row_id) {
                                 return $va_list_item['name_plural'];
                             }
                         }
                     }
                 }
             }
             if (isset($va_field_info['BOUNDS_CHOICE_LIST'])) {
                 $va_choice_list = $va_field_info['BOUNDS_CHOICE_LIST'];
                 if (is_array($va_choice_list)) {
                     foreach ($va_choice_list as $vs_val => $vn_id) {
                         if ($vn_id == $pn_row_id) {
                             return $vs_val;
                         }
                     }
                 }
             }
             return '???';
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         default:
             if ($ps_facet_name == '_search') {
                 return $pn_row_id;
             }
             return 'Invalid type';
             break;
             # -----------------------------------------------------
     }
 }