diff --git a/targets/islandscholar/js/islandscholar_results.js b/targets/islandscholar/js/islandscholar_results.js index d675d8a..4d8033e 100644 --- a/targets/islandscholar/js/islandscholar_results.js +++ b/targets/islandscholar/js/islandscholar_results.js @@ -1,7 +1,7 @@ Drupal.behaviors.roblib_search_islandscholar = { - attach: function(context, settings) { + attach: function (context, settings) { url = settings.roblib_search_islandscholar.search_url; - jQuery.getJSON(url, function(data) { + jQuery.getJSON(url, function (data) { var items = []; var numberOfDocs = 0; try { @@ -16,87 +16,70 @@ Drupal.behaviors.roblib_search_islandscholar = { var counter = 0; var divs = new Array(); var content = new Array(); - jQuery.each(data.response.docs, function(key, val) { + jQuery.each(data.response.docs, function (key, val) { id = 'roblib-search-islandscholar-' + counter; content[counter] = ''; - if(typeof val['mods.abstract'] !== 'undefined' ){ - content[counter] = val['mods.abstract'][0]; + if (typeof val['mods_abstract_s'] !== 'undefined') { + content[counter] = val['mods_abstract_s'][0]; } else { content[counter] = 'No abstract available'; } divs[counter++] = id; items.push('
\n\
\n\ - ' + val.Title_sorted + '
'); + ' + val['dc.title'] + '
'); try { - items.push('
'); - jQuery.each(val["mods.author"], function(key2, val2){ - items.push('' + val2 + '; ') - }) - items.push('
') - } catch (e){ + items.push('
'); + jQuery.each(val["mods_author_lastname_first_ms"], function (key2, val2) { + items.push('' + val2 + '; ') + }) + items.push('
') + } catch (e) { } - try { - items.push('
'); - - try{ - if (typeof val["mods.hostTitle"][0] !== 'undefined') { - items.push('' + val["mods.hostTitle"][0] + ' ') - } - - } catch (err){ - - } - try{ - jQuery.each(val.dateIssued, function(key2, val2){ - items.push('' + val2 + ' ') - }) - } catch(err){ - - } - try{ - jQuery.each(val["mods.volume"], function(key2, val2){ - items.push('Vol. ' + val2 + ' ') - }) - } catch (err){ - - } - try{ - jQuery.each(val["mods.issue"], function(key2, val2){ - items.push('Issue ' + val2 + ', ') - }) - } catch (err){ - - } - try{ - jQuery.each(val["mods.pageStart"], function(key2, val2){ - items.push('p' + val2 + '') - }) - } catch (err){ - - } - try{ - jQuery.each(val["mods.pageEnd"], function(key2, val2){ - items.push('-' + val2 + ',') - }) - } catch (err){ - - } - jQuery.each(val.genre, function(key2, val2){ - items.push('
' + val2 + '
') - }) - try{ - if(jQuery.inArray('OBJ',val.hasDatastreams) > 0){ - items.push('
full text
') ; - } - } catch (err){ - } - items.push('
') - } catch (e){ + items.push('
'); + + + if (typeof val.mods_relatedItem_host_titleInfo_title_s !== 'undefined') { + items.push('' + val.mods_relatedItem_host_titleInfo_title_s + ' ') + } + + + if (typeof val.mods_canonical_date_issued_s !== 'undefined') { + items.push('' + val.mods_canonical_date_issued_s + ' ') + } + + + if (typeof val.mods_part_detail_volume_number_s !== 'undefined') { + items.push('Vol. ' + val.mods_part_detail_volume_number_s + ' ') + } + + if (typeof val.mods_part_detail_issue_number_s !== 'undefined') { + items.push('Issue ' + val.mods_part_detail_issue_number_s + ', ') + } + + + if (typeof val.mods_part_extent_start_s !== 'undefined') { + items.push('p' + val.mods_part_extent_start_s + '') + } + + + if (typeof val.mods_part_extent_end_s !== 'undefined') { + items.push('-' + val.mods_part_extent_end_s + ',') } + + if (typeof val.mods_genre_s !== 'undefined') { + items.push('
' + val.mods_genre_s + '
'); + } + + if (jQuery.inArray('PDF', val.fedora_datastreams_ms) > 0) { + items.push('
full text
'); + } + + items.push('
'); + items.push(''); }); diff --git a/targets/islandscholar/roblib_search_islandscholar.module b/targets/islandscholar/roblib_search_islandscholar.module index c00d946..93606c4 100644 --- a/targets/islandscholar/roblib_search_islandscholar.module +++ b/targets/islandscholar/roblib_search_islandscholar.module @@ -47,6 +47,21 @@ function roblib_search_islandscholar_config_form($form, &$form_state) { '#description' => t('The number of results to display in the Bento box'), '#required' => TRUE, ); + $form['roblib_search_islandscholar_fq'] = array( + '#type' => 'textarea', + '#title' => t('Filter Query'), + '#default_value' => variable_get('roblib_search_islandscholar_fq', 'PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'), + '#description' => t('A query used to restrict the results to namespace and content models'), + '#required' => TRUE, + ); + + $form['roblib_search_islandscholar_qf'] = array( + '#type' => 'textarea', + '#title' => t('Query Field'), + '#default_value' => variable_get('roblib_search_islandscholar_qf', 'dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'), + '#description' => t('The fields to query and a weight for each field.'), + '#required' => TRUE, + ); return system_settings_form($form); } @@ -90,7 +105,7 @@ function roblib_search_islandscholar_block_info() { $blocks['roblib_islandscholar_results'] = array( // info: The name of the block. - 'info' => t('Islandscholar Solr Search Results block'), + 'info' => t('Roblib Islandscholar Solr Search Results block'), // Block caching options (per role, per user, etc.) 'cache' => DRUPAL_CACHE_PER_ROLE, // default ); @@ -141,9 +156,10 @@ function roblib_search_islandscholar_get_search_url($query){ $data = array( 'wt' => 'json', 'q' => $query , - 'fq' => 'PID:ir* AND (rels.hasModel:info\:fedora/islandora\:thesisCModel OR rels.hasModel:info\:fedora/islandora\:citationCModel)', - 'qf' => 'mods.title^3.0 mods.subTitle^2.5 mods.author^5.0 mods.department^2.0 mods.abstract^1.5 dc.title^2.5 mods.subject^1.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 mods.genre^1.0 mods.hostTitle^2.0 mods.issn^1.0 mods.date^2.0 pdf.text^2.0 dsm.PDF^2.0 collection_title^1.0', + 'fq' => variable_get('roblib_search_islandscholar_fq','PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'), + 'qf' => variable_get('roblib_search_islandscholar_qf','dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'), 'rows' => $num_results, + 'defType' => 'dismax', ); $url = url($solr_url . '/select', array('query' => $data)); return $url;