diff --git a/css/roblib_search.base.css b/css/roblib_search.base.css index 266dc83..f3c8abd 100644 --- a/css/roblib_search.base.css +++ b/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; diff --git a/targets/solr_site/js/solr_site_reserves.js b/targets/solr_site/js/solr_site_reserves.js new file mode 100644 index 0000000..9d81b59 --- /dev/null +++ b/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('
\n\ +
\n\ + ' + val.label + '
'); + }); + 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('see all results'); + } + }); + } + +} diff --git a/targets/solr_site/roblib_search_solr_site.module b/targets/solr_site/roblib_search_solr_site.module index e5ea654..5cf5175 100755 --- a/targets/solr_site/roblib_search_solr_site.module +++ b/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'] = '
'; $variables['title_suffix'] = '
'; break; + + case 'roblib_search_solr_site-roblib_search_solr_site_reserves': + $variables['title_prefix'] = '
'; + $variables['title_suffix'] = '
'; + 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. * diff --git a/targets/solr_site/theme/theme.inc b/targets/solr_site/theme/theme.inc index d094bc0..0b4ca58 100755 --- a/targets/solr_site/theme/theme.inc +++ b/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'];