/** * Returns string representing the name of the item the browse will return * * If $ps_mode is 'singular' [default] then the singular version of the name is returned, otherwise the plural is returned */ public function browseName($ps_mode = 'singular') { $vb_type_restriction_has_changed = false; $vn_type_id = $this->opo_result_context->getTypeRestriction($vb_type_restriction_has_changed); $t_list = new ca_lists(); $t_list->load(array('list_code' => 'occurrence_types')); $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null)); $va_hier = caExtractValuesByUserLocale($t_list_item->getHierarchyWithLabels()); if (!($vs_name = $ps_mode == 'singular' ? $va_hier[$vn_type_id]['name_singular'] : $va_hier[$vn_type_id]['name_plural'])) { $vs_name = '???'; } return $vs_name; }
public function info($pa_parameters) { parent::info($pa_parameters); $t_list = $this->view->getVar('t_item'); if ($t_list->getPrimaryKey()) { $va_labels = $t_list->getDisplayLabels(); $this->view->setVar('labels', $t_list->getPrimaryKey() ? $va_labels : array()); $this->view->setVar('idno', $t_list->get('idno')); } $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null)); $this->view->setVar('t_list_item', $t_list_item); if ($vn_item_id = $t_list_item->getPrimaryKey()) { $va_children = caExtractValuesByUserLocaleFromHierarchyChildList($t_list_item->getHierarchyChildren(null, array('additionalTableToJoin' => 'ca_list_item_labels', 'additionalTableJoinType' => 'LEFT', 'additionalTableSelectFields' => array('name_plural', 'locale_id'), 'additionalTableWheres' => array('(ca_list_item_labels.is_preferred = 1 OR ca_list_item_labels.is_preferred IS NULL)'))), 'item_id', 'name_plural', 'item_value'); $this->view->setVar('children', $va_children); } return $this->render('widget_list_info_html.php', true); }
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")); ?> <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"];
function caGetListItemIdno($pn_item_id, $pa_options = null) { global $g_list_item_idno_cache; if (isset($g_list_item_idno_cache[$pn_item_id])) { return $g_list_item_idno_cache[$pn_item_id]; } $t_item = new ca_list_items(); if ($o_trans = caGetOption('transaction', $pa_options, null)) { $t_item->setTransaction($o_trans); } $t_item->load($pn_item_id); return $g_list_item_idno_cache[$pn_item_id] = $t_item->get('idno'); }
public function processDisplays() { require_once __CA_MODELS_DIR__ . "/ca_bundle_displays.php"; require_once __CA_MODELS_DIR__ . "/ca_bundle_display_placements.php"; require_once __CA_MODELS_DIR__ . "/ca_bundle_display_type_restrictions.php"; $o_config = Configuration::load(); $vo_dm = Datamodel::load(); if ($this->ops_base_name) { // "merge" profile and its base $va_displays = array(); if ($this->opo_base->displays) { foreach ($this->opo_base->displays->children() as $vo_display) { $va_displays[self::getAttribute($vo_display, "code")] = $vo_display; } } if ($this->opo_profile->displays) { foreach ($this->opo_profile->displays->children() as $vo_display) { $va_displays[self::getAttribute($vo_display, "code")] = $vo_display; } } } else { if ($this->opo_profile->displays) { foreach ($this->opo_profile->displays->children() as $vo_display) { $va_displays[self::getAttribute($vo_display, "code")] = $vo_display; } } } if (!is_array($va_displays) || sizeof($va_displays) == 0) { return true; } foreach ($va_displays as $vo_display) { $vs_display_code = self::getAttribute($vo_display, "code"); $vb_system = self::getAttribute($vo_display, "system"); $vs_table = self::getAttribute($vo_display, "type"); if ($o_config->get($vs_table . '_disable')) { continue; } $t_display = $this->opb_updating ? ca_bundle_displays::find(array('code' => $vs_display_code, 'type' => $vs_table), array('returnAs' => 'firstModelInstance')) : false; $t_display = $t_display ? $t_display : new ca_bundle_displays(); $t_display->setMode(ACCESS_WRITE); $t_display->set("display_code", $vs_display_code); $t_display->set("is_system", $vb_system); $t_display->set("table_num", $vo_dm->getTableNum($vs_table)); $t_display->set("user_id", 1); // let administrative user own these $this->_processSettings($t_display, $vo_display->settings); if ($t_display->getPrimaryKey()) { $t_display->update(); } else { $t_display->insert(); } if ($t_display->numErrors()) { $this->addError("There was an error while inserting display {$vs_display_code}: " . join(" ", $t_display->getErrors())); } else { self::addLabelsFromXMLElement($t_display, $vo_display->labels, $this->opa_locales); if ($t_display->numErrors()) { $this->addError("There was an error while inserting display label for {$vs_display_code}: " . join(" ", $t_display->getErrors())); } if (!$this->processDisplayPlacements($t_display, $vo_display->bundlePlacements, null)) { return false; } } if ($vo_display->typeRestrictions) { foreach ($vo_display->typeRestrictions->children() as $vo_restriction) { $t_list = new ca_lists(); $t_list_item = new ca_list_items(); $vs_restriction_code = trim((string) self::getAttribute($vo_restriction, "code")); $vs_type = trim((string) self::getAttribute($vo_restriction, "type")); $t_instance = $vo_dm->getInstanceByTableNum($vn_table_num = $vo_dm->getTableNum($vs_table)); $vs_type_list_name = $t_instance->getFieldListCode($t_instance->getTypeFieldName()); if ($vs_type) { $t_list->load(array('list_code' => $vs_type_list_name)); $t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'idno' => $vs_type)); } $vn_type_id = $vs_type ? $t_list_item->getPrimaryKey() : null; $t_restriction = $this->opb_updating ? ca_bundle_display_type_restrictions::find(array('table_num' => $vn_table_num, 'type_id' => $vn_type_id), array('returnAs' => 'firstModelInstance')) : false; $t_restriction = $t_restriction ? $t_restriction : new ca_bundle_display_type_restrictions(); $t_restriction->setMode(ACCESS_WRITE); $t_restriction->set('table_num', $vn_table_num); $t_restriction->set('include_subtypes', (bool) $vo_restriction->includeSubtypes ? 1 : 0); $t_restriction->set('type_id', $vn_type_id); $t_restriction->set('display_id', $t_display->getPrimaryKey()); $this->_processSettings($t_restriction, $vo_restriction->settings); if ($t_restriction->getPrimaryKey()) { $t_restriction->update(); } else { $t_restriction->insert(); } if ($t_restriction->numErrors()) { $this->addError("There was an error while inserting type restriction {$vs_restriction_code} in display {$vs_display_code}: " . join("; ", $t_restriction->getErrors())); } } } if ($vo_display->userAccess) { $t_user = new ca_users(); $va_display_users = array(); foreach ($vo_display->userAccess->children() as $vo_permission) { $vs_user = trim((string) self::getAttribute($vo_permission, "user")); $vn_access = $this->_convertUserGroupAccessStringToInt(self::getAttribute($vo_permission, 'access')); if ($vn_access && $t_user->load(array('user_name' => $vs_user))) { $va_display_users[$t_user->getUserID()] = $vn_access; } else { $this->addError("User name or access value invalid for display {$vs_display_code} (permission item with user name '{$vs_user}')"); } } if (sizeof($va_display_users) > 0) { $t_display->addUsers($va_display_users); } } if ($vo_display->groupAccess) { $t_group = new ca_user_groups(); $va_display_groups = array(); foreach ($vo_display->groupAccess->children() as $vo_permission) { $vs_group = trim((string) self::getAttribute($vo_permission, "group")); $vn_access = $this->_convertUserGroupAccessStringToInt(self::getAttribute($vo_permission, 'access')); if ($vn_access && $t_group->load(array('code' => $vs_group))) { $va_display_groups[$t_group->getPrimaryKey()] = $vn_access; } else { $this->addError("Group code or access value invalid for display {$vs_display_code} (permission item with group code '{$vs_group}')"); } } if (sizeof($va_display_groups) > 0) { $t_display->addUserGroups($va_display_groups); } } } return true; }
function caLightboxSetListItem($po_request, $t_set, $va_check_access = array(), $pa_options = array()) { if (!$t_set->get("set_id")) { return false; } $vb_write_access = false; if ($pa_options["write_access"]) { $vb_write_access = true; } $va_set_items = caExtractValuesByUserLocale($t_set->getItems(array("user_id" => $po_request->user->get("user_id"), "thumbnailVersions" => array("iconlarge", "icon"), "checkAccess" => $va_check_access, "limit" => 5))); $vs_set_display = ""; $vs_set_display .= "<div class='lbSetContainer'><div class='lbSet " . ($vb_write_access ? "" : "readSet") . "'><div class='lbSetContent'>\n"; if (!$vb_write_access) { $vs_set_display .= "<div class='pull-right caption'>Read Only</div>"; } $vs_set_display .= "<H5>" . caNavLink($po_request, $t_set->getLabelForDisplay(), "", "", "Sets", "setDetail", array("set_id" => $t_set->get("set_id"))) . "</H5>"; $va_lightbox_display_name = caGetSetDisplayName(); $vs_lightbox_display_name = $va_lightbox_display_name["singular"]; $vs_lightbox_display_name_plural = $va_lightbox_display_name["plural"]; if (sizeof($va_set_items)) { $vs_primary_image_block = ""; $vs_secondary_image_block = ""; $vn_i = 1; $t_list_items = new ca_list_items(); foreach ($va_set_items as $va_set_item) { $t_list_items->load($va_set_item["type_id"]); $vs_placeholder = getPlaceholder($t_list_items->get("idno"), "placeholder_media_icon"); if ($vn_i == 1) { # --- is the iconlarge version available? $vs_large_icon = "icon"; if ($va_set_item["representation_url_iconlarge"]) { $vs_large_icon = "iconlarge"; } if ($va_set_item["representation_tag_" . $vs_large_icon]) { $vs_primary_image_block .= "<div class='col-sm-6'><div class='lbSetImg'>" . caNavLink($po_request, $va_set_item["representation_tag_" . $vs_large_icon], "", "", "Sets", "setDetail", array("set_id" => $t_set->get("set_id"))) . "</div><!-- end lbSetImg --></div>\n"; } else { $vs_primary_image_block .= "<div class='col-sm-6'><div class='lbSetImg'>" . caNavLink($po_request, "<div class='lbSetImgPlaceholder'>" . $vs_placeholder . "</div><!-- end lbSetImgPlaceholder -->", "", "", "Sets", "setDetail", array("set_id" => $t_set->get("set_id"))) . "</div><!-- end lbSetImg --></div>\n"; } } else { if ($va_set_item["representation_tag_icon"]) { $vs_secondary_image_block .= "<div class='col-xs-3 col-sm-6 lbSetThumbCols'><div class='lbSetThumb'>" . caNavLink($po_request, $va_set_item["representation_tag_icon"], "", "", "Sets", "setDetail", array("set_id" => $t_set->get("set_id"))) . "</div><!-- end lbSetThumb --></div>\n"; } else { $vs_secondary_image_block .= "<div class='col-xs-3 col-sm-6 lbSetThumbCols'>" . caNavLink($po_request, "<div class='lbSetThumbPlaceholder'>" . caGetThemeGraphic($po_request, 'spacer.png') . $vs_placeholder . "</div><!-- end lbSetThumbPlaceholder -->", "", "", "Sets", "setDetail", array("set_id" => $t_set->get("set_id"))) . "</div>\n"; } } $vn_i++; } while ($vn_i < 6) { $vs_secondary_image_block .= "<div class='col-xs-3 col-sm-6 lbSetThumbCols'>" . caNavLink($po_request, "<div class='lbSetThumbPlaceholder'>" . caGetThemeGraphic($po_request, 'spacer.png') . "</div><!-- end lbSetThumbPlaceholder -->", "", "", "Sets", "setDetail", array("set_id" => $t_set->get("set_id"))) . "</div>"; $vn_i++; } } else { $vs_primary_image_block .= "<div class='col-sm-6'><div class='lbSetImg'><div class='lbSetImgPlaceholder'>" . _t("this %1 contains no items", $vs_lightbox_display_name) . "</div><!-- end lbSetImgPlaceholder --></div><!-- end lbSetImg --></div>\n"; $i = 1; while ($vn_i < 4) { $vs_secondary_image_block .= "<div class='col-xs-3 col-sm-6 lbSetThumbCols'><div class='lbSetThumbPlaceholder'>" . caGetThemeGraphic($po_request, 'spacer.png') . "</div><!-- end lbSetThumbPlaceholder --></div>"; $vn_i++; } } $vs_set_display .= "<div class='row'>" . $vs_primary_image_block . "<div class='col-sm-6'><div id='comment" . $t_set->get("set_id") . "' class='lbSetComment'><!-- load comments here --></div>\n<div class='lbSetThumbRowContainer'><div class='row lbSetThumbRow' id='lbSetThumbRow" . $t_set->get("set_id") . "'>" . $vs_secondary_image_block . "</div><!-- end row --></div><!-- end lbSetThumbRowContainer --></div><!-- end col --></div><!-- end row -->"; $vs_set_display .= "</div><!-- end lbSetContent -->\n"; $vs_set_display .= "<div class='lbSetExpandedInfo' id='lbExpandedInfo" . $t_set->get("set_id") . "'>\n<hr><div>created by: " . trim($t_set->get("ca_users.fname") . " " . $t_set->get("ca_users.lname")) . "</div>\n"; $vs_set_display .= "<div>Num items: " . $t_set->getItemCount(array("user_id" => $po_request->user->get("user_id"), "checkAccess" => $va_check_access)) . "</div>\n"; if ($vb_write_access) { $vs_set_display .= "<div class='pull-right'>" . caNavLink($po_request, '<span class="glyphicon glyphicon-trash"></span>', '', '', 'Sets', 'DeleteSet', array('set_id' => $t_set->get("set_id")), array("title" => _t("Delete"))) . "</div>\n"; } $vs_set_display .= "<div><a href='#' onclick='jQuery(\"#comment" . $t_set->get("set_id") . "\").load(\"" . caNavUrl($po_request, '', 'Sets', 'AjaxListComments', array('item_id' => $t_set->get("set_id"), 'tablename' => 'ca_sets', 'set_id' => $t_set->get("set_id"))) . "\", function(){jQuery(\"#lbSetThumbRow" . $t_set->get("set_id") . "\").hide(); jQuery(\"#comment" . $t_set->get("set_id") . "\").show();}); return false;' title='" . _t("Comments") . "'><span class='glyphicon glyphicon-comment'></span> <small>" . $t_set->getNumComments() . "</small></a>"; if ($vb_write_access) { $vs_set_display .= " <a href='#' onclick='caMediaPanel.showPanel(\"" . caNavUrl($po_request, '', 'Sets', 'setForm', array("set_id" => $t_set->get("set_id"))) . "\"); return false;' title='" . _t("Edit Name/Description") . "'><span class='glyphicon glyphicon-edit'></span></a>"; } $vs_set_display .= "</div>\n"; $vs_set_display .= "</div><!-- end lbSetExpandedInfo --></div><!-- end lbSet --></div><!-- end lbSetContainer -->\n"; return $vs_set_display; }
$vs_message = "\tLINKING {$vs_child_id} to parent {$vs_parent_id}"; if (($vn_l = 200 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if (!($vn_child_item_id = $va_aat_id_to_item_id[$vs_child_id])) { print "ERROR: no list item id for child_id {$vs_child_id} (were there previous errors?)\n"; continue; } if (!($vn_parent_item_id = $va_aat_id_to_item_id[$vs_parent_id])) { print "ERROR: no list item id for parent_id {$vs_child_id} (were there previous errors?)\n"; continue; } if (!$t_item->load($vn_child_item_id)) { print "ERROR: could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})\n"; continue; } $t_item->set('parent_id', $vn_parent_item_id); $t_item->update(); if ($t_item->numErrors()) { print "ERROR: could not set parent_id for {$vs_child_id} (was translated to item_id={$vn_child_item_id}): " . join('; ', $t_item->getErrors()) . "\n"; } } if ($vn_list_item_relation_type_id_related > 0) { print "\n\nADDING RELATED TERM LINKS...\n"; $vn_last_message_length = 0; $t_item = new ca_list_items(); $t_link = new ca_list_items_x_list_items(); $t_link->setMode(ACCESS_WRITE);
public function _genTypeNav($pa_params) { $t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true); $t_list = new ca_lists(); $t_list->load(array('list_code' => $t_subject->getTypeListCode())); $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null)); $va_hier = caExtractValuesByUserLocale($t_list_item->getHierarchyWithLabels()); $va_restrict_to_types = null; if ($t_subject->getAppConfig()->get('perform_type_access_checking')) { $va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_tablename, array('access' => __CA_BUNDLE_ACCESS_READONLY__)); } $va_types = array(); if (is_array($va_hier)) { $va_types_by_parent_id = array(); $vn_root_id = $t_list->getRootItemIDForList($t_subject->getTypeListCode()); // organize items by parent id, exclude root foreach ($va_hier as $vn_item_id => $va_item) { if ($vn_item_id == $vn_root_id) { continue; } // skip root if (is_array($va_restrict_to_types) && !in_array($vn_item_id, $va_restrict_to_types)) { continue; } $va_types_by_parent_id[$va_item['parent_id']][] = $va_item; } foreach ($va_hier as $vn_item_id => $va_item) { if (is_array($va_restrict_to_types) && !in_array($vn_item_id, $va_restrict_to_types)) { continue; } if ($va_item['parent_id'] != $vn_root_id) { continue; } // does this item have sub-items? if (isset($va_item['item_id']) && isset($va_types_by_parent_id[$va_item['item_id']]) && is_array($va_types_by_parent_id[$va_item['item_id']])) { $va_subtypes = $this->_getSubTypes($va_types_by_parent_id[$va_item['item_id']], $va_types_by_parent_id, $va_restrict_to_types); } else { $va_subtypes = array(); } $va_types[] = array('displayName' => $va_item['name_plural'], 'parameters' => array('type_id' => $va_item['item_id']), 'is_enabled' => $va_item['is_enabled'], 'navigation' => $va_subtypes); } } return $va_types; }
$va_images = caGetDisplayImagesForAuthorityItems($vs_table, $va_ids, array('version' => 'small', 'relationshipTypes' => caGetOption('selectMediaUsingRelationshipTypes', $va_options, null), 'checkAccess' => $va_access_values)); $vn_c = 0; $qr_res->seek($vn_start); } $t_list_item = new ca_list_items(); $vs_add_to_lightbox_msg = addslashes(_t('Add to lightbox')); while ($qr_res->nextHit() && $vn_c < $vn_hits_per_block) { $vn_id = $qr_res->get("{$vs_table}.{$vs_pk}"); $vs_idno_detail_link = caDetailLink($this->request, $qr_res->get("{$vs_table}.idno"), '', $vs_table, $vn_id); $vs_label_detail_link = caDetailLink($this->request, $qr_res->get("{$vs_table}.preferred_labels.name"), '', $vs_table, $vn_id); $vs_thumbnail = ""; $vs_type_placeholder = ""; $vs_typecode = ""; if ($vs_table == 'ca_objects') { if (!($vs_thumbnail = $qr_res->getMediaTag('ca_object_representations.media', 'medium', array("checkAccess" => $va_access_values)))) { $t_list_item->load($qr_res->get("type_id")); $vs_typecode = $t_list_item->get("idno"); if ($vs_type_placeholder = getPlaceholder($vs_typecode, "placeholder_media_icon")) { $vs_thumbnail = "<div class='bResultItemImgPlaceholder'>" . $vs_type_placeholder . "</div>"; } else { $vs_thumbnail = $vs_default_placeholder_tag; } } $vs_rep_detail_link = caDetailLink($this->request, $vs_thumbnail, '', $vs_table, $vn_id); } else { if ($va_images[$vn_id]) { $vs_thumbnail = $va_images[$vn_id]; } else { $vs_thumbnail = $vs_default_placeholder_tag; } $vs_rep_detail_link = caDetailLink($this->request, $vs_thumbnail, '', $vs_table, $vn_id);
/** * Returns number of elements in system * * @param $pb_root_elements_only boolean If true, then only root elements are counted; default is false * @param $pm_table_name_or_num mixed Optional table name or number to filter list with. If specified then only elements that have a type restriction to the table are counted. If omitted (default) then all elements, regardless of type restrictions, are returned. * @param $pm_type_name_or_id mixed Optional type code or type_id to restrict elements to. If specified then only elements that have a type restriction to the specified table and type are counted. * @return int The number of elements */ public static function getElementCount($pb_root_elements_only = false, $pm_table_name_or_num = null, $pm_type_name_or_id = null) { $o_dm = Datamodel::load(); $vn_table_num = $o_dm->getTableNum($pm_table_name_or_num); $vo_db = new Db(); $va_wheres = array(); if ($pb_root_elements_only) { $va_wheres[] = 'cme.parent_id is NULL'; } if ($vn_table_num) { $va_wheres[] = 'cmtr.table_num = ?'; $va_where_params[] = (int) $vn_table_num; if ($pm_type_name_or_id) { $t_list_item = new ca_list_items(); if (!is_numeric($pm_type_name_or_id)) { $t_list_item->load(array('idno' => $pm_type_name_or_id)); } else { $t_list_item->load((int) $pm_type_name_or_id); } $va_type_ids = array(); if ($vn_type_id = $t_list_item->getPrimaryKey()) { $va_type_ids[$vn_type_id] = true; if ($qr_children = $t_list_item->getHierarchy($vn_type_id, array())) { while ($qr_children->nextRow()) { $va_type_ids[$qr_children->get('item_id')] = true; } } $va_wheres[] = '((cmtr.type_id = ?) OR (cmtr.include_subtypes = 1 AND cmtr.type_id IN (?)))'; $va_where_params[] = (int) $vn_type_id; $va_where_params[] = $va_type_ids; } } $vs_wheres = ' WHERE ' . join(' AND ', $va_wheres); $qr_tmp = $vo_db->query("\n\t\t\t\tSELECT count(*) c\n\t\t\t\tFROM ca_metadata_elements cme\n\t\t\t\tINNER JOIN ca_metadata_type_restrictions AS cmtr ON cme.hier_element_id = cmtr.element_id\n\t\t\t\t{$vs_wheres}\n\t\t\t", $va_where_params); } else { if (sizeof($va_wheres)) { $vs_wheres = ' WHERE ' . join(' AND ', $va_wheres); } else { $vs_wheres = ''; } $qr_tmp = $vo_db->query("\n\t\t\t\tSELECT count(*) c\n\t\t\t\tFROM ca_metadata_elements cme\n\t\t\t\t{$vs_wheres}\n\t\t\t"); } if ($qr_tmp->nextRow()) { return $qr_tmp->get('c'); } return 0; }
/** * Returns navigation fragment for types and subtypes of a given primary item type (Eg. ca_objects). Used to generate dynamic type menus * from database by AppNavigation class. * * @param array $pa_params Array of parameters used to generate menu * @return array List of types with subtypes ready for inclusion in a menu spec */ public function _genTypeNav($pa_params) { $t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name, true); $t_list = new ca_lists(); $t_list->load(array('list_code' => $t_subject->getTypeListCode())); $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null)); $va_hier = caExtractValuesByUserLocale($t_list_item->getHierarchyWithLabels()); $vn_sort_type = $t_list->get('default_sort'); $va_restrict_to_types = null; if ($t_subject->getAppConfig()->get('perform_type_access_checking')) { $va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_EDIT__)); } $va_types = array(); if (is_array($va_hier)) { $va_types_by_parent_id = array(); $vn_root_id = $t_list->getRootItemIDForList($t_subject->getTypeListCode()); foreach ($va_hier as $vn_item_id => $va_item) { if ($vn_item_id == $vn_root_id) { continue; } // skip root $va_types_by_parent_id[$va_item['parent_id']][] = $va_item; } foreach ($va_hier as $vn_item_id => $va_item) { if (is_array($va_restrict_to_types) && !in_array($vn_item_id, $va_restrict_to_types)) { continue; } if ($va_item['parent_id'] != $vn_root_id) { continue; } // does this item have sub-items? $va_subtypes = array(); if (!(bool) $this->getRequest()->config->get($this->ops_table_name . '_navigation_new_menu_shows_top_level_types_only') && !(bool) $this->getRequest()->config->get($this->ops_table_name . '_enforce_strict_type_hierarchy')) { if (isset($va_item['item_id']) && isset($va_types_by_parent_id[$va_item['item_id']]) && is_array($va_types_by_parent_id[$va_item['item_id']])) { $va_subtypes = $this->_getSubTypes($va_types_by_parent_id[$va_item['item_id']], $va_types_by_parent_id, $vn_sort_type, $va_restrict_to_types); } } switch ($vn_sort_type) { case 0: // label // label default: $vs_key = $va_item['name_singular']; break; case 1: // rank $vs_key = sprintf("%08d", (int) $va_item['rank']); break; case 2: // value $vs_key = $va_item['item_value']; break; case 3: // identifier $vs_key = $va_item['idno_sort']; break; } $va_types[$vs_key][] = array('displayName' => $va_item['name_singular'], 'parameters' => array('type_id' => $va_item['item_id']), 'is_enabled' => $va_item['is_enabled'], 'navigation' => $va_subtypes); } ksort($va_types); } $va_types_proc = array(); foreach ($va_types as $vs_sort_key => $va_items) { foreach ($va_items as $vn_i => $va_item) { $va_types_proc[] = $va_item; } } return $va_types_proc; }
/** * When returning text will return plural value of list item unless useSingular option is set to true, in which case singular version of list item label will be used. * * @param array Optional array of options. Support options are: * list_id = if set then the numeric item_id value is translated into label text in the current locale. If not set then the numeric item_id is returned. * useSingular = If list_id is set then by default the returned text is the plural label. Setting this option to true will force use of the singular label. [Default is false] * showHierarchy = If true then hierarchical parents of list item will be returned and hierarchical options described below will be used to control the output [Default is false] * returnIdno = If true list item idno is returned rather than preferred label [Default is false] * idsOnly = Return numeric item_id only [Default is false] * alwaysReturnItemID = Synonym for idsOnly [Default is false] * output = what value for the list to return. Valid values are text [display text], idno [identifier; same as returnIdno option], value [numeric item_id; same as idsOnly option]. [Default is value] * * HIERARCHICAL OPTIONS: * direction - For hierarchy specifications (eg. ca_objects.hierarchy) this determines the order in which the hierarchy is returned. ASC will return the hierarchy root first while DESC will return it with the lowest node first. Default is ASC. * top - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the root down. Default is to not limit. * bottom - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the lowest node up. Default is to not limit. * hierarchicalDelimiter - Text to place between items in a hierarchy for a hierarchical specification (eg. ca_objects.hierarchy) when returning as a string * removeFirstItems - If set to a non-zero value, the specified number of items at the top of the hierarchy will be omitted. For example, if set to 2, the root and first child of the hierarchy will be omitted. Default is zero (don't delete anything). * transaction = the transaction to execute database actions within. [Default is null] * @return string The value */ public function getDisplayValue($pa_options = null) { if (isset($pa_options['output'])) { switch (strtolower($pa_options['output'])) { case 'idno': $pa_options['returnIdno'] = true; break; case 'text': $pa_options['returnIdno'] = false; $pa_options['idsOnly'] = false; break; default: $pa_options['idsOnly'] = true; break; } } if ($vb_return_idno = isset($pa_options['returnIdno']) && (bool) $pa_options['returnIdno']) { return caGetListItemIdno($this->opn_item_id); } if (is_null($vb_ids_only = isset($pa_options['idsOnly']) ? (bool) $pa_options['idsOnly'] : null)) { $vb_ids_only = isset($pa_options['alwaysReturnItemID']) ? (bool) $pa_options['alwaysReturnItemID'] : false; } if ($vb_ids_only) { return (int) $this->opn_item_id; } $vn_list_id = is_array($pa_options) && isset($pa_options['list_id']) ? (int) $pa_options['list_id'] : null; if ($vn_list_id > 0) { $t_list = new ca_lists(); if ($o_trans = isset($pa_options['transaction']) ? $pa_options['transaction'] : null) { $t_list->setTransaction($o_trans); } $t_item = new ca_list_items(); if ($pa_options['showHierarchy'] || $vb_return_idno) { if ($o_trans) { $t_item->setTransaction($o_trans); } } $vs_get_spec = isset($pa_options['useSingular']) && $pa_options['useSingular'] ? 'preferred_labels.name_singular' : 'preferred_labels.name_plural'; // do we need to get the hierarchy? if ($pa_options['showHierarchy']) { $t_item->load((int) $this->opn_item_id); return $t_item->get('ca_list_items.hierarchy.' . $vs_get_spec, array_merge(array('removeFirstItems' => 1, 'delimiter' => ' ➔ ', $pa_options))); } return $t_list->getItemFromListForDisplayByItemID($vn_list_id, $this->opn_item_id, isset($pa_options['useSingular']) && $pa_options['useSingular'] ? false : true); } return $this->ops_text_value; }
private function _parameterRestrictionsApply($pa_parameters, $ps_controller, $ps_action, $pa_fake_parameters) { $t_item = new ca_list_items(); foreach ($pa_parameters as $vs_key => $va_value_data) { if ($vs_key == "type" && !is_array($va_value_data) && strlen($va_value_data) > 0) { if (!$t_item->load(array("idno" => $va_value_data))) { return false; } // if there is no explicit type_id parameter we need to figure out the subject with the information we have // (which is basically the controller name) and get the type_id by ourselves if ($pa_fake_parameters["type_id"]) { $vs_type_id = $pa_fake_parameters["type_id"]; } else { $vs_type_id = $this->opo_request->getParameter("type_id", pInteger); } if ($vs_type_id == "") { $vs_table = $this->_convertControllerAndActionToSubjectTable($ps_controller, $ps_action); if ($vs_table) { $t_instance = new $vs_table(); if ($pa_fake_parameters[$t_instance->primaryKey()]) { $vn_id = $pa_fake_parameters[$t_instance->primaryKey()]; } else { $vn_id = $this->opo_request->getParameter($t_instance->primaryKey(), pInteger); } $t_instance->load($vn_id); if (intval($t_instance->get("type_id")) != intval($t_item->getPrimaryKey())) { return false; } } } else { if (intval($t_item->getPrimaryKey()) != intval($vs_type_id)) { return false; } } } else { if (isset($pa_fake_parameters[$vs_key])) { $vs_fake_val = $pa_fake_parameters[$vs_key]; if (preg_match("/\\{[a-z_]*\\}/", $vs_fake_val)) { // fake value is placeholder for actual value inserted into forms via JS later -> set some fake actual integer value $vs_fake_val = 1; } } else { $vs_fake_val = null; } if (substr($va_value_data["value"], 0, 1) == "!") { switch ($va_value_data["type"]) { case "int": if (intval(substr($va_value_data["value"], 1)) == intval($vs_fake_val ? $vs_fake_val : $this->opo_request->getParameter($vs_key, pInteger))) { return false; } break; case "float": if (floatval(substr($va_value_data["value"], 1)) == floatval($vs_fake_val ? $vs_fake_val : $this->opo_request->getParameter($vs_key, pFloat))) { return false; } break; default: if (strval(substr($va_value_data["value"], 1)) == strval($vs_fake_val ? $vs_fake_val : $this->opo_request->getParameter($vs_key, pString))) { return false; } break; } } else { if ($va_value_data["value"] == "not_set") { if ($this->opo_request->getParameter($vs_key, pInteger) != "" || !is_null($vs_fake_val)) { return false; } } else { switch ($va_value_data["type"]) { case "int": if (intval($va_value_data["value"]) != intval($vs_fake_val ? $vs_fake_val : $this->opo_request->getParameter($vs_key, pInteger))) { return false; } break; case "float": if (floatval($va_value_data["value"]) != floatval($vs_fake_val ? $vs_fake_val : $this->opo_request->getParameter($vs_key, pFloat))) { return false; } break; default: if (strval($va_value_data["value"]) != strval($vs_fake_val ? $vs_fake_val : $this->opo_request->getParameter($vs_key, pString))) { return false; } break; } } } } } return true; }
/** * Returns COinS tags for inclusion in page * * @param SearchResult_or_BundleableLabelableBaseModelWithAttributes_subclass $pm_instance_or_result * @param string $ps_output_type * @param array $pa_options */ public static function getTags($pm_instance_or_result, $ps_output_type = null, $pa_options = null) { $va_config = COinS::_getConfig($vs_table_name = $pm_instance_or_result->tableName(), $ps_output_type); $va_urls = array(); if (is_subclass_of($pm_instance_or_result, 'BaseModel')) { $qr_res = $pm_instance_or_result->makeSearchResult($pm_instance_or_result->tableName(), array($pm_instance_or_result->getPrimaryKey())); } else { $qr_res = $pm_instance_or_result; } $o_dm = Datamodel::load(); $t_instance = $o_dm->getInstanceByTableName($vs_table_name, true); $vs_type_fld_name = $t_instance->getTypeFieldName(); $t_item = new ca_list_items(); while ($qr_res->nextHit()) { $vs_type_name = null; if ($vn_type_id = $qr_res->get($vs_type_fld_name)) { if ($t_item->load($vn_type_id)) { $vs_type_name = $t_item->get('idno'); } } $va_mappings = isset($va_config[$vs_type_name]) ? $va_config[$vs_type_name] : $va_config['__default__']; $va_people_mappings = $va_mappings['People']; unset($va_mappings['People']); $va_item = $va_people = array(); foreach ($va_mappings as $vs_key => $va_mapping) { if (!is_array($va_mapping)) { $vs_static = (string) $va_mapping; } else { $vs_static = $va_mapping['value']; $vs_bundle = $va_mapping['bundle']; $va_options = $va_mapping['options']; } if ($vs_bundle) { $va_item[$vs_key] = $qr_res->get($vs_bundle, $va_options); } else { $va_item[$vs_key] = $vs_static; } } if (is_array($va_people_mappings)) { foreach ($va_people_mappings as $vn_person_type => $va_mapping) { if (!is_array($va_mapping)) { $vs_static = (string) $va_mapping; } else { $vs_static = $va_mapping['value']; $vs_forename_bundle = $va_mapping['forename']; $vs_surname_bundle = $va_mapping['surname']; $va_options = $va_mapping['options']; } $vs_forename = $qr_res->get($vs_forename_bundle, $va_options); $vs_surname = $qr_res->get($vs_surname_bundle, $va_options); if ($vs_forename || $vs_surname) { $va_people[] = array('DocRelationship' => $vn_person_type, 'FirstName' => $vs_forename, 'LastName' => $vs_surname); } } } $va_urls[] = $vs_url = COinS::_CreateOpenURL($va_item, $va_people); $va_tags[] = "<span class='Z3988' title='{$vs_url}'></span>"; } $vb_return_urls = isset($pa_options['returnUrls']) && $pa_options['returnUrls']; if (isset($pa_options['returnAsArray']) && $pa_options['returnAsArray']) { return $vb_return_urls ? $va_urls : $va_tags; } else { $vs_delimiter = isset($pa_options['delimiter']) ? $pa_options['delimiter'] : "\n"; return join($vs_delimiter, $vb_return_urls ? $va_urls : $va_tags); } }
print $vs_dob . ")"; } print "<br/>"; } print "</H5>"; } ?> <HR/> <?php $va_classification_links = array(); $t_list_item = new ca_list_items(); $va_decorative_types = $t_object->get("ca_objects.decorative_types", array("returnAsArray" => true)); if (sizeof($va_decorative_types)) { foreach ($va_decorative_types as $va_decorative_type) { $vn_decorative_type = $va_decorative_type["decorative_types"]; $t_list_item->load($vn_decorative_type); if (trim($t_list_item->get("ca_list_item_labels.name_singular"))) { $va_classification_links[] = caNavLink($this->request, $t_list_item->get("ca_list_item_labels.name_singular"), "", "", "Browse", "Objects", array("facet" => "decorative_types_facet", "id" => $vn_decorative_type)); } } if (sizeof($va_classification_links)) { print "<H6>Classification</H6>"; print join(", ", $va_classification_links); } } $va_documentation_types = $t_object->get("ca_objects.documentation_types", array("returnAsArray" => true)); if (sizeof($va_documentation_types)) { foreach ($va_documentation_types as $va_documentation_type) { $vn_documentation_type = $va_documentation_type["documentation_types"]; $t_list_item->load($vn_documentation_type); if (trim($t_list_item->get("ca_list_item_labels.name_singular"))) {
/** * @param mixed $ps_value * @param array $pa_element_info * @param array $pa_options Options are: * alwaysTreatValueAsIdno = Always try to convert $ps_value to a list idno value, even if it is numeric * * @return array */ public function parseValue($ps_value, $pa_element_info, $pa_options = null) { $vb_treat_value_as_idno = caGetOption('alwaysTreatValueAsIdno', $pa_options, false); $vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? true : (bool) $pa_element_info['settings']['requireValue']; $ps_orig_value = $ps_value; if ($vb_treat_value_as_idno || preg_match('![^\\d]+!', $ps_value)) { // try to convert idno to item_id if ($vn_id = ca_lists::getItemID($pa_element_info['list_id'], $ps_value, $pa_options)) { $ps_value = $vn_id; } } if (!$vb_require_value && !(int) $ps_value) { return array('value_longtext1' => null, 'item_id' => null); } elseif ($vb_require_value && !(int) $ps_value) { $this->postError(1970, _t('Value %1 [%2] cannot be blank', $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'ListAttributeValue->parseValue()'); return false; } 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), 'ListAttributeValue->parseValue()'); return false; } $t_item = new ca_list_items(); if ($o_trans = caGetOption('transaction', $pa_options, null)) { $t_item->setTransaction($o_trans); } if (!$t_item->load((int) $ps_value)) { if ($ps_value) { $this->postError(1970, _t('%1 is not a valid list item_id for %2 [%3]', $ps_value, $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'ListAttributeValue->parseValue()'); } else { if ($vb_require_value) { $this->postError(1970, _t('Value %1 [%2] cannot be blank', $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'ListAttributeValue->parseValue()'); return false; } return null; } return false; } if ((int) $t_item->get('list_id') != (int) $pa_element_info['list_id']) { $this->postError(1970, _t('Item is not in the correct list for element %1. List id is %2 but should be %3. Value was %4', $pa_element_info["element_code"], $t_item->get('list_id'), $pa_element_info['list_id'], "{$ps_orig_value}/{$ps_value}"), 'ListAttributeValue->parseValue()'); return false; } return array('value_longtext1' => $ps_value, 'item_id' => (int) $ps_value); }
/** * */ 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 = '<' . _t('BLANK') . '>'; 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; }
/** * Returns item_id of root node for list */ public function getRootListItemID($pm_list_name_or_id = null) { if ($pm_list_name_or_id) { $vn_list_id = $this->_getListID($pm_list_name_or_id); } else { $vn_list_id = $this->getPrimaryKey(); } if (!$vn_list_id) { return null; } $t_items = new ca_list_items(); $t_items->load(array('list_id' => $vn_list_id, 'parent_id' => null)); return $t_items->getPrimaryKey(); }
/** * */ public function getTypeMenu() { $t_list = new ca_lists(); $t_list->load(array('list_code' => $this->getTypeListCode())); $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null)); $va_hierarchy = caExtractValuesByUserLocale($t_list_item->getHierarchyWithLabels()); $va_types = array(); if (is_array($va_hierarchy)) { $va_types_by_parent_id = array(); $vn_root_id = null; foreach ($va_hierarchy as $vn_item_id => $va_item) { if (!$vn_root_id) { $vn_root_id = $va_item['parent_id']; continue; } $va_types_by_parent_id[$va_item['parent_id']][] = $va_item; } foreach ($va_hierarchy as $vn_item_id => $va_item) { if ($va_item['parent_id'] != $vn_root_id) { continue; } // does this item have sub-items? if (isset($va_types_by_parent_id[$va_item['item_id']]) && is_array($va_types_by_parent_id[$va_item['item_id']])) { $va_subtypes = $this->_getSubTypes($va_types_by_parent_id[$va_item['item_id']], $va_types_by_parent_id); } else { $va_subtypes = array(); } $va_types[] = array('displayName' => $va_item['name_singular'], 'parameters' => array('type_id' => $va_item['item_id']), 'navigation' => $va_subtypes); } } return $va_types; }
/** * Generates standard-format inspector panels for editors * * @param View $po_view Inspector view object * @param array $pa_options Optional array of options. Supported options are: * backText = a string to use as the "back" button text; default is "Results" * * @return string HTML implementing the inspector */ function caEditorInspector($po_view, $pa_options = null) { require_once __CA_MODELS_DIR__ . '/ca_sets.php'; require_once __CA_MODELS_DIR__ . '/ca_data_exporters.php'; $t_item = $po_view->getVar('t_item'); $vs_table_name = $t_item->tableName(); if (($vs_priv_table_name = $vs_table_name) == 'ca_list_items') { $vs_priv_table_name = 'ca_lists'; } $vn_item_id = $t_item->getPrimaryKey(); $o_result_context = $po_view->getVar('result_context'); $t_ui = $po_view->getVar('t_ui'); $t_type = method_exists($t_item, "getTypeInstance") ? $t_item->getTypeInstance() : null; $vs_type_name = method_exists($t_item, "getTypeName") ? $t_item->getTypeName() : ''; if (!$vs_type_name) { $vs_type_name = $t_item->getProperty('NAME_SINGULAR'); } $va_reps = $po_view->getVar('representations'); $o_dm = Datamodel::load(); if ($t_item->isHierarchical()) { $va_ancestors = $po_view->getVar('ancestors'); $vn_parent_id = $t_item->get($t_item->getProperty('HIERARCHY_PARENT_ID_FLD')); } else { $va_ancestors = array(); $vn_parent_id = null; } // action extra to preserve currently open screen across next/previous links $vs_screen_extra = $po_view->getVar('screen') ? '/' . $po_view->getVar('screen') : ''; if ($vs_type_name == "list item") { $vs_style = "style='height:auto;'"; } if ($vn_item_id | $po_view->request->getAction() === 'Delete') { $vs_buf = '<h3 class="nextPrevious" ' . $vs_style . '>' . caEditorFindResultNavigation($po_view->request, $t_item, $o_result_context, $pa_options) . "</h3>\n"; } $vs_color = null; if ($t_type) { $vs_color = trim($t_type->get('color')); } if (!$vs_color && $t_ui) { $vs_color = trim($t_ui->get('color')); } if (!$vs_color) { $vs_color = "FFFFFF"; } $vs_buf .= "<h4><div id='caColorbox' style='border: 6px solid #{$vs_color};'>\n"; $vs_icon = null; if ($t_type) { $vs_icon = $t_type->getMediaTag('icon', 'icon'); } if (!$vs_icon && $t_ui) { $vs_icon = $t_ui->getMediaTag('icon', 'icon'); } if ($vs_icon) { $vs_buf .= "<div id='inspectoricon' style='border-right: 6px solid #{$vs_color}; border-bottom: 6px solid #{$vs_color}; -moz-border-radius-bottomright: 8px; -webkit-border-bottom-right-radius: 8px;'>\n{$vs_icon}</div>\n"; } if ($po_view->request->getAction() === 'Delete' && $po_view->request->getParameter('confirm', pInteger)) { $vs_buf .= "<strong>" . _t("Deleted %1", $vs_type_name) . "</strong>\n"; $vs_buf .= "<br style='clear: both;'/></div></h4>\n"; } else { if ($vn_item_id) { if (!$po_view->request->config->get("{$vs_priv_table_name}_inspector_disable_headline")) { if ($po_view->request->user->canDoAction("can_edit_" . $vs_priv_table_name) && sizeof($t_item->getTypeList()) > 1) { $vs_buf .= "<strong>" . _t("Editing %1", $vs_type_name) . ": </strong>\n"; } else { $vs_buf .= "<strong>" . _t("Viewing %1", $vs_type_name) . ": </strong>\n"; } } if ($t_item->hasField('is_deaccessioned') && $t_item->get('is_deaccessioned') && $t_item->get('deaccession_date', array('getDirectDate' => true)) <= caDateToHistoricTimestamp(_t('now'))) { // If currently deaccessioned then display deaccession message $vs_buf .= "<br/><div class='inspectorDeaccessioned'>" . _t('Deaccessioned %1', $t_item->get('deaccession_date')) . "</div>\n"; if ($vs_deaccession_notes = $t_item->get('deaccession_notes')) { TooltipManager::add(".inspectorDeaccessioned", $vs_deaccession_notes); } } else { if ($po_view->request->user->canDoAction('can_see_current_location_in_inspector_ca_objects')) { if ($t_ui && method_exists($t_item, "getObjectHistory") && (is_array($va_placements = $t_ui->getPlacementsForBundle('ca_objects_history')) && sizeof($va_placements) > 0)) { // // Output current "location" of object in life cycle. Configuration is taken from a ca_objects_history bundle configured for the current editor // $va_placement = array_shift($va_placements); $va_bundle_settings = $va_placement['settings']; if (is_array($va_history = $t_item->getObjectHistory($va_bundle_settings, array('limit' => 1, 'currentOnly' => true))) && sizeof($va_history) > 0) { $va_current_location = array_shift(array_shift($va_history)); if (!($vs_inspector_current_location_label = $po_view->request->config->get("ca_objects_inspector_current_location_label"))) { $vs_inspector_current_location_label = _t('Current'); } if ($va_current_location['display']) { $vs_buf .= "<div class='inspectorCurrentLocation'><strong>" . $vs_inspector_current_location_label . ':</strong><br/>' . $va_current_location['display'] . "</div>"; } } } elseif (method_exists($t_item, "getLastLocationForDisplay")) { // If no ca_objects_history bundle is configured then display the last storage location if ($vs_current_location = $t_item->getLastLocationForDisplay("<ifdef code='ca_storage_locations.parent.preferred_labels'>^ca_storage_locations.parent.preferred_labels ➜ </ifdef>^ca_storage_locations.preferred_labels.name")) { $vs_buf .= "<br/><div class='inspectorCurrentLocation'>" . _t('Location: %1', $vs_current_location) . "</div>\n"; $vs_full_location_hierarchy = $t_item->getLastLocationForDisplay("^ca_storage_locations.hierarchy.preferred_labels.name%delimiter=_➜_"); if ($vs_full_location_hierarchy !== $vs_current_location) { TooltipManager::add(".inspectorCurrentLocation", $vs_full_location_hierarchy); } } } } } // // Display flags; expressions for these are defined in app.conf in the <table_name>_inspector_display_flags directive // if (is_array($va_display_flags = $po_view->request->config->getAssoc("{$vs_table_name}_inspector_display_flags"))) { $va_display_flag_buf = array(); foreach ($va_display_flags as $vs_exp => $vs_display_flag) { $va_exp_vars = array(); foreach (ExpressionParser::getVariableList($vs_exp) as $vs_var_name) { $va_exp_vars[$vs_var_name] = $t_item->get($vs_var_name, array('returnIdno' => true)); } if (ExpressionParser::evaluate($vs_exp, $va_exp_vars)) { $va_display_flag_buf[] = $t_item->getWithTemplate("{$vs_display_flag}"); } } if (sizeof($va_display_flag_buf) > 0) { $vs_buf .= join("; ", $va_display_flag_buf); } } $vs_label = ''; $vb_dont_use_labels_for_ca_objects = (bool) $t_item->getAppConfig()->get('ca_objects_dont_use_labels'); if (!($vs_table_name === 'ca_objects' && $vb_dont_use_labels_for_ca_objects)) { if ($vs_get_spec = $po_view->request->config->get("{$vs_table_name}_inspector_display_title")) { $vs_label = caProcessTemplateForIDs($vs_get_spec, $vs_table_name, array($t_item->getPrimaryKey())); } else { $va_object_collection_collection_ancestors = $po_view->getVar('object_collection_collection_ancestors'); if ($t_item->tableName() == 'ca_objects' && $t_item->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled') && is_array($va_object_collection_collection_ancestors) && sizeof($va_object_collection_collection_ancestors)) { $va_collection_links = array(); foreach ($va_object_collection_collection_ancestors as $va_collection_ancestor) { $va_collection_links[] = caEditorLink($po_view->request, $va_collection_ancestor['label'], '', 'ca_collections', $va_collection_ancestor['collection_id']); } $vs_label .= join(" / ", $va_collection_links) . ' > '; } if (method_exists($t_item, 'getLabelForDisplay')) { $vn_parent_index = sizeof($va_ancestors) - 1; if ($vn_parent_id && ($vs_table_name != 'ca_places' || $vn_parent_index > 0)) { $va_parent = $va_ancestors[$vn_parent_index]; $vs_disp_fld = $t_item->getLabelDisplayField(); if ($va_parent['NODE'][$vs_disp_fld] && ($vs_editor_link = caEditorLink($po_view->request, $va_parent['NODE'][$vs_disp_fld], '', $vs_table_name, $va_parent['NODE'][$t_item->primaryKey()]))) { $vs_label .= $vs_editor_link . ' > ' . $t_item->getLabelForDisplay(); } else { $vs_label .= ($va_parent['NODE'][$vs_disp_fld] ? $va_parent['NODE'][$vs_disp_fld] . ' > ' : '') . $t_item->getLabelForDisplay(); } } else { $vs_label .= $t_item->getLabelForDisplay(); if ($vs_table_name === 'ca_editor_uis' && in_array($po_view->request->getAction(), array('EditScreen', 'DeleteScreen', 'SaveScreen'))) { $t_screen = new ca_editor_ui_screens($po_view->request->getParameter('screen_id', pInteger)); if (!($vs_screen_name = $t_screen->getLabelForDisplay())) { $vs_screen_name = _t('new screen'); } $vs_label .= " > " . $vs_screen_name; } } } else { $vs_label .= $t_item->get('name'); } } } $vb_show_idno = (bool) ($vs_idno = $t_item->get($t_item->getProperty('ID_NUMBERING_ID_FIELD'))); if (!$vs_label) { switch ($vs_table_name) { case 'ca_commerce_orders': if ($t_item->get('order_type') == 'L') { if ($vs_org = $t_item->get('billing_organization')) { $vs_label = _t('%5 #%4 on %1 to %2 (%3)', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $vs_org, $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } else { $vs_label = _t('%4 #%3 on %1 to %2', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } } else { if ($vs_org = $t_item->get('billing_organization')) { $vs_label = _t('%5 #%4 on %1 from %2 (%3)', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $vs_org, $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } else { $vs_label = _t('%4 #%3 on %1 from %2', caGetLocalizedDate($t_item->get('created_on', array('getDirectDate' => true)), array('dateFormat' => 'delimited', 'timeOmit' => true)), $t_item->get('billing_fname') . ' ' . $t_item->get('billing_lname'), $t_item->getOrderNumber(), caUcFirstUTF8Safe($t_item->getProperty('NAME_SINGULAR'))); } } break; default: if ($vs_table_name === 'ca_objects' && $vb_dont_use_labels_for_ca_objects) { $vs_label = $vs_idno; $vb_show_idno = false; } else { $vs_label = '[' . _t('BLANK') . ']'; } break; } } $vs_buf .= "<div class='recordTitle {$vs_table_name}' style='width:190px; overflow:hidden;'>{$vs_label}" . ($vb_show_idno ? "<a title='{$vs_idno}'>" . ($vs_idno ? " ({$vs_idno})" : '') : "") . "</a></div>"; if ($vs_table_name === 'ca_object_lots' && $t_item->getPrimaryKey()) { $vs_buf .= "<div id='inspectorLotMediaDownload'><strong>" . (($vn_num_objects = $t_item->numObjects()) == 1 ? _t('Lot contains %1 object', $vn_num_objects) : _t('Lot contains %1 objects', $vn_num_objects)) . "</strong>\n"; } if ($po_view->request->config->get("include_custom_inspector")) { if (file_exists($po_view->request->getViewsDirectoryPath() . "/bundles/inspector_info.php")) { $vo_inspector_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_inspector_view->setVar('t_item', $t_item); $vs_buf .= $vo_inspector_view->render('inspector_info.php'); } } } else { $vs_parent_name = ''; if ($vn_parent_id = $po_view->request->getParameter('parent_id', pInteger)) { $t_parent = clone $t_item; $t_parent->load($vn_parent_id); $vs_parent_name = $t_parent->getLabelForDisplay(); } $vs_buf .= "<div class='creatingNew'>" . _t("Creating new %1", $vs_type_name) . " " . ($vs_parent_name ? _t("%1 > New %2", $vs_parent_name, $vs_type_name) : '') . "</div>\n"; $vs_buf .= "<br/>\n"; } // ------------------------------------------------------------------------------------- if ($t_item->getPrimaryKey()) { if (sizeof($va_reps) > 0) { $va_imgs = array(); $vs_buf .= "<div id='inspectorMedia'>"; $vn_r = $vn_primary_index = 0; foreach ($va_reps as $va_rep) { if (!($va_rep['info']['preview170']['WIDTH'] && $va_rep['info']['preview170']['HEIGHT'])) { continue; } if ($vb_is_primary = isset($va_rep['is_primary']) && (bool) $va_rep['is_primary']) { $vn_primary_index = $vn_r; } $va_imgs[] = "{url:'" . $va_rep['urls']['preview170'] . "', width: " . $va_rep['info']['preview170']['WIDTH'] . ", height: " . $va_rep['info']['preview170']['HEIGHT'] . ", link: '#', onclick: 'caMediaPanel.showPanel(\\'" . caNavUrl($po_view->request, '*', '*', 'GetMediaOverlay', array($t_item->primaryKey() => $vn_item_id, 'representation_id' => $va_rep['representation_id'])) . "\\')'}"; $vn_r++; } if (sizeof($va_reps) > 1) { $vs_buf .= "\n\t\t\t\t\t<div class='leftScroll'>\n\t\t\t\t\t\t<a href='#' onclick='inspectorInfoRepScroller.scrollToPreviousImage(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_SCROLL_LT__) . "</a>\n\t\t\t\t\t</div>\n\t\t"; } if (sizeof($va_imgs) > 0) { $vs_buf .= "\n\t\t\t\t<div id='inspectorInfoRepScrollingViewer' style='position: relative;'>\n\t\t\t\t\t<div id='inspectorInfoRepScrollingViewerContainer'>\n\t\t\t\t\t\t<div id='inspectorInfoRepScrollingViewerImageContainer'></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t"; if (sizeof($va_reps) > 1) { $vs_buf .= "\n\t\t\t\t\t<div class='rightScroll'>\n\t\t\t\t\t\t<a href='#' onclick='inspectorInfoRepScroller.scrollToNextImage(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_SCROLL_RT__) . "</a>\n\t\t\t\t\t</div>\n\t\t"; } TooltipManager::add(".leftScroll", _t('Previous')); TooltipManager::add(".rightScroll", _t('Next')); $vs_buf .= "<script type='text/javascript'>"; $vs_buf .= "\n\t\t\t\t\tvar inspectorInfoRepScroller = caUI.initImageScroller([" . join(",", $va_imgs) . "], 'inspectorInfoRepScrollingViewerImageContainer', {\n\t\t\t\t\t\t\tcontainerWidth: 170, containerHeight: 170,\n\t\t\t\t\t\t\timageCounterID: 'inspectorInfoRepScrollingViewerCounter',\n\t\t\t\t\t\t\tscrollingImageClass: 'inspectorInfoRepScrollerImage',\n\t\t\t\t\t\t\tscrollingImagePrefixID: 'inspectorInfoRep',\n\t\t\t\t\t\t\tinitialIndex: {$vn_primary_index}\n\t\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t</script>"; } $vs_buf .= "</div>\n"; if ($vs_get_spec = $po_view->request->config->get("{$vs_table_name}_inspector_display_below_media")) { $vs_buf .= caProcessTemplateForIDs($vs_get_spec, $vs_table_name, array($t_item->getPrimaryKey())); } } $vs_buf .= "<div id='toolIcons'>"; if ($vn_item_id) { # --- watch this link $vs_watch = ""; if (in_array($vs_table_name, array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations'))) { require_once __CA_MODELS_DIR__ . '/ca_watch_list.php'; $t_watch_list = new ca_watch_list(); $vs_watch = "<div class='watchThis'><a href='#' title='" . _t('Add/remove item to/from watch list.') . "' onclick='caToggleItemWatch(); return false;' id='caWatchItemButton'>" . caNavIcon($po_view->request, $t_watch_list->isItemWatched($vn_item_id, $t_item->tableNum(), $po_view->request->user->get("user_id")) ? __CA_NAV_BUTTON_UNWATCH__ : __CA_NAV_BUTTON_WATCH__) . "</a></div>"; $vs_buf .= "\n<script type='text/javascript'>\n\t\tfunction caToggleItemWatch() {\n\t\t\tvar url = '" . caNavUrl($po_view->request, $po_view->request->getModulePath(), $po_view->request->getController(), 'toggleWatch', array($t_item->primaryKey() => $vn_item_id)) . "';\n\t\t\t\n\t\t\tjQuery.getJSON(url, {}, function(data, status) {\n\t\t\t\tif (data['status'] == 'ok') {\n\t\t\t\t\tjQuery('#caWatchItemButton').html((data['state'] == 'watched') ? '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_UNWATCH__)) . "' : '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_WATCH__)) . "');\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log('Error toggling watch status for item: ' + data['errors']);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t</script>\n"; } $vs_buf .= "{$vs_watch}\n"; TooltipManager::add("#caWatchItemButton", _t('Watch/Unwatch this record')); if ($po_view->request->user->canDoAction("can_change_type_{$vs_table_name}")) { $vs_buf .= "<div id='inspectorChangeType'><div id='inspectorChangeTypeButton'><a href='#' onclick='caTypeChangePanel.showPanel(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_CHANGE__ . " Change Type", array('title' => _t('Change type'))) . "</a></div></div>\n"; $vo_change_type_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_change_type_view->setVar('t_item', $t_item); FooterManager::add($vo_change_type_view->render("change_type_html.php")); TooltipManager::add("#inspectorChangeType", _t('Change Record Type')); } if ($t_item->getPrimaryKey() && $po_view->request->config->get($vs_table_name . '_show_add_child_control_in_inspector')) { $vb_show_add_child_control = true; if (is_array($va_restrict_add_child_control_to_types = $po_view->request->config->getList($vs_table_name . '_restrict_child_control_in_inspector_to_types')) && sizeof($va_restrict_add_child_control_to_types)) { $t_type_instance = $t_item->getTypeInstance(); if (!in_array($t_type_instance->get('idno'), $va_restrict_add_child_control_to_types) && !in_array($t_type_instance->getPrimaryKey(), $va_restrict_add_child_control_to_types)) { $vb_show_add_child_control = false; } } if ($vb_show_add_child_control) { if ((bool) $po_view->request->config->get($vs_table_name . '_enforce_strict_type_hierarchy')) { // strict menu $vs_type_list = $t_item->getTypeListAsHTMLFormElement('type_id', array('style' => 'width: 90px; font-size: 9px;'), array('childrenOfCurrentTypeOnly' => true, 'directChildrenOnly' => $po_view->request->config->get($vs_table_name . '_enforce_strict_type_hierarchy') == '~' ? false : true, 'returnHierarchyLevels' => true, 'access' => __CA_BUNDLE_ACCESS_EDIT__)); } else { // all types $vs_type_list = $t_item->getTypeListAsHTMLFormElement('type_id', array('style' => 'width: 90px; font-size: 9px;'), array('access' => __CA_BUNDLE_ACCESS_EDIT__)); } if ($vs_type_list) { $vs_buf .= "<div id='inspectorCreateChild'><div id='inspectorCreateChildButton'><a href='#' onclick='caCreateChildPanel.showPanel(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_CHILD__, array('title' => _t('Create Child Record'))) . "</a></div></div>\n"; $vo_create_child_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_create_child_view->setVar('t_item', $t_item); $vo_create_child_view->setVar('type_list', $vs_type_list); FooterManager::add($vo_create_child_view->render("create_child_html.php")); TooltipManager::add("#inspectorCreateChildButton", _t('Create a child record under this one')); } } } } if ($po_view->request->user->canDoAction('can_duplicate_' . $vs_table_name) && $t_item->getPrimaryKey()) { $vs_buf .= '<div id="caDuplicateItemButton">'; $vs_buf .= caFormTag($po_view->request, 'Edit', 'DuplicateItemForm', $po_view->request->getModulePath() . '/' . $po_view->request->getController(), 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true, 'noTimestamp' => true)); $vs_buf .= caFormSubmitLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DUPLICATE__), '', 'DuplicateItemForm'); $vs_buf .= caHTMLHiddenInput($t_item->primaryKey(), array('value' => $t_item->getPrimaryKey())); $vs_buf .= caHTMLHiddenInput('mode', array('value' => 'dupe')); $vs_buf .= "</form>"; $vs_buf .= "</div>"; TooltipManager::add("#caDuplicateItemButton", _t('Duplicate this %1', mb_strtolower($vs_type_name, 'UTF-8'))); } // // Download media in lot ($vn_num_objects is only set for object lots) if ($vn_num_objects > 0) { $vs_buf .= "<div id='inspectorLotMediaDownloadButton'>" . caNavLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DOWNLOAD__), "button", $po_view->request->getModulePath(), $po_view->request->getController(), 'getLotMedia', array('lot_id' => $t_item->getPrimaryKey(), 'download' => 1), array()) . "</div>\n"; TooltipManager::add('#inspectorLotMediaDownloadButton', _t("Download all media associated with objects in this lot")); } // // Download media in set if ($vs_table_name == 'ca_sets' && sizeof($t_item->getItemRowIDs()) > 0) { $vs_buf .= "<div id='inspectorSetMediaDownloadButton'>" . caNavLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DOWNLOAD__), "button", $po_view->request->getModulePath(), $po_view->request->getController(), 'getSetMedia', array('set_id' => $t_item->getPrimaryKey(), 'download' => 1), array()) . "</div>\n"; TooltipManager::add('#inspectorSetMediaDownloadButton', _t("Download all media associated with records in this set")); } $vs_more_info = ''; // list of sets in which item is a member $t_set = new ca_sets(); if (is_array($va_sets = caExtractValuesByUserLocale($t_set->getSetsForItem($t_item->tableNum(), $t_item->getPrimaryKey(), array('user_id' => $po_view->request->getUserID(), 'access' => __CA_SET_READ_ACCESS__)))) && sizeof($va_sets)) { $va_links = array(); foreach ($va_sets as $vn_set_id => $va_set) { $va_links[] = "<a href='" . caEditorUrl($po_view->request, 'ca_sets', $vn_set_id) . "'>" . $va_set['name'] . "</a>"; } $vs_more_info .= "<div><strong>" . (sizeof($va_links) == 1 ? _t("In set") : _t("In sets")) . "</strong> " . join(", ", $va_links) . "</div>\n"; } // export options if ($vn_item_id && ($vs_select = $po_view->getVar('available_mappings_as_html_select'))) { $vs_more_info .= "<div class='inspectorExportControls'>" . caFormTag($po_view->request, 'exportItem', 'caExportForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_more_info .= $vs_select; $vs_more_info .= caHTMLHiddenInput($t_item->primaryKey(), array('value' => $t_item->getPrimaryKey())); $vs_more_info .= caHTMLHiddenInput('download', array('value' => 1)); $vs_more_info .= caFormSubmitLink($po_view->request, 'Export ›', 'button', 'caExportForm'); $vs_more_info .= "</form></div>"; } $va_creation = $t_item->getCreationTimestamp(); $va_last_change = $t_item->getLastChangeTimestamp(); if ($va_creation['timestamp'] || $va_last_change['timestamp']) { $vs_more_info .= "<div class='inspectorChangeDateList'>"; if ($va_creation['timestamp']) { if (!trim($vs_name = $va_creation['fname'] . ' ' . $va_creation['lname'])) { $vs_name = null; } $vs_interval = ($vn_t = time() - $va_creation['timestamp']) == 0 ? _t('Just now') : _t('%1 ago', caFormatInterval($vn_t, 2)); $vs_more_info .= "<div class='inspectorChangeDateListLine' id='caInspectorCreationDate'>" . ($vs_name ? _t('<strong>Created</strong><br/>%1 by %2', $vs_interval, $vs_name) : _t('<strong>Created</strong><br/>%1', $vs_interval)) . "</div>"; TooltipManager::add("#caInspectorCreationDate", "<h2>" . _t('Created on') . "</h2>" . _t('Created on %1', caGetLocalizedDate($va_creation['timestamp'], array('dateFormat' => 'delimited')))); } if ($va_last_change['timestamp'] && $va_creation['timestamp'] != $va_last_change['timestamp']) { if (!trim($vs_name = $va_last_change['fname'] . ' ' . $va_last_change['lname'])) { $vs_name = null; } $vs_interval = ($vn_t = time() - $va_last_change['timestamp']) == 0 ? _t('Just now') : _t('%1 ago', caFormatInterval($vn_t, 2)); $vs_more_info .= "<div class='inspectorChangeDateListLine' id='caInspectorChangeDate'>" . ($vs_name ? _t('<strong>Last changed</strong><br/>%1 by %2', $vs_interval, $vs_name) : _t('<strong>Last changed</strong><br/>%1', $vs_interval)) . "</div>"; TooltipManager::add("#caInspectorChangeDate", "<h2>" . _t('Last changed on') . "</h2>" . _t('Last changed on %1', caGetLocalizedDate($va_last_change['timestamp'], array('dateFormat' => 'delimited')))); } if (method_exists($t_item, 'getMetadataDictionaryRuleViolations') && is_array($va_violations = $t_item->getMetadataDictionaryRuleViolations()) && ($vn_num_violations = sizeof($va_violations)) > 0) { $va_violation_messages = array(); foreach ($va_violations as $vn_violation_id => $va_violation) { $vs_label = $t_item->getDisplayLabel($va_violation['bundle_name']); $va_violation_messages[] = "<li><em><u>{$vs_label}</u></em> " . $va_violation['violationMessage'] . "</li>"; } $vs_more_info .= "<div id='caInspectorViolationsList'>" . ($vs_num_violations_display = "<img src='" . $po_view->request->getThemeUrlPath() . "/graphics/icons/warning_small.gif' border='0'/> " . ($vn_num_violations > 1 ? _t('%1 problems require attention', $vn_num_violations) : _t('%1 problem requires attention', $vn_num_violations))) . "</div>\n"; TooltipManager::add("#caInspectorViolationsList", "<h2>{$vs_num_violations_display}</h2><ol>" . join("\n", $va_violation_messages)) . "</ol>\n"; } $vs_more_info .= "</div>\n"; } if ($vs_get_spec = $po_view->request->config->get("{$vs_table_name}_inspector_display_more_info")) { $vs_more_info .= caProcessTemplateForIDs($vs_get_spec, $vs_table_name, array($t_item->getPrimaryKey())); } if ($vs_more_info) { $vs_buf .= "<div class='button info'><a href='#' id='inspectorMoreInfo'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_INFO2__) . "</a></div>\n\t\t\t<div id='inspectorInfo' >"; $vs_buf .= $vs_more_info . "</div>\n"; TooltipManager::add("#inspectorMoreInfo", _t('See more information about this record')); } $vs_buf .= "</div><!--End tooIcons-->"; } // ------------------------------------------------------------------------------------- // // Item-specific information // // // Output info for related items // if (!$t_item->getPrimaryKey()) { // only applies to new records $vs_rel_table = $po_view->request->getParameter('rel_table', pString); $vn_rel_type_id = $po_view->request->getParameter('rel_type_id', pString); $vn_rel_id = $po_view->request->getParameter('rel_id', pInteger); if ($vs_rel_table && $po_view->request->datamodel->tableExists($vs_rel_table) && $vn_rel_type_id && $vn_rel_id) { $t_rel = $po_view->request->datamodel->getTableInstance($vs_rel_table); if ($t_rel && $t_rel->load($vn_rel_id)) { $vs_buf .= '<strong>' . _t("Will be related to %1", $t_rel->getTypeName()) . '</strong>: ' . $t_rel->getLabelForDisplay(); } } } // // Output lot info for ca_objects // $vb_is_currently_part_of_lot = true; if (!($vn_lot_id = $t_item->get('lot_id'))) { $vn_lot_id = $po_view->request->getParameter('lot_id', pInteger); $vb_is_currently_part_of_lot = false; } if ($vs_table_name === 'ca_objects' && $vn_lot_id) { require_once __CA_MODELS_DIR__ . '/ca_object_lots.php'; $va_lot_lots = caGetTypeListForUser('ca_object_lots', array('access' => __CA_BUNDLE_ACCESS_READONLY__)); $t_lot = new ca_object_lots($vn_lot_id); if ($t_lot->get('deleted') == 0 && in_array($t_lot->get('type_id'), $va_lot_lots)) { if (!($vs_lot_displayname = $t_lot->get('idno_stub'))) { if (!($vs_lot_displayname = $t_lot->getLabelForDisplay())) { $vs_lot_displayname = "Lot {$vn_lot_id}"; } } if ($vs_lot_displayname) { if (!($vs_part_of_lot_msg = $po_view->request->config->get("ca_objects_inspector_part_of_lot_msg"))) { $vs_part_of_lot_msg = _t('Part of lot'); } if (!($vs_will_be_part_of_lot_msg = $po_view->request->config->get("ca_objects_inspector_will_be_part_of_lot_msg"))) { $vs_will_be_part_of_lot_msg = _t('Will be part of lot'); } $vs_buf .= "<strong>" . ($vb_is_currently_part_of_lot ? $vs_part_of_lot_msg : $vs_will_be_part_of_lot_msg) . "</strong>: " . caNavLink($po_view->request, $vs_lot_displayname, '', 'editor/object_lots', 'ObjectLotEditor', 'Edit', array('lot_id' => $vn_lot_id)); } } } $va_object_container_types = $po_view->request->config->getList('ca_objects_container_types'); $va_object_component_types = $po_view->request->config->getList('ca_objects_component_types'); $vb_can_add_component = $vs_table_name === 'ca_objects' && $t_item->getPrimaryKey() && $po_view->request->user->canDoAction('can_create_ca_objects') && $t_item->canTakeComponents(); if (method_exists($t_item, 'getComponentCount')) { if ($vn_component_count = $t_item->getComponentCount()) { if ($t_ui && ($vs_component_list_screen = $t_ui->getScreenWithBundle("ca_objects_components_list", $po_view->request)) && $vs_component_list_screen !== $po_view->request->getActionExtra()) { $vs_component_count_link = caNavLink($po_view->request, $vn_component_count == 1 ? _t('%1 component', $vn_component_count) : _t('%1 components', $vn_component_count), '', '*', '*', $po_view->request->getAction() . '/' . $vs_component_list_screen, array($t_item->primaryKey() => $t_item->getPrimaryKey())); } else { $vs_component_count_link = $vn_component_count == 1 ? _t('%1 component', $vn_component_count) : _t('%1 components', $vn_component_count); } $vs_buf .= "<br/><strong>" . _t('Has') . ":</strong> {$vs_component_count_link}"; } } if ($vb_can_add_component) { $vs_buf .= ' <a href="#" onclick=\'caObjectComponentPanel.showPanel("' . caNavUrl($po_view->request, '*', 'ObjectComponent', 'Form', array('parent_id' => $t_item->getPrimaryKey())) . '"); return false;\')>' . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . '</a>'; $vo_change_type_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/"); $vo_change_type_view->setVar('t_item', $t_item); FooterManager::add($vo_change_type_view->render("create_component_html.php")); } // // Output lot info for ca_object_lots // if ($vs_table_name === 'ca_object_lots' && $t_item->getPrimaryKey()) { $va_component_types = $po_view->request->config->getList('ca_objects_component_types'); if (is_array($va_component_types) && sizeof($va_component_types)) { $vs_buf .= "<strong>" . (($vn_num_objects = $t_item->numObjects(null, array('return' => 'objects'))) == 1 ? _t('Lot contains %1 object', $vn_num_objects) : _t('Lot contains %1 objects', $vn_num_objects)) . "</strong>\n"; $vs_buf .= "<strong>" . (($vn_num_components = $t_item->numObjects(null, array('return' => 'components'))) == 1 ? _t('Lot contains %1 component', $vn_num_components) : _t('Lot contains %1 components', $vn_num_components)) . "</strong>\n"; } else { $vs_buf .= "<strong>" . (($vn_num_objects = $t_item->numObjects()) == 1 ? _t('Lot contains %1 object', $vn_num_objects) : _t('Lot contains %1 objects', $vn_num_objects)) . "</strong>\n"; } if ((bool) $po_view->request->config->get('allow_automated_renumbering_of_objects_in_a_lot') && ($va_nonconforming_objects = $t_item->getObjectsWithNonConformingIdnos())) { $vs_buf .= '<br/><br/><em>' . (($vn_c = sizeof($va_nonconforming_objects)) == 1 ? _t('There is %1 object with non-conforming numbering', $vn_c) : _t('There are %1 objects with non-conforming numbering', $vn_c)) . "</em>\n"; $vs_buf .= "<a href='#' onclick='jQuery(\"#inspectorNonConformingNumberList\").toggle(250); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__); $vs_buf .= "<div id='inspectorNonConformingNumberList' class='inspectorNonConformingNumberList'><div class='inspectorNonConformingNumberListScroll'><ol>\n"; foreach ($va_nonconforming_objects as $vn_object_id => $va_object_info) { $vs_buf .= '<li>' . caEditorLink($po_view->request, $va_object_info['idno'], '', 'ca_objects', $vn_object_id) . "</li>\n"; } $vs_buf .= "</ol></div>"; $vs_buf .= caNavLink($po_view->request, _t('Re-number objects') . ' ›', 'button', $po_view->request->getModulePath(), $po_view->request->getController(), 'renumberObjects', array('lot_id' => $t_item->getPrimaryKey())); $vs_buf .= "</div>\n"; } require_once __CA_MODELS_DIR__ . '/ca_objects.php'; $t_object = new ca_objects(); $vs_buf .= "<div class='inspectorLotObjectTypeControls'><form action='#' id='caAddObjectToLotForm'>"; if ((bool) $po_view->request->config->get('ca_objects_enforce_strict_type_hierarchy')) { // strict menu $vs_buf .= _t('Add new %1 to lot', $t_object->getTypeListAsHTMLFormElement('type_id', array('id' => 'caAddObjectToLotForm_type_id'), array('childrenOfCurrentTypeOnly' => true, 'directChildrenOnly' => $po_view->request->config->get('ca_objects_enforce_strict_type_hierarchy') == '~' ? false : true, 'returnHierarchyLevels' => true, 'access' => __CA_BUNDLE_ACCESS_EDIT__))); } else { // all types $vs_buf .= _t('Add new %1 to lot', $t_object->getTypeListAsHTMLFormElement('type_id', array('id' => 'caAddObjectToLotForm_type_id'), array('access' => __CA_BUNDLE_ACCESS_EDIT__))); } $vs_buf .= " <a href='#' onclick='caAddObjectToLotForm()'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . '</a>'; $vs_buf .= "</form></div>\n"; $vs_buf .= "<script type='text/javascript'>\n\tfunction caAddObjectToLotForm() { \n\t\twindow.location='" . caEditorUrl($po_view->request, 'ca_objects', 0, false, array('lot_id' => $t_item->getPrimaryKey(), 'rel' => 1, 'type_id' => '')) . "' + jQuery('#caAddObjectToLotForm_type_id').val();\n\t}\n\tjQuery(document).ready(function() {\n\t\tjQuery('#objectLotsNonConformingNumberList').hide();\n\t});\n</script>\n"; } if ($vs_table_name === 'ca_objects') { // // Output loan info for ca_objects // if ($po_view->request->user->canDoAction('can_manage_clients') && ($va_loan_details = $t_item->isOnLoan())) { $vs_buf .= "<div>" . caNavLink($po_view->request, _t('On loan to %1', $va_loan_details['billing_fname'] . ' ' . $va_loan_details['billing_lname']), 'inspectorOnLoan', 'client/library', 'OrderEditor', 'Edit', array('order_id' => $va_loan_details['order_id'])) . "</div>"; } // // Output checkout info for ca_objects // if ((bool) $po_view->request->config->get('enable_client_services') && ((bool) $po_view->request->config->get('enable_client_services_sales') || (bool) $po_view->request->config->get('enable_client_services_library')) && $t_item->canBeCheckedOut() && ($va_checkout_status = $t_item->getCheckoutStatus(array('returnAsArray' => true)))) { $vs_buf .= "<div class='inspectorCheckedOut'>" . $va_checkout_status['status_display']; if ($va_checkout_status['user_name']) { $vs_buf .= _t("; checked out by %1", $va_checkout_status['user_name']); } $vs_buf .= "</div>"; } } // // Output related objects for ca_object_representations // if ($vs_table_name === 'ca_object_representations') { foreach (array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_loans', 'ca_movements') as $vs_rel_table) { if (sizeof($va_objects = $t_item->getRelatedItems($vs_rel_table))) { $vs_buf .= "<div><strong>" . _t("Related %1", $o_dm->getTableProperty($vs_rel_table, 'NAME_PLURAL')) . "</strong>: <br/>\n"; $vs_screen = ''; if ($t_ui = ca_editor_uis::loadDefaultUI($vs_rel_table, $po_view->request, null)) { $vs_screen = $t_ui->getScreenWithBundle('ca_object_representations', $po_view->request); } foreach ($va_objects as $vn_rel_id => $va_rel_info) { if ($vs_label = array_shift($va_rel_info['labels'])) { $vs_buf .= caEditorLink($po_view->request, '← ' . $vs_label . ' (' . $va_rel_info['idno'] . ')', '', $vs_rel_table, $va_rel_info[$o_dm->getTablePrimaryKeyName($vs_rel_table)], array(), array(), array('action' => 'Edit' . ($vs_screen ? "/{$vs_screen}" : ""))) . "<br/>\n"; } } $vs_buf .= "</div>\n"; } } } // // Output related object reprsentation for ca_representation_annotation // if ($vs_table_name === 'ca_representation_annotations') { if ($vn_representation_id = $t_item->get('representation_id')) { $vs_buf .= "<div><strong>" . _t("Applied to representation") . "</strong>: <br/>\n"; $t_rep = new ca_object_representations($vn_representation_id); $vs_buf .= caNavLink($po_view->request, '← ' . $t_rep->getLabelForDisplay(), '', 'editor/object_representations', 'ObjectRepresentationEditor', 'Edit/' . $po_view->getVar('representation_editor_screen'), array('representation_id' => $vn_representation_id)) . '<br/>'; $vs_buf .= "</div>\n"; } } // // Output extra useful info for sets // if ($vs_table_name === 'ca_sets') { $vn_set_item_count = $t_item->getItemCount(array('user_id' => $po_view->request->getUserID())); if ($vn_set_item_count > 0 && $po_view->request->user->canDoAction('can_batch_edit_' . $o_dm->getTableName($t_item->get('table_num')))) { $vs_buf .= caNavButton($po_view->request, __CA_NAV_BUTTON_BATCH_EDIT__, _t('Batch edit'), 'editorBatchSetEditorLink', 'batch', 'Editor', 'Edit', array('set_id' => $t_item->getPrimaryKey()), array(), array('icon_position' => __CA_NAV_BUTTON_ICON_POS_LEFT__, 'no_background' => true, 'dont_show_content' => true)); } $vs_buf .= "<div><strong>" . _t("Number of items") . "</strong>: {$vn_set_item_count}<br/>\n"; if ($t_item->getPrimaryKey()) { $vn_set_table_num = $t_item->get('table_num'); $vs_set_table_name = $o_dm->getTableName($vn_set_table_num); $vs_buf .= "<strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_set_table_num) . "<br/>\n"; $vs_buf .= "</div>\n"; } else { if ($vn_set_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<div><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_set_table_num) . "<br/>\n"; $vs_buf .= "</div>\n"; } } $t_user = new ca_users(($vn_user_id = $t_item->get('user_id')) ? $vn_user_id : $po_view->request->getUserID()); if ($t_user->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t('Owner') . "</strong>: " . $t_user->get('fname') . ' ' . $t_user->get('lname') . "</div>\n"; } if ($po_view->request->user->canDoAction('can_export_' . $vs_set_table_name) && $t_item->getPrimaryKey() && sizeof(ca_data_exporters::getExporters($vn_set_table_num)) > 0) { $vs_buf .= '<div style="border-top: 1px solid #aaaaaa; margin-top: 5px; font-size: 10px; text-align: right;" id="caExportItemButton">'; $vs_buf .= _t('Export this set of records') . " "; $vs_buf .= "<a class='button' onclick='jQuery(\"#exporterFormList\").show();' style='text-align:right;' href='#'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . "</a>"; $vs_buf .= caFormTag($po_view->request, 'ExportData', 'caExportForm', 'manage/MetadataExport', 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_buf .= "<div id='exporterFormList'>"; $vs_buf .= ca_data_exporters::getExporterListAsHTMLFormElement('exporter_id', $vn_set_table_num, array('id' => 'caExporterList'), array('width' => '135px')); $vs_buf .= caHTMLHiddenInput('set_id', array('value' => $t_item->getPrimaryKey())); $vs_buf .= caFormSubmitLink($po_view->request, _t('Export') . " ›", "button", "caExportForm"); $vs_buf .= "</div>\n"; $vs_buf .= "</form>"; $vs_buf .= "</div>"; $vs_buf .= "<script type='text/javascript'>"; $vs_buf .= "jQuery(document).ready(function() {"; $vs_buf .= "jQuery(\"#exporterFormList\").hide();"; $vs_buf .= "});"; $vs_buf .= "</script>"; } } // // Output extra useful info for set items // if ($vs_table_name === 'ca_set_items') { AssetLoadManager::register("panel"); $t_set = new ca_sets(); if ($t_set->load($vn_set_id = $t_item->get('set_id'))) { $vs_buf .= "<div><strong>" . _t("Part of set") . "</strong>: " . caEditorLink($po_view->request, $t_set->getLabelForDisplay(), '', 'ca_sets', $vn_set_id) . "<br/>\n"; $t_content_instance = $t_item->getAppDatamodel()->getInstanceByTableNum($vn_item_table_num = $t_item->get('table_num')); if ($t_content_instance->load($vn_row_id = $t_item->get('row_id'))) { $vs_label = $t_content_instance->getLabelForDisplay(); if ($vs_id_fld = $t_content_instance->getProperty('ID_NUMBERING_ID_FIELD')) { $vs_label .= " (" . $t_content_instance->get($vs_id_fld) . ")"; } $vs_buf .= "<strong>" . _t("Is %1", caGetTableDisplayName($vn_item_table_num, false) . "</strong>: " . caEditorLink($po_view->request, $vs_label, '', $vn_item_table_num, $vn_row_id)) . "<br/>\n"; } $vs_buf .= "</div>\n"; } } // // Output extra useful info for lists // if ($vs_table_name === 'ca_lists' && $t_item->getPrimaryKey()) { $vs_buf .= "<strong>" . _t("Number of items") . "</strong>: " . $t_item->numItemsInList() . "<br/>\n"; $t_list_item = new ca_list_items(); $t_list_item->load(array('list_id' => $t_item->getPrimaryKey(), 'parent_id' => null)); $vs_type_list = $t_list_item->getTypeListAsHTMLFormElement('type_id', array('style' => 'width: 90px; font-size: 9px;'), array('access' => __CA_BUNDLE_ACCESS_EDIT__)); if ($vs_type_list) { $vs_buf .= '<div style="border-top: 1px solid #aaaaaa; margin-top: 5px; font-size: 10px;">'; $vs_buf .= caFormTag($po_view->request, 'Edit', 'NewChildForm', 'administrate/setup/list_item_editor/ListItemEditor', 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_buf .= _t('Add a %1 to this list', $vs_type_list) . caHTMLHiddenInput($t_list_item->primaryKey(), array('value' => '0')) . caHTMLHiddenInput('parent_id', array('value' => $t_list_item->getPrimaryKey())); $vs_buf .= caFormSubmitLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__), '', 'NewChildForm'); $vs_buf .= "</form></div>\n"; } } // // Output containing list for list items // if ($vs_table_name === 'ca_list_items') { if ($t_list = $po_view->getVar('t_list')) { $vn_list_id = $t_list->getPrimaryKey(); $vs_buf .= "<strong>" . _t("Part of") . "</strong>: " . caEditorLink($po_view->request, $t_list->getLabelForDisplay(), '', 'ca_lists', $vn_list_id) . "<br/>\n"; if ($t_item->get('is_default')) { $vs_buf .= "<strong>" . _t("Is default for list") . "</strong><br/>\n"; } } } // // Output containing relationship type name for relationship types // if ($vs_table_name === 'ca_relationship_types') { if (!($t_rel_instance = $t_item->getAppDatamodel()->getInstanceByTableNum($t_item->get('table_num'), true))) { if ($vn_parent_id = $po_view->request->getParameter('parent_id', pInteger)) { $t_rel_type = new ca_relationship_types($vn_parent_id); $t_rel_instance = $t_item->getAppDatamodel()->getInstanceByTableNum($t_rel_type->get('table_num'), true); } } if ($t_rel_instance) { $vs_buf .= "<div><strong>" . _t("Is a") . "</strong>: " . $t_rel_instance->getProperty('NAME_SINGULAR') . "<br/></div>\n"; } } // // Output extra useful info for metadata elements // if ($vs_table_name === 'ca_metadata_elements' && $t_item->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t("Element code") . "</strong>: " . $t_item->get('element_code') . "<br/></div>\n"; if (sizeof($va_uis = $t_item->getUIs()) > 0) { $vs_buf .= "<div><strong>" . _t("Referenced by user interfaces") . "</strong>:<br/>\n"; foreach ($va_uis as $vn_ui_id => $va_ui_info) { $vs_buf .= caNavLink($po_view->request, $va_ui_info['name'], '', 'administrate/setup/interface_screen_editor', 'InterfaceScreenEditor', 'Edit', array('ui_id' => $vn_ui_id, 'screen_id' => $va_ui_info['screen_id'])); $vs_buf .= " (" . $o_dm->getTableProperty($va_ui_info['editor_type'], 'NAME_PLURAL') . ")<br/>\n"; } $vs_buf .= "</div>\n"; } } // // Output related objects for ca_editor_uis and ca_editor_ui_screens // if ($vs_table_name === 'ca_editor_uis') { $vs_buf .= "<div><strong>" . _t("Number of screens") . "</strong>: " . (int) $t_item->getScreenCount() . "\n"; if ($t_item->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t("Edits") . "</strong>: " . caGetTableDisplayName($t_item->get('editor_type')) . "<br/>\n"; } else { $vs_buf .= "<div><strong>" . _t("Edits") . "</strong>: " . caGetTableDisplayName($po_view->request->getParameter('editor_type', pInteger)) . "<br/>\n"; } $vs_buf .= "</div>\n"; } // // Output related objects for ca_editor_uis and ca_editor_ui_screens // if ($vs_table_name === 'ca_editor_ui_screens') { $t_ui = new ca_editor_uis($vn_ui_id = $t_item->get('ui_id')); $vs_buf .= "<div><strong>" . _t("Part of") . "</strong>: " . caNavLink($po_view->request, $t_ui->getLabelForDisplay(), '', 'administrate/setup/interface_editor', 'InterfaceEditor', 'Edit', array('ui_id' => $vn_ui_id)) . "\n"; $vs_buf .= "</div>\n"; } // // Output extra useful info for bundle displays // if ($vs_table_name === 'ca_bundle_displays') { $vs_buf .= "<div><strong>" . _t("Number of placements") . "</strong>: " . $t_item->getPlacementCount(array('user_id' => $po_view->request->getUserID())) . "<br/>\n"; if ($t_item->getPrimaryKey()) { $vn_content_table_num = $t_item->get('table_num'); $vs_buf .= "<strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } else { if ($vn_content_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<div><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } } $t_user = new ca_users(($vn_user_id = $t_item->get('user_id')) ? $vn_user_id : $po_view->request->getUserID()); if ($t_user->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t('Owner') . "</strong>: " . $t_user->get('fname') . ' ' . $t_user->get('lname') . "</div>\n"; } } // // Output extra useful info for search forms // if ($vs_table_name === 'ca_search_forms') { $vs_buf .= "<div><strong>" . _t("Number of placements") . "</strong>: " . $t_item->getPlacementCount(array('user_id' => $po_view->request->getUserID())) . "<br/>\n"; if ($t_item->getPrimaryKey()) { $vn_content_table_num = $t_item->get('table_num'); $vs_buf .= "<strong>" . _t("Searches for") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } else { if ($vn_content_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<strong>" . _t("Searches for") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "\n"; $vs_buf .= "</div>\n"; } } $t_user = new ca_users(($vn_user_id = $t_item->get('user_id')) ? $vn_user_id : $po_view->request->getUserID()); if ($t_user->getPrimaryKey()) { $vs_buf .= "<div><strong>" . _t('Owner') . "</strong>: " . $t_user->get('fname') . ' ' . $t_user->get('lname') . "</div>\n"; } } // // Output extra useful info for tours // if ($vs_table_name === 'ca_tours' && $t_item->getPrimaryKey()) { $vs_buf .= "<br/><strong>" . _t("Number of stops") . "</strong>: " . $t_item->getStopCount() . "<br/>\n"; } // // Output containing tour for tour stops // if ($vs_table_name === 'ca_tour_stops') { $t_tour = new ca_tours($vn_tour_id = $t_item->get('tour_id')); $vs_buf .= "<strong>" . _t("Part of") . "</strong>: " . caEditorLink($po_view->request, $t_tour->getLabelForDisplay(), '', 'ca_tours', $vn_tour_id) . "<br/>\n"; } // // Output extra useful info for bundle mappings // if ($vs_table_name === 'ca_bundle_mappings') { if ($t_item->getPrimaryKey()) { $vn_content_table_num = $t_item->get('table_num'); $vs_buf .= "<br/><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Type") . "</strong>: " . $t_item->getChoiceListValue('direction', $t_item->get('direction')) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Target format") . "</strong>: " . $t_item->get('target') . "<br/>\n"; $va_stats = $t_item->getMappingStatistics(); $vs_buf .= "<div><strong>" . _t("Number of groups") . "</strong>: " . $va_stats['groupCount'] . "<br/>\n"; $vs_buf .= "<strong>" . _t("Number of rules") . "</strong>: " . $va_stats['ruleCount'] . "<br/>\n"; $vs_buf .= "</div>\n"; } else { if ($vn_content_table_num = $po_view->request->getParameter('table_num', pInteger)) { $vs_buf .= "<div><strong>" . _t("Type of content") . "</strong>: " . caGetTableDisplayName($vn_content_table_num) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Type") . "</strong>: " . $t_item->getChoiceListValue('direction', $po_view->request->getParameter('direction', pString)) . "<br/>\n"; $vs_buf .= "<strong>" . _t("Target format") . "</strong>: " . $po_view->request->getParameter('target', pString) . "<br/>\n"; $vs_buf .= "<div><strong>" . _t("Number of groups") . "</strong>: 0<br/>\n"; $vs_buf .= "<strong>" . _t("Number of rules") . "</strong>: 0</div>\n"; $vs_buf .= "</div>\n"; } } } // // Output extra useful info for client services/commerce orders // if ($vs_table_name === 'ca_commerce_orders') { $o_client_services_config = Configuration::load($po_view->request->config->get('client_services_config')); $va_order_totals = $t_item->getOrderTotals(); if ($va_order_totals['fee'] + $va_order_totals['tax'] + $va_order_totals['shipping'] + $va_order_totals['handling'] + $va_order_totals['additional_order_fees'] + $va_order_totals['additional_item_fees'] != 0) { $vs_currency_symbol = $o_client_services_config->get('currency_symbol'); $vs_buf .= "<table style='margin-left: 10px;'>"; $vs_buf .= "<tr><td><strong>" . _t("Items") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['fee']) . " (" . (int) $va_order_totals['items'] . ")</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("S+H") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['shipping'] + $va_order_totals['handling']) . "</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("Tax") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['tax']) . "</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("Addtl fees") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['additional_order_fees'] + $va_order_totals['additional_item_fees']) . "</td></tr>\n"; $vs_buf .= "<tr><td><strong>" . _t("Total") . '</strong></td><td>' . $vs_currency_symbol . sprintf("%4.2f", $va_order_totals['fee'] + $va_order_totals['tax'] + $va_order_totals['shipping'] + $va_order_totals['handling'] + $va_order_totals['additional_order_fees'] + $va_order_totals['additional_item_fees']) . "</td></tr>\n"; $vs_buf .= "</table>"; $vs_buf .= "<strong>" . $t_item->getFieldInfo('payment_status', 'LABEL') . "</strong>: " . $t_item->getChoiceListValue('payment_status', $t_item->get('payment_status')) . "<br/>\n"; } $vs_buf .= "<br/><strong>" . $t_item->getFieldInfo('order_status', 'LABEL') . "</strong>: " . $t_item->getChoiceListValue('order_status', $t_item->get('order_status')) . "<br/>\n"; if ($vs_shipping_date = $t_item->get('shipping_date', array('dateFormat' => 'delimited', 'timeOmit' => true))) { $vs_buf .= "<strong>" . $t_item->getFieldInfo('shipping_date', 'LABEL') . "</strong>: " . $vs_shipping_date; if ($vs_shipped_on_date = $t_item->get('shipped_on_date', array('dateFormat' => 'delimited'))) { $vs_buf .= " (" . _t('shipped %1', $vs_shipped_on_date) . ")"; } else { $vs_buf .= " (" . _t('not shipped') . ")"; } $vs_buf .= "<br/>\n"; } if (($vn_shipping_method = $t_item->get('shipping_method')) && $t_item->getChoiceListValue('shipping_method', $vn_shipping_method) != 'None') { $vs_buf .= "<strong>" . $t_item->getFieldInfo('shipping_method', 'LABEL') . "</strong>: " . $t_item->getChoiceListValue('shipping_method', $vn_shipping_method) . "<br/>\n"; } } // // Output configurable additional info from config, if set // if ($vs_additional_info = $po_view->request->config->get("{$vs_table_name}_inspector_additional_info")) { if (is_array($vs_additional_info)) { $vs_buf .= "<br/>"; foreach ($vs_additional_info as $vs_info) { $vs_buf .= caProcessTemplateForIDs($vs_info, $vs_table_name, array($t_item->getPrimaryKey()), array('requireLinkTags' => true)) . "<br/>\n"; } } else { $vs_buf .= "<br/>" . caProcessTemplateForIDs($vs_additional_info, $vs_table_name, array($t_item->getPrimaryKey()), array('requireLinkTags' => true)) . "<br/>\n"; } } // ------------------------------------------------------------------------------------- // Export if ($t_item->getPrimaryKey() && $po_view->request->config->get($vs_table_name . '_show_add_child_control_in_inspector')) { $vb_show_add_child_control = true; if (is_array($va_restrict_add_child_control_to_types = $po_view->request->config->getList($vs_table_name . '_restrict_child_control_in_inspector_to_types')) && sizeof($va_restrict_add_child_control_to_types)) { $t_type_instance = $t_item->getTypeInstance(); if (!in_array($t_type_instance->get('idno'), $va_restrict_add_child_control_to_types) && !in_array($t_type_instance->getPrimaryKey(), $va_restrict_add_child_control_to_types)) { $vb_show_add_child_control = false; } } } if ($po_view->request->user->canDoAction('can_export_' . $vs_table_name) && $t_item->getPrimaryKey() && sizeof(ca_data_exporters::getExporters($t_item->tableNum())) > 0) { $vs_buf .= '<div style="border-top: 1px solid #aaaaaa; margin-top: 5px; font-size: 10px; text-align: right;" id="caExportItemButton">'; $vs_buf .= _t('Export this %1', mb_strtolower($vs_type_name, 'UTF-8')) . " "; $vs_buf .= "<a class='button' onclick='jQuery(\"#exporterFormList\").show();' style='text-align:right;' href='#'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_ADD__) . "</a>"; $vs_buf .= caFormTag($po_view->request, 'ExportSingleData', 'caExportForm', 'manage/MetadataExport', 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true)); $vs_buf .= "<div id='exporterFormList'>"; $vs_buf .= ca_data_exporters::getExporterListAsHTMLFormElement('exporter_id', $t_item->tableNum(), array('id' => 'caExporterList'), array('width' => '120px')); $vs_buf .= caHTMLHiddenInput('item_id', array('value' => $t_item->getPrimaryKey())); $vs_buf .= caFormSubmitLink($po_view->request, _t('Export') . " ›", "button", "caExportForm"); $vs_buf .= "</div>\n"; $vs_buf .= "</form>"; $vs_buf .= "</div>"; $vs_buf .= "<script type='text/javascript'>"; $vs_buf .= "jQuery(document).ready(function() {"; $vs_buf .= "jQuery(\"#exporterFormList\").hide();"; $vs_buf .= "});"; $vs_buf .= "</script>"; } $vs_buf .= "</div></h4>\n"; $vs_buf .= "<script type='text/javascript'>\n\t\t\tvar inspectorCookieJar = jQuery.cookieJar('caCookieJar');"; if ($t_item->getPrimaryKey()) { if ($vs_more_info) { $vs_buf .= "\t\t\t\n\t\t\tif (inspectorCookieJar.get('inspectorMoreInfoIsOpen') == undefined) {\t\t// default is to have info open\n\t\t\t\tinspectorCookieJar.set('inspectorMoreInfoIsOpen', 1);\n\t\t\t}\n\t\t\tif (inspectorCookieJar.get('inspectorMoreInfoIsOpen') == 1) {\n\t\t\t\tjQuery('#inspectorInfo').toggle(0);\n\t\t\t\tjQuery('#inspectorMoreInfo').html('" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_COLLAPSE__)) . "');\n\t\t\t}\n\t\t\n\t\t\tjQuery('#inspectorMoreInfo').click(function() {\n\t\t\t\tjQuery('#inspectorInfo').slideToggle(350, function() { \n\t\t\t\t\tinspectorCookieJar.set('inspectorMoreInfoIsOpen', (this.style.display == 'block') ? 1 : 0); \n\t\t\t\t\tjQuery('#inspectorMoreInfo').html((this.style.display == 'block') ? '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_COLLAPSE__)) . "' : '" . addslashes(caNavIcon($po_view->request, __CA_NAV_BUTTON_INFO2__)) . "');\n\t\t\t\t\tcaResizeSideNav();\n\t\t\t\t}); \n\t\t\t\treturn false;\n\t\t\t});\n\t\t"; } if (sizeof($va_reps)) { $vs_buf .= "\n\t\tif (inspectorCookieJar.get('inspectorShowMediaIsOpen') == undefined) {\t\t// default is to have media open\n\t\t\tinspectorCookieJar.set('inspectorShowMediaIsOpen', 1);\n\t\t}\n\t\t\n\t\tif (inspectorCookieJar.get('inspectorShowMediaIsOpen') == 1) {\n\t\t\tjQuery('#inspectorMedia').toggle();\n\t\t}\n\t\n\t\tjQuery('#caColorbox').on('click', function(e) {\n\t\t\tif (e.altKey) {\n\t\t\t\tjQuery('#inspectorMedia').slideToggle(200, function() { \n\t\t\t\t\tinspectorCookieJar.set('inspectorShowMediaIsOpen', (this.style.display == 'block') ? 1 : 0); \n\t\t\t\t\t\tcaResizeSideNav();\n\t\t\t\t}); \n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\t\t\t\t"; } } $vs_buf .= "</script>\n"; } $o_app_plugin_manager = new ApplicationPluginManager(); $va_hookAppend = $o_app_plugin_manager->hookAppendToEditorInspector(array("t_item" => $t_item)); if (is_string($va_hookAppend["caEditorInspectorAppend"])) { $vs_buf .= $va_hookAppend["caEditorInspectorAppend"]; } return $vs_buf; }
/** * 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); }
/** * * * @return string */ function caLoadAAT($ps_path_to_aat_data = null, $pa_options = null) { if (!$ps_path_to_aat_data) { $ps_path_to_aat_data = "./AAT.xml"; } if (!file_exists($ps_path_to_aat_data)) { die("ERROR: cannot find AAT data.\n"); } require_once __CA_LIB_DIR__ . '/core/Db.php'; require_once __CA_MODELS_DIR__ . '/ca_locales.php'; require_once __CA_MODELS_DIR__ . '/ca_lists.php'; require_once __CA_MODELS_DIR__ . '/ca_list_items.php'; require_once __CA_MODELS_DIR__ . '/ca_list_items_x_list_items.php'; require_once __CA_MODELS_DIR__ . '/ca_relationship_types.php'; $_ = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/en_US/messages.mo', 'en_US'); $t_locale = new ca_locales(); $pn_en_locale_id = $t_locale->loadLocaleByCode('en_US'); // create vocabulary list record (if it doesn't exist already) $t_list = new ca_lists(); if (!$t_list->load(array('list_code' => 'aat'))) { $t_list->setMode(ACCESS_WRITE); $t_list->set('list_code', 'aat'); $t_list->set('is_system_list', 0); $t_list->set('is_hierarchical', 1); $t_list->set('use_as_vocabulary', 1); $t_list->insert(); if ($t_list->numErrors()) { print "ERROR: couldn't create ca_list row for AAT: " . join('; ', $t_list->getErrors()) . "\n"; die; } $t_list->addLabel(array('name' => 'Art & Architecture Thesaurus'), $pn_en_locale_id, null, true); } $vn_list_id = $t_list->getPrimaryKey(); // get list item types (should be defined by base installation profile [base.profile]) // if your installation didn't use a profile inheriting from base.profile then you should make sure // that a list with code='list_item_types' is defined and the following four item codes are defined. // If these are not defined then the AAT will still import, but without any distinction between // terms, facets and guide terms $vn_list_item_type_concept = $t_list->getItemIDFromList('list_item_types', 'concept'); $vn_list_item_type_facet = $t_list->getItemIDFromList('list_item_types', 'facet'); $vn_list_item_type_guide_term = $t_list->getItemIDFromList('list_item_types', 'guide_term'); $vn_list_item_type_hierarchy_name = $t_list->getItemIDFromList('list_item_types', 'hierarchy_name'); // get list item label types (should be defined by base installation profile [base.profile]) // if your installation didn't use a profile inheriting from base.profile then you should make sure // that a list with code='list_item_label_types' is defined and the following four item codes are defined. // If these are not defined then the AAT will still import, but without any distinction between // terms, facets and guide terms $vn_list_item_label_type_uf = $t_list->getItemIDFromList('list_item_label_types', 'uf'); $vn_list_item_label_type_alt = $t_list->getItemIDFromList('list_item_label_types', 'alt'); // get list item-to-item relationship type (should be defined by base installation profile [base.profile]) // if your installation didn't use a profile inheriting from base.profile then you should make sure // that a ca_list_items_x_list_items relationship type with code='related' is defined. Otherwise import of term-to-term // relationships will fail. $t_rel_types = new ca_relationship_types(); $vn_list_item_relation_type_id_related = $t_rel_types->getRelationshipTypeID('ca_list_items_x_list_items', 'related'); // load voc_terms $o_xml = new XMLReader(); $o_xml->open($ps_path_to_aat_data); print "READING AAT TERMS...\n"; $va_parent_child_links = array(); $va_item_item_links = array(); $va_aat_id_to_item_id = array(); $vn_last_message_length = 0; $va_subject = array(); $vn_term_count = 0; while ($o_xml->read()) { switch ($o_xml->name) { # --------------------------- case 'Subject': if ($o_xml->nodeType == XMLReader::END_ELEMENT) { if ($va_subject['subject_id'] == '300000000') { break; } // skip top-level root $vs_preferred_term = $va_subject['preferred_term']; switch ($va_subject['record_type']) { case 'Concept': $vn_type_id = $vn_list_item_type_hierarchy_name; $pb_is_enabled = true; break; case 'Facet': $vn_type_id = $vn_list_item_type_facet; $vs_preferred_term = '<' . $vs_preferred_term . '>'; $pb_is_enabled = false; break; case 'Guide Term': $vn_type_id = $vn_list_item_type_guide_term; $vs_preferred_term = '<' . $vs_preferred_term . '>'; $pb_is_enabled = false; break; case 'Hierarchy Name': $vn_type_id = $vn_list_item_type_hierarchy_name; $pb_is_enabled = false; break; default: $vn_type_id = null; $pb_is_enabled = true; break; } print str_repeat(chr(8), $vn_last_message_length); $vs_message = "\tIMPORTING #" . ($vn_term_count + 1) . " [" . $va_subject['subject_id'] . "] " . $vs_preferred_term; if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if ($t_item = $t_list->addItem($va_subject['subject_id'], $pb_is_enabled, false, null, $vn_type_id, $va_subject['subject_id'], '', 4, 1)) { $va_aat_id_to_item_id[$va_subject['subject_id']] = $t_item->getPrimaryKey(); if ($va_subject['preferred_parent_subject_id'] != 300000000) { $va_parent_child_links[$va_subject['subject_id']] = $va_subject['preferred_parent_subject_id']; } // add preferred labels if (!$t_item->addLabel(array('name_singular' => trim(htmlentities($vs_preferred_term, ENT_NOQUOTES)), 'name_plural' => trim(htmlentities($vs_preferred_term, ENT_NOQUOTES)), 'description' => $va_subject['description']), $pn_en_locale_id, null, true)) { print "ERROR: Could not add preferred label to AAT term [" . $va_subject['subject_id'] . "] " . $vs_preferred_term . ": " . join("; ", $t_item->getErrors()) . "\n"; } // add alternate labels if (is_array($va_subject['non_preferred_terms'])) { for ($vn_i = 0; $vn_i < sizeof($va_subject['non_preferred_terms']); $vn_i++) { $vs_np_label = $va_subject['non_preferred_terms'][$vn_i]; $vs_np_term_type = $va_subject['non_preferred_term_types'][$vn_i]; switch ($vs_np_term_type) { case 'Used For Term': $vn_np_term_type_id = $vn_list_item_label_type_uf; break; case 'Alternate Descriptor': $vn_np_term_type_id = $vn_list_item_label_type_alt; break; default: $vn_np_term_type_id = null; break; } if (!$t_item->addLabel(array('name_singular' => trim(htmlentities($vs_np_label, ENT_NOQUOTES)), 'name_plural' => trim(htmlentities($vs_np_label, ENT_NOQUOTES)), 'description' => ''), $pn_en_locale_id, $vn_np_term_type_id, false)) { print "ERROR: Could not add non-preferred label to AAT term [" . $va_subject['subject_id'] . "] " . $vs_np_label . "\n"; //: ".join("; ", $t_item->getErrors())."\n"; } } } // record item-item relations if (is_array($va_subject['related_subjects'])) { foreach ($va_subject['related_subjects'] as $vs_rel_subject_id) { $va_item_item_links[$va_subject['subject_id']] = $vs_rel_subject_id; } } $vn_term_count++; } else { print "ERROR: Could not import AAT term [" . $va_subject['subject_id'] . "] " . $vs_preferred_term . ": " . join("; ", $t_list->getErrors()) . "\n"; } } else { $va_subject = array('subject_id' => $o_xml->getAttribute('Subject_ID')); } break; # --------------------------- # --------------------------- case 'Descriptive_Note': while ($o_xml->read()) { switch ($o_xml->name) { case 'Note_Text': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['description'] = $o_xml->value; break; } break; case 'Descriptive_Note': break 2; } } break; # --------------------------- # --------------------------- case 'Record_Type': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['record_type'] = $o_xml->value; break; } break; # --------------------------- # --------------------------- case 'Facet_Code': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['facet_code'] = $o_xml->value; break; } break; # --------------------------- # --------------------------- case 'Parent_Relationships': $vn_parent_id = $vs_historic_flag = null; while ($o_xml->read()) { switch ($o_xml->name) { case 'Preferred_Parent': while ($o_xml->read()) { switch ($o_xml->name) { case 'Parent_Subject_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $vn_parent_id = $o_xml->value; break; } break; case 'Historic_Flag': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $vs_historic_flag = $o_xml->value; break; } break; case 'Preferred_Parent': $va_subject['preferred_parent_subject_id'] = $vn_parent_id; break 2; } } break; case 'Parent_Relationships': break 2; } } break; # --------------------------- # --------------------------- case 'Preferred_Term': while ($o_xml->read()) { switch ($o_xml->name) { case 'Term_Type': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['preferred_term_type'] = $o_xml->value; break; } break; case 'Term_Text': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['preferred_term'] = $o_xml->value; break; } break; case 'Term_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['preferred_term_id'] = $o_xml->value; break; } break; break; case 'Preferred_Term': break 2; } } break; # --------------------------- # --------------------------- case 'Non-Preferred_Term': while ($o_xml->read()) { switch ($o_xml->name) { case 'Term_Type': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['non_preferred_term_types'][] = $o_xml->value; break; } break; case 'Term_Text': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['non_preferred_terms'][] = $o_xml->value; break; } break; case 'Term_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['non_preferred_term_ids'][] = $o_xml->value; break; } break; case 'Non-Preferred_Term': break 2; } } break; # --------------------------- # --------------------------- case 'VP_Subject_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['related_subjects'][] = $o_xml->value; break; } break; # --------------------------- } } $o_xml->close(); print "\n\nLINKING TERMS IN HIERARCHY...\n"; $vn_last_message_length = 0; $t_item = new ca_list_items(); $t_item->setMode(ACCESS_WRITE); foreach ($va_parent_child_links as $vs_child_id => $vs_parent_id) { print str_repeat(chr(8), $vn_last_message_length); $vs_message = "\tLINKING {$vs_child_id} to parent {$vs_parent_id}"; if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if (!($vn_child_item_id = $va_aat_id_to_item_id[$vs_child_id])) { print "ERROR: no list item id for child_id {$vs_child_id} (were there previous errors?)\n"; continue; } if (!($vn_parent_item_id = $va_aat_id_to_item_id[$vs_parent_id])) { print "ERROR: no list item id for parent_id {$vs_child_id} (were there previous errors?)\n"; continue; } if (!$t_item->load($vn_child_item_id)) { print "ERROR: could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})\n"; continue; } $t_item->set('parent_id', $vn_parent_item_id); $t_item->update(); if ($t_item->numErrors()) { print "ERROR: could not set parent_id for {$vs_child_id} (was translated to item_id={$vn_child_item_id}): " . join('; ', $t_item->getErrors()) . "\n"; } } if ($vn_list_item_relation_type_id_related > 0) { print "\n\nADDING RELATED TERM LINKS...\n"; $vn_last_message_length = 0; $t_item = new ca_list_items(); $t_link = new ca_list_items_x_list_items(); $t_link->setMode(ACCESS_WRITE); foreach ($va_item_item_links as $vs_left_id => $vs_right_id) { print str_repeat(chr(8), $vn_last_message_length); $vs_message = "\tLINKING {$vs_left_id} to {$vs_right_id}"; if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if (!($vn_left_item_id = $va_aat_id_to_item_id[$vs_left_id])) { print "ERROR: no list item id for left_id {$vs_left_id} (were there previous errors?)\n"; continue; } if (!($vn_right_item_id = $va_aat_id_to_item_id[$vs_right_id])) { print "ERROR: no list item id for right_id {$vs_right_id} (were there previous errors?)\n"; continue; } $t_link->set('term_left_id', $vn_left_item_id); $t_link->set('term_right_id', $vn_right_item_id); $t_link->set('type_id', $vn_list_item_relation_type_id_related); $t_link->insert(); if ($t_link->numErrors()) { print "ERROR: could not set link between {$vs_left_id} (was translated to item_id={$vn_left_item_id}) and {$vs_right_id} (was translated to item_id={$vn_right_item_id}): " . join('; ', $t_link->getErrors()) . "\n"; } } } else { print "WARNING: Skipped import of term-term relationships because the ca_list_items_x_list_items 'related' relationship type is not defined for your installation\n"; } print "\n\nIMPORT COMPLETE.\n"; }
foreach ($va_labels as $vs_label) { $vs_caption .= $vs_label; } # --- get the height of the image so can calculate padding needed to center vertically $va_media_info = $qr_hits->getMediaInfo('ca_object_representations.media', 'thumbnail'); $vn_padding_top = 0; $vn_padding_top_bottom = (130 - $va_media_info["HEIGHT"]) / 2; $vs_image = $qr_hits->getMediaTag('ca_object_representations.media', 'thumbnail'); if (!$vs_image) { # --- get the placeholder graphic from the novamuse theme $va_themes = caExtractValuesByUserLocale($qr_hits->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); if (file_exists($this->request->getThemeDirectoryPath() . "/graphics/novamuse/placeholders/small/" . $t_list_item->get("idno") . ".png")) { $vs_image = "<img src='" . $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/small/" . $t_list_item->get("idno") . ".png'>"; $vn_padding_top_bottom = 5; } } } if (!$vs_image) { $vs_image = "<img src='" . $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/small/placeholder.png'>"; $vn_padding_top_bottom = 5; } } print "<td align='center' valign='top' class='searchResultTd'><div class='searchThumbBg searchThumbnail" . $vn_object_id . "' style='padding: " . $vn_padding_top_bottom . "px 0px " . $vn_padding_top_bottom . "px 0px;'>"; if ($this->request->config->get('allow_detail_for_ca_objects')) { print caNavLink($this->request, $vs_image, '', 'Detail', 'Object', 'Show', array('object_id' => $qr_hits->get('ca_objects.object_id'))); } else {
/** * * * @return string */ function caLoadULAN($ps_path_to_ulan_data = null, $ps_path_to_ulan_config = null, $pa_options = null) { require_once __CA_LIB_DIR__ . '/core/Db.php'; require_once __CA_LIB_DIR__ . '/core/Configuration.php'; require_once __CA_LIB_DIR__ . '/ca/Utils/DataMigrationUtils.php'; require_once __CA_MODELS_DIR__ . '/ca_locales.php'; require_once __CA_MODELS_DIR__ . '/ca_entities.php'; require_once __CA_MODELS_DIR__ . '/ca_entities_x_entities.php'; require_once __CA_MODELS_DIR__ . '/ca_lists.php'; require_once __CA_MODELS_DIR__ . '/ca_list_items.php'; require_once __CA_MODELS_DIR__ . '/ca_list_items_x_list_items.php'; require_once __CA_MODELS_DIR__ . '/ca_relationship_types.php'; $t = new Timer(); $o_log = new KLogger(__CA_APP_DIR__ . '/log', KLogger::INFO); $va_parent_child_links = array(); $va_item_item_links = array(); $va_ulan_id_to_item_id = array(); $o_log->logInfo("Starting import of Getty ULAN"); define('__CA_DONT_DO_SEARCH_INDEXING__', true); $_ = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/en_US/messages.mo', 'en_US'); $t_locale = new ca_locales(); $pn_en_locale_id = $t_locale->loadLocaleByCode('en_US'); if (!($o_config = Configuration::load($ps_path_to_ulan_config))) { $o_log->logError("Could not load ULAN import configuration file"); die("ERROR: Could not load ULAN import configuration\n"); } $vs_ulan_import_mode = $o_config->get('ulan_import_target'); $t_list = null; if ($vs_ulan_import_mode == 'ca_entities') { $va_ulan_types = $o_config->getAssoc('ulan_entity_types'); $va_mapping = $o_config->getAssoc('ulan_entity_mapping'); } elseif ($vs_ulan_import_mode == 'ca_list_items') { $va_ulan_types = $o_config->getAssoc('ulan_list_item_types'); if (!($vs_ulan_list_code = $o_config->get('ulan_import_list'))) { $vs_ulan_list_code = 'ULAN'; } // create vocabulary list record (if it doesn't exist already) $t_list = new ca_lists(); if (!$t_list->load(array('list_code' => $vs_ulan_list_code))) { $t_list->setMode(ACCESS_WRITE); $t_list->set('list_code', $vs_ulan_list_code); $t_list->set('is_system_list', 0); $t_list->set('is_hierarchical', 1); $t_list->set('use_as_vocabulary', 1); $t_list->insert(); if ($t_list->numErrors()) { $o_log->logError("Could not create list record for ULAN: " . join('; ', $t_list->getErrors())); die("ERROR: couldn't create ca_list row for ULAN: " . join('; ', $t_list->getErrors()) . "\n"); } $t_list->addLabel(array('name' => 'Union List of Artist Names'), $pn_en_locale_id, null, true); } $vn_list_id = $t_list->getPrimaryKey(); $va_mapping = $o_config->getAssoc('ulan_list_item_mapping'); } else { $o_log->logError("Invalid ULAN import mode {$vs_ulan_import_mode}"); die("ERROR: invalid ULAN import mode {$vs_ulan_import_mode}\n"); } $vn_last_message_length = 0; $vn_term_count = 0; $va_subject = array(); foreach (array('ULAN1.xml', 'ULAN2.xml', 'ULAN3.xml') as $vs_file) { if (!$ps_path_to_ulan_data) { $ps_path_to_ulan_data = "."; } if (!file_exists($ps_path_to_ulan_data . "/{$vs_file}")) { $o_log->logError("Could not find ULAN data file {$vs_file}"); print "[ERROR] cannot find ULAN data.\n"; continue; } $o_log->logInfo("Processing ULAN file {$vs_file}"); print "[Notice] Processing ULAN file {$vs_file}\n"; // load $o_xml = new XMLReader(); $o_xml->open($ps_path_to_ulan_data . '/' . $vs_file); while ($o_xml->read()) { switch ($o_xml->name) { # --------------------------- case 'Subject': if ($o_xml->nodeType == XMLReader::END_ELEMENT) { if (in_array($va_subject['subject_id'], array('500000000', '500000001'))) { break; } // skip top-level root $vs_preferred_term = $va_subject['preferred_term']; $pb_is_enabled = false; switch ($va_subject['record_type']) { case 'Person': default: $vn_type_id = $va_ulan_types['Person']; $pb_is_enabled = true; break; case 'Corporate Body': $vn_type_id = $va_ulan_types['Corporate Body']; $pb_is_enabled = true; break; } print str_repeat(chr(8), $vn_last_message_length); $vs_message = "\tIMPORTING #" . ($vn_term_count + 1) . " [" . $va_subject['subject_id'] . "] " . $vs_preferred_term; if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if ($vs_ulan_import_mode == 'ca_entities') { $va_np_labels = array(); if (is_array($va_subject['non_preferred_terms'])) { for ($vn_i = 0; $vn_i < sizeof($va_subject['non_preferred_terms']); $vn_i++) { $va_np_labels[] = DataMigrationUtils::splitEntityName(trim(htmlentities($va_subject['non_preferred_terms'][$vn_i]))); } } $t_item = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName(trim(htmlentities($vs_preferred_term, ENT_NOQUOTES))), $vn_type_id, $pn_en_locale_id, array('idno' => $va_subject['subject_id']), array('nonPreferredLabels' => $va_np_labels, 'returnInstance' => true)); if (!$t_item) { $o_log->logError("Failed to create entity for ULAN artist {$vs_preferred_term}"); break; } $t_item->setMode(ACCESS_WRITE); $va_ulan_id_to_item_id[$va_subject['subject_id']] = $t_item->getPrimaryKey(); } else { if ($t_item = $t_list->addItem($va_subject['subject_id'], $pb_is_enabled, false, null, $vn_type_id, $va_subject['subject_id'], '', 4, 1)) { $va_ulan_id_to_item_id[$va_subject['subject_id']] = $t_item->getPrimaryKey(); if ($va_subject['preferred_parent_subject_id'] != 500000000) { $va_parent_child_links[$va_subject['subject_id']] = $va_subject['preferred_parent_subject_id']; } // add preferred labels if (!$t_item->addLabel(array('name_singular' => trim(htmlentities($vs_preferred_term, ENT_NOQUOTES)), 'name_plural' => trim(htmlentities($vs_preferred_term, ENT_NOQUOTES)), 'description' => $va_subject['description']), $pn_en_locale_id, null, true)) { $o_log->logError("Could not add preferred label to ULAN term [" . $va_subject['subject_id'] . "] " . $vs_preferred_term . ": " . join("; ", $t_item->getErrors())); } // add alternate labels if (is_array($va_subject['non_preferred_terms'])) { for ($vn_i = 0; $vn_i < sizeof($va_subject['non_preferred_terms']); $vn_i++) { $vs_np_label = $va_subject['non_preferred_terms'][$vn_i]; $vs_np_term_type = $va_subject['non_preferred_term_types'][$vn_i]; switch ($vs_np_term_type) { case 'Used For Term': $vn_np_term_type_id = $vn_list_item_label_type_uf; break; case 'Alternate Descriptor': $vn_np_term_type_id = $vn_list_item_label_type_alt; break; default: $vn_np_term_type_id = null; break; } if (!$t_item->addLabel(array('name_singular' => trim(htmlentities($vs_np_label, ENT_NOQUOTES)), 'name_plural' => trim(htmlentities($vs_np_label, ENT_NOQUOTES)), 'description' => ''), $pn_en_locale_id, $vn_np_term_type_id, false)) { $o_log->logError("Could not add non-preferred label to ULAN term [" . $va_subject['subject_id'] . "] " . $vs_np_label); } } } } else { $o_log->logError("Could not import ULAN term [" . $va_subject['subject_id'] . "] " . $vs_preferred_term . ": " . join("; ", $t_list->getErrors())); break; } } // Map content fields foreach ($va_mapping as $vs_dest => $vs_source) { $va_values = array(); switch ($vs_source) { case 'biography': if (!is_array($va_subject['biographies'])) { break; } foreach ($va_subject['biographies'] as $va_bio) { $va_values[] = $va_bio['text']; } break; case 'biography_dates': if (!is_array($va_subject['biographies'])) { break; } foreach ($va_subject['biographies'] as $va_bio) { if ($va_bio['birth_date'] == 1000 || $va_bio['birth_date'] < -5000) { if ($va_bio['death_date'] >= 2050) { break 2; } else { $va_values[] = "before " . $va_bio['death_date']; } } elseif ($va_bio['death_date'] >= 2050) { $va_values[] = "after " . $va_bio['birth_date']; } else { $va_values[] = $va_bio['birth_date'] . " - " . $va_bio['death_date']; } } break; case 'sex': if (!is_array($va_subject['biographies'])) { break; } foreach ($va_subject['biographies'] as $va_bio) { $va_values[] = $va_bio['sex']; } break; case 'nationality_name': if (!is_array($va_subject['nationalities'])) { break; } foreach ($va_subject['nationalities'] as $va_nationality) { $va_values[] = $va_nationality['name']; } break; case 'nationality_code': if (!is_array($va_subject['nationalities'])) { break; } foreach ($va_subject['nationalities'] as $va_nationality) { $va_values[] = $va_nationality['code']; } break; case 'role_name': if (!is_array($va_subject['roles'])) { break; } foreach ($va_subject['roles'] as $va_role) { $va_values[] = $va_role['name']; } break; case 'role_code': if (!is_array($va_subject['roles'])) { break; } foreach ($va_subject['roles'] as $va_role) { $va_values[] = $va_role['code']; } break; } if (sizeof($va_values)) { $va_dest = explode('.', $vs_dest); $vs_fld = array_pop($va_dest); if ($t_item->hasField($vs_fld)) { $t_item->set($vs_fld, join("\n", $va_values)); } else { foreach ($va_values as $vs_value) { $t_item->addAttribute(array('locale_id' => $pn_en_locale_id, $vs_fld => $vs_value), $vs_fld); } } $t_item->update(array('dontCheckCircularReferences' => true, 'dontSetHierarchicalIndexing' => true)); if ($t_item->numErrors()) { $o_log->logError("Could not update ULAN list item with content values: " . join("; ", $t_item->getErrors())); } } } // record item-item relations if (is_array($va_subject['related_subjects'])) { foreach ($va_subject['related_subjects'] as $vs_rel_subject_id) { $va_item_item_links[$va_subject['subject_id']] = $vs_rel_subject_id; } } $vn_term_count++; } else { $va_subject = array('subject_id' => $o_xml->getAttribute('Subject_ID')); } break; # --------------------------- # --------------------------- case 'Biographies': while ($o_xml->read()) { switch ($o_xml->name) { case 'Preferred_Biography': $va_bio = array(); while ($o_xml->read()) { switch ($o_xml->name) { case 'Biography_Text': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_bio['text'] = $o_xml->value; break; } break; case 'Birth_Date': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_bio['birth_date'] = $o_xml->value; if ($va_bio['birth_date'] < 0) { $va_bio['birth_date'] = abs($va_bio['birth_date']) . " BCE"; } break; } break; case 'Death_Date': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_bio['death_date'] = $o_xml->value; if ($va_bio['death_date'] < 0) { $va_bio['death_date'] = abs($va_bio['death_date']) . " BCE"; } break; } break; case 'Sex': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_bio['sex'] = $o_xml->value; break; } break; case 'Preferred_Biography': break 2; } } $va_subject['biographies'][] = $va_bio; break; case 'Biographies': break 2; } } break; # --------------------------- # --------------------------- case 'Nationalities': while ($o_xml->read()) { switch ($o_xml->name) { case 'Preferred_Nationality': $va_nationality = array(); while ($o_xml->read()) { switch ($o_xml->name) { case 'Nationality_Code': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_nationality['code'] = $o_xml->value; $va_nationality['name'] = array_pop(explode('/', $o_xml->value)); break; } break; case 'Preferred_Nationality': break 2; } } $va_subject['nationalities'][] = $va_nationality; break; case 'Nationalities': break 2; } } break; # --------------------------- # --------------------------- case 'Roles': while ($o_xml->read()) { switch ($o_xml->name) { case 'Preferred_Role': $va_role = array(); while ($o_xml->read()) { switch ($o_xml->name) { case 'Role_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_role['code'] = $o_xml->value; $va_role['name'] = array_pop(explode('/', $o_xml->value)); break; } break; case 'Preferred_Role': break 2; } } $va_subject['roles'][] = $va_role; break; case 'Roles': break 2; } } break; # --------------------------- # --------------------------- case 'Record_Type': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['record_type'] = $o_xml->value; break; } break; # --------------------------- # --------------------------- case 'Hierarchy': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['hierarchy'] = $o_xml->value; break; } break; # --------------------------- # --------------------------- case 'Parent_Relationships': $vn_parent_id = $vs_historic_flag = null; while ($o_xml->read()) { switch ($o_xml->name) { case 'Preferred_Parent': while ($o_xml->read()) { switch ($o_xml->name) { case 'Parent_Subject_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $vn_parent_id = $o_xml->value; break; } break; case 'Historic_Flag': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $vs_historic_flag = $o_xml->value; break; } break; case 'Preferred_Parent': $va_subject['preferred_parent_subject_id'] = $vn_parent_id; break 2; } } break; case 'Parent_Relationships': break 2; } } break; # --------------------------- # --------------------------- case 'Preferred_Term': while ($o_xml->read()) { switch ($o_xml->name) { case 'Term_Type': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['preferred_term_type'] = $o_xml->value; break; } break; case 'Term_Text': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['preferred_term'] = $o_xml->value; break; } break; case 'Term_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['preferred_term_id'] = $o_xml->value; break; } break; break; case 'Preferred_Term': break 2; } } break; # --------------------------- # --------------------------- case 'Non-Preferred_Term': while ($o_xml->read()) { switch ($o_xml->name) { case 'Term_Type': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['non_preferred_term_types'][] = $o_xml->value; break; } break; case 'Term_Text': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['non_preferred_terms'][] = $o_xml->value; break; } break; case 'Term_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['non_preferred_term_ids'][] = $o_xml->value; break; } break; case 'Non-Preferred_Term': break 2; } } break; # --------------------------- # --------------------------- case 'VP_Subject_ID': switch ($o_xml->nodeType) { case XMLReader::ELEMENT: $o_xml->read(); $va_subject['related_subjects'][] = $o_xml->value; break; } break; # --------------------------- } } $o_xml->close(); } $o_log->logInfo("Begin linking ULAN terms in hierarchy"); print "\n\nLINKING TERMS IN HIERARCHY...\n"; $vn_last_message_length = 0; $t_list = new ca_lists(); $t_item = new ca_list_items(); $t_item->setMode(ACCESS_WRITE); $vn_list_root_id = $t_list->getRootListItemID($vn_list_id); foreach ($va_parent_child_links as $vs_child_id => $vs_parent_id) { print str_repeat(chr(8), $vn_last_message_length); $vs_message = "\tLINKING {$vs_child_id} to parent {$vs_parent_id}"; if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if (in_array($vs_parent_id, array('500000000', '500000001'))) { if (!$t_item->load($vn_child_item_id)) { $o_log->logError("Could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})"); continue; } $t_item->set('parent_id', $vn_list_root_id); $t_item->update(array('dontCheckCircularReferences' => true, 'dontSetHierarchicalIndexing' => true)); if ($t_item->numErrors()) { $o_log->logError("Could not set parent_id for {$vs_child_id} to root): " . join('; ', $t_item->getErrors())); continue; } $va_ulan_id_to_item_id[$vs_parent_id] = $vn_list_root_id; } if (!($vn_child_item_id = $va_ulan_id_to_item_id[$vs_child_id])) { $o_log->logError("No list item id for child_id {$vs_child_id} (were there previous errors?)"); continue; } if (!($vn_parent_item_id = $va_ulan_id_to_item_id[$vs_parent_id])) { $o_log->logError("No list item id for parent_id {$vs_parent_id} (were there previous errors?)"); continue; } if (!$t_item->load($vn_child_item_id)) { $o_log->logError("Could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})"); continue; } $t_item->set('parent_id', $vn_parent_item_id); $t_item->update(array('dontCheckCircularReferences' => true, 'dontSetHierarchicalIndexing' => true)); if ($t_item->numErrors()) { $o_log->logError("Could not set parent_id for {$vs_child_id} (was translated to item_id={$vn_child_item_id}): " . join('; ', $t_item->getErrors())); } } if ($vn_list_item_relation_type_id_related > 0) { $o_log->logInfo("Begin adding ULAN related term links"); $vn_last_message_length = 0; $t_item = new ca_list_items(); $t_link = new ca_list_items_x_list_items(); $t_link->setMode(ACCESS_WRITE); foreach ($va_item_item_links as $vs_left_id => $vs_right_id) { print str_repeat(chr(8), $vn_last_message_length); $vs_message = "\tLINKING {$vs_left_id} to {$vs_right_id}"; if (($vn_l = 100 - strlen($vs_message)) < 1) { $vn_l = 1; } $vs_message .= str_repeat(' ', $vn_l); $vn_last_message_length = strlen($vs_message); print $vs_message; if (!($vn_left_item_id = $va_ulan_id_to_item_id[$vs_left_id])) { $o_log->logError("No list item id for left_id {$vs_left_id} (were there previous errors?)"); continue; } if (!($vn_right_item_id = $va_ulan_id_to_item_id[$vs_right_id])) { $o_log->logError("No list item id for right_id {$vs_right_id} (were there previous errors?)"); continue; } $t_link->set('term_left_id', $vn_left_item_id); $t_link->set('term_right_id', $vn_right_item_id); $t_link->set('type_id', $vn_list_item_relation_type_id_related); $t_link->insert(); if ($t_link->numErrors()) { $o_log->logError("Could not set link between {$vs_left_id} (was translated to item_id={$vn_left_item_id}) and {$vs_right_id} (was translated to item_id={$vn_right_item_id}): " . join('; ', $t_link->getErrors())); } } } else { $o_log->logWarn("Skipped import of term-term relationships because the ca_list_items_x_list_items 'related' relationship type is not defined for your installation"); } $vn_duration = $t->getTime(1); $vs_time = caFormatInterval($vn_duration); $o_log->logInfo("Rebuilding hierarchical indices..."); $t_item->rebuildAllHierarchicalIndexes(); $o_log->logInfo("ULAN import complete. Took {$vs_time} ({$vn_duration})"); print "\n\nIMPORT COMPLETE. Took {$vs_time} ({$vn_duration})\n"; }
_id{n}" value="{id}"/> </td> <td> <a href="#" class="caDeleteItemButton"><?php print caNavIcon($this->request, __CA_NAV_BUTTON_DEL_BUNDLE__); ?> </a> </td> </tr> </table> <?php } else { $vn_use_as_root_id = 'null'; if (sizeof($va_settings['restrict_to_lists']) == 1) { $t_item = new ca_list_items(); if ($t_item->load(array('list_id' => $va_settings['restrict_to_lists'][0], 'parent_id' => null))) { $vn_use_as_root_id = $t_item->getPrimaryKey(); } } ?> <div style="float: right;"><a href="#" class="caDeleteItemButton"><?php print caNavIcon($this->request, __CA_NAV_BUTTON_DEL_BUNDLE__); ?> </a></div> <div style='width: 700px; height: <?php print $va_settings['hierarchicalBrowserHeight']; ?> ;'> <div id='<?php
/** * Will return plural value of list item unless useSingular option is set to true, in which case singular version of list item label will be used. * * @param array Optional array of options. Support options are: * list_id = if set then the numeric item_id value is translated into label text in the current locale. If not set then the numeric item_id is returned. * useSingular = If list_id is set then by default the returned text is the plural label. Setting this option to true will force use of the singular label. [Default is false] * showHierarchy = If true then hierarchical parents of list item will be returned and hierarchical options described below will be used to control the output [Default is false] * returnIdno = If true list item idno is returned rather than preferred label [Default is false] * idsOnly = Return numeric item_id only [Default is false] * HIERARCHICAL OPTIONS: * direction - For hierarchy specifications (eg. ca_objects.hierarchy) this determines the order in which the hierarchy is returned. ASC will return the hierarchy root first while DESC will return it with the lowest node first. Default is ASC. * top - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the root down. Default is to not limit. * bottom - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the lowest node up. Default is to not limit. * hierarchicalDelimiter - Text to place between items in a hierarchy for a hierarchical specification (eg. ca_objects.hierarchy) when returning as a string * removeFirstItems - If set to a non-zero value, the specified number of items at the top of the hierarchy will be omitted. For example, if set to 2, the root and first child of the hierarchy will be omitted. Default is zero (don't delete anything). * transaction = the transaction to execute database actions within. [Default is null] * @return string The value */ public function getDisplayValue($pa_options = null) { if ($vb_return_idno = isset($pa_options['returnIdno']) && (bool) $pa_options['returnIdno']) { return caGetListItemIdno($this->ops_text_value); } $vb_ids_only = (bool) caGetOption('idsOnly', $pa_options, false); if ($vb_ids_only) { return (int) $this->ops_text_value; } $vn_list_id = is_array($pa_options) && isset($pa_options['list_id']) ? (int) $pa_options['list_id'] : null; if ($vn_list_id > 0) { $t_list = new ca_lists(); if ($o_trans = caGetOption('transaction', $pa_options, null)) { $t_list->setTransaction($o_trans); } $t_item = new ca_list_items(); if ($pa_options['showHierarchy'] || $vb_return_idno) { if ($o_trans) { $t_item->setTransaction($o_trans); } } $vs_get_spec = isset($pa_options['useSingular']) && $pa_options['useSingular'] ? 'name_singular' : 'name_plural'; // do we need to get the hierarchy? if ($pa_options['showHierarchy']) { $t_item->load($this->ops_text_value); return $t_item->get('ca_list_items.hierarchy.' . $vs_get_spec, $pa_options); } return $t_list->getItemFromListForDisplayByItemID($vn_list_id, $this->ops_text_value, isset($pa_options['useSingular']) && $pa_options['useSingular'] ? false : true); } return $this->ops_text_value; }