From dcb8f210336e3f2e5731969694946d0695d6472b Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Thu, 17 Nov 2011 14:50:44 -0400 Subject: [PATCH 01/13] Set the version to 11.3.beta1 --- islandora_solr_config/islandora_solr_config.info | 2 +- islandora_solr_search.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora_solr_config/islandora_solr_config.info b/islandora_solr_config/islandora_solr_config.info index 7d79fc4a..1f8c1c28 100644 --- a/islandora_solr_config/islandora_solr_config.info +++ b/islandora_solr_config/islandora_solr_config.info @@ -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.0 +version = 11.3beta1 core = 6.x diff --git a/islandora_solr_search.info b/islandora_solr_search.info index 5e11b256..95384976 100644 --- a/islandora_solr_search.info +++ b/islandora_solr_search.info @@ -2,5 +2,5 @@ name = Islandora Solr Search dependencies[] = fedora_repository description = searches a solr index package = Islandora Search -version = 11.2.0 +version = 11.3beta1 core = 6.x From 7c3ecbf24ceeda40c1f2c56e89364d607c0570c4 Mon Sep 17 00:00:00 2001 From: Danny Joris Date: Thu, 17 Nov 2011 22:30:54 -0400 Subject: [PATCH 02/13] added optional facet toggle + moved css and js files in separate folders --- IslandoraSolrResults.inc | 37 +++++++++++++++++++ .../islandora_solr_search.css | 7 ++++ islandora_solr_search.admin.inc | 9 ++++- islandora_solr_search.module | 2 +- js/islandora_solr_search_shown_limit.js | 12 ++++++ 5 files changed, 65 insertions(+), 2 deletions(-) rename islandora_solr_search.css => css/islandora_solr_search.css (94%) create mode 100644 js/islandora_solr_search_shown_limit.js diff --git a/IslandoraSolrResults.inc b/IslandoraSolrResults.inc index 74e388be..20d06314 100644 --- a/IslandoraSolrResults.inc +++ b/IslandoraSolrResults.inc @@ -325,6 +325,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"; @@ -337,6 +341,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 @@ -375,15 +380,47 @@ class IslandoraSolrResults { } if ($facet_count >= 2) { $facet_output .='
'; + + // 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 .= '' . t('Show more') . ''; + $facet_output .= ''; + $facet_output .= ''; + } + $facet_output .='
'; } } } + 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 // diff --git a/islandora_solr_search.css b/css/islandora_solr_search.css similarity index 94% rename from islandora_solr_search.css rename to css/islandora_solr_search.css index d6b4fc07..3c372534 100644 --- a/islandora_solr_search.css +++ b/css/islandora_solr_search.css @@ -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; } \ No newline at end of file diff --git a/islandora_solr_search.admin.inc b/islandora_solr_search.admin.inc index 049cf63f..35c0ac46 100644 --- a/islandora_solr_search.admin.inc +++ b/islandora_solr_search.admin.inc @@ -188,11 +188,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.
+ '#description' => t('Set the maximum number of terms that should be returned to the user.
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'), ); diff --git a/islandora_solr_search.module b/islandora_solr_search.module index bbe99131..156932cd 100644 --- a/islandora_solr_search.module +++ b/islandora_solr_search.module @@ -440,7 +440,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(); diff --git a/js/islandora_solr_search_shown_limit.js b/js/islandora_solr_search_shown_limit.js new file mode 100644 index 00000000..4f108ed5 --- /dev/null +++ b/js/islandora_solr_search_shown_limit.js @@ -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; + }); + +}); \ No newline at end of file From 25e0af5cd8c6c13094a6830f78b67a745bd50db9 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Tue, 29 Nov 2011 09:52:39 -0400 Subject: [PATCH 03/13] New version and removed id tags --- islandora_solr_config/islandora_solr_config.info | 2 +- islandora_solr_search.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora_solr_config/islandora_solr_config.info b/islandora_solr_config/islandora_solr_config.info index 1f8c1c28..ba39074c 100644 --- a/islandora_solr_config/islandora_solr_config.info +++ b/islandora_solr_config/islandora_solr_config.info @@ -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.3beta1 +version = 11.3beta2 core = 6.x diff --git a/islandora_solr_search.info b/islandora_solr_search.info index 95384976..68748185 100644 --- a/islandora_solr_search.info +++ b/islandora_solr_search.info @@ -2,5 +2,5 @@ name = Islandora Solr Search dependencies[] = fedora_repository description = searches a solr index package = Islandora Search -version = 11.3beta1 +version = 11.3beta2 core = 6.x From bf7d81ca666f81801d07d55424443eac56f8a2a2 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Tue, 29 Nov 2011 09:57:14 -0400 Subject: [PATCH 04/13] Changed logic on solr detect --- IslandoraSolrQueryProcessor.inc | 25 +++++++++++------ islandora_solr_search.admin.inc | 50 +++++++++++++++++++++++++++------ islandora_solr_search.install | 2 +- islandora_solr_search.module | 5 +++- 4 files changed, 64 insertions(+), 18 deletions(-) diff --git a/IslandoraSolrQueryProcessor.inc b/IslandoraSolrQueryProcessor.inc index 07cba4bc..657c66b6 100644 --- a/IslandoraSolrQueryProcessor.inc +++ b/IslandoraSolrQueryProcessor.inc @@ -41,7 +41,7 @@ class IslandoraSolrQueryProcessor { * @param type $dismax * @return type */ - function buildAndExecuteQuery($query, $fq=NULL, $dismax=NULL) { + function buildAndExecuteQuery($query, $fq=NULL, $dismax=NULL, $params = NULL) { if (variable_get('islandora_solr_search_block_request_handler', NULL) == 'standard') { $namespace = trim(variable_get('solr_namespace_restriction', NULL)); @@ -61,7 +61,8 @@ class IslandoraSolrQueryProcessor { } } } - $this->buildQuery($query, $fq, $dismax); + $this->buildQuery($query, $fq, $dismax, $params); + return $this->executeQuery(); } @@ -69,11 +70,12 @@ class IslandoraSolrQueryProcessor { * Default implementation for solr search. You can configure others in the block config settings * @todo Get rid of the global $facetArray? It is the only global yet relied upon. */ - function buildQuery($query, $fq=NULL, $dismax=NULL) { + function buildQuery($query, $fq=NULL, $dismax=NULL, $params = array()) { // Get pager variable $startPage = isset($_GET['page']) ? $_GET['page'] : 0; $this->solrLimit = variable_get('islandora_solr_search_num_of_results', 20); global $base_url, $facetArray; //used by facet block as well + // -- cut here -- // Get display profile $islandora_solr_primary_display = variable_get('islandora_solr_primary_display', 'default'); @@ -83,7 +85,11 @@ class IslandoraSolrQueryProcessor { return ""; } $profile = $profiles[$islandora_solr_primary_display]; - + if ($profile['params']) { + foreach ($profile['params'] as $param) { + $params[] = $param; + } + } // Include the file for the display profile require_once(drupal_get_path('module', $profile['module']) . '/' . $profile['file']); @@ -106,14 +112,14 @@ class IslandoraSolrQueryProcessor { $facetFields = implode(",", array_keys($facetArray)); $keys = array(''); $snippetArray = islandora_build_substitution_list(variable_get("islandora_solr_snippet_field", "")); - if(is_array($snippetArray)){ + if (is_array($snippetArray)) { $keys = array_keys($snippetArray); } $facetlimit = variable_get('islandora_solr_search_block_facet_limit', '12'); $facetMinCount = variable_get('islandora_solr_search_block_facet_min_count', '2'); $requestHandler = variable_get("islandora_solr_search_block_request_handler", "standard"); - $highlight_field = variable_get("islandora_solr_snippet_field", ""); + $highlight_field = variable_get("islandora_solr_snippet_field", ""); $this->solrParams = array( 'facet' => 'true', 'facet.mincount' => $facetMinCount, @@ -121,11 +127,14 @@ class IslandoraSolrQueryProcessor { 'qt' => $requestHandler, 'hl' => 'true', 'hl.fl' => trim($keys[0]), - 'hl.fragsize' =>400, + 'hl.fragsize' => 400, 'facet.field' => explode(',', $facetFields), //comma separated list configured in the block config ); + if (is_array($params)) { + $this->solrParams = array_merge($this->solrParams, $params); + } $debugQuery = (variable_get('islandora_solr_search_debug_mode', 0) ? "TRUE" : NULL ); //any val incl. 'FALSE' is treated as TRUE by Solr if ($fq != NULL && $fq != '-') { @@ -190,7 +199,7 @@ class IslandoraSolrQueryProcessor { // At this point let's invoke a hook for third-party modules to mess about // with the query parameters if they need to. Third party modules may alter // this object's query parameters if they wish. - // module_invoke_all("islandora_solr_search_query_processor", &$this); + module_invoke_all("islandora_solr_search_query_processor", &$this); return; } diff --git a/islandora_solr_search.admin.inc b/islandora_solr_search.admin.inc index acb8662a..4fbc8146 100644 --- a/islandora_solr_search.admin.inc +++ b/islandora_solr_search.admin.inc @@ -90,6 +90,16 @@ function islandora_solr_admin_settings(&$form_state) { '#description' => t("Enter a namespace ie 'demo' to restrict results to PIDs within that namespace
note: this setting may only be used with 'standard' request handler."), ); } + + $form['islandora_solr_sortfield'] = array( + '#type' => 'textfield', + '#title' => t("Field on which to sort results"), + '#description' => t("If this field is left blank results will be sorted by relevance to the query.
+ Only fields defined in the schema as both stored and not multivalued may be used for sorting.
"), + '#default_value' => variable_get('islandora_solr_sortfield', ''), + ); + + $profiles = module_invoke_all("islandora_solr_primary_display"); uksort($profiles, "sort_default_first"); foreach ($profiles as $machine_name => $profile) { @@ -136,6 +146,25 @@ function islandora_solr_admin_settings(&$form_state) { '#default_value' => variable_get('islandora_solr_search_block_repeat', '3'), ); + $form['sort_fields'] = array( + '#type' => 'fieldset', + '#collapsible' => TRUE, + ); + + $form['sort_fields']['islandora_solr_search_sort_field'] = array( + '#type' => 'textfield', '#title' => t('Sort field'), + '#size' => 20, + '#description' => t('Results will be sorted on this field. If left blank will default to score '), + '#default_value' => variable_get('islandora_solr_search_sort_field', ''), + ); + + $form['sort_fields']['islandora_solr_search_sort_order'] = array( + '#type' => 'radios', + '#title' => t('Sort Order'), + '#options' => array('asc' => t('Accending'), 'desc' => t('Decending')), + '#default_value' => 'desc', + ); + $form['islandora_solr_searchterms'] = array( '#type' => 'textarea', '#title' => t('Search Terms'), @@ -155,9 +184,11 @@ function islandora_solr_admin_settings(&$form_state) { Note: This feature is not supported by all display profiles. "), '#wysiwyg' => FALSE, ); + $form['islandora_solr_search_block_facets'] = array( '#type' => 'textarea', '#title' => t('Facet Fields'), + '#default_value' => variable_get('islandora_solr_search_block_facets', ''), '#description' => t("Indicate which fields will appear in the Islandora Facet Block.
Enter terms on separate lines using the following pattern: field [tilde] preferred label. ie dc.title ~ Title "), '#wysiwyg' => FALSE, @@ -231,15 +262,18 @@ function islandora_solr_admin_settings(&$form_state) { * Checks availability of Solr installation * */ + function solr_available($solr_url) { - // path from url is parsed to allow graceful inclusion or exclusion of 'http://' - $pathParts = parse_url($solr_url); - $path = 'http://' . $pathParts['host'] . ':' . $pathParts['port'] . $pathParts['path'] . '/admin/file'; - $test = @fopen($path, "r"); - if ($test) { - return TRUE; + $handle = curl_init($solr_url); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); + $response = curl_exec($handle); + $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); + $retval = TRUE; + if ($httpCode % 100 == 4) { + $retval = FALSE; } - return FALSE; + curl_close($handle); + return $retval; } /** @@ -278,7 +312,7 @@ function check_dismax($solr_url, $selected_handler) { foreach ($handler->lst as $first) { foreach ($first->str as $str) { if ($str['name'] == 'qf') { - $dismax= TRUE; + $dismax = TRUE; $dismax = true; } } diff --git a/islandora_solr_search.install b/islandora_solr_search.install index f42a735a..36b131a7 100644 --- a/islandora_solr_search.install +++ b/islandora_solr_search.install @@ -28,7 +28,7 @@ function islandora_solr_search_requirements($phase) { if ($phase == 'install') { - if (!class_exists(Apache_Solr_Service)) { + if (!class_exists('Apache_Solr_Service')) { $requirements['islandora_solr_search'] = array( 'title' => $t('Missing Apache Client'), 'description' => $t('This module requires the ' . l('Apache Solr php client', 'http://code.google.com/p/solr-php-client') . '. Please install the client directory in the root directory of this module before continuing.'), diff --git a/islandora_solr_search.module b/islandora_solr_search.module index c3fef4b5..7b31a138 100644 --- a/islandora_solr_search.module +++ b/islandora_solr_search.module @@ -246,6 +246,7 @@ function islandora_solr_search_block_form_validate($form, &$form_state) { * @param type $form_state */ function islandora_solr_simple_search_form_submit($form, &$form_state) { + $form_state['rebuild'] = TRUE; $searchString = $form_state['values']['islandora_simple_search_query']; $searchString = htmlspecialchars(drupal_urlencode($searchString), ENT_QUOTES, 'utf-8', FALSE); $searchString = str_replace('/', '~slsh~', $searchString); //replace the slash so url doesn't break @@ -297,8 +298,9 @@ function islandora_solr_search($query, $fq=NULL, $dismax=NULL) { global $queryClass; islandora_solr_search_init(); + // Build and execute Apache Solr query - $queryResult = $queryClass->buildAndExecuteQuery($query, $fq, $dismax); + $queryResult = $queryClass->buildAndExecuteQuery("$query $addition_string", $fq, $dismax); // Get the preferred display profile // Order: First choice is what's in the ?profile query var @@ -367,6 +369,7 @@ function islandora_solr_search($query, $fq=NULL, $dismax=NULL) { * @param type $form_state */ function islandora_solr_search_block_form_submit($form, &$form_state) { + $form_state['rebuild'] = TRUE; global $queryClass; islandora_solr_search_init(); From 59db2175a539b46754764da588f1d6a883d96ef3 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Tue, 29 Nov 2011 12:41:33 -0400 Subject: [PATCH 05/13] aded classes for first and last row and column --- .../IslandoraSolrResultsTable.inc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/islandora_solr_config/IslandoraSolrResultsTable.inc b/islandora_solr_config/IslandoraSolrResultsTable.inc index c8e784a6..bc108e7e 100644 --- a/islandora_solr_config/IslandoraSolrResultsTable.inc +++ b/islandora_solr_config/IslandoraSolrResultsTable.inc @@ -112,19 +112,26 @@ class IslandoraSolrResultsTable extends IslandoraSolrResults { foreach ($values as $num => $val_array) { unset($rowclass); $result_num = $recordStart + $num + 1; - $rows[$row][] = array( + $rows[$row]['data'][] = array( 'data' => (isset($val_array['PID']) ? l($result_num,'fedora/repository/'.$val_array['PID']) : $result_num), 'header' => TRUE, + 'class' => 'col-first' + ); - foreach ($fields as $field) { - if (isset ($val_array[$field])) { - $rows[$row][] = $val_array[$field]; - } else { - $rows[$row][] = ''; + $field_count = count($fields); + foreach ($fields as $fieldnum => $field) { + if (!isset ($val_array[$field])) { + $val_array['field'] = " "; } + $cell_data = array('data' => $val_array[$field]); + $rows[$row]['data'][] = $cell_data; + } + $rows[$row]['data'][$field_count]['class'] = 'col-last'; $row++; } + $rows[0]['class'] = 'row-first'; + $rows[$row -1]['class'] = 'row-last'; $output .= theme_table($header,$rows,array('class'=>'islandora_solr_search_results_table')); From 859bf219a1ac8a99531ff4f8b52855d10bc106ff Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Wed, 30 Nov 2011 16:10:23 -0400 Subject: [PATCH 06/13] added snippets to default search --- IslandoraSolrResults.inc | 19 ++++++++++++++++++- .../islandora_solr_config.module | 5 +---- islandora_solr_search.admin.inc | 8 +------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/IslandoraSolrResults.inc b/IslandoraSolrResults.inc index 680d0e6b..00d0ac76 100644 --- a/IslandoraSolrResults.inc +++ b/IslandoraSolrResults.inc @@ -140,7 +140,13 @@ class IslandoraSolrResults { $title = NULL; $recordStart = $results->response->start; $limitResults = variable_get('islandora_solr_search_limit_result_fields', 0); + $rawResponse = $results->getRawResponse(); + $responseArray = json_decode($rawResponse, true); + $docs = $responseArray['response']['docs']; + //retrieve 'highlighing' from resultset. + $highlightResults = $responseArray['highlighting']; $highlights = $results->highlighting; + foreach ($highlights as $highlight) { $fields = get_object_vars($highlight); $keys = array_keys($fields); @@ -160,7 +166,7 @@ class IslandoraSolrResults { foreach ($results->response->docs as $doc) { $rows = array(); $row = 0; - + $snippet = null; foreach ($doc as $field => $value) { if ($limitResults && empty($this->resultFieldArray[$field])) { @@ -177,14 +183,25 @@ class IslandoraSolrResults { } if ($field == 'PID') { + $pid = $value; $l = l($value, 'fedora/repository/' . htmlspecialchars($value, ENT_QUOTES, 'utf-8')); $rows[$row][] = $l; + if (is_array($keys)) { + $snippet = $highlightResults[$value][$keys[0]]; + } } else { $rows[$row][] = $value; } $row++; } + if ($snippet) { + $rows[$row][] = array( + 'data' => 'Full Text', + 'header' => TRUE, + ); + $rows[$row][] = $snippet[0]; + } $items[] = theme_table(NULL, $rows, array('class' => 'islandora_solr_search_results_object')); } $output = theme_item_list($items, $title, $type, array('class' => 'stuff', 'start' => ($recordStart + 1))); diff --git a/islandora_solr_config/islandora_solr_config.module b/islandora_solr_config/islandora_solr_config.module index 067ffc2e..57fd261b 100644 --- a/islandora_solr_config/islandora_solr_config.module +++ b/islandora_solr_config/islandora_solr_config.module @@ -8,7 +8,6 @@ * Configuration module for islandora_solr_search.module */ - /** * Implements hook_islandora_solr_primary_display() */ @@ -38,6 +37,7 @@ function islandora_solr_config_islandora_solr_primary_display() { 'function' => "displayResults", 'description' => t('A tabular output for maps. Depends upon the existence of a TN datastream in fedora objects returned as results.') ), + ); } @@ -61,7 +61,6 @@ function islandora_solr_config_islandora_solr_secondary_display() { /** * Implementation of hook_help() */ - function islandora_solr_config_help($path, $arg) { switch ($path) { @@ -75,8 +74,6 @@ function islandora_solr_config_help($path, $arg) {
  • Method - displayResults ", array('!page' => l("Islandora_solr_search configuration page", 'admin/settings/islandora_solr_search'),) - - ); } } diff --git a/islandora_solr_search.admin.inc b/islandora_solr_search.admin.inc index 4fbc8146..7a7fe2ac 100644 --- a/islandora_solr_search.admin.inc +++ b/islandora_solr_search.admin.inc @@ -91,13 +91,7 @@ function islandora_solr_admin_settings(&$form_state) { ); } - $form['islandora_solr_sortfield'] = array( - '#type' => 'textfield', - '#title' => t("Field on which to sort results"), - '#description' => t("If this field is left blank results will be sorted by relevance to the query.
    - Only fields defined in the schema as both stored and not multivalued may be used for sorting.
    "), - '#default_value' => variable_get('islandora_solr_sortfield', ''), - ); + $profiles = module_invoke_all("islandora_solr_primary_display"); From 1169a52892026e08933ccc71464ebd5b24579930 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 12 Dec 2011 13:20:53 -0400 Subject: [PATCH 07/13] Fixed version --- islandora_solr_config/islandora_solr_config.info | 2 +- islandora_solr_search.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora_solr_config/islandora_solr_config.info b/islandora_solr_config/islandora_solr_config.info index ba39074c..59c8d0ab 100644 --- a/islandora_solr_config/islandora_solr_config.info +++ b/islandora_solr_config/islandora_solr_config.info @@ -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.3beta2 +version = 11.3beta3 core = 6.x diff --git a/islandora_solr_search.info b/islandora_solr_search.info index 68748185..abdb8370 100644 --- a/islandora_solr_search.info +++ b/islandora_solr_search.info @@ -2,5 +2,5 @@ name = Islandora Solr Search dependencies[] = fedora_repository description = searches a solr index package = Islandora Search -version = 11.3beta2 +version = 11.3beta3 core = 6.x From e2dde736411d813ab0f322eb3d667ddf7b96b616 Mon Sep 17 00:00:00 2001 From: William Panting Date: Fri, 16 Dec 2011 16:36:30 -0400 Subject: [PATCH 08/13] showing facets when there is only one? --- IslandoraSolrResults.inc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/IslandoraSolrResults.inc b/IslandoraSolrResults.inc index 20d06314..57f3d142 100644 --- a/IslandoraSolrResults.inc +++ b/IslandoraSolrResults.inc @@ -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 = '') { @@ -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 .= "
    "; @@ -325,10 +325,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"; @@ -378,30 +378,30 @@ class IslandoraSolrResults { $facet_count++; } } - if ($facet_count >= 2) { + if ($facet_count >= 1) { $facet_output .='
    '; - + // 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++; @@ -411,7 +411,7 @@ class IslandoraSolrResults { $facet_output .= theme_item_list($list_items_hidden, NULL, $list_type, $list_attributes); $facet_output .= '
    '; } - + $facet_output .='
    '; } } @@ -442,7 +442,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) { @@ -528,7 +528,7 @@ class IslandoraSolrResults { /** * Build simple solr form * @global type $islandora_query - * @return type + * @return type */ function build_simple_solr_form() { $required = FALSE; @@ -557,7 +557,7 @@ class IslandoraSolrResults { /** * Theme solr search form * @param type $form - * @return type + * @return type */ function theme_solr_search_form($form) { if (!isset($repeat)) { From 2f5c050ace478087fb196c56f84cad947cc049a8 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Tue, 10 Jan 2012 14:36:15 -0400 Subject: [PATCH 09/13] Changed version --- islandora_solr_config/islandora_solr_config.info | 2 +- islandora_solr_search.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora_solr_config/islandora_solr_config.info b/islandora_solr_config/islandora_solr_config.info index 59c8d0ab..b7de2ff4 100644 --- a/islandora_solr_config/islandora_solr_config.info +++ b/islandora_solr_config/islandora_solr_config.info @@ -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.3beta3 +version = 11.3.1 core = 6.x diff --git a/islandora_solr_search.info b/islandora_solr_search.info index abdb8370..c002e9b6 100644 --- a/islandora_solr_search.info +++ b/islandora_solr_search.info @@ -2,5 +2,5 @@ name = Islandora Solr Search dependencies[] = fedora_repository description = searches a solr index package = Islandora Search -version = 11.3beta3 +version = 11.3.1 core = 6.x From 7586e04b451652cce441b5389c216d222c449d5f Mon Sep 17 00:00:00 2001 From: William Panting Date: Mon, 16 Jan 2012 11:10:55 -0400 Subject: [PATCH 10/13] changed demoFoxmlToSolr.xsl to demoFoxmlToSolr.xslt --- solr_xmls/demoFoxmlToSolr.xsl | 803 ---------------------------------- 1 file changed, 803 deletions(-) delete mode 100644 solr_xmls/demoFoxmlToSolr.xsl diff --git a/solr_xmls/demoFoxmlToSolr.xsl b/solr_xmls/demoFoxmlToSolr.xsl deleted file mode 100644 index e16a778e..00000000 --- a/solr_xmls/demoFoxmlToSolr.xsl +++ /dev/null @@ -1,803 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - access.person - - - - - - access.group - - - - - - - - tag - - - - tagUser - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - info:fedora/ilives:pageCModel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 37449c79c40b3663c238f236f4482c7cd51fdab7 Mon Sep 17 00:00:00 2001 From: William Panting Date: Mon, 16 Jan 2012 11:11:23 -0400 Subject: [PATCH 11/13] changed demoFoxmlToSolr.xsl to demoFoxmlToSolr.xslt --- solr_xmls/demoFoxmlToSolr.xslt | 803 +++++++++++++++++++++++++++++++++ 1 file changed, 803 insertions(+) create mode 100644 solr_xmls/demoFoxmlToSolr.xslt diff --git a/solr_xmls/demoFoxmlToSolr.xslt b/solr_xmls/demoFoxmlToSolr.xslt new file mode 100644 index 00000000..e16a778e --- /dev/null +++ b/solr_xmls/demoFoxmlToSolr.xslt @@ -0,0 +1,803 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + access.person + + + + + + access.group + + + + + + + + tag + + + + tagUser + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + info:fedora/ilives:pageCModel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From d92e47b4ffcdbea6a9df30317f62dcd114449625 Mon Sep 17 00:00:00 2001 From: Danny Joris Date: Mon, 16 Jan 2012 12:03:40 -0400 Subject: [PATCH 12/13] add the ability to switch displays through the url - needs bit of finetuning by adding the ability to limit available displays --- IslandoraSolrQueryProcessor.inc | 16 +++++++++---- IslandoraSolrResults.inc | 42 +++++++++++++++++++++++++-------- islandora_solr_search.module | 8 ++++--- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/IslandoraSolrQueryProcessor.inc b/IslandoraSolrQueryProcessor.inc index 7e65f164..06e5613b 100644 --- a/IslandoraSolrQueryProcessor.inc +++ b/IslandoraSolrQueryProcessor.inc @@ -144,6 +144,13 @@ class IslandoraSolrQueryProcessor { } $this->solrStart = max(0, $startPage) * $this->solrLimit; + // look for the current display + $display = isset($_GET['display']) ? $_GET['display'] : ''; + $query = ''; + if ($display) { + $query = array('display' => $display); + } + // The breadcrumb should go in the display class $queryurl = "islandora/solr/search/" . replaceSlashes($this->solrQuery); $breadcrumb_fq = $islandora_fq; @@ -154,6 +161,7 @@ class IslandoraSolrQueryProcessor { $value = restoreSlashes(trim(substr($facet, strpos($facet, ":") + 1), '"')); $options = array('html' => TRUE); $options['attributes']['title'] = $facet; + $options['query'] = $query; // query for display $crumblink = $queryurl . "/" . $breadcrumb_fq . (empty($this->solrDefType) ? '' : '/' . $this->solrDefType); $cut_fq = $this->delete_filter($islandora_fq, $facet); $cutlink = $queryurl . "/" . $cut_fq . (empty($this->solrDefType) ? '' : '/' . $this->solrDefType); @@ -161,7 +169,7 @@ class IslandoraSolrQueryProcessor { $options['attributes']['class'] = "strikethrough"; } $breadcrumb[] = l($value, $crumblink, $options) . - " (" . l("x", $cutlink, array('attributes' => array('title' => "Remove " . $facet))) . ")"; + " (" . l("x", $cutlink, array('attributes' => array('title' => "Remove " . $facet), 'query' => $query)) . ")"; $breadcrumb_fq = $this->delete_filter($breadcrumb_fq, $facet); } } @@ -176,8 +184,8 @@ class IslandoraSolrQueryProcessor { } } if ($queryval != '%252F') { - $breadcrumb[] = l($queryval, $queryurl . "/-", array('attributes' => array('title' => $this->solrQuery))) . - " (" . l("x", $cutlink, array('attributes' => array('title' => "Remove " . $facet))) . ")"; + $breadcrumb[] = l($queryval, $queryurl . "/-", array('attributes' => array('title' => $this->solrQuery), 'query' => $query)) . + " (" . l("x", $cutlink, array('attributes' => array('title' => "Remove " . $facet), 'query' => $query)) . ")"; } } $breadcrumb[] = l(t('Home'), NULL); @@ -190,7 +198,7 @@ class IslandoraSolrQueryProcessor { // At this point let's invoke a hook for third-party modules to mess about // with the query parameters if they need to. Third party modules may alter // this object's query parameters if they wish. - // module_invoke_all("islandora_solr_search_query_processor", &$this); + module_invoke_all("islandora_solr_search_query_processor", &$this); return; } diff --git a/IslandoraSolrResults.inc b/IslandoraSolrResults.inc index 20d06314..140ee637 100644 --- a/IslandoraSolrResults.inc +++ b/IslandoraSolrResults.inc @@ -220,6 +220,14 @@ class IslandoraSolrResults { $solrQueryProcessor->solrResult->facet_counts->facet_fields : NULL; //dsm($islandora_facets); + + // look for the current display + $display = isset($_GET['display']) ? $_GET['display'] : ''; + $query = ''; + if ($display) { + $query = array('display' => $display); + } + if (strlen(trim($solrQueryProcessor->solrQuery))) { // Variables to build a drupal-ish unordered list @@ -231,9 +239,12 @@ class IslandoraSolrResults { // OK, so it's a list of one. // In the future, we could reasonably break the query on boolean operators // and allow one part to be removed at a time. - $query_list_items[] .= l( - 'Remove search term', 'islandora/solr/search/' . " " . '/' . replaceSlashes($islandora_fq) . '/dismax', array('html' => TRUE) - ) . ' ' . stripslashes($solrQueryProcessor->solrQuery); + + // set link properties + $image = 'Remove search term'; + $link = 'islandora/solr/search/' . " " . '/' . replaceSlashes($islandora_fq) . '/dismax'; + + $query_list_items[] .= l($image, $link, array('html' => TRUE, 'query' => $query )) . ' ' . stripslashes($solrQueryProcessor->solrQuery); $output .= '
    '; @@ -271,9 +282,12 @@ class IslandoraSolrResults { $exclude = TRUE; $filter_name = substr($filter_name, 1); } - $filter_list_items[] = l( - 'Remove this filter', 'islandora/solr/search/' . replaceSlashes($solrQueryProcessor->solrQuery) . '/' . replaceSlashes($filter_disable) . '/' . $solrQueryProcessor->solrDefType, array('html' => TRUE) - ) . ' ' . $this->facetFieldArray[$filter_name] . ($exclude ? ' != ' : ' = ') . $filter_value; + + // set link properties + $image = 'Remove this filter'; + $link = 'islandora/solr/search/' . replaceSlashes($solrQueryProcessor->solrQuery) . '/' . replaceSlashes($filter_disable) . '/' . $solrQueryProcessor->solrDefType; + + $filter_list_items[] = l($image, $link, array('html' => TRUE, 'query' => $query )) . ' ' . $this->facetFieldArray[$filter_name] . ($exclude ? ' != ' : ' = ') . $filter_value; } } @@ -368,12 +382,20 @@ class IslandoraSolrResults { $evenodd = ( $facet_count % 2 ? 'odd' : 'even' ); $lplus = 'islandora/solr/search/' . $solrQueryProcessor->solrQuery . '/' . $filter_include . '/' . $solrQueryProcessor->solrDefType; $lminus = 'islandora/solr/search/' . $solrQueryProcessor->solrQuery . '/' . $filter_exclude . '/' . $solrQueryProcessor->solrDefType; + + + // look for the current display + $display = isset($_GET['display']) ? $_GET['display'] : ''; + $query = ''; + if ($display) { + $query = array('display' => $display); + } + $text = $name; - $attrs = array(); - $list_items[] = l($text, $lplus, $attrs) . ' (' . $number . ')' . + $list_items[] = l($text, $lplus, array('query' => $query)) . ' (' . $number . ')' . '' . - l('+', $lplus, array('attributes' => array('class' => 'plus'))) . ' ' . - l('-', $lminus, array('attributes' => array('class' => 'minus'))) . + l('+', $lplus, array('attributes' => array('class' => 'plus'), 'query' => $query )) . ' ' . + l('-', $lminus, array('attributes' => array('class' => 'minus'), 'query' => $query )) . ''; $facet_count++; } diff --git a/islandora_solr_search.module b/islandora_solr_search.module index 156932cd..6695003b 100644 --- a/islandora_solr_search.module +++ b/islandora_solr_search.module @@ -301,14 +301,16 @@ function islandora_solr_search($query, $fq=NULL, $dismax=NULL) { // Build and execute Apache Solr query $queryResult = $queryClass->buildAndExecuteQuery($query, $fq, $dismax); + // get profiles + $primary_profiles = module_invoke_all("islandora_solr_primary_display"); + $secondary_profiles = module_invoke_all("islandora_solr_secondary_display"); // Get the preferred display profile // Order: First choice is what's in the ?profile query var // Second choice is the primary display profile // Third choice is the default IslandoraSolrResults - $islandora_solr_primary_display = variable_get('islandora_solr_primary_display', 'default'); + $islandora_solr_primary_display = ((isset($_GET['display']) AND array_key_exists($_GET['display'], $primary_profiles)) ? $_GET['display'] : variable_get('islandora_solr_primary_display', 'default')); $islandora_solr_selected_display = isset($_GET['solr_profile']) ? $_GET['solr_profile'] : NULL; - $primary_profiles = module_invoke_all("islandora_solr_primary_display"); - $secondary_profiles = module_invoke_all("islandora_solr_secondary_display"); + // TODO: Also filter secondary displays against those checked in the configuration options. if (isset($secondary_profiles[$islandora_solr_selected_display])) { From d21d3347c1400cbecdc16710c20c383ab7375046 Mon Sep 17 00:00:00 2001 From: Danny Joris Date: Mon, 16 Jan 2012 13:59:21 -0400 Subject: [PATCH 13/13] if there is a typo in the ?display parameter, make sure the links dont output that typo again. Instead use the current (default) display name --- IslandoraSolrQueryProcessor.inc | 8 +++++++- IslandoraSolrResults.inc | 6 ++++-- islandora_solr_search.module | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/IslandoraSolrQueryProcessor.inc b/IslandoraSolrQueryProcessor.inc index ed70b710..b14ef545 100644 --- a/IslandoraSolrQueryProcessor.inc +++ b/IslandoraSolrQueryProcessor.inc @@ -154,7 +154,13 @@ class IslandoraSolrQueryProcessor { $this->solrStart = max(0, $startPage) * $this->solrLimit; // look for the current display - $display = isset($_GET['display']) ? $_GET['display'] : ''; + // it seems like this function is happening before we even look which display + // to use, so we'll have to check again using hook_invoke_all and checking + // the variable. + $primary_profiles = module_invoke_all("islandora_solr_primary_display"); + $islandora_solr_primary_display = ((isset($_GET['display']) AND array_key_exists($_GET['display'], $primary_profiles)) ? $_GET['display'] : variable_get('islandora_solr_primary_display', 'default')); + //global $current_display; + $display = isset($_GET['display']) ? $islandora_solr_primary_display : ''; $query = ''; if ($display) { $query = array('display' => $display); diff --git a/IslandoraSolrResults.inc b/IslandoraSolrResults.inc index 18a727a0..6864ffa0 100644 --- a/IslandoraSolrResults.inc +++ b/IslandoraSolrResults.inc @@ -239,7 +239,8 @@ class IslandoraSolrResults { //dsm($islandora_facets); // look for the current display - $display = isset($_GET['display']) ? $_GET['display'] : ''; + global $current_display; + $display = isset($_GET['display']) ? $current_display : ''; $query = ''; if ($display) { $query = array('display' => $display); @@ -402,7 +403,8 @@ class IslandoraSolrResults { // look for the current display - $display = isset($_GET['display']) ? $_GET['display'] : ''; + global $current_display; + $display = isset($_GET['display']) ? $current_display : ''; $query = ''; if ($display) { $query = array('display' => $display); diff --git a/islandora_solr_search.module b/islandora_solr_search.module index f063a211..124666ce 100644 --- a/islandora_solr_search.module +++ b/islandora_solr_search.module @@ -6,6 +6,8 @@ module_load_include('inc', 'islandora_solr_search', 'IslandoraSolrQueryProcessor //$islandora_query; $queryClass; +// set current display +$current_display; /** * @file @@ -313,6 +315,9 @@ function islandora_solr_search($query, $fq=NULL, $dismax=NULL) { $islandora_solr_primary_display = ((isset($_GET['display']) AND array_key_exists($_GET['display'], $primary_profiles)) ? $_GET['display'] : variable_get('islandora_solr_primary_display', 'default')); $islandora_solr_selected_display = isset($_GET['solr_profile']) ? $_GET['solr_profile'] : NULL; + // set global variable + global $current_display; + $current_display = $islandora_solr_primary_display; // TODO: Also filter secondary displays against those checked in the configuration options. if (isset($secondary_profiles[$islandora_solr_selected_display])) {