Browse Source

added reserves block refactored some of the solr search stuff

2.x-ebsco
Paul Pound 10 years ago
parent
commit
1ab1dd0ca7
  1. 5
      css/roblib_search.base.css
  2. 42
      targets/solr_site/js/solr_site_reserves.js
  3. 68
      targets/solr_site/roblib_search_solr_site.module
  4. 33
      targets/solr_site/theme/theme.inc

5
css/roblib_search.base.css

@ -54,6 +54,11 @@
border-left-width: 10px;
}
.roblib-search-solr-reserves-header {
border-left-color:#888000;
border-left-width: 10px;
}
.roblib-search-solr-bestbet-header {
border-left-color:tan;
border-left-width: 10px;

42
targets/solr_site/js/solr_site_reserves.js

@ -0,0 +1,42 @@
Drupal.behaviors.roblib_search_solr_site_reserves = {
attach: function(context, settings) {
$url = settings.roblib_search_solr_site_reserves.search_url;
query = settings.roblib_search_solr_site_results.search_query;
baseUrl = settings.roblib_search_solr_site_results.base_url;
default_site_type = settings.roblib_search_solr_site_results.default_site_type + '/';
jQuery.getJSON($url, function(data) {
var items = [];
var numberOfDocs = 0;
try {
numberOfDocs = data.response.docs.length;
} catch (err) {
// do nothing leave docLength at 0
}
if (numberOfDocs < 1) {
jQuery('#' + 'roblib-search-content-solr-site-reserves').empty().append('No Results');
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-reserves').hide();
} else {
jQuery('#' + 'roblib-search-content-solr-site-reserves').empty();
var counter = 0;
var divs = new Array();
var content = new Array();
jQuery.each(data.response.docs, function(key, val) {
id = 'roblib_search_solr_reserves_' + counter;
content[counter] = val.teaser;
divs[counter++] = id;
items.push('<div class ="roblib-search-row" id="' + id + '">\n\
<div class="roblib-title reserves">\n\
<a href="' + val.url + '">' + val.label + '</a></div></div>');
});
jQuery('#' + 'roblib-search-content-solr-site-reserves').empty().append(items.join(''));
qtipify(divs, content, 'Description');
}
if (numberOfDocs > 0)
{
jQuery('#' + 'roblib-search-solr-site-reserves-more').empty().append('<a href="'+ baseUrl + '/search/' + default_site_type + query +'?f[0]=bundle:course_reserve">see all results</a>');
}
});
}
}

68
targets/solr_site/roblib_search_solr_site.module

@ -29,6 +29,14 @@ function roblib_search_solr_site_menu() {
'access arguments' => array('search roblib solr_site'),
);
$items['roblib_search/solr_site/reserves/%'] = array(
'title' => 'BestBet',
'page callback' => 'roblib_search_solr_site_reserves',
'page arguments' => array(3),
'type' => MENU_CALLBACK,
'access arguments' => array('search roblib solr_site'),
);
$items['roblib_search/solr_site/databases/%'] = array(
'title' => 'solr_site databases',
'page callback' => 'roblib_search_solr_site_databases',
@ -113,29 +121,11 @@ function roblib_search_solr_site_theme() {
return array(
// results page
'roblib_search_solr_site_bestbet' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-solr-site-results',
'variables' => array('results' => NULL),
),
'roblib_search_solr_site_databases' => array(
'roblib_search_solr_site' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-solr-site-results',
'variables' => array('results' => NULL),
),
'roblib_search_solr_site_guides' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-solr-site-results',
'variables' => array('results' => NULL),
),
'roblib_search_solr_site_results' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-solr-site-results',
'variables' => array('results' => NULL),
'variables' => array('type' => NULL),
),
);
}
@ -173,6 +163,13 @@ function roblib_search_solr_site_block_info() {
'cache' => DRUPAL_CACHE_PER_ROLE, // default
);
$blocks['roblib_search_solr_site_reserves'] = array(
// info: The name of the block.
'info' => t('Roblib Solr Search Reserves Block'),
// Block caching options (per role, per user, etc.)
'cache' => DRUPAL_CACHE_PER_ROLE, // default
);
return $blocks;
}
@ -206,6 +203,11 @@ function roblib_search_solr_site_preprocess_panels_pane(&$variables, $hook) {
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-solr-results-header">';
$variables['title_suffix'] = '</div>';
break;
case 'roblib_search_solr_site-roblib_search_solr_site_reserves':
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-solr-reserves-header">';
$variables['title_suffix'] = '</div>';
break;
}
}
@ -216,22 +218,27 @@ function roblib_search_solr_site_block_view($delta = '') {
switch ($delta) {
case 'roblib_search_solr_site_bestbet':
$block['subject'] = t('Best Bets');
$block['content'] = theme('roblib_search_solr_site_bestbet', array('results' => NULL));
$block['content'] = theme('roblib_search_solr_site', array('type' => 'bestbet'));
break;
case 'roblib_search_solr_site_db':
$block['subject'] = t('Databases');
$block['content'] = theme('roblib_search_solr_site_databases', array('results' => NULL));
$block['content'] = theme('roblib_search_solr_site', array('type' => 'databases'));
break;
case 'roblib_search_solr_site_guides':
$block['subject'] = t('Guides');
$block['content'] = theme('roblib_search_solr_site_guides', array('results' => NULL));
$block['content'] = theme('roblib_search_solr_site', array('type' => 'guides'));
break;
case 'roblib_search_solr_site_results':
$block['subject'] = t('Library Site');
$block['content'] = theme('roblib_search_solr_site_results', array('results' => NULL));
$block['content'] = theme('roblib_search_solr_site', array('type' => 'results'));
break;
case 'roblib_search_solr_site_reserves':
$block['subject'] = t('Reserves');
$block['content'] = theme('roblib_search_solr_site', array('type' => 'reserves'));
break;
}
return $block;
@ -279,6 +286,19 @@ function roblib_search_solr_site_databases($query) {
exit();
}
/**
* Send the query to solr but limit the results so it only includes content of type database.
*
* Print json and exit so the javascript can consume the json.
*
* @param string $query
* The solr search string.
*/
function roblib_search_solr_site_reserves($query) {
print roblib_search_solr_site_get_results($query, 'bundle:course_reserve');
exit();
}
/**
* Send the query to solr but limit the results so it only includes content of tagged with the guide keyword.
*

33
targets/solr_site/theme/theme.inc

@ -4,43 +4,16 @@
*
*/
/**
* @param $variables
*/
function roblib_search_solr_site_preprocess_roblib_search_solr_site_bestbet(&$variables) {
roblib_search_solr_site_preprocessor($variables, 'bestbet');
}
/**
* @param $variables
*/
function roblib_search_solr_site_preprocess_roblib_search_solr_site_results(&$variables) {
roblib_search_solr_site_preprocessor($variables, 'results');
}
/**
* @param $variables
*/
function roblib_search_solr_site_preprocess_roblib_search_solr_site_databases(&$variables) {
roblib_search_solr_site_preprocessor($variables, 'databases');
}
/**
* @param $variables
*/
function roblib_search_solr_site_preprocess_roblib_search_solr_site_guides(&$variables) {
roblib_search_solr_site_preprocessor($variables, 'guides');
}
/**
* @param array $variables
* @param string $type
*
* @return string
*/
function roblib_search_solr_site_preprocessor(&$variables, $type) {
function roblib_search_solr_site_preprocess_roblib_search_solr_site(&$variables){
//function roblib_search_solr_site_preprocessor(&$variables, $type) {
global $base_url;
$type = $variables['type'];
if (!isset($query)) {
if (isset($_GET['roblib_query'])) {
$query = $_GET['roblib_query'];

Loading…
Cancel
Save