protected function getAllItemInfo() { $va_info = parent::getAllItemInfo(); if ($this->getTableName() == 'ca_objects' && is_array($va_info) && sizeof($va_info) > 0) { $t_object = new ca_objects($va_info['object_id']['value']); if (!$t_object->getPrimaryKey()) { return $va_info; } // include number of 'likes' (comments) $va_info['likes'] = (int) $t_object->getNumComments(null); // include copyright holder $vs_copyright_holder = $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => 'copyright')); if ($vs_copyright_holder) { $va_info['copyright_holder'] = $vs_copyright_holder; } // include urls for reference img $va_objects = $t_object->getRelatedItems('ca_objects', array('restrictToRelationshipTypes' => 'reference')); if (!is_array($va_objects) || sizeof($va_objects) != 1) { return $va_info; } $va_object = array_shift($va_objects); $t_rel_object = new ca_objects($va_object['object_id']); $va_rep = $t_rel_object->getPrimaryRepresentation(array('preview170', 'medium', 'alhalqa1000', 'alhalqa2000')); if (!is_array($va_rep) || !is_array($va_rep['urls'])) { return $va_info; } $va_info['reference_image_urls'] = $va_rep['urls']; } return $va_info; }
public function Index() { $va_participate_ids = array(); $t_participate = new ca_sets(); # --- participate set - set name assigned in eastend.conf - plugin conf file $t_participate->load(array('set_code' => $this->opo_plugin_config->get('participate_set_name'))); # Enforce access control on set if (sizeof($this->opa_access_values) == 0 || sizeof($this->opa_access_values) && in_array($t_participate->get("access"), $this->opa_access_values)) { $this->view->setVar('participate_set_id', $t_participate->get("set_id")); $va_participate_ids = array_keys(is_array($va_tmp = $t_participate->getItemRowIDs(array('checkAccess' => $this->opa_access_values, 'shuffle' => 1))) ? $va_tmp : array()); // These are the entity ids in the set } # --- loop through featured ids and grab the object's image $t_object = new ca_objects(); $va_participate_images = array(); foreach ($va_participate_ids as $vn_participate_object_id) { $va_tmp = array(); $t_object->load($vn_participate_object_id); $va_tmp["object_id"] = $vn_participate_object_id; $va_image = $t_object->getPrimaryRepresentation(array("mediumlarge")); # --- don't show records with status ars/vaga don't show image if ($t_object->get("ca_objects.object_status") != 348) { if ($t_object->get("ca_objects.object_status") == 349) { $va_tmp["vaga_class"] = "vagaDisclaimer"; } $va_tmp["image"] = $va_image["tags"]["mediumlarge"]; $va_tmp["caption"] = $t_object->get("ca_objects.caption"); $va_tmp["title"] = $t_object->getLabelForDisplay(); } $va_participate_images[$vn_participate_object_id] = $va_tmp; } $this->view->setVar("participate_images", $va_participate_images); $this->render('participate_html.php'); }
function recentlyAdded() { // redirect user if not logged in if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn() || $this->request->config->get('show_bristol_only') && !$this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form")); } elseif ($this->request->config->get('show_bristol_only') && $this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, "bristol", "Show", "Index")); } $t_object = new ca_objects(); $va_recently_added_objects = $t_object->getRecentlyAddedItems(25, array('checkAccess' => caGetUserAccessValues($this->request))); $va_entries = array(); $va_object_ids = array(); foreach ($va_recently_added_objects as $va_object) { $va_object_ids[] = $va_object['object_id']; } $va_labels = $t_object->getPreferredDisplayLabelsForIDs($va_object_ids); // TODO: Need to get object descriptions and last update times properly foreach ($va_labels as $vn_object_id => $vs_label) { $va_entries[] = array('title' => $vs_label, 'link' => $vs_link = $this->request->config->get('site_host') . caNavUrl($this->request, '', 'Detail/Object', 'Index', array('object_id' => $vn_object_id)), 'guid' => $vs_link, 'lastUpdate' => time(), 'description' => '', 'pubDate' => time()); } $va_feed_data = array('title' => _t('Recently added'), 'link' => $this->request->getRequestUrl(true), 'charset' => 'UTF-8', 'entries' => $va_entries); $o_feed = Zend_Feed::importArray($va_feed_data, 'rss'); $this->view->setVar('feed', $o_feed); $this->render('Feed/feed_recently_added_xml.php'); }
function recentlyAdded() { // redirect user if not logged in if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn() || $this->request->config->get('show_bristol_only') && !$this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form")); } elseif ($this->request->config->get('show_bristol_only') && $this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, "bristol", "Show", "Index")); } $t_object = new ca_objects(); if (($vn_num_items = (int) $this->request->config->get('rss_number_of_items')) <= 0) { $vn_num_items = 10; } $va_recently_added_objects = $t_object->getRecentlyAddedItems($vn_num_items, array('checkAccess' => caGetUserAccessValues($this->request))); $va_entries = array(); $va_object_ids = array(); foreach ($va_recently_added_objects as $va_object) { $va_object_ids[] = $va_object['object_id']; } $qr_res = $t_object->makeSearchResult('ca_objects', $va_object_ids); $vs_description_bundle = $this->request->config->get('rss_description'); while ($qr_res->nextHit()) { $vn_object_id = $qr_res->get('ca_objects.object_id'); if (!($vn_creation_time = $t_object->getCreationTimestamp($vn_object_id, array('timestampOnly' => true)))) { $vn_creation_time = time(); } if (!($vn_update_time = $t_object->getLastChangeTimestamp($vn_object_id, array('timestampOnly' => true)))) { $vn_update_time = time(); } $va_entries[] = array('title' => $qr_res->get('ca_objects.preferred_labels.name'), 'link' => $vs_link = $this->request->config->get('site_host') . caNavUrl($this->request, '', 'Detail/Object', 'Index', array('object_id' => $vn_object_id)), 'guid' => $vs_link, 'lastUpdate' => $vn_update_time, 'description' => $vs_description_bundle ? $qr_res->getMediaTag("ca_object_representations.media", "preview") . "\n" . $qr_res->get($vs_description_bundle) : '', 'pubDate' => $vn_creation_time); } $va_feed_data = array('title' => _t('Recently added'), 'link' => $this->request->getRequestUrl(true), 'charset' => 'UTF-8', 'entries' => $va_entries); $o_feed = Zend_Feed::importArray($va_feed_data, 'rss'); $this->view->setVar('feed', $o_feed); $this->render('Feed/feed_recently_added_xml.php'); }
protected function search($pa_bundles = null) { $va_return = parent::search($pa_bundles); if ($this->getTableName() == 'ca_objects' && is_array($va_return['results']) && sizeof($va_return['results']) > 0) { $pb_only_with_likes = (bool) $this->opo_request->getParameter('likesOnly', pInteger); foreach ($va_return['results'] as $vn_k => &$va_result) { $t_object = new ca_objects($va_result['object_id']); if (!$t_object->getPrimaryKey()) { continue; } // include number of 'likes' (comments) $va_result['likes'] = (int) $t_object->getNumComments(null); if ($pb_only_with_likes && !$va_result['likes']) { unset($va_return['results'][$vn_k]); continue; } // include copyright holder $vs_copyright_holder = $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => 'copyright')); if ($vs_copyright_holder) { $va_result['copyright_holder'] = $vs_copyright_holder; } // include urls for reference img $va_objects = $t_object->getRelatedItems('ca_objects', array('restrictToRelationshipTypes' => 'reference')); if (!is_array($va_objects) || sizeof($va_objects) != 1) { continue; } $va_object = array_shift($va_objects); $t_rel_object = new ca_objects($va_object['object_id']); $va_rep = $t_rel_object->getPrimaryRepresentation(array('preview170', 'medium', 'alhalqa1000', 'alhalqa2000')); if (!is_array($va_rep) || !is_array($va_rep['urls'])) { continue; } $va_result['reference_image_urls'] = $va_rep['urls']; } if ($this->opo_request->getParameter('sort', pString) == 'likes') { if (strtolower($this->opo_request->getParameter('sortDirection', pString)) == 'asc') { usort($va_return['results'], function ($a, $b) { return $a['likes'] - $b['likes']; }); } else { // default is desc usort($va_return['results'], function ($a, $b) { return $b['likes'] - $a['likes']; }); } } } return $va_return; }
public function testFindByPreferredLabelWithPurify() { $vm_ret = ca_objects::find(['preferred_labels' => ['name' => 'Sound & Motion']], ['purifyWithFallback' => false, 'purify' => true, 'returnAs' => 'ids']); $this->assertInternalType('array', $vm_ret); $this->assertCount(1, $vm_ret); $this->assertEquals($this->opn_object_id, $vm_ret[0]); }
public function testDelete() { $va_objects = array(); $this->assertGreaterThan(0, $va_objects[] = $this->addTestRecord('ca_objects', array('intrinsic_fields' => array('type_id' => 'dataset'), 'preferred_labels' => array(array("locale" => "en_US", "name" => "My test dataset"))))); $this->assertGreaterThan(0, $va_objects[] = $this->addTestRecord('ca_objects', array('intrinsic_fields' => array('type_id' => 'physical_object'), 'preferred_labels' => array(array("locale" => "en_US", "name" => "Test physical object"))))); foreach ($va_objects as $vn_object_id) { $t_object = new ca_objects($vn_object_id); $t_object->setMode(ACCESS_WRITE); $t_object->delete(true, array('hard' => true)); } $o_search = caGetSearchInstance('ca_objects'); $o_result = $o_search->search('dataset'); $this->assertEquals(0, $o_result->numHits(), 'dataset should not be indexed anymore'); $o_result = $o_search->search('physical'); $this->assertEquals(0, $o_result->numHits(), 'physical object should not be indexed anymore'); }
/** * */ public function __call($ps_function, $pa_args) { AssetLoadManager::register("carousel"); $va_access_values = caGetUserAccessValues($this->request); $this->view->setVar('access_values', $va_access_values); # # --- if there is a set configured to show on the front page, load it now # $va_featured_ids = array(); if ($vs_set_code = $this->config->get("front_page_set_code")) { $t_set = new ca_sets(); $t_set->load(array('set_code' => $vs_set_code)); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $this->view->setVar('featured_set_id', $t_set->get("set_id")); $this->view->setVar('featured_set', $t_set); $va_featured_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); $this->view->setVar('featured_set_item_ids', $va_featured_ids); $this->view->setVar('featured_set_items_as_search_result', caMakeSearchResult('ca_objects', $va_featured_ids)); } } # # --- no configured set/items in set so grab random objects with media # if (sizeof($va_featured_ids) == 0) { $t_object = new ca_objects(); $va_featured_ids = array_keys($t_object->getRandomItems(10, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1))); $this->view->setVar('featured_set_item_ids', $va_featured_ids); $this->view->setVar('featured_set_items_as_search_result', caMakeSearchResult('ca_objects', $va_featured_ids)); } $this->view->setVar('config', $this->config); $o_result_context = new ResultContext($this->request, 'ca_objects', 'front'); $this->view->setVar('result_context', $o_result_context); $o_result_context->setAsLastFind(); // // Try to load selected page if it exists in Front/, otherwise load default Front/front_page_html.php // $ps_function = preg_replace("![^A-Za-z0-9_\\-]+!", "", $ps_function); $vs_path = "Front/{$ps_function}_html.php"; if (file_exists(__CA_THEME_DIR__ . "/views/{$vs_path}")) { $this->render($vs_path); } else { $this->render("Front/front_page_html.php"); } }
/** * */ public function renderWidget($ps_widget_id, &$pa_settings) { parent::renderWidget($ps_widget_id, $pa_settings); $t_object = new ca_objects(); # get a random object for display $va_random_item = $t_object->getRandomItems(1, array('hasRepresentations' => 1)); if (sizeof($va_random_item) > 0) { foreach ($va_random_item as $vn_object_id => $va_object_info) { $t_object->load($vn_object_id); $va_rep = $t_object->getPrimaryRepresentation(array('medium')); $this->opo_view->setVar('object_id', $vn_object_id); $this->opo_view->setVar('image', $va_rep["tags"]["medium"]); $this->opo_view->setVar('label', $t_object->getLabelForDisplay()); } } $this->opo_view->setVar('request', $this->getRequest()); return $this->opo_view->render('main_html.php'); }
{{{<ifdef code="ca_objects.topic"><div class='unit'><h6>Topic</h6><span class='metaFloat'>^ca_objects.topic</span></div></ifdef>}}} {{{<ifdef code="ca_objects.description"><h6>Description</h6>^ca_objects.description<br/></ifdef>}}} {{{<ifdef code="ca_objects.courtesy"><div class='unit'><h6>Courtesy<h6><span class='metaFloat'>^ca_objects.courtesy</span></div></ifdef>}}} {{{<ifdef code="ca_objects.rights.rightsText"><div class='unit'><h6>Rights</h6><span class='metaFloat'>^ca_objects.rights.rightsText</span></div></ifdef>}}} <?php if ($vs_entities = $t_object->get("ca_entities", array('delimiter' => '<br/>', 'template' => '^preferred_labels (^relationship_typename)', "returnAsLink" => true))) { print "<div class='unit'><H6>" . _t('Related Entities') . "</H6> <span class='metaData'>{$vs_entities}</span></div><!-- end unit -->"; } if ($t_object->get('type_id') == 21) { $va_children = $t_object->getHierarchyChildren(null, array('idsOnly' => true)); print "<div class='unit rings'><h6><b>" . _t("Rings") . "</b></h6>"; foreach ($va_children as $va_child_key => $va_child_id) { $t_ring = new ca_objects($va_child_id); print caNavLink($this->request, $t_ring->get("ca_objects.preferred_labels.name"), '', '', 'Detail', 'objects/' . $va_child_id) . "<br/>"; } print "</div>"; } ?> </div><!-- end col --> </div><!-- end row --></div><!-- end container --> </div><!-- end col --> <div class='navLeftRight col-xs-1 col-sm-1 col-md-1 col-lg-1'> <div class="detailNavBgRight"> {{{nextLink}}} </div><!-- end detailNavBgLeft --> </div><!-- end col -->
/** * * * @param RequestHTTP $po_request * @param array $pa_options * @param array $pa_additional_display_options * @return string HTML output */ function caRepresentationViewerHTMLBundleForSearchResult($po_data, $po_request, $pa_options = null, $pa_additional_display_options = null) { $ps_version = $po_request->getParameter('version', pString); $va_access_values = isset($pa_options['access']) && is_array($pa_options['access']) ? $pa_options['access'] : array(); $vs_display_type = isset($pa_options['display']) && $pa_options['display'] ? $pa_options['display'] : 'media_overlay'; $vs_container_dom_id = isset($pa_options['containerID']) && $pa_options['containerID'] ? $pa_options['containerID'] : null; $vn_object_id = isset($pa_options['object_id']) && $pa_options['object_id'] ? $pa_options['object_id'] : null; $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null; $vn_order_item_id = isset($pa_options['order_item_id']) && $pa_options['order_item_id'] ? $pa_options['order_item_id'] : null; $vb_media_editor = isset($pa_options['mediaEditor']) && $pa_options['mediaEditor'] ? true : false; $vb_no_controls = isset($pa_options['noControls']) && $pa_options['noControls'] ? true : false; $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null; $t_object = new ca_objects($vn_object_id); //if (!$t_object->getPrimaryKey()) { return false; } if (!$po_data->getPrimaryKey() && $t_object->getPrimaryKey() && method_exists($po_data, 'load')) { $po_data->load($t_object->getPrimaryRepresentationID(array('checkAccess' => $va_access_values))); } $t_set_item = new ca_set_items(); if ($vn_item_id) { $t_set_item->load($vn_item_id); } $t_order_item = new ca_commerce_order_items(); if ($vn_order_item_id) { $t_order_item->load($vn_order_item_id); } $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/'); $o_view->setVar('t_object', $t_object); $o_view->setVar('t_set_item', $t_set_item); $o_view->setVar('t_order_item', $t_order_item); $o_view->setVar('use_media_editor', $vb_media_editor); $o_view->setVar('noControls', $vb_no_controls); $va_rep_display_info = array(); if (isset($pa_options['use_book_viewer'])) { $va_rep_display_info['use_book_viewer'] = (bool) $pa_options['use_book_viewer']; } if ($t_object->getPrimaryKey()) { $o_view->setVar('reps', $va_reps = $t_object->getRepresentations(array('icon'), null, array("return_with_access" => $va_access_values))); } $t_media = new Media(); $va_buf = array(); while ($po_data->nextHit()) { if (method_exists($po_data, 'numFiles')) { $o_view->setVar('num_multifiles', $po_data->numFiles()); } $o_view->setVar('t_object_representation', $po_data); if (($vn_representation_id = $po_data->getPrimaryKey()) && (!sizeof($va_access_values) || in_array($po_data->get('access'), $va_access_values))) { // check rep access $va_rep_display_info = caGetMediaDisplayInfo($vs_display_type, $vs_mimetype = $po_data->getMediaInfo('media', 'INPUT', 'MIMETYPE')); $va_rep_display_info['poster_frame_url'] = $po_data->getMediaUrl('media', $va_rep_display_info['poster_frame_version']); $va_additional_display_options = array(); if (is_array($pa_additional_display_options) && isset($pa_additional_display_options[$vs_mimetype]) && is_array($pa_additional_display_options[$vs_mimetype])) { $va_additional_display_options = $pa_additional_display_options[$vs_mimetype]; } $o_view->setVar('display_options', caGetMediaDisplayInfo('detail', $vs_mimetype)); $o_view->setVar('display_type', $vs_display_type); $o_view->setVar('representation_id', $vn_representation_id); $o_view->setVar('t_object_representation', $po_data); $o_view->setVar('versions', $va_versions = $po_data->getMediaVersions('media')); $o_view->setVar('containerID', $vs_container_dom_id . $vn_representation_id); $o_view->setVar('version_type', $t_media->getMimetypeTypename($po_data->getMediaInfo('media', 'original', 'MIMETYPE'))); if ($t_object->getPrimaryKey()) { $vn_next_rep = $vn_prev_rep = null; $va_rep_list = array_values($va_reps); foreach ($va_rep_list as $vn_i => $va_rep) { if ($va_rep['representation_id'] == $vn_representation_id) { if (isset($va_rep_list[$vn_i - 1])) { $vn_prev_rep = $va_rep_list[$vn_i - 1]['representation_id']; } if (isset($va_rep_list[$vn_i + 1])) { $vn_next_rep = $va_rep_list[$vn_i + 1]['representation_id']; } $o_view->setVar('representation_index', $vn_i + 1); } } $o_view->setVar('previous_representation_id', $vn_prev_rep); $o_view->setVar('next_representation_id', $vn_next_rep); } if (!in_array($ps_version, $va_versions)) { if (!($ps_version = $va_rep_display_info['display_version'])) { $ps_version = null; } } $o_view->setVar('version_info', $po_data->getMediaInfo('media', $ps_version)); $o_view->setVar('version', $ps_version); } $va_buf[$vn_representation_id] = $o_view->render('representation_viewer_html.php'); } return $va_buf; }
} ?> <div id="frontPage" class="subhomeslide"> <?php $va_access_values = caGetUserAccessValues($this->request); $this->config = caGetFrontConfig(); if ($vs_set_code = $this->config->get("front_page_set_code_CJF")) { $t_set = new ca_sets(); $t_set->load(array('set_code' => $vs_set_code)); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $va_item_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); } } if (is_array($va_item_ids) && sizeof($va_item_ids)) { $t_object = new ca_objects(); $va_item_media = $t_object->getPrimaryMediaForIDs($va_item_ids, array("mediumlarge"), array('checkAccess' => $va_access_values)); $va_item_labels = $t_object->getPreferredDisplayLabelsForIDs($va_item_ids); } if (is_array($va_item_media) && sizeof($va_item_media)) { ?> <div class="jcarousel-wrapper slidecontainer"> <!-- Carousel --> <div class="jcarousel"> <ul> <?php foreach ($va_item_media as $vn_object_id => $va_media) { print "<li>" . caDetailLink($this->request, $va_media["tags"]["mediumlarge"], '', 'ca_objects', $vn_object_id) . "</li>"; } ?>
/** * * * @param $ps_field - * @param $pa_options - * returnAsArray - * delimiter - * template - * locale - * returnAllLocales - Returns requested value in all locales for which it is defined. Default is false. Note that this is not supported for hierarchy specifications (eg. ca_objects.hierarchy). * 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). * checkAccess = array of access values to filter results by; if defined only items with the specified access code(s) are returned. Only supported for <table_name>.hierarchy.preferred_labels and <table_name>.children.preferred_labels because these returns sets of items. For <table_name>.parent.preferred_labels, which returns a single row at most, you should do access checking yourself. (Everything here applies equally to nonpreferred_labels) * sort = optional bundles to sort returned values on. Only supported for <table_name>.children.preferred_labels. The bundle specifiers are fields with or without tablename. * sort_direction = direction to sort results by, either 'asc' for ascending order or 'desc' for descending order; default is 'asc' * convertCodesToDisplayText = if true then non-preferred label type_ids are automatically converted to display text in the current locale; default is false (return non-preferred label type_id raw) */ public function get($ps_field, $pa_options = null) { $vs_template = isset($pa_options['template']) ? $pa_options['template'] : null; $vb_return_as_array = isset($pa_options['returnAsArray']) ? (bool) $pa_options['returnAsArray'] : false; $vb_return_all_locales = isset($pa_options['returnAllLocales']) ? (bool) $pa_options['returnAllLocales'] : false; $vs_delimiter = isset($pa_options['delimiter']) ? $pa_options['delimiter'] : ' '; $vb_convert_codes_to_display_text = isset($pa_options['convertCodesToDisplayText']) ? (bool) $pa_options['convertCodesToDisplayText'] : false; if ($vb_return_all_locales && !$vb_return_as_array) { $vb_return_as_array = true; } // if desired try to return values in a preferred language/locale $va_preferred_locales = null; if (isset($pa_options['locale']) && $pa_options['locale']) { $va_preferred_locales = array($pa_options['locale']); } // does get refer to an attribute? $va_tmp = explode('.', $ps_field); if ($va_tmp[1] == 'hierarchy' && sizeof($va_tmp) == 2) { $va_tmp[2] = 'preferred_labels'; $ps_field = join('.', $va_tmp); } $t_label = $this->getLabelTableInstance(); $t_instance = $this; if (sizeof($va_tmp) >= 3 && ($va_tmp[2] == 'preferred_labels' && (!$va_tmp[3] || $t_label->hasField($va_tmp[3]))) || $va_tmp[1] == 'hierarchy') { switch ($va_tmp[1]) { case 'parent': if ($this->isHierarchical() && ($vn_parent_id = $this->get($this->getProperty('HIERARCHY_PARENT_ID_FLD')))) { $t_instance = $this->getAppDatamodel()->getInstanceByTableNum($this->tableNum()); if (!$t_instance->load($vn_parent_id)) { $t_instance = $this; } else { unset($va_tmp[1]); $va_tmp = array_values($va_tmp); } } break; case 'children': if ($this->isHierarchical()) { unset($va_tmp[1]); // remove 'children' from field path $va_tmp = array_values($va_tmp); $vs_childless_path = join('.', $va_tmp); $va_data = array(); $va_children_ids = $this->getHierarchyChildren(null, array('idsOnly' => true)); if (is_array($va_children_ids) && sizeof($va_children_ids)) { $t_instance = $this->getAppDatamodel()->getInstanceByTableNum($this->tableNum()); $vb_check_access = is_array($pa_options['checkAccess']) && $t_instance->hasField('access'); $va_sort = isset($pa_options['sort']) ? $pa_options['sort'] : null; if (!is_array($va_sort) && $va_sort) { $va_sort = array($va_sort); } if (!is_array($va_sort)) { $va_sort = array(); } $vs_sort_direction = isset($pa_options['sort_direction']) && in_array(strtolower($pa_options['sort_direction']), array('asc', 'desc')) ? strtolower($pa_options['sort_direction']) : 'asc'; $qr_children = $this->makeSearchResult($this->tableName(), $va_children_ids); $vs_table = $this->tableName(); while ($qr_children->nextHit()) { if ($vb_check_access && !in_array($qr_children->get("{$vs_table}.access"), $pa_options['checkAccess'])) { continue; } $vs_sort_key = ''; foreach ($va_sort as $vs_sort) { $vs_sort_key .= $vs_sort ? $qr_children->get($vs_sort) : 0; } if (!is_array($va_data[$vs_sort_key])) { $va_data[$vs_sort_key] = array(); } $va_data[$vs_sort_key] = array_merge($va_data[$vs_sort_key], $qr_children->get($vs_childless_path, array_merge($pa_options, array('returnAsArray' => true)))); } ksort($va_data); if ($vs_sort_direction && $vs_sort_direction == 'desc') { $va_data = array_reverse($va_data); } $va_sorted_data = array(); foreach ($va_data as $vs_sort_key => $va_items) { foreach ($va_items as $vs_k => $vs_v) { $va_sorted_data[] = $vs_v; } } $va_data = $va_sorted_data; } if ($vb_return_as_array) { return $va_data; } else { return join($vs_delimiter, $va_data); } } break; case 'hierarchy': $vs_direction = isset($pa_options['direction']) ? strtoupper($pa_options['direction']) : null; if (!in_array($vs_direction, array('ASC', 'DESC'))) { $vs_direction = 'ASC'; } $vn_top = (int) isset($pa_options['top']) ? strtoupper($pa_options['top']) : 0; if ($vn_top < 0) { $vn_top = 0; } $vn_bottom = (int) isset($pa_options['bottom']) ? strtoupper($pa_options['bottom']) : 0; if ($vn_bottom < 0) { $vn_bottom = 0; } $vs_pk = $this->primaryKey(); $vs_label_table_name = $this->getLabelTableName(); $t_label_instance = $this->getLabelTableInstance(); if (!$vs_template && ($vs_display_field = $t_label_instance->hasField($va_tmp[2]) ? $t_label_instance->tableName() . "." . $va_tmp[2] : ($this->hasField($va_tmp[2]) ? $this->tableName() . "." . $va_tmp[2] : null))) { $vs_template = "^{$vs_display_field}"; } $vn_top_id = null; if (!($va_ancestor_list = $this->getHierarchyAncestors(null, array('idsOnly' => true, 'includeSelf' => true)))) { $va_ancestor_list = array(); } // TODO: this should really be in a model subclass if ($this->tableName() == 'ca_objects' && $this->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled') && ($vs_coll_rel_type = $this->getAppConfig()->get('ca_objects_x_collections_hierarchy_relationship_type'))) { require_once __CA_MODELS_DIR__ . '/ca_objects.php'; if ($this->getPrimaryKey() == $vn_top_id) { $t_object = $this; } else { $t_object = new ca_objects($vn_top_id); } if (is_array($va_collections = $t_object->getRelatedItems('ca_collections', array('restrictToRelationshipTypes' => $vs_coll_rel_type)))) { require_once __CA_MODELS_DIR__ . '/ca_collections.php'; $t_collection = new ca_collections(); foreach ($va_collections as $vn_i => $va_collection) { if ($va_collections_ancestor_list = $t_collection->getHierarchyAncestors($va_collection['collection_id'], array('idsOnly' => true, 'includeSelf' => true))) { $va_ancestor_list = array_merge($va_ancestor_list, $va_collections_ancestor_list); } break; // for now only process first collection (no polyhierarchies) } } } // remove root and children if so desired if (isset($pa_options['removeFirstItems']) && (int) $pa_options['removeFirstItems'] > 0) { for ($vn_i = 0; $vn_i < (int) $pa_options['removeFirstItems']; $vn_i++) { array_pop($va_ancestor_list); } } if ($vs_display_field != $va_tmp[2]) { if ($this->hasField($va_tmp[2])) { $vs_display_field = $va_tmp[2]; } } $vb_check_access = is_array($pa_options['checkAccess']) && $this->hasField('access'); if ($vb_check_access) { $va_access_values = $this->getFieldValuesForIDs($va_ancestor_list, array('access')); $va_ancestor_list = array(); foreach ($va_access_values as $vn_ancestor_id => $vn_access_value) { if (in_array($vn_access_value, $pa_options['checkAccess'])) { $va_ancestor_list[] = $vn_ancestor_id; } } } if ($vs_template) { $va_tmp = caProcessTemplateForIDs($vs_template, $this->tableName(), $va_ancestor_list, array('returnAsArray' => true)); } else { $va_tmp = $this->getPreferredDisplayLabelsForIDs($va_ancestor_list, array('returnAsArray' => true, 'returnAllLocales' => $vb_return_all_locales)); } if ($vn_top > 0) { $va_tmp = array_slice($va_tmp, sizeof($va_tmp) - $vn_top, $vn_top, true); } else { if ($vn_bottom > 0) { $va_tmp = array_slice($va_tmp, 0, $vn_bottom, true); } } if ($vs_direction == 'ASC') { $va_tmp = array_reverse($va_tmp, true); } if (caGetOption('returnAsLink', $pa_options, false)) { $va_tmp = caCreateLinksFromText(array_values($va_tmp), $this->tableName(), array_keys($va_tmp)); } if ($vb_return_as_array) { return $va_tmp; } else { $vs_hier_delimiter = isset($pa_options['hierarchicalDelimiter']) ? $pa_options['hierarchicalDelimiter'] : $pa_options['delimiter']; return join($vs_hier_delimiter, $va_tmp); } break; } } switch (sizeof($va_tmp)) { case 1: switch ($va_tmp[0]) { # --------------------------------------------- case 'preferred_labels': if (!$vb_return_as_array) { $va_labels = caExtractValuesByUserLocale($t_instance->getPreferredLabels(), null, $va_preferred_locales); $vs_disp_field = $this->getLabelDisplayField(); $va_values = array(); foreach ($va_labels as $vn_row_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { if ($vs_template) { $va_values[] = caProcessTemplate($vs_template, $va_label, array('removePrefix' => 'preferred_labels.')); } else { $va_values[] = $va_label[$vs_disp_field]; } } } return join($vs_delimiter, $va_values); } else { $va_labels = $t_instance->getPreferredLabels(null, false); if ($vb_return_all_locales) { return $va_labels; } else { // Simplify array by getting rid of third level array which is unnecessary since // there is only ever one preferred label for a locale $va_labels = caExtractValuesByUserLocale($va_labels, null, $va_preferred_locales); $va_processed_labels = array(); foreach ($va_labels as $vn_label_id => $va_label_list) { $va_processed_labels[$vn_label_id] = $va_label_list[0]; } return $va_processed_labels; } } break; # --------------------------------------------- # --------------------------------------------- case 'nonpreferred_labels': if (!$vb_return_as_array) { $vs_disp_field = $this->getLabelDisplayField(); $va_labels = caExtractValuesByUserLocale($t_instance->getNonPreferredLabels(), null, $va_preferred_locales); $t_list = new ca_lists(); if ($vb_convert_codes_to_display_text) { $va_types = $t_list->getItemsForList($this->getLabelTableInstance()->getFieldInfo('type_id', 'LIST_CODE'), array('extractValuesByUserLocale' => true)); } $va_values = array(); foreach ($va_labels as $vn_row_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { if ($vs_template) { $va_label_values = $va_label; $va_label_values['typename_singular'] = $va_types[$va_label['type_id']]['name_singular']; $va_label_values['typename_plural'] = $va_types[$va_label['type_id']]['name_plural']; if ($vb_convert_codes_to_display_text) { $va_label_values['type_id'] = $va_types[$va_label['type_id']]['name_singular']; } $va_values[] = caProcessTemplate($vs_template, $va_label_values, array('removePrefix' => 'nonpreferred_labels.')); } else { if ($vb_convert_codes_to_display_text && $vs_disp_field == 'type_id') { $va_values[] = $va_types[$va_label[$vs_disp_field]]['name_singular']; } else { $va_values[] = $va_label[$vs_disp_field]; } } } } return join($vs_delimiter, $va_values); $va_labels = caExtractValuesByUserLocale($t_instance->getNonPreferredLabels(null, false)); $vs_disp_field = $this->getLabelDisplayField(); $va_processed_labels = array(); foreach ($va_labels as $vn_label_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { $va_processed_labels[] = $va_label[$vs_disp_field]; } } return join($vs_delimiter, $va_processed_labels); } else { $va_labels = $t_instance->getNonPreferredLabels(null, false); if ($vb_return_all_locales) { return $va_labels; } else { return caExtractValuesByUserLocale($va_labels, null, $va_preferred_locales); } } break; # --------------------------------------------- } break; case 2: case 3: if ($va_tmp[0] === $t_instance->tableName()) { switch ($va_tmp[1]) { # --------------------------------------------- case 'preferred_labels': if (!$vb_return_as_array) { if (isset($va_tmp[2]) && $va_tmp[2]) { $vs_disp_field = $va_tmp[2]; } else { $vs_disp_field = $this->getLabelDisplayField(); } $va_labels = caExtractValuesByUserLocale($t_instance->getPreferredLabels(), null, $va_preferred_locales); $va_values = array(); foreach ($va_labels as $vn_row_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { if ($vs_template) { $va_values[] = caProcessTemplate($vs_template, $va_label, array('removePrefix' => 'preferred_labels.')); } else { $va_values[] = $va_label[$vs_disp_field]; } } } return join($vs_delimiter, $va_values); } else { $va_labels = $t_instance->getPreferredLabels(null, false); if (!$vb_return_all_locales) { // Simplify array by getting rid of third level array which is unnecessary since // there is only ever one preferred label for a locale $va_labels = caExtractValuesByUserLocale($va_labels, null, $va_preferred_locales); $va_processed_labels = array(); foreach ($va_labels as $vn_label_id => $va_label_list) { $va_processed_labels[$vn_label_id] = $va_label_list[0]; } $va_labels = $va_processed_labels; } if (isset($va_tmp[2]) && $va_tmp[2]) { // specific field if ($vb_return_all_locales) { foreach ($va_labels as $vn_label_id => $va_labels_by_locale) { foreach ($va_labels_by_locale as $vn_locale_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { $va_labels[$vn_label_id][$vn_locale_id][$vn_i] = $va_label[$va_tmp[2]]; } } } } else { // get specified field value foreach ($va_labels as $vn_label_id => $va_label_info) { $va_labels[$vn_label_id] = $va_label_info[$va_tmp[2]]; } } } return $va_labels; } break; # --------------------------------------------- # --------------------------------------------- case 'nonpreferred_labels': if (!$vb_return_as_array) { if (isset($va_tmp[2]) && $va_tmp[2]) { $vs_disp_field = $va_tmp[2]; } else { $vs_disp_field = $this->getLabelDisplayField(); } $va_labels = caExtractValuesByUserLocale($t_instance->getNonPreferredLabels(), null, $va_preferred_locales); $t_list = new ca_lists(); if ($vb_convert_codes_to_display_text) { $va_types = $t_list->getItemsForList($this->getLabelTableInstance()->getFieldInfo('type_id', 'LIST_CODE'), array('extractValuesByUserLocale' => true)); } $va_values = array(); foreach ($va_labels as $vn_row_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { if ($vs_template) { $va_label_values = $va_label; $va_label_values['typename_singular'] = $va_types[$va_label['type_id']]['name_singular']; $va_label_values['typename_plural'] = $va_types[$va_label['type_id']]['name_plural']; if ($vb_convert_codes_to_display_text) { $va_label_values['type_id'] = $va_types[$va_label['type_id']]['name_singular']; } $va_values[] = caProcessTemplate($vs_template, $va_label_values, array('removePrefix' => 'nonpreferred_labels.')); } else { if ($vb_convert_codes_to_display_text && $vs_disp_field == 'type_id') { $va_values[] = $va_types[$va_label[$vs_disp_field]]['name_singular']; } else { $va_values[] = $va_label[$vs_disp_field]; } } } } return join($vs_delimiter, $va_values); } else { $va_labels = $t_instance->getNonPreferredLabels(null, false); if (!$vb_return_all_locales) { $va_labels = caExtractValuesByUserLocale($va_labels, null, $va_preferred_locales); } if (isset($va_tmp[2]) && $va_tmp[2]) { // specific field if ($vb_return_all_locales) { foreach ($va_labels as $vn_label_id => $va_labels_by_locale) { foreach ($va_labels_by_locale as $vn_locale_id => $va_label_list) { foreach ($va_label_list as $vn_i => $va_label) { $va_labels[$vn_label_id][$vn_locale_id][$vn_i] = $va_label[$va_tmp[2]]; } } } } else { // get specified field value foreach ($va_labels as $vn_label_id => $va_label_info) { foreach ($va_label_info as $vn_id => $va_label) { $va_labels[$vn_label_id] = $va_label[$va_tmp[2]]; } } } } return $va_labels; } break; # --------------------------------------------- } } break; } return parent::get($ps_field, $pa_options); }
<hr> <h1>Artists by Last Name</h1> <?php //$o_artist_search = new ObjectSearch(); //$qr_artists = $o_artist_search->search("ca_entities.preferred_labels.displayname/artist:*"); $o_db = new Db(); $qr_res = $o_db->query("\n\t\t\tSELECT DISTINCT e.entity_id FROM ca_entities e\n\t\t\tINNER JOIN ca_entity_labels AS el ON el.entity_id = e.entity_id\n\t\t\tINNER JOIN ca_objects_x_entities AS oxe ON e.entity_id = oxe.entity_id\n\t\t\tWHERE\n\t\t\t\toxe.type_id = 103 AND e.deleted = 0 AND el.is_preferred = 1\n\t\t\tORDER BY\n\t\t\t\tel.surname, el.forename\n\t\t"); $qr_artists = caMakeSearchResult('ca_entities', $qr_res->getAllFieldValues('entity_id')); $va_artists = array(); while ($qr_artists->nextHit()) { $va_has_artwork = false; if ($qr_artists->get('ca_objects', array('restrictToRelationshipTypes' => 'artist', 'checkAccess' => $va_access_values))) { $va_artworks = $qr_artists->get('ca_objects', array('restrictToRelationshipTypes' => 'artist', 'checkAccess' => $va_access_values, 'returnAsArray' => true)); foreach ($va_artworks as $vn_artwork_key => $va_artwork) { $vn_artwork_id = $va_artwork['object_id']; $t_object = new ca_objects($vn_artwork_id); if ($t_object->get('ca_objects.type_id') == 28) { $va_has_artwork = true; } } if ($va_has_artwork == true) { $va_first_letter = substr($qr_artists->get('ca_entities.preferred_labels.surname'), 0, 1); $va_artists[$va_first_letter][] = $qr_artists->get('ca_entities.preferred_labels.displayname', array('returnAsLink' => true)); } } } #print "<pre>"; #print_r($va_artists); #print "<pre>"; foreach ($va_artists as $va_letter_key => $va_artist_name) { print "<div class='letterMenu'><a href='#" . $va_letter_key . "'>" . $va_letter_key . "</a></div>";
} # --- map if ($this->request->config->get('ca_objects_map_attribute') && $t_object->get($this->request->config->get('ca_objects_map_attribute'))) { $o_map = new GeographicMap(300, 200, 'map'); $o_map->mapFrom($t_object, $this->request->config->get('ca_objects_map_attribute')); print "<div class='unit'>" . $o_map->render('HTML') . "</div>"; } # --- output related object images as links $va_related_objects = $t_object->get("ca_objects", array("returnAsArray" => 1, 'checkAccess' => $va_access_values)); if (sizeof($va_related_objects)) { print "<div class='unit'><div class='unitHeader'>" . _t("Related Objects") . "</div>"; print "<table border='0' cellspacing='0' cellpadding='0' width='100%' id='objDetailRelObjects'>"; $col = 0; $vn_numCols = 4; foreach ($va_related_objects as $vn_rel_id => $va_info) { $t_rel_object = new ca_objects($va_info["object_id"]); $va_reps = $t_rel_object->getPrimaryRepresentation(array('icon', 'small'), null, array('return_with_access' => $va_access_values)); if ($col == 0) { print "<tr>"; } print "<td align='center' valign='middle' class='imageIcon icon" . $va_info["object_id"] . "'>"; print caNavLink($this->request, $va_reps['tags']['icon'], '', 'Detail', 'Object', 'Show', array('object_id' => $va_info["object_id"])); // set view vars for tooltip $this->setVar('tooltip_representation', $va_reps['tags']['small']); $this->setVar('tooltip_title', $va_info['label']); $this->setVar('tooltip_idno', $va_info["idno"]); TooltipManager::add(".icon" . $va_info["object_id"], $this->render('../Results/ca_objects_result_tooltip_html.php')); print "</td>"; $col++; if ($col < $vn_numCols) { print "<td align='center'><!-- empty --></td>";
if ($vs_table == "ca_occurrences") { $va_related_objects = $qr_res->get('ca_objects.object_id', array('returnAsArray' => true)); $va_first_object_id = $va_related_objects[0]; $t_object = new ca_objects($va_first_object_id); $va_rep = $t_object->get('ca_object_representations.media.small'); if ($t_object->get('ca_object_representations.media.small')) { $va_cell_width = "style='width:auto'"; #$va_cell_width = "style='width:".$t_object->get('ca_object_representations.media.small.width')."px;'"; } else { $va_cell_width = "style='width:180px;'"; } } else { if ($vs_table == "ca_collections") { $va_related_objects = $qr_res->get('ca_objects.object_id', array('returnAsArray' => true)); $va_first_object_id = $va_related_objects[0]; $t_object = new ca_objects($va_first_object_id); $va_rep = $t_object->get('ca_object_representations.media.small'); if ($t_object->get('ca_object_representations.media.small')) { $va_cell_width = "style='width:auto'"; #$va_cell_width = "style='width:".$t_object->get('ca_object_representations.media.small.width')."px;'"; } else { $va_cell_width = "style='width:180px;'"; } } else { $va_rep = $qr_res->get('ca_object_representations.media.small'); if ($qr_res->get('ca_object_representations.media.small')) { $va_cell_width = "style='width:auto'"; #$va_cell_width = "style='width:".$qr_res->get('ca_object_representations.media.small.width')."px;'"; } else { $va_cell_width = "style='width:180px;'"; }
/** * 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; }
<?php require_once __CA_MODELS_DIR__ . "/ca_sets.php"; include_once __CA_LIB_DIR__ . "/ca/Search/OccurrenceSearch.php"; include_once __CA_MODELS_DIR__ . "/ca_occurrences.php"; $va_access_values = caGetUserAccessValues($this->request); if ($vs_set_code = $this->request->config->get("featured_art_set")) { AssetLoadManager::register("carousel"); $t_set = new ca_sets(); $t_set->load(array('set_code' => $vs_set_code)); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $va_item_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 0))) ? $va_tmp : array()); } if (is_array($va_item_ids) && sizeof($va_item_ids)) { $t_object = new ca_objects(); $va_item_media = $t_object->getPrimaryMediaForIDs($va_item_ids, array("slideshowsmall"), array('checkAccess' => caGetUserAccessValues($this->request))); } } ?> <div class="container"> <div class="row collection"> <div class="col-sm-6"> <div class="advSearch"> <h1>Search Collection</h1> {{{form}}} <div class="advancedSearchField"> Title:<br/> {{{ca_objects.preferred_labels.name%width=220px}}} </div>
public function setItemInfo() { $va_access_values = caGetUserAccessValues($this->request); $pn_set_id = $this->request->getParameter('set_id', pInteger); $t_set = new ca_sets($pn_set_id); $this->view->setVar('set_id', $pn_set_id); $pn_set_item_id = $this->request->getParameter('set_item_id', pInteger); $t_set_item = new ca_set_items($pn_set_item_id); $va_set_item_info = array(); $va_items = $t_set->getItemIDs(array("checkAccess" => $va_access_values)); $pn_previous_id = ""; foreach ($va_items as $vn_item_id => $va_item_info) { if ($va_set_item_info["item_id"]) { $va_set_item_info["next_id"] = $vn_item_id; break; } if ($pn_set_item_id == $vn_item_id) { $va_set_item_info["previous_id"] = $pn_previous_id; $va_set_item_info["item_id"] = $vn_item_id; } $pn_previous_id = $vn_item_id; } $va_set_item_info["item_id"] = $t_set_item->get("item_id"); $va_reps = $t_set_item->getRepresentations(array("mediumlarge", "small"), null, array("return_with_access" => $va_access_values)); $va_rep = array_shift($va_rep); $this->view->setVar('t_object_representation', $t_rep = new ca_object_representations($va_rep['representation_id'])); $va_rep_display_info = caGetMediaDisplayInfo('cropped_gallery_media_overlay', $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE')); $this->view->setVar('rep_display_version', $va_rep_display_info['display_version']); unset($va_display_info['display_version']); $va_rep_display_info['poster_frame_url'] = $t_rep->getMediaUrl('media', $va_rep_display_info['poster_frame_version']); unset($va_display_info['poster_frame_version']); $this->view->setVar('rep_display_options', $va_rep_display_info); $va_set_item_info["info"] = $va_rep['info']; $va_set_item_info["label"] = $t_set_item->getLabelForDisplay(); $va_set_item_info["description"] = $t_set_item->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLineBreaks' => true)); $va_set_item_info["item_description"] = $t_set_item->get($this->opo_plugin_config->get('set_item_description_element_code'), array('convertLineBreaks' => true)); $va_set_item_info["row_id"] = $t_set_item->get("row_id"); $va_set_item_info["lesson"] = $t_set_item->get('set_item_description'); $t_object = new ca_objects($t_set_item->get("row_id")); $va_set_item_info["object_label"] = $t_object->getLabelForDisplay(); $this->view->setVar('item_info', $va_set_item_info); $this->render($this->ops_theme . '/ajax_item_info_html.php'); }
?> <div id="detailTools"> <div class="detailTool"><a href='#' onclick='jQuery("#detailComments").slideToggle(); return false;'><span class="glyphicon glyphicon-comment"></span>Comments (<?php print sizeof($va_comments); ?> )</a><span class="glyphicon glyphicon-share-alt"></span>{{{shareLink}}}</div><!-- end detailTool --> <div id='detailComments'>{{{itemComments}}}</div><!-- end itemComments --> </div><!-- end detailTools --> </div><!-- end col --> <div class='col-md-6 col-lg-6'> <H4>{{{^ca_places.preferred_labels.name}}}</H4> {{{<ifdef code="ca_places.description"><br/>^ca_places.description<br/></ifdef>}}}<br/> <?php print "<p>" . caNavLink($this->request, _t("View all related objects"), "btn btn-default", "", "Browse", "objects", array("facet" => "place_facet", "id" => $t_item->get("place_id"))) . "</p>"; $t_object_thumb = new ca_objects(); $va_entities = $t_item->get("ca_entities", array("returnAsArray" => true, "checkAccess" => $va_access_values)); if (sizeof($va_entities)) { if (sizeof($va_entities) == 1) { print "<H6>Related person/organisation</H6>"; } else { print "<H6>Related people/organisations</H6>"; } $t_rel_entity = new ca_entities(); foreach ($va_entities as $va_entity) { $t_rel_entity->load($va_entity["entity_id"]); $t_object_thumb->load($t_rel_entity->get("ca_objects.object_id", array("restrictToRelationshipTypes" => array("cover"), "checkAccess" => $va_access_values))); $vs_thumb = $t_object_thumb->get("ca_object_representations.media.icon", array("checkAccess" => $va_access_values)); if ($vs_thumb) { print "<div class='row'><div class='col-sm-3 col-md-3 col-lg-3'>" . $vs_thumb . "</div>\n"; print "<div class='col-sm-9 col-md-9 col-lg-9'>\n";
/** * QuickLook */ public function QuickLook() { $vn_object_id = (int) $this->request->getParameter('object_id', pInteger); $t_object = new ca_objects($vn_object_id); $t_rep = new ca_object_representations($t_object->getPrimaryRepresentationID()); $this->response->addContent(caGetMediaViewerHTMLBundle($this->request, array('display' => 'media_overlay', 't_subject' => $t_object, 't_representation' => $t_rep, 'containerID' => 'caMediaPanelContentArea'))); }
<div class="unit"><h2><?php print _t("Related") . " " . $va_item_types[$vn_occurrence_type_id]['name_singular'] . (sizeof($va_occurrence_list) > 1 ? "s" : ""); ?> </h2> <?php foreach ($va_occurrence_list as $vn_rel_occurrence_id => $va_info) { print "<div>" . ($this->request->config->get('allow_detail_for_ca_occurrences') ? caNavLink($this->request, $va_info["label"], '', 'Detail', 'Occurrence', 'Show', array('occurrence_id' => $vn_rel_occurrence_id)) : $va_info["label"]) . " (" . $va_info['relationship_typename'] . ")</div>"; } print "</div><!-- end unit -->"; } } # --- objects $va_objects = $t_occurrence->get("ca_objects", array("returnAsArray" => 1, 'checkAccess' => $va_access_values)); $va_sorted_objects = array(); if (sizeof($va_objects) > 0) { $t_obj = new ca_objects(); $va_item_types = $t_obj->getTypeList(); foreach ($va_objects as $va_object) { $t_obj->load($va_object['object_id']); $va_sorted_objects[$va_object['item_type_id']][$va_object['object_id']] = $va_object; } foreach ($va_sorted_objects as $vn_object_type_id => $va_object_list) { ?> <div class="unit"><h2><?php print _t("Related") . " " . $va_item_types[$vn_object_type_id]['name_singular'] . (sizeof($va_object_list) > 1 ? "s" : ""); ?> </h2> <?php foreach ($va_object_list as $vn_rel_object_id => $va_info) { print "<div>" . ($this->request->config->get('allow_detail_for_ca_objects') ? caNavLink($this->request, $va_info["idno"], '', 'Detail', 'Object', 'Show', array('object_id' => $vn_rel_object_id)) : $va_info["label"]) . " (" . $va_info['relationship_typename'] . ")</div>"; }
$vs_bundle_preview = '(' . $vn_items_in_hier . ') ' . caProcessTemplateForIDs("^preferred_labels", $t_subject->tableName(), array($t_subject->getPrimaryKey())); switch ($vs_priv_table) { case 'ca_relationship_types': $vb_has_privs = $this->request->user->canDoAction('can_configure_relationship_types'); break; case 'ca_tour_stops': $vb_has_privs = $this->request->user->canDoAction('can_create_ca_tours'); break; default: $vb_has_privs = $this->request->user->canDoAction('can_create_' . $vs_priv_table); break; } $vb_objects_x_collections_hierarchy_enabled = (bool) $t_subject->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled'); $vs_disabled_items_mode = $t_subject->getAppConfig()->get($t_subject->tableName() . '_hierarchy_browser_disabled_items_mode'); $vs_disabled_items_mode = $vs_disabled_items_mode ? $vs_disabled_items_mode : 'hide'; $t_object = new ca_objects(); $va_search_lookup_extra_params = array('noInline' => 1); if ($t_subject->getProperty('HIERARCHY_ID_FLD') && ($vn_hier_id = (int) $t_subject->get($t_subject->getProperty('HIERARCHY_ID_FLD')))) { $va_search_lookup_extra_params['currentHierarchyOnly'] = $vn_hier_id; } if (in_array($t_subject->tableName(), array('ca_objects', 'ca_collections')) && $vb_objects_x_collections_hierarchy_enabled) { $va_lookup_urls = array('search' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'Get', $va_search_lookup_extra_params), 'levelList' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'GetHierarchyLevel'), 'ancestorList' => caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'GetHierarchyAncestorList')); $vs_edit_url = caNavUrl($this->request, 'lookup', 'ObjectCollectionHierarchy', 'Edit') . '/id/'; $vn_init_id = $t_subject->tableName() . "-" . $pn_id; } else { $va_lookup_urls = caJSONLookupServiceUrl($this->request, $t_subject->tableName(), $va_search_lookup_extra_params); $vs_edit_url = caEditorUrl($this->request, $t_subject->tableName()); $vn_init_id = $pn_id; } $vb_strict_type_hierarchy = (bool) $this->request->config->get($t_subject->tableName() . '_enforce_strict_type_hierarchy'); $vs_type_selector = trim($t_subject->getTypeListAsHTMLFormElement("{$vs_id_prefix}type_id", array('id' => "{$vs_id_prefix}typeList"), array('childrenOfCurrentTypeOnly' => $vb_strict_type_hierarchy, 'includeSelf' => !$vb_strict_type_hierarchy, 'directChildrenOnly' => $vb_strict_type_hierarchy)));
?> </div> </page_header> <table class="listtable" width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <?php $tr_count = 0; $vo_result->seek(0); while ($vo_result->nextHit()) { $vn_object_id = $vo_result->get('object_id'); ?> <?php $vn_count = 0; $t_object = new ca_objects($vn_object_id); $thumb_rep = $t_object->getPrimaryRepresentation(array('preview')); // Skip first few columns as needed if ($vn_count < $vn_start) { $vn_count++; continue; } if ($tr_count == 0) { print "<tr>"; } $vs_display_value = $t_display->getDisplayValue($vo_result, $vn_placement_id, array('forReport' => true, 'purify' => true)); print "<td valign='bottom' align='center' width='100'><table cellpadding='0' cellspacing='0' width='100' height='100%' align='center' border='0'><tr align='center' border='0' valign='middle'><td align='center' border='0' valign='middle' style='text-align:center;'>" . $thumb_rep["tags"]["preview"]; print "</td></tr><tr valign='bottom' align='center'><td nowrap='wrap' border='0' align='center' style='word-wrap: break-word; width: 150px; background-color:#eee;' border='1px solid #ccc;'>" . $t_object->get('ca_objects.preferred_labels') . "<br/>" . $t_object->get('ca_objects.idno') . "<br/>" . $t_object->get('ca_collections.preferred_labels'); print "</td></tr></table></td>"; $vn_count++; if ($tr_count == 4) {
/** * Import oral histories from specified directory into CollectiveAccess database */ public function commandImportOralHistories() { $o_conf = $this->getToolConfig(); // Get locale from config and translate to numeric code $t_locale = new ca_locales(); $pn_locale_id = $t_locale->localeCodeToID($o_conf->get('locale')); $o_log = $this->getLogger(); $o_progress = $this->getProgressBar(0); $vs_transcript_dir = $this->getSetting("transcript_directory"); if (!is_readable($vs_transcript_dir)) { if ($o_log) { $o_log->logError($vs_err_msg = _t("Transcript directory %1 is not readable", $vs_transcript_dir)); } if ($o_progress) { $o_progress->setError($vs_err_msg); $o_progress->finish(); } return false; } $vs_audio_dir = $this->getSetting("audio_directory"); if (!is_readable($vs_audio_dir)) { if ($o_log) { $o_log->logError($vs_err_msg = _t("Audio directory %1 is not readable", $vs_audio_dir)); } if ($o_progress) { $o_progress->setError($vs_err_msg); $o_progress->finish(); } return false; } if ($o_progress) { $o_progress->start("Starting oral history import"); } // ---------------------------------------------------------------------- // process main data $r_dir = opendir($vs_transcript_dir); while (($vs_file = readdir($r_dir)) !== false) { if ($vs_file[0] == '.') { continue; } // Get markup and fix it up to be valid XML $vs_markup = file_get_contents($vs_transcript_dir . $vs_file); $vs_markup = preg_replace('!&!', '&', $vs_markup); $vs_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><transcript>{$vs_markup}</transcript>"; try { $o_xml = new SimpleXMLElement($vs_xml); } catch (Exception $e) { $o_log->logError("Could not parse XML transcript for {$vs_transcript_dir}{$vs_file}: " . $e->getMessage()); continue; } $vs_idno = (string) $o_xml->identifier; if (!file_exists($vs_media_path = "{$vs_audio_dir}{$vs_idno}.mp3")) { $o_log->logError("No audio file found for {$vs_idno}. File path was {$vs_media_path}"); continue; } $vs_title = (string) $o_xml->title; $vs_date_created = (string) $o_xml->datecreated; $vs_format = (string) $o_xml->format; $vs_medium = (string) $o_xml->medium; $vs_place_recorded = (string) $o_xml->placeRecorded; $vs_rights = (string) $o_xml->rights; $vs_extent = (string) $o_xml->extent; $vs_country = (string) $o_xml->countryOfOrigin; $va_interviewers = array(); foreach ($o_xml->interviewer as $o_interviewer) { $va_interviewers[(string) $o_interviewer->attributes()->abbreviation] = (string) $o_interviewer; } $va_participants = array(); foreach ($o_xml->participant as $o_participant) { $va_participants[(string) $o_participant->attributes()->abbreviation] = (string) $o_participant; } $va_observers = array(); if ($o_xml->observer) { foreach ($o_xml->observer as $o_observer) { $va_observers[] = (string) $o_observer; } } // Create object $t_object = new ca_objects(); $t_object->setMode(ACCESS_WRITE); if (!$t_object->load(array('idno' => $vs_idno, 'deleted' => 0))) { $t_object->set('type_id', 'oral_history'); $t_object->set('idno', $vs_idno); $t_object->set('status', 0); $t_object->set('access', 1); } $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'dc_format' => $vs_format), 'dc_format'); $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'dates_value' => $vs_date_created, 'dc_dates_types' => 'created'), 'date'); $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'medium' => $vs_medium), 'medium'); $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'interview_location' => $vs_place_recorded), 'interview_location'); $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'rights' => $vs_rights), 'rights'); $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'extent' => $vs_extent), 'extent'); $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'countryOfOrigin' => $vs_country), 'countryOfOrigin'); if (!$t_object->getPrimaryKey()) { $t_object->insert(); DataMigrationUtils::postError($t_object, 'While inserting object'); if ($t_object->numErrors()) { $o_log->logError("While adding object for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } $t_object->addLabel(array('name' => $vs_title), $pn_locale_id, null, true); DataMigrationUtils::postError($t_object, 'While adding object label'); if ($t_object->numErrors()) { $o_log->logError("While adding object label for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } } else { $t_object->update(); DataMigrationUtils::postError($t_object, 'While updating object'); if ($t_object->numErrors()) { $o_log->logError("While updating object for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } } // add entities foreach ($va_interviewers as $vs_abbr => $vs_name) { $vn_entity_id = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName($vs_name), 'ind', $pn_locale_id); $t_object->addRelationship('ca_entities', $vn_entity_id, 'interviewer'); DataMigrationUtils::postError($t_object, "While adding interviewer {$vs_name} to object"); if ($t_object->numErrors()) { $o_log->logError("While adding interview {$vs_name} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } } foreach ($va_participants as $vs_abbr => $vs_name) { $vn_entity_id = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName($vs_name), 'ind', $pn_locale_id); $t_object->addRelationship('ca_entities', $vn_entity_id, 'interviewee'); DataMigrationUtils::postError($t_object, "While adding interviewee {$vs_name} to object"); if ($t_object->numErrors()) { $o_log->logError("While adding interviee {$vs_name} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } } foreach ($va_observers as $vn_i => $vs_name) { $vn_entity_id = DataMigrationUtils::getEntityID(DataMigrationUtils::splitEntityName($vs_name), 'ind', $pn_locale_id); $t_object->addRelationship('ca_entities', $vn_entity_id, 'observer'); DataMigrationUtils::postError($t_object, "While adding observer {$vs_name} to object"); if ($t_object->numErrors()) { $o_log->logError("While adding observer {$vs_name} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } } // Add media $t_rep = $t_object->addRepresentation($vs_media_path, "front", $pn_locale_id, 0, 1, true, array(), array('returnRepresentation' => true)); DataMigrationUtils::postError($t_object, "While adding representation {$vs_media_path} to object"); if ($t_object->numErrors()) { $o_log->logError("While adding representation {$vs_media_path} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_object->getErrors())); } if ($t_object->numErrors()) { continue; } $va_clips = array(); foreach ($o_xml->clip as $o_clip) { $vs_content = nl2br(preg_replace('!^[\\n\\r\\t]+!', '', trim((string) $o_clip->asXML()))); $vs_start = (string) $o_clip->attributes()->start; $va_themes = $va_places = array(); foreach ($o_clip->children() as $o_node) { $vs_tag = (string) $o_node->getName(); switch ($vs_tag) { case 'place': $va_places[] = (string) $o_node; break; default: $va_themes[] = $vs_tag; break; } } $va_clips[] = array('start' => $vs_start, 'content' => $vs_content, 'themes' => $va_themes, 'places' => $va_places); } foreach ($va_clips as $vn_i => $va_clip) { $vs_start = $va_clip['start']; if (!($vs_end = $va_clips[$vn_i + 1]['start'])) { $va_info = $t_rep->getMediaInfo('media', 'original'); $vs_end = $va_info['PROPERTIES']['duration']; } //print "[$vs_start/$vs_end] (".join('/', $va_clip['themes'])."); (".join('/', $va_clip['places']).") ".substr($va_clip['content'], 0, 30)."\n\n\n"; $t_annotation = $t_rep->addAnnotation("{$vs_start} ... {$vs_end}", $pn_locale_id, 1, array('startTimecode' => $vs_start, 'endTimecode' => $vs_end), 0, 1, array('transcription' => $va_clip['content']), array('returnAnnotation' => true)); DataMigrationUtils::postError($t_rep, "While adding annotation to representation"); if ($t_rep->numErrors()) { $o_log->logError("While adding annotation {$vs_start}/{$vs_end} to {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_rep->getErrors())); } if ($t_annotation) { foreach ($va_clip['themes'] as $vs_theme) { $t_annotation->addRelationship('ca_list_items', $vs_theme, 'describes'); DataMigrationUtils::postError($t_annotation, "While adding theme {$vs_theme} to annotation"); if ($t_annotation->numErrors()) { $o_log->logError("While adding theme {$vs_theme} to annotation {$vs_start}/{$vs_end} for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_annotation->getErrors())); } } foreach ($va_clip['places'] as $vs_place) { if ($vn_place_id = ca_places::find(array('preferred_labels' => array('name' => $vs_place)), array('returnAs' => 'firstId'))) { $t_annotation->addRelationship('ca_places', $vn_place_id, 'describes'); DataMigrationUtils::postError($t_annotation, "While adding place {$vs_place} to annotation"); if ($t_annotation->numErrors()) { $o_log->logError("While adding place {$vs_place} to annotation {$vs_start}/{$vs_end} for {$vs_transcript_dir}{$vs_file}: " . join("; ", $t_annotation->getErrors())); } } } } } $o_log->logInfo("Imported {$vs_file}"); } $o_progress->finish("Completed processing"); if ($o_log) { $o_log->logDebug(_t("Ended oral history import")); } return true; }
/** * Returns name of hierarchy for currently loaded row or, if specified, row identified by optional $pn_id parameter * * @param int $pn_id Optional object_id to return hierarchy name for. If not specified, the currently loaded row is used. * @return string The name of the hierarchy */ public function getHierarchyName($pn_id = null) { if (!$pn_id) { $pn_id = $this->getPrimaryKey(); } $va_ancestors = $this->getHierarchyAncestors($pn_id, array('idsOnly' => true)); if (is_array($va_ancestors) && sizeof($va_ancestors)) { $vn_parent_id = array_pop($va_ancestors); $t_object = new ca_objects($vn_parent_id); return $t_object->getLabelForDisplay(false); } else { if ($pn_id == $this->getPrimaryKey()) { return $this->getLabelForDisplay(true); } else { $t_object = new ca_objects($pn_id); return $t_object->getLabelForDisplay(true); } } }
} ?> <div id="splashBrowsePanel" class="browseSelectPanel" style="z-index:1000;"> <a href="#" onclick="caUIBrowsePanel.hideBrowsePanel()" class="browseSelectPanelButton"></a> <div id="splashBrowsePanelContent"> </div> </div> <script type="text/javascript"> var caUIBrowsePanel = caUI.initBrowsePanel({ facetUrl: '<?php print caNavUrl($this->request, '', 'Browse', 'getFacet'); ?> '}); </script><pre> <?php $t_featured = new ca_objects($this->getVar("featured_content_id")); $t_info = $t_featured->getPrimaryRepresentation(array('mediumlarge'), null, array('return_with_access' => $va_access_values)); $vn_image_height = $t_info['info']['mediumlarge']['HEIGHT']; $vn_padding_top_bottom = (450 - $vn_image_height) / 2; ?> </pre> <div id="hpFeatured"> <table cellpadding="0" cellspacing="0"><tr><td valign="middle" align="center"><div> <img src='<?php print $this->request->getThemeUrlPath(); ?> /graphics/ladyliberty.png' border='0'> <?php # print caNavLink($this->request, $this->getVar("featured_content_mediumlarge"), '', 'Detail', 'Object', 'Show', array('object_id' => $this->getVar("featured_content_id"))); ?> </div></td></tr></table>
closeSelector: '.close', onLoad: function() { // #bristolboxContent is what actually gets filled with content; #bristolbox wraps #bristolboxContent... if we loaded directly into #bristolbox then we'd have a harder time controlling presentation in some cases. jQuery('#bristolboxContent').load('<?php print caNavUrl($this->request, 'bristol', 'Show', 'setItemInfo', array('set_id' => $t_set->get("set_id"))); ?> /set_item_id/' + item_id); }, onClose: function() { jQuery('#bristolboxContent').html(''); } }); } </script> <?php $t_object = new ca_objects(); foreach ($va_items as $va_item) { $t_object->load($va_item['row_id']); ?> <a href="#" onclick="showOverlayForItem(<?php print $va_item['item_id']; ?> ); return false;"> <div class="setItemContainer"> <div class="setItem" id="item<?php print $va_item['item_id']; ?> "><?php print $va_item['representation_tag_widepreview']; ?>
?> <!--</div>--> <?php #$va_media_array = array_slice($va_media_array, 0); $i = 0; foreach ($va_item_media as $vn_object_id => $va_media) { # print "<pre>"; # print_r($va_media); # print "</pre>"; if ($i != 0) { $t_object = new ca_objects($vn_object_id); $vs_image_tag = $va_media["tags"]["widepreview"]; print "<div class='featuredImg'>" . caNavLink($this->request, $vs_image_tag, '', 'Detail', 'Object', 'Show', array('object_id' => $vn_object_id)); print "<div class='featuredTitleSmall'>" . caNavLink($this->request, $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => array('artist'))), '', 'Detail', 'Object', 'Show', array('object_id' => $vn_object_id)) . "</div></div>"; } else { $t_object = new ca_objects($vn_object_id); print "<div id='hpFeatured'>"; print "<div class='featuredImg' style='margin-bottom:5px'>" . caNavLink($this->request, $va_media["tags"]["splashpic"], '', 'Detail', 'Object', 'Show', array('object_id' => $vn_object_id)) . "</div>"; print "<div class='featuredTitle'>" . caNavLink($this->request, $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => array('artist'))), '', 'Detail', 'Object', 'Show', array('object_id' => $vn_object_id)) . "</div>"; print "</div>"; } if ($i == 3) { print "<div style='clear:both;height:0px; width:100%'></div>"; } $i++; } ?> <div id="newsList" style="width:200px; margin-top:30px;"> <div class="item detail">
$vn_item_count = 0; $va_tooltips = array(); $t_list = new ca_lists(); $vn_i = 0; while ($vn_i < $vn_items_per_page && $vo_result->nextHit()) { $vs_dates = $vo_result->get('ca_occurrences.productionDate'); $vs_class = ""; $vn_item_count++; if ($vn_item_count == 2) { $vs_class = "resultBg"; $vn_item_count = 0; } $vn_occurrence_id = $vo_result->get('ca_occurrences.occurrence_id'); if ($depicts = $vo_result->get('ca_objects.object_id', array('restrictToRelationshipTypes' => array('depicts')))) { $object_id = $depicts; } else { $object_id = $vo_result->get('ca_objects.object_id'); } $t_object = new ca_objects($object_id); $va_object_media = $t_object->getMediaTag('ca_object_representations.media', 'icon'); $va_labels = $vo_result->getDisplayLabels($this->request); print "<div" . ($vs_class ? " class='{$vs_class}'" : "") . ">"; print caNavLink($this->request, "<div class='resultIcon'>" . $va_object_media . "</div><div class='resultText'> " . join($va_labels, "; "), '', 'Detail', 'Occurrence', 'Show', array('occurrence_id' => $vn_occurrence_id)); if ($vs_dates) { print "<br/> " . $vs_dates; } print "</div></div>\n"; $vn_i++; } print "</div>\n"; }