/** * */ public function getItemInfo() { $ps_search = str_replace('"', '', $this->request->getParameter('search', pString)); $va_values = array(); $t_item = new ca_commerce_order_items(); $o_search = new ObjectSearch(); $qr_res = $o_search->search("ca_objects.idno:\"{$ps_search}\""); if (!$qr_res->numHits()) { $qr_res = $o_search->search($ps_search); } $va_object_ids = array(); while ($qr_res->nextHit()) { $va_object_ids[] = (int) $qr_res->get('ca_objects.object_id'); } $va_items = array('search' => $ps_search, 'matches' => array()); if (sizeof($va_object_ids)) { $o_db = new Db(); $qr_items = $o_db->query("\n\t\t\t\t\tSELECT i.item_id, o.order_id\n\t\t\t\t\tFROM ca_commerce_order_items i\n\t\t\t\t\tINNER JOIN ca_commerce_orders AS o ON o.order_id = i.order_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tobject_id IN (?) AND o.order_type = 'L' AND i.loan_return_date IS NULL\n\t\t\t\t", array($va_object_ids)); while ($qr_items->nextRow()) { $t_item = new ca_commerce_order_items($qr_items->get('item_id')); $t_order = $t_item->getOrder(); $va_values = $t_item->getFieldValuesArray(); $va_values['user'] = $t_order->getOrderTransactionUserName(); // get object label $t_object = $t_item->getItemObject(); $va_values['object'] = $t_object->get('ca_objects.preferred_labels.name'); $va_values['idno'] = $t_object->get('ca_objects.idno'); // generate display dates $va_values['loan_checkout_date_raw'] = $va_values['loan_checkout_date']; $va_values['loan_checkout_date'] = caGetLocalizedDate($va_values['loan_checkout_date'], array('dateFormat' => 'delimited', 'timeOmit' => true)); $va_values['loan_due_date_raw'] = $va_values['loan_due_date']; $va_values['loan_due_date'] = caGetLocalizedDate($va_values['loan_due_date'], array('dateFormat' => 'delimited', 'timeOmit' => true)); if ($va_values['loan_due_date_raw'] < time()) { $va_values['loan_due_date'] .= " (<em>" . _t("Overdue by %1", caFormatInterval(time() - $va_values['loan_due_date_raw'], 2)) . "</em>)"; } $va_values['order_number'] = $t_order->getOrderNumber(); $va_rep = $t_object->getPrimaryRepresentation(array('thumbnail')); $va_values['thumbnail_tag'] = $va_rep['tags']['thumbnail']; $va_items['matches'][] = $va_values; } } $this->view->setVar('items', $va_items); return $this->render('ajax_order_item_info_json.php'); }
public function testInsertLoadAndDeleteCycleWithCaObjectsModel() { $t_list = new ca_lists(); $va_object_types = $t_list->getItemsForList('object_types'); $this->assertGreaterThan(0, sizeof($va_object_types), "No object types available"); $va_object_types = caExtractValuesByUserLocale($va_object_types); $this->assertGreaterThan(0, sizeof($va_object_types), "No locale-filtered object types available"); $vn_locale_id = 1; $t_object = new ca_objects(); $t_object->setMode(ACCESS_WRITE); $vn_item_id = 0; foreach ($va_object_types as $va_object_type) { if (intval($va_object_type['is_enabled']) === 1) { $vn_item_id = $va_object_type['item_id']; } } $this->assertGreaterThan(0, $vn_item_id, 'No enabled object type found'); $t_object->set('type_id', $vn_item_id); $t_object->set('locale_id', $vn_locale_id); $t_object->set('idno', time()); $t_object->addAttribute(array('description' => 'Test description', 'locale_id' => $vn_locale_id), 'description'); $vb_res = $t_object->insert(); $this->assertTrue($vb_res !== false, 'Insert returned non-true value'); // insert() returns false OR the primary key, therefore simply asserting $vb_res being true doesn't cut it $this->assertEquals($t_object->numErrors(), 0, "Errors on insert: " . join('; ', $t_object->getErrors())); $this->opa_test_record_ids['ca_objects'][] = $t_object->getPrimaryKey(); $vb_res = $t_object->addLabel(array('name' => 'Unit test object'), $vn_locale_id, null, true); $this->assertGreaterThan(0, $vb_res, 'AddLabel returned zero value but should return non-zero label_id: ' . join('; ', $t_object->getErrors())); $t_object2 = new ca_objects(); $vb_res = $t_object2->load($t_object->getPrimaryKey()); $this->assertTrue($vb_res, 'Load of newly created record failed [record does not seem to exist or return row id was invalid?]'); $this->assertEquals($t_object2->getLabelForDisplay(), 'Unit test object', 'Retrieved row label does not match'); $this->assertEquals($t_object2->getAttributesForDisplay('description'), 'Test description', 'Retrieved value for attribute "description" does not match expected value'); // try to search for it $o_search = new ObjectSearch(); $qr_hits = $o_search->search("Unit test object"); $this->assertGreaterThan(0, $qr_hits->numHits(), 'Search for ca_object by label found no results'); $vb_found_object = false; while ($qr_hits->nextHit()) { if ($qr_hits->get('object_id') == $t_object->getPrimaryKey()) { $vb_found_object = true; break; } } $this->assertTrue($vb_found_object, 'ca_object was not in returned search results for ca_object by label'); // try delete $t_object->delete(true, array('hard' => true)); $this->assertEquals($t_object->numErrors(), 0, "Errors on delete: " . join('; ', $t_object->getErrors())); }
/** * 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')); }
/** * Returns content for overlay containing details for object representation */ private function _renderMediaView($ps_view_name, $ps_media_context) { $pn_object_id = $this->request->getParameter('object_id', pInteger); $pn_representation_id = $this->request->getParameter('representation_id', pInteger); $pn_year = $this->request->getParameter('year', pInteger); $this->view->setVar("year", $pn_year); $va_periods = $this->ops_periods; $this->view->setVar('object_id', $pn_object_id); $t_object = new ca_objects($pn_object_id); # --- get caption and photocredit $this->view->setVar("caption", $t_object->get("description")); $this->view->setVar("photographer", $t_object->get("provenance")); $t_rep = new ca_object_representations($pn_representation_id); $this->view->setVar('representation_id', $pn_representation_id); $this->view->setVar('t_object_representation', $t_rep); if ($this->request->config->get("dont_enforce_access_settings")) { $va_access_values = array(); } else { $va_access_values = caGetUserAccessValues($this->request); } if (!$t_object->getPrimaryKey()) { die("Invalid object_id"); } if (!$t_rep->getPrimaryKey()) { die("Invalid representation_id"); } if (sizeof($va_access_values) && !in_array($t_object->get('access'), $va_access_values)) { die("Invalid object_id"); } if (sizeof($va_access_values) && !in_array($t_rep->get('access'), $va_access_values)) { die("Invalid rep_id"); } $this->view->setVar('t_display_rep', $t_rep); // Get media for display using configured rules $va_rep_display_info = caGetMediaDisplayInfo($ps_media_context, $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE')); // set version $this->view->setVar('display_version', $va_rep_display_info['display_version']); // set other options $this->view->setVar('display_options', $va_rep_display_info); // Get all representation as icons for navigation # --- do a search for all chronology image objects # --- determine the period from the year foreach ($va_periods as $i => $va_per_info) { if ($pn_year >= $va_per_info["start"] && $pn_year <= $va_per_info["end"]) { $vn_period = $i; break; } } # --- what is year to search by? $vn_y = ""; if ($va_periods[$vn_period]["displayAllYears"] == 1) { $vn_y = $va_periods[$vn_period]["start"] . "-" . $va_periods[$vn_period]["end"]; } else { $vn_y = $pn_year; } # --- get type is for chron images $t_list = new ca_lists(); $vn_chron_images_type_id = $t_list->getItemIDFromList('object_types', 'chronology_image'); $o_obj_search = new ObjectSearch(); $qr_chron_images = $o_obj_search->search("ca_objects.access:1 AND ca_objects.date.parsed_date:\"" . $vn_y . "\" AND ca_objects.type_id:{$vn_chron_images_type_id}", array("sort" => "ca_objects.date.parsed_date", "no_cache" => !$this->opb_cache_searches)); $va_thumbnails = array(); if ($qr_chron_images->numHits() > 0) { $t_image_objects = new ca_objects(); $i = 1; while ($qr_chron_images->nextHit()) { $t_image_objects->load($qr_chron_images->get("ca_objects.object_id")); if ($t_primary_rep = $t_image_objects->getPrimaryRepresentationInstance()) { $va_temp = array(); if (!sizeof($va_access_values) || in_array($t_primary_rep->get('access'), $va_access_values)) { $va_temp["representation_id"] = $t_primary_rep->get("representation_id"); $va_temp["rep_icon"] = $t_primary_rep->getMediaTag('media', 'icon'); $va_temp["rep_tiny"] = $t_primary_rep->getMediaTag('media', 'tinyicon'); $va_temp["object_id"] = $qr_chron_images->get("ca_objects.object_id"); $va_thumbnails[$qr_chron_images->get("ca_objects.object_id")] = $va_temp; if ($vn_getNext == 1) { $this->view->setVar("next_object_id", $qr_chron_images->get("object_id")); $this->view->setVar("next_representation_id", $t_primary_rep->get("representation_id")); $vn_getNext = 0; } if ($qr_chron_images->get("object_id") == $pn_object_id) { $this->view->setVar("representation_index", $i); $this->view->setVar("previous_object_id", $vn_prev_obj_id); $this->view->setVar("previous_representation_id", $vn_prev_rep_id); $vn_getNext = 1; } $vn_prev_obj_id = $qr_chron_images->get("object_id"); $vn_prev_rep_id = $t_primary_rep->get("representation_id"); $i++; } } } } $this->view->setVar('reps', $va_thumbnails); return $this->render("Chronology/{$ps_view_name}.php"); }
public function testChildrenGet() { $o_search = new ObjectSearch(); $qr_res = $o_search->search('ca_objects.idno:' . $this->ops_object_idno); $qr_res->nextHit(); // // Get intrinsic field from children // $vs_value = 'CIHP.TEST.1; CIHP.TEST.2'; $va_val = $qr_res->get('ca_objects.children.idno', array('returnAsArray' => false, 'returnAllLocales' => false, 'delimiter' => '; ')); $this->assertInternalType("string", $va_val, "Returned value should be string"); $this->assertEquals($vs_value, $va_val, "Returned value is incorrect"); $vs_value = 'CIHP.TEST.1'; $va_val = $qr_res->get('ca_objects.children.idno', array('returnAsArray' => true, 'returnAllLocales' => false)); $this->assertInternalType("array", $va_val, "Returned value should be array"); $this->assertGreaterThan(0, sizeof($va_val), "Size of returned array should be greater than 0"); $this->assertContains($vs_value, $va_val, "Value in array is incorrect"); $va_val = $qr_res->get('ca_objects.children.idno', array('returnAsArray' => true, 'returnAllLocales' => true)); $this->assertInternalType("array", $va_val, "Returned value should be array"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Second level of returned value should be array"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Third level of returned value should be array"); $va_val = array_shift($va_val); $this->assertContains($vs_value, $va_val, "Value in array is incorrect"); // // Get preferred labels from children // $vs_value = 'Canonical test sub-record No. 1; Canonical test sub-record No. 2'; $va_val = $qr_res->get('ca_objects.children.preferred_labels.name', array('returnAsArray' => false, 'returnAllLocales' => false, 'delimiter' => '; ')); $this->assertInternalType("string", $va_val, "Returned value should be string"); $this->assertEquals($vs_value, $va_val, "Returned value is incorrect"); $va_val = $qr_res->get('ca_objects.children.preferred_labels.name', array('returnAsArray' => true, 'returnAllLocales' => false)); $this->assertInternalType("array", $va_val, "Returned value should be array"); $this->assertGreaterThan(0, sizeof($va_val), "Size of returned array should be greater than 0"); $vs_value = 'Canonical test sub-record No. 1'; $this->assertContains($vs_value, $va_val, "Value in array is incorrect"); $va_val = $qr_res->get('ca_objects.children.preferred_labels.name', array('returnAsArray' => true, 'returnAllLocales' => true)); $this->assertInternalType("array", $va_val, "Returned value should be array"); $this->assertGreaterThan(0, sizeof($va_val), "Size of returned array should be greater than 0"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Second level of returned value should be array"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Third level of returned value should be array"); $this->assertContains($vs_value, $va_val, "Value in array is incorrect"); // // Get attributes from children // $va_val = $qr_res->get('ca_objects.children.description', array('returnAsArray' => false, 'returnAllLocales' => false)); $this->assertInternalType("string", $va_val, "Returned value should be string"); $va_val = $qr_res->get('ca_objects.children.description', array('returnAsArray' => true, 'returnAllLocales' => false)); $this->assertInternalType("array", $va_val, "Returned value should be array"); $this->assertGreaterThan(0, sizeof($va_val), "Size of returned array should greater than 0"); $this->assertArrayHasKey('description', $va_tmp = array_shift($va_val), "Returned array should have key 'description'"); $va_val = $qr_res->get('ca_objects.children.description', array('returnAsArray' => true, 'returnAllLocales' => true)); $this->assertInternalType("array", $va_val, "Returned value should be array"); $this->assertGreaterThan(0, sizeof($va_val), "Size of returned array should be greater than 0"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Second level of returned value should be array"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Third level of returned value should be array"); $va_val = array_shift($va_val); $this->assertInternalType("array", $va_val, "Fourth level of returned value should be array"); $this->assertArrayHasKey('description', $va_val, "Returned array should have key 'description'"); }
$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> <title><?php print $this->request->config->get('html_page_title');
/** * */ public function Get() { $ps_query = $this->request->getParameter('term', pString); $o_search = new ObjectSearch(); $qr_res = $o_search->search($ps_query); $va_object_ids = array(); while ($qr_res->nextHit()) { $va_object_ids[$qr_res->get('object_id')] = false; } if (sizeof($va_object_ids)) { // get checked out items $o_db = new Db(); $qr_checked_out_items = $o_db->query("\n\t\t\t\t\tSELECT DISTINCT i.object_id, i.loan_due_date\n\t\t\t\t\tFROM ca_commerce_order_items i\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ti.loan_return_date IS NULL and i.loan_checkout_date > 0 AND i.object_id IN (?)\n\t\t\t\t", array(array_keys($va_object_ids))); while ($qr_checked_out_items->nextRow()) { $va_object_ids[$qr_checked_out_items->get('object_id')] = $qr_checked_out_items->get('loan_due_date'); } $t_object = new ca_objects(); $qr_res = $t_object->makeSearchResult('ca_objects', array_keys($va_object_ids)); $va_items = caProcessRelationshipLookupLabel($qr_res, $t_object, array()); foreach ($va_items as $vn_object_id => $va_object) { if ((int) $va_object_ids[$vn_object_id] > 0) { $vs_due_date_for_display = caGetLocalizedDate($va_object_ids[$vn_object_id], array('format' => 'delimited', 'timeOmit' => true)); $va_items[$vn_object_id]['label'] .= ' [<em>' . _t('on loan through %1', $vs_due_date_for_display) . '</em>]'; $va_items[$vn_object_id]['due_date'] = $va_object_ids[$vn_object_id]; $va_items[$vn_object_id]['due_date_display'] = $vs_due_date_for_display; } } } if (!is_array($va_items)) { $va_items = array(); } if (!sizeof($va_items)) { // nothing found $va_items[0] = array('label' => _t('No matches found'), 'type_id' => null, 'object_id' => 0); } $this->view->setVar('object_list', $va_items); $this->view->setVar('object_id_list', $va_object_ids); return $this->render('ajax_object_list_html.php'); }
private function _doSearch($ps_type, $ps_search, $ps_sort) { $va_access_values = caGetUserAccessValues($this->request); $vb_no_cache = (bool) $this->request->getParameter('no_cache', pInteger); if (!$this->request->user->canDoAction('can_search_' . ($ps_type == 'ca_tour_stops' ? 'ca_tours' : $ps_type))) { return ''; } switch ($ps_type) { case 'ca_objects': $o_object_search = new ObjectSearch(); return $o_object_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_object_lots': $o_object_lots_search = new ObjectLotSearch(); return $o_object_lots_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_entities': $o_entity_search = new EntitySearch(); return $o_entity_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_places': $o_place_search = new PlaceSearch(); return $o_place_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_occurrences': $o_occurrence_search = new OccurrenceSearch(); return $o_occurrence_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_collections': $o_collection_search = new CollectionSearch(); return $o_collection_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_storage_locations': $o_storage_location_search = new StorageLocationSearch(); return $o_storage_location_search->search($ps_search == '*' ? '(ca_storage_locations.is_enabled:1)' : '(' . $ps_search . ') AND (ca_storage_locations.is_enabled:1)', array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_loans': $o_loan_search = new LoanSearch(); return $o_loan_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_movements': $o_movement_search = new MovementSearch(); return $o_movement_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_tours': $o_tour_search = new TourSearch(); return $o_tour_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; case 'ca_tour_stops': $o_tour_stop_search = new TourStopSearch(); return $o_tour_stop_search->search($ps_search, array('sort' => $ps_sort, 'search_source' => 'Quick', 'limit' => $this->opn_num_results_per_item_type, 'no_cache' => $vb_no_cache, 'checkAccess' => $va_access_values)); break; default: return null; break; } }
print "\\\"" . "description" . "\\\":\\\"" . $search_results->get('ca_objects.work_description') . "\\\", <br>"; print "\\\"" . "media" . "\\\":\\\"" . $search_results->get('ca_objects.work_medium') . "\\\", <br>"; print "\\\"" . "Measurements" . "\\\":\\\"" . $search_results->get('ca_objects.work_dimensions', array('convertCodesToDisplayText' => true)) . "\\\", <br>"; print "\\\"" . "work_date" . "\\\":\\\"" . $search_results->get('ca_objects.work_date') . "\\\", <br>"; print "\\\"" . "Creation Date" . "\\\":\\\"" . $search_results->get("ca_objects.date", array('delimiter' => ': ', 'convertCodesToDisplayText' => true)) . "\\\", <br>"; print "\\\"" . "Creator(s)" . "\\\":\\\"" . $search_results->get('ca_objects_x_entities.type', array('delimiter' => '; ', 'convertCodesToDisplayText' => true)) . "\\\", <br>"; //print "\\\"".""."\\\":\\\"".""."\\\", <br>"; //print "\\\"".""."\\\":\\\"".""."\\\", <br>"; //print "\\\"".""."\\\":\\\"".""."\\\", <br>"; //print "\\\"".""."\\\":\\\"".""."\\\", <br>"; //print "\\\"".""."\\\":\\\"".""."\\\", <br>"; print "}fdsh"; } else { $searcher = new ObjectSearch(); //Apparently CA uses Lucene syntax to form queries, should exploit that for advanced search $search_results = $searcher->search($sterm, null); $count = 0; $result = array(); while ($search_results->nextHit()) { $result[] = "{\\\"name\\\" : \\\"" . $search_results->get('ca_objects.preferred_labels.name') . "\\\", \\\"url\\\" : \\\"" . $search_results->getMediaUrl('ca_object_representations.media', "original") . "\\\", \\\"thumb\\\" : \\\"" . $search_results->getMediaUrl('ca_object_representations.media', "thumbnail") . "\\\", \\\"idno\\\" : \\\"" . $search_results->get('idno') . "\\\", \\\"artist\\\" : \\\"" . $search_results->get('ca_entities', array('delimiter' => '; ', 'restrictToRelationshipTypes' => 'artist')) . "\\\", \\\"description\\\" : \\\"" . $search_results->get('ca_objects.description') . "\\\", \\\"id\\\" : \\\"" . $search_results->get('ca_objects.object_id') . "\\\"}"; $count++; //print $search_results->get("ca_object_labels.name_sort"); //print "Hit ".$count.": ".$search_results->get('ca_objects.preferred_labels.name')."<br/>\n"; //print "url: ".$search_results->getMediaUrl('ca_object_representations.media', "original")."<br/>\n"; //print "path: ".$search_results->getMediaPath('ca_object_representations.media', "original")."<br/>\n"; } $i = $start; if ($end == NULL || $end >= $count) { $end = $count; } //maybe use .numHits() and .seek($index)
public function jumpToDetail() { $o_search = new ObjectSearch(); $qr_res = $o_search->search($this->request->getParameter('search', pString)); $va_ids = array(); while ($qr_res->nextHit()) { $va_ids[] = $qr_res->get('ca_objects.object_id'); } $this->view->setVar('ids', $va_ids); $this->render('ajax_object_lookup_json.php'); }
print caNavLink($this->request, $t_object->get("ca_objects.date.display_date"), '', 'Chronology', 'Detail', '', array('year' => $vn_start_date)); print "<br/>"; } else { print $t_object->get("ca_objects.date.display_date") . "<br/>"; } } # --- display number of sub-items if ($t_object->get("ca_objects.extent")) { print $t_object->get("extent") . " " . _t("example") . ($t_object->get("ca_objects.extent") == 1 ? "" : "s"); } print "</div><!-- end unit -->"; # --------------------------------------------------- # --- display search result like display of child objects if this is a group record # --------------------------------------------------- $o_search = new ObjectSearch(); $vo_result = $o_search->search("ca_objects.access:1 AND ca_objects.parent:{$vn_object_id}", array("sort" => "ca_objects.idno_sort")); #$va_children = $t_object->get("ca_objects.children.preferred_labels", array('returnAsArray' => 1, 'checkAccess' => $va_access_values)); #print "<pre>"; #print_r($va_children); #print "</pre>"; $va_tooltips = array(); $col = 0; print "<div style='clear:right; margin:20px 0px 20px 0px;'>"; $va_child_artworks = array(); while ($vo_result->nextHit()) { if ($vo_result->get("ca_objects.object_id") != $vn_object_id) { $va_child_artworks[] = $vo_result->get("ca_objects.object_id"); if (!($vs_idno = $vo_result->get('ca_objects.idno'))) { $vs_idno = "???"; } $vn_child_object_id = $vo_result->get('ca_objects.object_id');
/** * 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(); }
function RefineSearch() { $vs_refine = ""; $pn_entity_id = $this->request->getParameter('entity_id', pInteger); $this->view->setVar('entity_id', $pn_entity_id); $t_entity = new ca_entities($pn_entity_id); $this->view->setVar('entity_name', $t_entity->getLabelForDisplay()); if ($pn_entity_id) { $vs_refine = " AND ca_entities.entity_id:" . $pn_entity_id; } $pn_occurrence_id = $this->request->getParameter('occurrence_id', pInteger); $this->view->setVar('occurrence_id', $pn_occurrence_id); $t_occurrence = new ca_occurrences($pn_occurrence_id); $this->view->setVar('occurrence_name', $t_occurrence->getLabelForDisplay()); if ($pn_occurrence_id) { $vs_refine = " AND ca_occurrences.occurrence_id:" . $pn_occurrence_id; } # --- style school $pn_item_id = $this->request->getParameter('item_id', pInteger); $this->view->setVar('item_id', $pn_item_id); $t_list_item = new ca_list_items($pn_item_id); $this->view->setVar('style_school_name', $t_list_item->getLabelForDisplay()); if ($pn_item_id) { $vs_refine = " AND ca_objects.style_school:" . $pn_item_id; } $vn_y = $this->ops_date_range; $va_period_data = array(); $o_obj_search_refine = new ObjectSearch(); $qr_objects_refine = $o_obj_search_refine->search("ca_objects.creation_date:\"" . $vn_y . "\" AND (ca_object.object_status:349 OR ca_object.object_status:347 OR ca_object.object_status:193)" . $vs_refine, array("sort" => "ca_objects.creation_date", "no_cache" => !$this->opb_cache_searches, "checkAccess" => $this->opa_access_values)); $va_object_ids = array(); while ($qr_objects_refine->nextHit()) { $va_object_ids[] = $qr_objects_refine->get("ca_objects.object_id"); } $qr_objects_refine->seek(0); $this->opo_result_context->setAsLastFind(); $this->opo_result_context->setResultList($va_object_ids); $this->opo_result_context->setParameter("period", $this->opn_period); $this->opo_result_context->saveContext(); $va_period_data["objects"] = $qr_objects_refine; $this->view->setVar('period_data', $va_period_data); $this->render('chronology_object_results_html.php'); }