Skip to content

Commit

Permalink
Substitute fields for human readable names a bit better.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-vessey committed Dec 14, 2011
1 parent 8698bd5 commit 48910e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion IslandoraSolrQueryProcessor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class IslandoraSolrQueryProcessor {
}
}
if (!empty($this->solrQuery) && strcmp($this->solrQuery, ' ')) {
$cutlink = "islandora/solr/search/ /" . $islandora_fq . "/dismax";
$cutlink = "islandora/solr/search/ /". $islandora_fq ."/dismax";

$queryval = $this->solrQuery;
$tokens = explode(" ", $queryval);
Expand Down
28 changes: 26 additions & 2 deletions IslandoraSolrResults.inc
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,30 @@ class IslandoraSolrResults {
);
return theme('fieldset', $fieldset_r);
}

const FIELD_ALL = 0, FIELD_SEARCH = 1, FIELD_FACET = 2, FIELD_RESULT = 3;

function _make_pattern($string) {
return "/^". preg_quote($string, '/') ."/";
}
function getSubstitutedFields($string_in, $type = FIELD_SEARCH) {
$replacements = NULL;
switch($type) {
case FIELD_SEARCH:
$replacements = $this->searchFieldArray;
break;
case FIELD_FACET:
$replacements = $this->facetFieldArray;
break;
case FIELD_RESULT:
$replacements = $this->resultFieldArray;
break;
case FIELD_ALL:
default:
$replacements = $this->allSubsArray;
}
return preg_replace(array_map(array($this, '_make_pattern'), array_keys($replacements)), array_values($replacements), $string_in);
}

/**
* Function: currentQuery
Expand Down Expand Up @@ -258,15 +282,15 @@ class IslandoraSolrResults {
// and allow one part to be removed at a time.
//
// Image loc: $base_url.'/'.drupal_get_path('module', 'islandora_solr_search').'/images/delete.png
$query = " ";
$query = "*:*";
$fq = replaceSlashes($islandora_fq);
$defType = $solrQueryProcessor->solrDefType;
$query_list_items[] .= l('-', "islandora/solr/search/$query/$fq/$defType",
array(
'html' => true,
'attributes' => array(
'class' => 'islandora_solr_add_remove_link'))
) . ' ' . stripslashes($solrQueryProcessor->solrQuery);
) . ' ' . $this->getSubstitutedFields(stripslashes($solrQueryProcessor->solrQuery), FIELD_SEARCH);


$output .= '<div class="islandora_solr_search_query_wrap">';
Expand Down

0 comments on commit 48910e4

Please sign in to comment.