diff --git a/app/lib/Browse/BrowseEngine.php b/app/lib/Browse/BrowseEngine.php index 2dcffcb5ea..980006e454 100755 --- a/app/lib/Browse/BrowseEngine.php +++ b/app/lib/Browse/BrowseEngine.php @@ -7,7 +7,7 @@ * ---------------------------------------------------------------------- * * Software by Whirl-i-Gig (http://www.whirl-i-gig.com) - * Copyright 2009-2020 Whirl-i-Gig + * Copyright 2009-2023 Whirl-i-Gig * * For more information visit http://www.CollectiveAccess.org * @@ -1691,9 +1691,11 @@ public function execute($pa_options=null) { } $vs_container_sql = ''; - if (!caGetOption('multiple', $va_facet_info, false) && is_array($va_element_code) && (sizeof($va_element_code) == 1) && is_array($va_container_ids[$va_element_code[0]]) && sizeof($va_container_ids[$va_element_code[0]])) { + + $container_element_code = (sizeof($va_element_code) >= 1) ? (ca_metadata_elements::getElementID($e = $va_element_code[sizeof($va_element_code) - 1]) ? $e : null) : null; + if (!caGetOption('multiple', $va_facet_info, false) && $container_element_code && sizeof($va_container_ids[$container_element_code] ?? [])) { $vs_container_sql = " AND ca_attributes.attribute_id IN (?)"; - $va_attr_values[] = $va_container_ids[$va_element_code[0]]; + $va_attr_values[] = $va_container_ids[$container_element_code]; } $vs_where_sql = ''; @@ -1723,8 +1725,8 @@ public function execute($pa_options=null) { if (is_array($va_element_code) && sizeof($va_element_code) == 1) { // is sub-element in container - $va_container_ids[$va_element_code[0]] = array_unique($qr_res->getAllFieldValues('attribute_id')); - $this->opo_ca_browse_cache->setParameter('container_ids', $va_container_ids[$va_element_code[0]]); + $va_container_ids[$container_element_code] = array_unique($qr_res->getAllFieldValues('attribute_id')); + $this->opo_ca_browse_cache->setParameter('container_ids', $va_container_ids[$container_element_code]); } if (!caGetOption('multiple', $va_facet_info, false)) { $vn_i++; @@ -1791,10 +1793,12 @@ public function execute($pa_options=null) { if ($vb_is_element) { $vs_container_sql = ''; + $container_element_code = (sizeof($va_element_code) >= 1) ? (ca_metadata_elements::getElementID($e = $va_element_code[sizeof($va_element_code) - 1]) ? $e : null) : null; + $va_attr_values = null; - if (is_array($va_element_code) && (sizeof($va_element_code) == 1) && is_array($va_container_ids[$va_element_code[0]]) && sizeof($va_container_ids[$va_element_code[0]])) { + if (is_array($va_element_code) && $container_element_code && sizeof($va_container_ids[$container_element_code] ?? [])) { $vs_container_sql = " AND ca_attributes.attribute_id IN (?)"; - $va_attr_values = $va_container_ids[$va_element_code[0]]; + $va_attr_values = $va_container_ids[$container_element_code]; } $filter_join = $filter_where = null; @@ -1896,7 +1900,7 @@ public function execute($pa_options=null) { if ($vb_is_element && is_array($va_element_code) && (sizeof($va_element_code) == 1)) { // is sub-element in container - $va_container_ids[$va_element_code[0]] = array_unique($qr_res->getAllFieldValues('attribute_id')); + $va_container_ids[$container_element_code] = array_unique($qr_res->getAllFieldValues('attribute_id')); $this->opo_ca_browse_cache->setParameter('container_ids', $va_container_ids); } @@ -1964,9 +1968,11 @@ public function execute($pa_options=null) { $va_params = [intval($vs_target_browse_table_num), $vn_element_id, $vn_start_in_meters, $vn_end_in_meters]; $vs_container_sql = ''; - if (is_array($va_element_code) && (sizeof($va_element_code) == 1) && is_array($va_container_ids[$va_element_code[0]]) && sizeof($va_container_ids[$va_element_code[0]])) { + $container_element_code = (sizeof($va_element_code) >= 1) ? (ca_metadata_elements::getElementID($e = $va_element_code[sizeof($va_element_code) - 1]) ? $e : null) : null; + + if (is_array($va_element_code) && $container_element_code && sizeof($va_container_ids[$container_element_code] ?? [])) { $vs_container_sql = " AND ca_attributes.attribute_id IN (?)"; - $va_params[] = $va_container_ids[$va_element_code[0]]; + $va_params[] = $va_container_ids[$container_element_code]; } $vs_sql = " @@ -1987,7 +1993,7 @@ public function execute($pa_options=null) { if ($vb_is_element && is_array($va_element_code) && (sizeof($va_element_code) == 1)) { // is sub-element in container - $va_container_ids[$va_element_code[0]] = array_unique($qr_res->getAllFieldValues('attribute_id')); + $va_container_ids[$container_element_code] = array_unique($qr_res->getAllFieldValues('attribute_id')); $this->opo_ca_browse_cache->setParameter('container_ids', $va_container_ids); } @@ -2053,9 +2059,11 @@ public function execute($pa_options=null) { $va_params = [intval($vs_target_browse_table_num), $vn_element_id, $vn_start_in_meters, $vn_end_in_meters]; $vs_container_sql = ''; - if (is_array($va_element_code) && (sizeof($va_element_code) == 1) && is_array($va_container_ids[$va_element_code[0]]) && sizeof($va_container_ids[$va_element_code[0]])) { + $container_element_code = (sizeof($va_element_code) >= 1) ? (ca_metadata_elements::getElementID($e = $va_element_code[sizeof($va_element_code) - 1]) ? $e : null) : null; + + if (is_array($va_element_code) && sizeof($va_container_ids[$container_element_code] ?? [])) { $vs_container_sql = " AND ca_attributes.attribute_id IN (?)"; - $va_params[] = $va_container_ids[$va_element_code[0]]; + $va_params[] = $va_container_ids[$container_element_code]; } $vs_sql = " @@ -2076,7 +2084,7 @@ public function execute($pa_options=null) { if ($vb_is_element && is_array($va_element_code) && (sizeof($va_element_code) == 1)) { // is sub-element in container - $va_container_ids[$va_element_code[0]] = array_unique($qr_res->getAllFieldValues('attribute_id')); + $va_container_ids[$container_element_code] = array_unique($qr_res->getAllFieldValues('attribute_id')); $this->opo_ca_browse_cache->setParameter('container_ids', $va_container_ids); } @@ -7389,10 +7397,12 @@ protected function doGetResults($po_result=null, $pa_options=null) { $sort_tmp = explode('.', $vs_sort); if(Datamodel::isRelationship($sort_tmp[0])) { $criteria = $this->getCriteria(); - + $t_rel = Datamodel::getInstance($sort_tmp[0], true); + $rel_tables = [$t_rel->getLeftTableName(), $t_rel->getRightTableName()]; foreach($criteria as $facet => $values) { $fi = $this->getInfoForFacet($facet); - if(is_array($fi) && ($fi['type'] === 'authority') && ($fi['table'] ?? null) && (sizeof($values) === 1)) { + + if(is_array($fi) && ($fi['type'] === 'authority') && ($fi['table'] ?? null) && in_array($fi['table'], $rel_tables, true) && (sizeof($values) === 1)) { // use first found authority facet as context, but only if a single value is set $v = array_shift(array_keys($values)); $opts['context'] = [$sort_tmp[0] => [Datamodel::primaryKey($fi['table']) => $v]]; diff --git a/app/lib/Search/SearchEngine.php b/app/lib/Search/SearchEngine.php index 249699e1e3..9f2f78e606 100755 --- a/app/lib/Search/SearchEngine.php +++ b/app/lib/Search/SearchEngine.php @@ -68,8 +68,8 @@ public function __construct($opo_db=null, $ps_tablename=null) { parent::__construct($opo_db); if ($ps_tablename != null) { $this->ops_tablename = $ps_tablename; } - $this->opa_options = array(); - $this->opa_result_filters = array(); + $this->opa_options = []; + $this->opa_result_filters = []; $this->opn_tablenum = Datamodel::getTableNum($this->ops_tablename); @@ -258,7 +258,6 @@ public function doSearch($ps_search, $po_result=null, $pa_options=null) { $o_rewritten_query = new Zend_Search_Lucene_Search_Query_Boolean($va_rewrite_results['terms'], $va_rewrite_results['signs']); $vs_search = $this->_queryToString($o_rewritten_query); - //print "
DEBUG: ".$ps_search.'/'.$vs_search."
"; // Filter deleted records out of final result if ((isset($pa_options['deletedOnly']) && $pa_options['deletedOnly']) && $t_table->hasField('deleted')) { @@ -338,7 +337,7 @@ public function doSearch($ps_search, $po_result=null, $pa_options=null) { } $o_res->seek(0); } else { - $va_hits = array(); + $va_hits = []; } if (isset($pa_options['sets']) && $pa_options['sets']) { @@ -442,16 +441,16 @@ public function getRandomResult($pn_num_hits=10, $po_result=null) { $o_res = new WLPlugSearchEngineCachedResult($va_hits, $this->opn_tablenum); if ($po_result) { - $po_result->init($o_res, array()); + $po_result->init($o_res, []); return $po_result; } else { - return new SearchResult($o_res, array()); + return new SearchResult($o_res, []); } } # ------------------------------------------------------------------ private function _rewriteQuery($po_query) { - $va_terms = array(); - $va_signs = array(); + $va_terms = []; + $va_signs = []; switch(get_class($po_query)) { case 'Zend_Search_Lucene_Search_Query_Boolean': $va_items = $po_query->getSubqueries(); @@ -460,7 +459,7 @@ private function _rewriteQuery($po_query) { $va_items = $po_query->getTerms(); break; default: - $va_items = array(); + $va_items = []; break; } @@ -481,13 +480,10 @@ private function _rewriteQuery($po_query) { $va_rewritten_terms = $this->_rewriteTerm($o_term, $va_old_signs[$vn_i]); if (sizeof($va_rewritten_terms['terms']) == 1) { $va_terms[] = new Zend_Search_Lucene_Search_Query_Term(array_shift($va_rewritten_terms['terms'])); - $va_signs[] = array_shift($va_rewritten_terms['signs']); } else { - for($vn_j = 0; $vn_j < sizeof($va_rewritten_terms['terms']); $vn_j++) { - $va_terms[] = new Zend_Search_Lucene_Search_Query_MultiTerm(array($va_rewritten_terms['terms'][$vn_j]), array($va_rewritten_terms['signs'][$vn_j])); - $va_signs[] = $va_rewritten_terms['signs'][$vn_j] ? true : is_null($va_rewritten_terms['signs'][$vn_j]) ? null : false; - } + $va_terms[] = new Zend_Search_Lucene_Search_Query_MultiTerm($va_rewritten_terms['terms'], $va_rewritten_terms['signs']); } + $va_signs[] = $va_old_signs[$vn_i]; break; case 'Zend_Search_Lucene_Index_Term': $va_rewritten_terms = $this->_rewriteTerm(new Zend_Search_Lucene_Search_Query_Term($o_term), $va_old_signs[$vn_i]); @@ -497,13 +493,13 @@ private function _rewriteQuery($po_query) { $o_mt = new Zend_Search_Lucene_Search_Query_MultiTerm($va_rewritten_terms['terms'], $va_rewritten_terms['signs']); } $va_terms[] = $o_mt; - $va_signs[] = sizeof($va_rewritten_terms['signs']) ? array_shift($va_rewritten_terms['signs']): true; + $va_signs[] = $va_old_signs[$vn_i]; break; case 'Zend_Search_Lucene_Search_Query_Wildcard': $va_rewritten_terms = $this->_rewriteTerm(new Zend_Search_Lucene_Search_Query_Term($o_term->getPattern()), $va_old_signs[$vn_i]); $o_mt = new Zend_Search_Lucene_Search_Query_MultiTerm($va_rewritten_terms['terms'], $va_rewritten_terms['signs']); $va_terms[] = $o_mt; - $va_signs[] = sizeof($va_rewritten_terms['signs']) ? array_shift($va_rewritten_terms['signs']): true; + $va_signs[] = $va_old_signs[$vn_i]; break; case 'Zend_Search_Lucene_Search_Query_Phrase': $va_phrase_items = $o_term->getTerms(); @@ -572,7 +568,7 @@ private function _rewriteTerm($po_term, $pb_sign) { $vs_bool = 'OR'; } - $va_terms = array(); + $va_terms = []; $vs_term = (string)$po_term->getTerm()->text; foreach($va_fields as $vs_field) { $va_tmp = explode(".", $vs_field); @@ -595,15 +591,15 @@ private function _rewriteTerm($po_term, $pb_sign) { $vs_term .= '|'; } $va_terms['terms'][] = new Zend_Search_Lucene_Index_Term($vs_term, $vs_field.($vs_rel_types ? "/{$vs_rel_types}" : '')); - $va_terms['signs'][] = ($vs_bool == 'AND') ? true : null; - $va_terms['options'][] = is_array($va_ap_info['options']) ? $va_ap_info['options'] : array(); + $va_terms['signs'][] = ($vs_bool == 'AND') ? true : false; + $va_terms['options'][] = is_array($va_ap_info['options']) ? $va_ap_info['options'] : []; } if (is_array($va_additional_criteria = $va_ap_info['additional_criteria'])) { foreach($va_additional_criteria as $vs_criterion) { $va_terms['terms'][] = new Zend_Search_Lucene_Index_Term($vs_criterion); - $va_terms['signs'][] = $vs_bool; - $va_terms['options'][] = is_array($va_ap_info['options']) ? $va_ap_info['options'] : array(); + $va_terms['signs'][] = ($vs_bool == 'AND') ? true : false; + $va_terms['options'][] = is_array($va_ap_info['options']) ? $va_ap_info['options'] : []; } } @@ -621,7 +617,7 @@ private function _rewriteTerm($po_term, $pb_sign) { return array( 'terms' => array(new Zend_Search_Lucene_Index_Term((string)((sizeof($va_matches) > 1) ? $va_matches[1] : $va_matches[0]), "{$vs_table_name}.{$vs_idno_fld}")), 'signs' => array($pb_sign), - 'options' => array() + 'options' => [] ); } } @@ -637,13 +633,13 @@ private function _rewriteTerm($po_term, $pb_sign) { return array( 'terms' => array(new Zend_Search_Lucene_Index_Term($po_term->getTerm()->text, $t_instance->getLabelTableName().'.'.((isset($va_tmp2[2]) && $va_tmp2[2]) ? $va_tmp2[2] : $t_instance->getLabelDisplayField()).($va_tmp[1] ? '/'.$va_tmp[1] : ''))), 'signs' => array($pb_sign), - 'options' => array() + 'options' => [] ); } } } - return array('terms' => array($po_term->getTerm()), 'signs' => array($pb_sign), 'options' => array()); + return array('terms' => [$po_term->getTerm()], 'signs' => [$pb_sign], 'options' => []); } # ------------------------------------------------------------------ /** @@ -652,7 +648,7 @@ private function _rewriteTerm($po_term, $pb_sign) { * @return array - rewritten phrases are *** Zend_Search_Lucene_Search_Query_Phrase *** objects */ private function _rewritePhrase($po_term, $pb_sign) { - $va_index_term_strings = array(); + $va_index_term_strings = []; $va_phrase_terms = $po_term->getTerms(); foreach($va_phrase_terms as $o_phrase_term) { $va_index_term_strings[] = $o_phrase_term->text; @@ -675,14 +671,14 @@ private function _rewritePhrase($po_term, $pb_sign) { foreach($va_fields as $vs_field) { $va_terms['terms'][] = new Zend_Search_Lucene_Search_Query_Phrase($va_index_term_strings, null, $vs_field); $va_terms['signs'][] = ($vs_bool == 'AND') ? true : null; - $va_terms['options'][] = is_array($va_ap_info['options']) ? $va_ap_info['options'] : array(); + $va_terms['options'][] = is_array($va_ap_info['options'] ?? null) ? $va_ap_info['options'] : []; } if (is_array($va_additional_criteria = $va_ap_info['additional_criteria'])) { foreach($va_additional_criteria as $vs_criterion) { $va_terms['terms'][] = new Zend_Search_Lucene_Index_Term($vs_criterion); $va_terms['signs'][] = $vs_bool; - $va_terms['options'][] = is_array($va_ap_info['options']) ? $va_ap_info['options'] : array(); + $va_terms['options'][] = is_array($va_ap_info['options'] ?? null) ? $va_ap_info['options'] : []; } } @@ -699,7 +695,7 @@ private function _rewritePhrase($po_term, $pb_sign) { return array( 'terms' => array(new Zend_Search_Lucene_Search_Query_Phrase($va_index_term_strings, null, $t_instance->getLabelTableName().'.'.$t_instance->getLabelDisplayField().($va_tmp[1] ? '/'.$va_tmp[1] : ''))), 'signs' => array($pb_sign), - 'options' => array() + 'options' => [] ); } } @@ -720,7 +716,7 @@ private function _rewriteRange($po_range) { if (!in_array($vs_bool = strtoupper($va_ap_info['boolean']), array('AND', 'OR'))) { $vs_bool = 'OR'; } - $va_tmp = array(); + $va_tmp = []; foreach($va_fields as $vs_field) { $po_range->getLowerTerm()->field = $vs_field; $po_range->getUpperTerm()->field = $vs_field; @@ -762,7 +758,7 @@ private function _queryToString($po_parsed_query) { $va_signs = null; break; default: - $va_items = array(); + $va_items = []; $va_signs = null; break; } @@ -774,11 +770,11 @@ private function _queryToString($po_parsed_query) { } if (($va_signs === null || $va_signs[$id] === true) && ($id)) { - $vs_query .= ' AND '; - } else if (($va_signs[$id] === false) && $id) { - $vs_query .= ' NOT '; + $vs_query .= 'AND '; + } else if ((is_null($va_signs[$id] ?? null) === true) && $id) { + $vs_query .= 'OR '; } else { - if ($id) { $vs_query .= ' OR '; } + if ($id) { $vs_query .= 'NOT '; } } switch(get_class($subquery)) { case 'Zend_Search_Lucene_Search_Query_Phrase': @@ -850,7 +846,7 @@ public function addResultFilter($ps_field, $ps_operator, $pm_value) { } # ------------------------------------------------------------------ public function clearResultFilters() { - $this->opa_result_filters = array(); + $this->opa_result_filters = []; } # ------------------------------------------------------------------ public function getResultFilters() { @@ -890,7 +886,7 @@ public function setTypeRestrictions($pa_type_codes_or_ids, $pa_options=null) { $pa_type_codes_or_ids = array_keys($va_type_list); } - $this->opa_search_type_ids = array(); + $this->opa_search_type_ids = []; foreach($pa_type_codes_or_ids as $vs_code_or_id) { if (!strlen($vs_code_or_id)) { continue; } if (!is_numeric($vs_code_or_id)) { @@ -946,7 +942,7 @@ public function getTypeRestrictionList($pa_options=null) { if (!is_array($va_pervasive_types) || !sizeof($va_pervasive_types)) { return $this->opa_search_type_ids; } if (is_array($this->opa_search_type_ids) && sizeof($this->opa_search_type_ids)) { - $va_filtered_types = array(); + $va_filtered_types = []; foreach($this->opa_search_type_ids as $vn_id) { if (in_array($vn_id, $va_pervasive_types)) { $va_filtered_types[] = $vn_id; @@ -994,7 +990,7 @@ public function setSourceRestrictions($pa_source_codes_or_ids, $pa_options=null) if (!($vs_list_name = $t_instance->getSourceListCode())) { return false; } $va_source_list = $t_instance->getSourceList(); - $this->opa_search_source_ids = array(); + $this->opa_search_source_ids = []; foreach($pa_source_codes_or_ids as $vs_code_or_id) { if (!strlen($vs_code_or_id)) { continue; } if (!is_numeric($vs_code_or_id)) { @@ -1030,7 +1026,7 @@ public function getSourceRestrictionList() { if (!is_array($va_pervasive_sources)) { return $this->opa_search_source_ids; } if (is_array($this->opa_search_source_ids) && sizeof($this->opa_search_source_ids)) { - $va_filtered_sources = array(); + $va_filtered_sources = []; foreach($this->opa_search_source_ids as $vn_id) { if (in_array($vn_id, $va_pervasive_sources)) { $va_filtered_sources[] = $vn_id; @@ -1117,7 +1113,7 @@ static function quickSearch($ps_search, $ps_tablename, $pn_tablenum, $pa_options $va_ids = $o_engine->quickSearch($pn_tablenum, $ps_search, $pa_options); - if (!is_array($va_ids) || !sizeof($va_ids)) { return array(); } + if (!is_array($va_ids) || !sizeof($va_ids)) { return []; } $t_instance = Datamodel::getInstanceByTableNum($pn_tablenum, true); $t_label_instance = $t_instance->getLabelTableInstance(); @@ -1163,7 +1159,7 @@ static function quickSearch($ps_search, $ps_tablename, $pn_tablenum, $pa_options {$vs_delete_sql} {$vs_limit_sql} "); - $va_hits = array(); + $va_hits = []; while($qr_res->nextRow()) { $va_hits[$qr_res->get($vs_pk)][$qr_res->get('locale_id')] = array( 'type_id' => $qr_res->get('type_id'), @@ -1228,7 +1224,7 @@ static public function getSearchExpressionForDisplay($ps_search, $ps_table) { * @return array */ static private function _getFieldList($po_query) { - $va_fields = array(); + $va_fields = []; switch(get_class($po_query)) { case 'Zend_Search_Lucene_Search_Query_Boolean': @@ -1238,7 +1234,7 @@ static private function _getFieldList($po_query) { $va_items = $po_query->getTerms(); break; default: - $va_items = array(); + $va_items = []; break; } diff --git a/themes/erfgoed_meetjesland_new/assets/pawtucket/css/theme.css b/themes/erfgoed_meetjesland_new/assets/pawtucket/css/theme.css index 08328c9d13..976d2cb79c 100644 --- a/themes/erfgoed_meetjesland_new/assets/pawtucket/css/theme.css +++ b/themes/erfgoed_meetjesland_new/assets/pawtucket/css/theme.css @@ -871,6 +871,9 @@ div.caMediaOverlayControls{ .bodytext a, #caFormOverlay a{ text-decoration:underline; } +.bodytext a.btn-default{ + text-decoration:none; +} #pageArea.staticPage img{ width:100%; height:auto; diff --git a/themes/erfgoed_meetjesland_new/views/pageFormat/pageHeader.php b/themes/erfgoed_meetjesland_new/views/pageFormat/pageHeader.php index e499891241..368209b3ec 100755 --- a/themes/erfgoed_meetjesland_new/views/pageFormat/pageHeader.php +++ b/themes/erfgoed_meetjesland_new/views/pageFormat/pageHeader.php @@ -187,6 +187,7 @@ function gtag(){dataLayer.push(arguments);}
  • request->getController() == "Gallery") ? 'class="active"' : ''; ?>>request, "Expo's", "", "", "Gallery", "Index"); ?>
  • request->getController() == "Collections") ? 'class="active"' : ''; ?>>request, "Collecties", "", "", "Collections", "index"); ?>
  • request->getController() == "Browse") ? 'class="active"' : ''; ?>>request, "Bladeren", "", "", "Browse", "Objects"); ?>
  • +
  • request->getController() == "Projecten") ? 'class="active"' : ''; ?>>request, "Projecten", "", "", "Projecten", ""); ?>