Skip to content

Commit

Permalink
resolved commit conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Stanley committed Jan 3, 2012
2 parents 859bf21 + fc6fe85 commit e3edc4c
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 18 deletions.
2 changes: 1 addition & 1 deletion IslandoraSolrQueryProcessor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class IslandoraSolrQueryProcessor {
'facet.limit' => $facetlimit,
'qt' => $requestHandler,
'hl' => 'true',
'hl.fl' => trim($keys[0]),
'hl.fl' => isset($keys[0]) ? trim($keys[0]) : NULL,
'hl.fragsize' => 400,
'facet.field' => explode(',', $facetFields), //comma separated list configured in the block config
);
Expand Down
57 changes: 48 additions & 9 deletions IslandoraSolrResults.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IslandoraSolrResults {
* @param type $solrQueryProcessor
* @param type $title
* @param type $output
* @return string
* @return string
*/
function displayResults($solrQueryProcessor, $title = "Search Results", $output = '') {

Expand Down Expand Up @@ -80,7 +80,7 @@ class IslandoraSolrResults {
}

// if number of elements is the same as the number of disabled displays,
// this means that there are no displays enabled.
// this means that there are no displays enabled.
if ($array_count != $i) {

$output .= "<div id='islandora_solr_secondary_display_profiles'>";
Expand Down Expand Up @@ -342,6 +342,10 @@ class IslandoraSolrResults {
if (empty($islandora_facets)) {
return $output; //no facets to show
}

// set counter to include javascript later
$i = 0;

foreach ($islandora_facets as $key => $field) {
$list_items = array();
$list_type = "ul";
Expand All @@ -354,6 +358,7 @@ class IslandoraSolrResults {
$filter_include = NULL;
$filter_exclude = NULL;
$disable_link = FALSE;
// dsm($field);
foreach ($field as $name => $number) {
if ($islandora_fq && $islandora_fq != '-') {//there are existing facets in the query
$disable_link = strstr($islandora_fq, $key . ':"' . replaceSlashes($name) . '"'); //we don't want a link for this facet as we already used it
Expand Down Expand Up @@ -390,27 +395,61 @@ class IslandoraSolrResults {
$facet_count++;
}
}
if ($facet_count >= 2) {
if ($facet_count >= 1) {
$facet_output .='<div class="islandora_solr_search_facet">';

// shown limit
$shown_limit = variable_get('islandora_solr_search_block_facet_shown_limit', 0);
$facetlimit = variable_get('islandora_solr_search_block_facet_limit', '12');
$facetMinCount = variable_get('islandora_solr_search_block_facet_min_count', '2');

$list_title = $this->facetFieldArray[$key];
$list_type = "ul";
$list_attributes = array('class' => 'islandora_solr_search_facet_list facet_list');

// set show more variable
$show_more = FALSE;

// split the array if shown_limit is between the min and max limits and if the total is larger than the shown_limit.
if ($facet_count > $shown_limit AND $shown_limit < $facetlimit AND $shown_limit > $facetMinCount) {
$list_items_hidden = array_slice($list_items, $shown_limit);
$list_items = array_slice($list_items, 0, $shown_limit);
$show_more = TRUE;
}

$facet_output .= theme_item_list($list_items, $list_title, $list_type, $list_attributes);

// set counter
if ($show_more == TRUE) {
$i++;
$facet_output .= '<a href="#" class="shown-toggle">' . t('Show more') . '</a>';
$facet_output .= '<a href="#" class="shown-toggle hidden">' . t('Show less') . '</a>';
$facet_output .= '<div class="toggle-wrapper hidden">';
$facet_output .= theme_item_list($list_items_hidden, NULL, $list_type, $list_attributes);
$facet_output .= '</div>';
}

$facet_output .='</div>';
}
}
}

if ($i >= 1) {
// if there is at least one occurence of a split array, we add js to the page.
drupal_add_js(drupal_get_path('module', 'islandora_solr_search') . '/js/islandora_solr_search_shown_limit.js');
}

//////////////////////////////////////////////////////////////////////////////////////
// as we add additional facets, we're repeatedly URL-encoding old facet //
// strings. when we double-encode quotation marks they're incomprehensible to solr. //
// This is a quick workaround: //
//////////////////////////////////////////////////////////////////////////////////////
$facet_output = str_replace('%2B', '%252B', $facet_output);
$output .='<div class="islandora_solr_search_facet_wrap">';
$output .= $facet_output;
$output .= '</div>';
if(!empty($facet_output)) {
$output .='<div class="islandora_solr_search_facet_wrap">';
$output .= $facet_output;
$output .= '</div>';
}

return $output;
}
Expand All @@ -420,7 +459,7 @@ class IslandoraSolrResults {
* @param type $repeat
* @param type $pathToSearchTerms
* @param type $query
* @return string
* @return string
*/
function build_solr_search_form($repeat = NULL, $pathToSearchTerms = NULL, $query = NULL) {

Expand Down Expand Up @@ -506,7 +545,7 @@ class IslandoraSolrResults {
/**
* Build simple solr form
* @global type $islandora_query
* @return type
* @return type
*/
function build_simple_solr_form() {
$required = FALSE;
Expand Down Expand Up @@ -535,7 +574,7 @@ class IslandoraSolrResults {
/**
* Theme solr search form
* @param type $form
* @return type
* @return type
*/
function theme_solr_search_form($form) {
if (!isset($repeat)) {
Expand Down
7 changes: 7 additions & 0 deletions islandora_solr_search.css → css/islandora_solr_search.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,11 @@ html.js .refresh-button {

.strikethrough {
text-decoration: line-through !important;
}

/* hide the 2nd list if a facet list is split in two */

.islandora_solr_search_facet .hidden
{
display: none;
}
2 changes: 1 addition & 1 deletion islandora_solr_config/islandora_solr_config.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ description = Example Code for Implementation of Islandora Solr Search Configura
dependencies[] = islandora_solr_search
description = Customizes Islandora solr search
package = Islandora Search
version = 11.2.beta2
version = 11.3beta3
core = 6.x
2 changes: 1 addition & 1 deletion islandora_solr_config/islandora_solr_config.module
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

// $Id$



/**
Expand Down
12 changes: 10 additions & 2 deletions islandora_solr_search.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function islandora_solr_admin_settings(&$form_state) {
'#default_value' => variable_get('islandora_solr_search_block_facets', ''),
'#description' => t("Indicate which fields will appear in the <strong>Islandora Facet Block</strong>.<br />
Enter terms on separate lines using the following pattern: field [tilde] preferred label. ie <strong>dc.title ~ Title</strong> "),
'#default_value' => variable_get('islandora_solr_search_block_facets', 'dc.subject ~ Subject,dc.type ~ Type'),
'#wysiwyg' => FALSE,
);

Expand Down Expand Up @@ -212,11 +213,18 @@ function islandora_solr_admin_settings(&$form_state) {
'#description' => t('Minimum facet count required for display'),
'#default_value' => variable_get('islandora_solr_search_block_facet_min_count', '2'),
);
$form['islandora_solr_search_block_facet_shown_limit'] = array(
'#type' => 'textfield',
'#title' => t('Initially shown facets'),
'#size' => 5,
'#description' => t('The number which should be shown initially. If there are more, then the a "Show more" button will allow the rest up to the value below to be shown. Use 0 to disable.'),
'#default_value' => variable_get('islandora_solr_search_block_facet_shown_limit', '0'),
);
$form['islandora_solr_search_block_facet_limit'] = array(
'#type' => 'textfield',
'#title' => t('Maximum Facets returned'),
'#size' => 5,
'#description' => t('Set the number of terms that should be returned to the user.<br />
'#description' => t('Set the maximum number of terms that should be returned to the user.<br />
For example, if there are 100 possible subjects in a faceted result, you may wish to return only the top 10.'),
'#default_value' => variable_get('islandora_solr_search_block_facet_limit', '10'),
);
Expand Down Expand Up @@ -307,7 +315,7 @@ function check_dismax($solr_url, $selected_handler) {
foreach ($first->str as $str) {
if ($str['name'] == 'qf') {
$dismax = TRUE;
$dismax = true;

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion islandora_solr_search.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name = Islandora Solr Search
dependencies[] = fedora_repository
description = searches a solr index
package = Islandora Search
version = 11.2.beta2
version = 11.3beta3
core = 6.x
7 changes: 4 additions & 3 deletions islandora_solr_search.module
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ function islandora_solr_search_block($op = 'list', $delta = 0, $edit = array())
$displayClass = new IslandoraSolrResults();
$block_function = $solr_blocks[$delta]['function'];
if (method_exists($displayClass, $block_function)) {
$block['content'] = $displayClass->$block_function($queryClass);
$content = $displayClass->$block_function($queryClass);
$block['content'] = !empty($content) ? $content : NULL;
}

// Otherwise, simply load the form.
Expand Down Expand Up @@ -251,7 +252,7 @@ function islandora_solr_simple_search_form_submit($form, &$form_state) {
$searchString = htmlspecialchars(drupal_urlencode($searchString), ENT_QUOTES, 'utf-8', FALSE);
$searchString = str_replace('/', '~slsh~', $searchString); //replace the slash so url doesn't break
$dismax = '';
if (variable_get('dismax_allowed', FALSE)) {
if (variable_get('dismax_allowed', TRUE)) {
$dismax = 'dismax';
}
drupal_goto("islandora/solr/search/$searchString/-/$dismax");
Expand Down Expand Up @@ -442,7 +443,7 @@ function islandora_solr_search_help($path, $arg) {
function islandora_solr_search_init() {
static $islandora_solr_search_init = FALSE;
if (!$islandora_solr_search_init) {
drupal_add_css(drupal_get_path('module', 'islandora_solr_search') . '/islandora_solr_search.css');
drupal_add_css(drupal_get_path('module', 'islandora_solr_search') . '/css/islandora_solr_search.css');
global $queryClass;
if (empty($queryClass)) {
$queryClass = new IslandoraSolrQueryProcessor();
Expand Down
12 changes: 12 additions & 0 deletions js/islandora_solr_search_shown_limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$(document).ready(function() {

// show more
$(".shown-toggle").click(function() {

$(this).siblings(".hidden, .toggle-wrapper").toggleClass('hidden');
$(this).toggleClass('hidden');

return false;
});

});

0 comments on commit e3edc4c

Please sign in to comment.