# -- get the collection type $o_lists = new ca_lists(); $vn_showcase_collection_type_id = $o_lists->getItemIDFromList('collection_types', 'archival_showcase'); $o_collectionSearch = new CollectionSearch(); $o_collectionSearch->addResultFilter("ca_collections.access", "IN", join($va_access_values, ", ")); $o_collectionSearch->addResultFilter("ca_collections.type_id", "=", $vn_showcase_collection_type_id); $o_showcase_collection_results = $o_collectionSearch->search("*"); if ($o_showcase_collection_results->numHits() > 0) { $o_showcase_collection_results->nextHit(); $vn_featured_collection_id = $o_showcase_collection_results->get("ca_collections.collection_id"); $vs_featured_collection_text = strip_tags($o_showcase_collection_results->get("ca_collections.description")); $vs_featured_collection_label = join($o_showcase_collection_results->getDisplayLabels($this->request), "; "); $vs_featured_collection_thumb = ""; # --- get an item from the collection to use it's media as the thumbnail $o_collectionItemSearch = new ObjectSearch(); $o_collectionItemSearch->addResultFilter("ca_collections.collection_id", "=", $o_showcase_collection_results->get("collection_id")); $o_collectionItemSearch->addResultFilter("ca_objects.access", "IN", join($va_access_values, ", ")); $o_collectionItemSearchResults = $o_collectionItemSearch->search("*"); if ($o_collectionItemSearchResults->numHits()) { while ($o_collectionItemSearchResults->nextHit()) { if ($vs_featured_collection_thumb = $o_collectionItemSearchResults->getMediaTag('ca_object_representations.media', 'icon', array('checkAccess' => $va_access_values))) { break; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
/** * Given a item_id (request parameter 'id') returns a list of direct children for use in the hierarchy browser * Returned data is JSON format */ public function Get($pa_additional_query_params = null, $pa_options = null) { $ps_query = $this->request->getParameter('term', pString); $pb_exact = $this->request->getParameter('exact', pInteger); $ps_exclude = $this->request->getParameter('exclude', pString); $va_excludes = explode(";", $ps_exclude); $ps_type = $this->request->getParameter('type', pString); $ps_types = $this->request->getParameter('types', pString); $pb_no_subtypes = (bool) $this->request->getParameter('noSubtypes', pInteger); $pb_quickadd = (bool) $this->request->getParameter('quickadd', pInteger); $pb_no_inline = (bool) $this->request->getParameter('noInline', pInteger); $t_object = new ca_objects(); $t_collection = new ca_collections(); if (!($pn_limit = $this->request->getParameter('limit', pInteger))) { $pn_limit = 100; } $va_items = array(); if (($vn_str_len = mb_strlen($ps_query)) > 0) { if ($vn_str_len < 3) { $pb_exact = true; } // force short strings to be an exact match (using a very short string as a stem would perform badly and return too many matches in most cases) $o_object_search = new ObjectSearch(); $o_collection_search = new CollectionSearch(); $pa_types = array(); if ($ps_types) { $pa_types = explode(';', $ps_types); } else { if ($ps_type) { $pa_types = array($ps_type); } } // Get type_ids $vs_type_query = ''; $va_ids = array(); if (sizeof($pa_types)) { $va_types = $this->opo_item_instance->getTypeList(); $va_types_proc = array(); foreach ($va_types as $vn_type_id => $va_type) { $va_types_proc[$vn_type_id] = $va_types_proc[$va_type['idno']] = $vn_type_id; } foreach ($pa_types as $ps_type) { if (isset($va_types_proc[$ps_type])) { $va_ids[$va_types_proc[$ps_type]] = true; } } $va_ids = array_keys($va_ids); if (sizeof($va_ids) > 0) { $t_list = new ca_lists(); if (!$pb_no_subtypes) { foreach ($va_ids as $vn_id) { $va_children = $t_list->getItemsForList($this->opo_item_instance->getTypeListCode(), array('item_id' => $vn_id, 'idsOnly' => true)); $va_ids = array_merge($va_ids, $va_children); } $va_ids = array_flip(array_flip($va_ids)); } $o_object_search->addResultFilter($this->opo_item_instance->tableName() . '.' . $this->opo_item_instance->getTypeFieldName(), 'IN', join(",", $va_ids)); } } else { $va_ids = null; } // add any additional search elements $vs_additional_query_params = ''; if (is_array($pa_additional_query_params) && sizeof($pa_additional_query_params)) { $vs_additional_query_params = ' AND (' . join(' AND ', $pa_additional_query_params) . ')'; } // add filters if (isset($pa_options['filters']) && is_array($pa_options['filters']) && sizeof($pa_options['filters'])) { foreach ($pa_options['filters'] as $va_filter) { $o_object_search->addResultFilter($va_filter[0], $va_filter[1], $va_filter[2]); } } // do search $va_opts = array('exclude' => $va_excludes, 'limit' => $pn_limit); if ($vn_restrict_to_hier_id = $this->request->getParameter('currentHierarchyOnly', pInteger)) { $o_object_search->addResultFilter('ca_objects.hier_object_id', '=', (int) $vn_restrict_to_hier_id); } $qr_res = $o_object_search->search('(' . $ps_query . (intval($pb_exact) ? '' : '*') . ')' . $vs_type_query . $vs_additional_query_params, array('search_source' => 'Lookup', 'no_cache' => false, 'sort' => 'ca_objects.idno_sort')); $qr_res->setOption('prefetch', $pn_limit); $qr_res->setOption('dontPrefetchAttributes', true); if (is_array($va_objects = caProcessRelationshipLookupLabel($qr_res, new ca_objects(), $va_opts))) { foreach ($va_objects as $vn_object_id => $va_object) { $va_objects[$vn_object_id]['id'] = 'ca_objects-' . $va_objects[$vn_object_id]['id']; } } //if ($vs_hier_fld && ($vn_restrict_to_hier_id = $this->request->getParameter('currentHierarchyOnly', pInteger))) { //$o_collection_search->addResultFilter('ca_collections.hier_collection_id', '=', (int)$vn_restrict_to_hier_id); // How to restrict objects? //} $qr_res = $o_collection_search->search('(' . $ps_query . (intval($pb_exact) ? '' : '*') . ')' . $vs_type_query . $vs_additional_query_params, array('search_source' => 'Lookup', 'no_cache' => false, 'sort' => 'ca_collections.idno_sort')); $qr_res->setOption('prefetch', $pn_limit); $qr_res->setOption('dontPrefetchAttributes', true); if (is_array($va_collections = caProcessRelationshipLookupLabel($qr_res, new ca_collections(), $va_opts))) { foreach ($va_collections as $vn_collection_id => $va_collection) { $va_collections[$vn_collection_id]['id'] = 'ca_collections-' . $va_collections[$vn_collection_id]['id']; } } } if (!is_array($va_objects)) { $va_objects = array(); } if (!is_array($va_collections)) { $va_collections = array(); } if (!sizeof($va_objects) && !sizeof($va_collections)) { $va_objects[-1] = _t('No matches found for <em>%1</em>', $ps_query); } $this->view->setVar('object_list', $va_objects); $this->view->setVar('collection_list', $va_collections); return $this->render(str_replace(' ', '_', 'ajax_object_collection_list_html.php')); }
/** * objects - accept timestamp to find num objects since a time */ private function numObjects($vn_since_timestamp = "") { $o_search = new ObjectSearch(); $o_search->addResultFilter("ca_objects.access", "IN", join(',', $this->opa_access_values)); if ($vn_since_timestamp) { #$o_search->addResultFilter("ca_objects.dates", ">", $vn_since_timestamp); } $qr_res = $o_search->search("*"); return $qr_res->numHits(); }