/** * */ public function __call($ps_function, $pa_args) { $o_config = caGetBrowseConfig(); $o_search_config = caGetSearchConfig(); $pa_options = array_shift($pa_args); $vb_is_advanced = (bool) $this->request->getParameter('_advanced', pInteger); $vs_find_type = $vb_is_advanced ? $this->ops_find_type . '_advanced' : $this->ops_find_type; $this->view->setVar("config", $o_config); $ps_function = strtolower($ps_function); $ps_type = $this->request->getActionExtra(); $this->view->setVar("browse_type", $ps_function); if (!($va_browse_info = caGetInfoForBrowseType($ps_function))) { // invalid browse type – throw error die("Invalid browse type {$ps_function}"); } $vs_class = $va_browse_info['table']; $va_types = caGetOption('restrictToTypes', $va_browse_info, array(), array('castTo' => 'array')); $this->opo_result_context = new ResultContext($this->request, $va_browse_info['table'], $vs_find_type); $this->opo_result_context->setAsLastFind(); MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Search %1", $va_browse_info["displayName"]) . ": " . $this->opo_result_context->getSearchExpression()); if ($vb_is_advanced) { $this->opo_result_context->setSearchExpression(caGetQueryStringForHTMLFormInput($this->opo_result_context)); } $this->view->setVar('browseInfo', $va_browse_info); $this->view->setVar('options', caGetOption('options', $va_browse_info, array(), array('castTo' => 'array'))); $ps_view = caGetOption('view', $pa_options, $this->request->getParameter('view', pString)); $va_views = caGetOption('views', $va_browse_info, array(), array('castTo' => 'array')); if (!is_array($va_views) || sizeof($va_views) == 0) { $va_views = array('list' => array(), 'images' => array(), 'timeline' => array(), 'map' => array(), 'timelineData' => array(), 'pdf' => array()); } else { $va_views['pdf'] = array(); } if (!in_array($ps_view, array_keys($va_views))) { $ps_view = array_shift(array_keys($va_views)); } $vs_format = $ps_view == 'timelineData' ? 'json' : 'html'; #caAddPageCSSClasses(array($vs_class, $ps_function, $ps_view)); caAddPageCSSClasses(array($vs_class, $ps_function)); $this->view->setVar('isNav', (bool) $this->request->getParameter('isNav', pInteger)); // flag for browses that originate from nav bar $t_instance = $this->getAppDatamodel()->getInstanceByTableName($vs_class, true); $vn_type_id = $t_instance->getTypeIDForCode($ps_type); $this->view->setVar('t_instance', $t_instance); $this->view->setVar('table', $va_browse_info['table']); $this->view->setVar('primaryKey', $t_instance->primaryKey()); $this->view->setVar('browse', $o_browse = caGetBrowseInstance($vs_class)); $this->view->setVar('views', caGetOption('views', $va_browse_info, array(), array('castTo' => 'array'))); $this->view->setVar('view', $ps_view); $this->view->setVar('viewIcons', $o_config->getAssoc("views")); // // Load existing browse if key is specified // if ($ps_cache_key = $this->request->getParameter('key', pString)) { $o_browse->reload($ps_cache_key); } if (is_array($va_types) && sizeof($va_types)) { $o_browse->setTypeRestrictions($va_types); } // // Clear criteria if required // if ($vs_remove_criterion = $this->request->getParameter('removeCriterion', pString)) { $o_browse->removeCriteria($vs_remove_criterion, array($this->request->getParameter('removeID', pString))); } if ((bool) $this->request->getParameter('clear', pInteger)) { $o_browse->removeAllCriteria(); } if ($this->request->getParameter('getFacet', pInteger)) { $vs_facet = $this->request->getParameter('facet', pString); $this->view->setVar('facet_name', $vs_facet); $this->view->setVar('key', $o_browse->getBrowseID()); $va_facet_info = $o_browse->getInfoForFacet($vs_facet); $this->view->setVar('facet_info', $va_facet_info); # --- pull in different views based on format for facet - alphabetical, list, hierarchy switch ($va_facet_info["group_mode"]) { case "alphabetical": case "list": default: $this->view->setVar('facet_content', $o_browse->getFacetContent($vs_facet, array("checkAccess" => $this->opa_access_values))); $this->render("Browse/list_facet_html.php"); break; case "hierarchical": $this->render("Browse/hierarchy_facet_html.php"); break; } return; } // // Add criteria and execute // $vs_search_expression = $this->opo_result_context->getSearchExpression(); if ($vs_facet = $this->request->getParameter('facet', pString)) { $o_browse->addCriteria($vs_facet, array($this->request->getParameter('id', pString))); } else { if ($o_browse->numCriteria() == 0) { $o_browse->addCriteria("_search", array($vs_search_expression . ($o_search_config->get('matchOnStem') && !preg_match('!\\*$!', $vs_search_expression) && preg_match('![\\w]+$!', $vs_search_expression) ? '*' : ''))); } } // // Sorting // $vb_sort_changed = false; $o_block_result_context = null; if (!($ps_sort = $this->request->getParameter("sort", pString))) { // inherit sort setting from multisearch? (used when linking to full results from multisearch result) if ($this->request->getParameter("source", pString) === 'multisearch') { $o_block_result_context = new ResultContext($this->request, $va_browse_info['table'], 'multisearch', $ps_function); if ($ps_sort !== $o_block_result_context->getCurrentSort() && $o_block_result_context->getCurrentSort()) { $ps_sort = $o_block_result_context->getCurrentSort(); $vb_sort_changed = true; } } if (!$ps_sort && !($ps_sort = $this->opo_result_context->getCurrentSort())) { if (is_array($va_sorts = caGetOption('sortBy', $va_browse_info, null))) { $ps_sort = array_shift(array_keys($va_sorts)); $vb_sort_changed = true; } } } else { $vb_sort_changed = true; } if ($vb_sort_changed) { # --- set the default sortDirection if available $va_sort_direction = caGetOption('sortDirection', $va_browse_info, null); if ($ps_sort_direction = $va_sort_direction[$ps_sort]) { $this->opo_result_context->setCurrentSortDirection($ps_sort_direction); } } if (!($ps_sort_direction = $this->request->getParameter("direction", pString))) { if (!($ps_sort_direction = $this->opo_result_context->getCurrentSortDirection())) { $ps_sort_direction = 'asc'; } } $this->opo_result_context->setCurrentSort($ps_sort); $this->opo_result_context->setCurrentSortDirection($ps_sort_direction); $va_sort_by = caGetOption('sortBy', $va_browse_info, null); $this->view->setVar('sortBy', is_array($va_sort_by) ? $va_sort_by : null); $this->view->setVar('sortBySelect', $vs_sort_by_select = is_array($va_sort_by) ? caHTMLSelect("sort", $va_sort_by, array('id' => "sort"), array("value" => $ps_sort)) : ''); $this->view->setVar('sortControl', $vs_sort_by_select ? _t('Sort with %1', $vs_sort_by_select) : ''); $this->view->setVar('sort', $ps_sort); $this->view->setVar('sort_direction', $ps_sort_direction); $va_options = array('checkAccess' => $this->opa_access_values); if ($va_restrict_to_fields = caGetOption('restrictSearchToFields', $va_browse_info, null)) { $va_options['restrictSearchToFields'] = $va_restrict_to_fields; } if (caGetOption('dontShowChildren', $va_browse_info, false)) { $o_browse->addResultFilter('ca_objects.parent_id', 'is', 'null'); } $o_browse->execute($va_options); // // Facets // if ($vs_facet_group = caGetOption('facetGroup', $va_browse_info, null)) { $o_browse->setFacetGroup($vs_facet_group); } $va_available_facet_list = caGetOption('availableFacets', $va_browse_info, null); $va_facets = $o_browse->getInfoForAvailableFacets(); if (is_array($va_available_facet_list) && sizeof($va_available_facet_list)) { foreach ($va_facets as $vs_facet_name => $va_facet_info) { if (!in_array($vs_facet_name, $va_available_facet_list)) { unset($va_facets[$vs_facet_name]); } } } foreach ($va_facets as $vs_facet_name => $va_facet_info) { $va_facets[$vs_facet_name]['content'] = $o_browse->getFacetContent($vs_facet_name, array("checkAccess" => $this->opa_access_values)); } $this->view->setVar('facets', $va_facets); $this->view->setVar('key', $vs_key = $o_browse->getBrowseID()); $this->request->session->setVar($ps_function . '_last_browse_id', $vs_key); // // Current criteria // $va_criteria = $o_browse->getCriteriaWithLabels(); if (isset($va_criteria['_search']) && isset($va_criteria['_search']['*'])) { unset($va_criteria['_search']); } $va_criteria_for_display = array(); foreach ($va_criteria as $vs_facet_name => $va_criterion) { $va_facet_info = $o_browse->getInfoForFacet($vs_facet_name); foreach ($va_criterion as $vn_criterion_id => $vs_criterion) { $va_criteria_for_display[] = array('facet' => $va_facet_info['label_singular'], 'facet_name' => $vs_facet_name, 'value' => $vs_criterion, 'id' => $vn_criterion_id); } } $this->view->setVar('criteria', $va_criteria_for_display); // // Results // $qr_res = $o_browse->getResults(array('sort' => $va_sort_by[$ps_sort], 'sort_direction' => $ps_sort_direction)); $this->view->setVar('result', $qr_res); if (!($pn_hits_per_block = $this->request->getParameter("n", pString))) { if (!($pn_hits_per_block = $this->opo_result_context->getItemsPerPage())) { $pn_hits_per_block = $o_config->get("defaultHitsPerBlock"); } } $this->opo_result_context->getItemsPerPage($pn_hits_per_block); $this->view->setVar('hits_per_block', $pn_hits_per_block); $this->view->setVar('start', $vn_start = $this->request->getParameter('s', pInteger)); $this->opo_result_context->setParameter('key', $vs_key); if (($vn_key_start = $vn_start - 500) < 0) { $vn_key_start = 0; } $qr_res->seek($vn_key_start); $this->opo_result_context->setResultList($qr_res->getPrimaryKeyValues(1000)); if ($o_block_result_context) { $o_block_result_context->setResultList($qr_res->getPrimaryKeyValues(1000)); $o_block_result_context->saveContext(); } $qr_res->seek($vn_start); $this->opo_result_context->saveContext(); if ($vn_type_id) { if ($this->render("Browse/{$vs_class}_{$vs_type}_{$ps_view}_{$vs_format}.php")) { return; } } switch ($ps_view) { case 'pdf': $this->_genExport($qr_res, $this->request->getParameter("export_format", pString), $vs_search_expression, $vs_search_expression); break; case 'timelineData': $this->view->setVar('view', 'timeline'); $this->render("Browse/browse_results_timelineData_json.php"); break; default: $this->render("Browse/browse_results_html.php"); break; } }
/** * */ public function __call($ps_function, $pa_args) { AssetLoadManager::register("panel"); AssetLoadManager::register("mediaViewer"); AssetLoadManager::register("carousel"); AssetLoadManager::register("readmore"); AssetLoadManager::register("maps"); $ps_function = strtolower($ps_function); $ps_id = urldecode($this->request->getActionExtra()); if (!isset($this->opa_detail_types[$ps_function]) || !isset($this->opa_detail_types[$ps_function]['table']) || !($vs_table = $this->opa_detail_types[$ps_function]['table'])) { // invalid detail type – throw error die("Invalid detail type"); } $t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true); if (($vb_use_identifiers_in_urls = caUseIdentifiersInUrls()) && substr($ps_id, 0, 3) == "id:") { $va_tmp = explode(":", $ps_id); $ps_id = (int) $va_tmp[1]; $vb_use_identifiers_in_urls = false; } if (!$t_table->load($vb_use_identifiers_in_urls && $t_table->getProperty('ID_NUMBERING_ID_FIELD') ? $t_table->hasField('deleted') ? array($t_table->getProperty('ID_NUMBERING_ID_FIELD') => $ps_id, 'deleted' => 0) : array($t_table->getProperty('ID_NUMBERING_ID_FIELD') => $ps_id) : ($t_table->hasField('deleted') ? array($t_table->primaryKey() => (int) $ps_id, 'deleted' => 0) : array($t_table->primaryKey() => (int) $ps_id)))) { // invalid id - throw error die("Invalid id"); } // Printables // merge displays with drop-in print templates // $va_export_options = caGetAvailablePrintTemplates('summary', array('table' => $t_table->tableName())); $this->view->setVar('export_formats', $va_export_options); $va_options = array(); foreach ($va_export_options as $vn_i => $va_format_info) { $va_options[$va_format_info['name']] = $va_format_info['code']; } // Get current display list $t_display = new ca_bundle_displays(); foreach (caExtractValuesByUserLocale($t_display->getBundleDisplays(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'checkAccess' => caGetUserAccessValues($this->request)))) as $va_display) { $va_options[$va_display['name']] = "_display_" . $va_display['display_id']; } ksort($va_options); $this->view->setVar('export_format_select', caHTMLSelect('export_format', $va_options, array('class' => 'searchToolsSelect'), array('value' => $this->view->getVar('current_export_format'), 'width' => '150px'))); # # Enforce access control # if (sizeof($this->opa_access_values) && $t_table->hasField('access') && !in_array($t_table->get("access"), $this->opa_access_values)) { $this->notification->addNotification(_t("This item is not available for view"), "message"); $this->response->setRedirect(caNavUrl($this->request, "", "", "", "")); return; } MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . $t_table->getTypeName() . ": " . $t_table->get('preferred_labels') . (($vs_idno = $t_table->get($t_table->getProperty('ID_NUMBERING_ID_FIELD'))) ? " [{$vs_idno}]" : "")); $vs_type = $t_table->getTypeCode(); $this->view->setVar('detailType', $vs_table); $this->view->setVar('item', $t_table); $this->view->setVar('itemType', $vs_type); caAddPageCSSClasses(array($vs_table, $ps_function, $vs_type)); // Do we need to pull in the multisearch result set? if (ResultContext::getLastFind($this->request, $vs_table, array('noSubtype' => true)) === 'multisearch') { $o_context = new ResultContext($this->request, $vs_table, 'multisearch', $ps_function); $o_context->setAsLastFind(); $o_context->saveContext(); } else { $o_context = ResultContext::getResultContextForLastFind($this->request, $vs_table); } $this->view->setVar('previousID', $vn_previous_id = $o_context->getPreviousID($t_table->getPrimaryKey())); $this->view->setVar('nextID', $vn_next_id = $o_context->getNextID($t_table->getPrimaryKey())); $this->view->setVar('previousURL', caDetailUrl($this->request, $vs_table, $vn_previous_id)); $this->view->setVar('nextURL', caDetailUrl($this->request, $vs_table, $vn_next_id)); $this->view->setVar('resultsURL', ResultContext::getResultsUrlForLastFind($this->request, $vs_table)); $va_options = isset($this->opa_detail_types[$ps_function]['options']) && is_array($this->opa_detail_types[$ps_function]['options']) ? $this->opa_detail_types[$ps_function]['options'] : array(); $this->view->setVar('previousLink', $vn_previous_id > 0 ? caDetailLink($this->request, caGetOption('previousLink', $va_options, _t('Previous')), '', $vs_table, $vn_previous_id) : ''); $this->view->setVar('nextLink', $vn_next_id > 0 ? caDetailLink($this->request, caGetOption('nextLink', $va_options, _t('Next')), '', $vs_table, $vn_next_id) : ''); $this->view->setVar('resultsLink', ResultContext::getResultsLinkForLastFind($this->request, $vs_table, caGetOption('resultsLink', $va_options, _t('Back')))); $this->view->setVar('commentsEnabled', (bool) $va_options['enableComments']); // // // if (method_exists($t_table, 'getPrimaryRepresentationInstance')) { if ($pn_representation_id = $this->request->getParameter('representation_id', pInteger)) { $t_representation = $this->opo_datamodel->getInstanceByTableName("ca_object_representations", true); $t_representation->load($pn_representation_id); } else { $t_representation = $t_table->getPrimaryRepresentationInstance(array("checkAccess" => $this->opa_access_values)); } if ($t_representation) { $this->view->setVar("t_representation", $t_representation); $this->view->setVar("representation_id", $t_representation->get("representation_id")); } else { $t_representation = $this->opo_datamodel->getInstanceByTableName("ca_object_representations", true); } $this->view->setVar("representationViewer", caObjectDetailMedia($this->request, $t_table->getPrimaryKey(), $t_representation, $t_table, array("primaryOnly" => caGetOption('representationViewerPrimaryOnly', $va_options, false), "dontShowPlaceholder" => caGetOption('representationViewerDontShowPlaceholder', $va_options, false)))); } // // map // if (!is_array($va_map_attributes = caGetOption('map_attributes', $va_options, array())) || !sizeof($va_map_attributes)) { if ($vs_map_attribute = caGetOption('map_attribute', $va_options, false)) { $va_map_attributes = array($vs_map_attribute); } } $this->view->setVar("map", ""); if (is_array($va_map_attributes) && sizeof($va_map_attributes)) { $o_map = new GeographicMap(($vn_width = caGetOption('map_width', $va_options, false)) ? $vn_width : 285, ($vn_height = caGetOption('map_height', $va_options, false)) ? $vn_height : 200, 'map'); $vn_mapped_count = 0; foreach ($va_map_attributes as $vs_map_attribute) { if ($t_table->get($vs_map_attribute)) { $o_map->mapFrom($t_table, $vs_map_attribute); $vn_mapped_count++; } } if ($vn_mapped_count > 0) { $this->view->setVar("map", $o_map->render('HTML')); } } // // comments, tags, rank // $this->view->setVar('averageRank', $t_table->getAverageRating(true)); $this->view->setVar('numRank', $t_table->getNumRatings(true)); # # User-generated comments, tags and ratings # $va_user_comments = $t_table->getComments(null, true); $va_comments = array(); if (is_array($va_user_comments)) { foreach ($va_user_comments as $va_user_comment) { if ($va_user_comment["comment"] || $va_user_comment["media1"] || $va_user_comment["media2"] || $va_user_comment["media3"] || $va_user_comment["media4"]) { # TODO: format date based on locale $va_user_comment["date"] = date("n/j/Y", $va_user_comment["created_on"]); # -- get name of commenter if ($va_user_comment["user_id"]) { $t_user = new ca_users($va_user_comment["user_id"]); $va_user_comment["author"] = $t_user->getName(); } elseif ($va_user_comment["name"]) { $va_user_comment["author"] = $va_user_comment["name"]; } $va_comments[] = $va_user_comment; } } } $this->view->setVar('comments', $va_comments); $va_user_tags = $t_table->getTags(null, true); $va_tags = array(); if (is_array($va_user_tags)) { foreach ($va_user_tags as $va_user_tag) { if (!in_array($va_user_tag["tag"], $va_tags)) { $va_tags[] = $va_user_tag["tag"]; } } } $this->view->setVar('tags_array', $va_tags); $this->view->setVar('tags', implode(", ", $va_tags)); $this->view->setVar("itemComments", caDetailItemComments($this->request, $t_table->getPrimaryKey(), $t_table, $va_comments, $va_tags)); // // share link // $this->view->setVar("shareLink", "<a href='#' onclick='caMediaPanel.showPanel(\"" . caNavUrl($this->request, '', 'Detail', 'ShareForm', array("tablename" => $t_table->tableName(), "item_id" => $t_table->getPrimaryKey())) . "\"); return false;'>Share</a>"); // find view // first look for type-specific view if (!$this->viewExists($vs_path = "Details/{$vs_table}_{$vs_type}_html.php")) { // If no type specific view use the default $vs_path = "Details/{$vs_table}_default_html.php"; } switch ($ps_view = $this->request->getParameter('view', pString)) { case 'pdf': $this->_genExport($t_table, $this->request->getParameter("export_format", pString), 'Detail', 'Detail'); break; default: // // Tag substitution // // Views can contain tags in the form {{{tagname}}}. Some tags, such as "itemType" and "detailType" are defined by // the detail controller. More usefully, you can pull data from the item being detailed by using a valid "get" expression // as a tag (Eg. {{{ca_objects.idno}}}. Even more usefully for some, you can also use a valid bundle display template // (see http://docs.collectiveaccess.org/wiki/Bundle_Display_Templates) as a tag. The template will be evaluated in the // context of the item being detailed. // $va_defined_vars = array_keys($this->view->getAllVars()); // get list defined vars (we don't want to copy over them) $va_tag_list = $this->getTagListForView($vs_path); // get list of tags in view foreach ($va_tag_list as $vs_tag) { if (in_array($vs_tag, $va_defined_vars)) { continue; } if (strpos($vs_tag, "^") !== false || strpos($vs_tag, "<") !== false) { $this->view->setVar($vs_tag, $t_table->getWithTemplate($vs_tag, array('checkAccess' => $this->opa_access_values))); } elseif (strpos($vs_tag, ".") !== false) { $this->view->setVar($vs_tag, $t_table->get($vs_tag, array('checkAccess' => $this->opa_access_values))); } else { $this->view->setVar($vs_tag, "?{$vs_tag}"); } } $this->render($vs_path); break; } }
/** * */ public function __call($ps_function, $pa_args) { $o_config = caGetBrowseConfig(); $this->view->setVar("config", $o_config); $ps_function = strtolower($ps_function); $ps_type = $this->request->getActionExtra(); if (!($va_browse_info = caGetInfoForBrowseType($ps_function))) { // invalid browse type – throw error die("Invalid browse type"); } MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Browse %1", $va_browse_info["displayName"])); $this->view->setVar("browse_type", $ps_function); $vs_class = $va_browse_info['table']; $va_types = caGetOption('restrictToTypes', $va_browse_info, array(), array('castTo' => 'array')); $this->opo_result_context = new ResultContext($this->request, $va_browse_info['table'], $this->ops_find_type); // Don't set last find when loading facet, as some other controllers use this action and setting // last find will disrupt ResultContext navigation by setting it to "browse" when in fact a search (or some other // context) is still in effect. if (!$this->request->getParameter('getFacet', pInteger)) { $this->opo_result_context->setAsLastFind(); } $this->view->setVar('browseInfo', $va_browse_info); $this->view->setVar('paging', in_array(strtolower($va_browse_info['paging']), array('continous', 'nextprevious', 'letter')) ? strtolower($va_browse_info['paging']) : 'continous'); $this->view->setVar('name', $va_browse_info['displayName']); $this->view->setVar('options', caGetOption('options', $va_browse_info, array(), array('castTo' => 'array'))); $ps_view = $this->request->getParameter('view', pString); $va_views = caGetOption('views', $va_browse_info, array(), array('castTo' => 'array')); if (!is_array($va_views) || sizeof($va_views) == 0) { $va_views = array('list' => array(), 'images' => array(), 'timeline' => array(), 'map' => array(), 'timelineData' => array(), 'pdf' => array()); } else { $va_views['pdf'] = array(); $va_views['timelineData'] = array(); } if (!in_array($ps_view, array_keys($va_views))) { $ps_view = array_shift(array_keys($va_views)); } $vs_format = $ps_view == 'timelineData' ? 'json' : 'html'; caAddPageCSSClasses(array($vs_class, $ps_function)); $this->view->setVar('isNav', $vb_is_nav = (bool) $this->request->getParameter('isNav', pInteger)); // flag for browses that originate from nav bar $t_instance = $this->getAppDatamodel()->getInstanceByTableName($vs_class, true); $vn_type_id = $t_instance->getTypeIDForCode($ps_type); $this->view->setVar('t_instance', $t_instance); $this->view->setVar('table', $va_browse_info['table']); $this->view->setVar('primaryKey', $t_instance->primaryKey()); $this->view->setVar('browse', $o_browse = caGetBrowseInstance($vs_class)); $this->view->setVar('views', caGetOption('views', $va_browse_info, array(), array('castTo' => 'array'))); $this->view->setVar('view', $ps_view); $this->view->setVar('viewIcons', $o_config->getAssoc("views")); // // Load existing browse if key is specified // if ($ps_cache_key = $this->request->getParameter('key', pString)) { $o_browse->reload($ps_cache_key); } if (is_array($va_types) && sizeof($va_types)) { $o_browse->setTypeRestrictions($va_types, array('dontExpandHierarchically' => caGetOption('dontExpandTypesHierarchically', $va_browse_info, false))); } // // Clear criteria if required // if ($vs_remove_criterion = $this->request->getParameter('removeCriterion', pString)) { $o_browse->removeCriteria($vs_remove_criterion, array($this->request->getParameter('removeID', pString))); } if ((bool) $this->request->getParameter('clear', pInteger)) { $o_browse->removeAllCriteria(); } // // Return facet content // if ($this->request->getParameter('getFacet', pInteger)) { $vs_facet = $this->request->getParameter('facet', pString); $vn_s = $vb_is_nav ? $this->request->getParameter('s', pInteger) : 0; // start menu-based browse menu facet data at page boundary; all others get the full facet $this->view->setVar('start', $vn_s); $this->view->setVar('limit', $vn_limit = $vb_is_nav ? 500 : null); // break facet into pages for menu-based browse menu $this->view->setVar('facet_name', $vs_facet); $this->view->setVar('key', $o_browse->getBrowseID()); $this->view->setVar('facet_info', $va_facet_info = $o_browse->getInfoForFacet($vs_facet)); # --- pull in different views based on format for facet - alphabetical, list, hierarchy switch ($va_facet_info["group_mode"]) { case "alphabetical": case "list": default: $this->view->setVar('facet_content', $o_browse->getFacet($vs_facet, array("checkAccess" => $this->opa_access_values, 'start' => $vn_s, 'limit' => $vn_limit))); $this->render("Browse/list_facet_html.php"); break; case "hierarchical": $this->render("Browse/hierarchy_facet_html.php"); break; } return; } // // Add criteria and execute // // Get any preset-criteria $va_base_criteria = caGetOption('baseCriteria', $va_browse_info, null); if ($vs_facet = $this->request->getParameter('facet', pString)) { $o_browse->addCriteria($vs_facet, array($this->request->getParameter('id', pString))); } else { if ($o_browse->numCriteria() == 0) { if (is_array($va_base_criteria)) { foreach ($va_base_criteria as $vs_facet => $vs_value) { $o_browse->addCriteria($vs_facet, $vs_value); } } else { $o_browse->addCriteria("_search", array("*")); } } } // // Sorting // $vb_sort_changed = false; if (!($ps_sort = $this->request->getParameter("sort", pString))) { if (!($ps_sort = $this->opo_result_context->getCurrentSort())) { if (is_array($va_sorts = caGetOption('sortBy', $va_browse_info, null))) { $ps_sort = array_shift(array_keys($va_sorts)); $vb_sort_changed = true; } } } else { $vb_sort_changed = true; } if ($vb_sort_changed) { # --- set the default sortDirection if available $va_sort_direction = caGetOption('sortDirection', $va_browse_info, null); if ($ps_sort_direction = $va_sort_direction[$ps_sort]) { $this->opo_result_context->setCurrentSortDirection($ps_sort_direction); } } if (!($ps_sort_direction = $this->request->getParameter("direction", pString))) { if (!($ps_sort_direction = $this->opo_result_context->getCurrentSortDirection())) { $ps_sort_direction = 'asc'; } } $this->opo_result_context->setCurrentSort($ps_sort); $this->opo_result_context->setCurrentSortDirection($ps_sort_direction); $va_sort_by = caGetOption('sortBy', $va_browse_info, null); $this->view->setVar('sortBy', is_array($va_sort_by) ? $va_sort_by : null); $this->view->setVar('sortBySelect', $vs_sort_by_select = is_array($va_sort_by) ? caHTMLSelect("sort", $va_sort_by, array('id' => "sort"), array("value" => $ps_sort)) : ''); $this->view->setVar('sortControl', $vs_sort_by_select ? _t('Sort with %1', $vs_sort_by_select) : ''); $this->view->setVar('sort', $ps_sort); $this->view->setVar('sort_direction', $ps_sort_direction); if (caGetOption('dontShowChildren', $va_browse_info, false)) { $o_browse->addResultFilter('ca_objects.parent_id', 'is', 'null'); } // // Current criteria // $va_criteria = $o_browse->getCriteriaWithLabels(); if (isset($va_criteria['_search']) && isset($va_criteria['_search']['*'])) { unset($va_criteria['_search']); } $o_browse->execute(array('checkAccess' => $this->opa_access_values, 'showAllForNoCriteriaBrowse' => true)); // // Facets // if ($vs_facet_group = caGetOption('facetGroup', $va_browse_info, null)) { $o_browse->setFacetGroup($vs_facet_group); } $va_available_facet_list = caGetOption('availableFacets', $va_browse_info, null); $va_facets = $o_browse->getInfoForAvailableFacets(); foreach ($va_facets as $vs_facet_name => $va_facet_info) { if (isset($va_base_criteria[$vs_facet_name])) { continue; } // skip base criteria $va_facets[$vs_facet_name]['content'] = $o_browse->getFacet($vs_facet_name, array("checkAccess" => $this->opa_access_values, 'checkAvailabilityOnly' => caGetOption('deferred_load', $va_facet_info, false, array('castTo' => 'bool')))); } $this->view->setVar('facets', $va_facets); $this->view->setVar('key', $vs_key = $o_browse->getBrowseID()); $this->request->session->setVar($ps_function . '_last_browse_id', $vs_key); // remove base criteria from display list if (is_array($va_base_criteria)) { foreach ($va_base_criteria as $vs_base_facet => $vs_criteria_value) { unset($va_criteria[$vs_base_facet]); } } $va_criteria_for_display = array(); foreach ($va_criteria as $vs_facet_name => $va_criterion) { $va_facet_info = $o_browse->getInfoForFacet($vs_facet_name); foreach ($va_criterion as $vn_criterion_id => $vs_criterion) { $va_criteria_for_display[] = array('facet' => $va_facet_info['label_singular'], 'facet_name' => $vs_facet_name, 'value' => $vs_criterion, 'id' => $vn_criterion_id); } } $this->view->setVar('criteria', $va_criteria_for_display); // // Results // $qr_res = $o_browse->getResults(array('sort' => $va_sort_by[$ps_sort], 'sort_direction' => $ps_sort_direction)); if ($vs_letter_bar_field = caGetOption('showLetterBarFrom', $va_browse_info, null)) { // generate letter bar $va_letters = array(); while ($qr_res->nextHit()) { $va_letters[caRemoveAccents(mb_strtolower(mb_substr($qr_res->get($vs_letter_bar_field), 0, 1)))]++; } $this->view->setVar('letterBar', $va_letters); $qr_res->seek(0); } $this->view->setVar('showLetterBar', (bool) $vs_letter_bar_field); if ($vs_letter_bar_field && ($vs_l = mb_strtolower($this->request->getParameter('l', pString)))) { $va_filtered_ids = array(); while ($qr_res->nextHit()) { if (caRemoveAccents(mb_strtolower(mb_substr($qr_res->get($vs_letter_bar_field), 0, 1))) == $vs_l) { $va_filtered_ids[] = $qr_res->getPrimaryKey(); } } if (sizeof($va_filtered_ids) > 0) { $qr_res = caMakeSearchResult($vs_class, $va_filtered_ids); } } $this->view->setVar('letter', $vs_l); $this->view->setVar('result', $qr_res); if (!($pn_hits_per_block = $this->request->getParameter("n", pString))) { if (!($pn_hits_per_block = $this->opo_result_context->getItemsPerPage())) { $pn_hits_per_block = $o_config->get("defaultHitsPerBlock"); } } $this->opo_result_context->getItemsPerPage($pn_hits_per_block); $this->view->setVar('hits_per_block', $pn_hits_per_block); $this->view->setVar('start', $vn_start = $this->request->getParameter('s', pInteger)); $this->opo_result_context->setParameter('key', $vs_key); if (!$this->request->isAjax()) { if (($vn_key_start = $vn_start - 500) < 0) { $vn_key_start = 0; } $qr_res->seek($vn_key_start); $this->opo_result_context->setResultList($qr_res->getPrimaryKeyValues(500)); $qr_res->seek($vn_start); } $this->opo_result_context->saveContext(); if ($ps_type) { if ($this->render("Browse/{$vs_class}_{$ps_type}_{$ps_view}_{$vs_format}.php")) { return; } } switch ($ps_view) { case 'pdf': $this->_genExport($qr_res, $this->request->getParameter("export_format", pString), $vs_search_expression, $this->getCriteriaForDisplay($o_browse)); break; case 'timelineData': $this->view->setVar('view', 'timeline'); $this->render("Browse/browse_results_timelineData_json.php"); break; default: $this->opo_result_context->setCurrentView($ps_view); $this->render("Browse/browse_results_html.php"); break; } }