Paul Pound
12 years ago
commit
78e51620d1
21 changed files with 830 additions and 0 deletions
@ -0,0 +1,18 @@
|
||||
/* |
||||
Document : roblib_search.base.css |
||||
Created on : Apr 9, 2013, 2:00:18 PM |
||||
Author : ppound |
||||
Description: |
||||
Purpose of the stylesheet follows. |
||||
*/ |
||||
|
||||
.panels-ipe-portlet-content{background:#f4f4f4 url(../img/bggradientresult.jpg) repeat-x top left;position:relative;overflow:hidden; padding: 5px;padding-left: 10px;} |
||||
.roblib-search-row { |
||||
border-bottom:1px #cecfcc dotted; |
||||
} |
||||
.panels-ipe-portlet-wrapper { |
||||
border-left:1px solid #cecfcc; border-right:1px solid #cecfcc; line-height: 2em; margin-bottom:10px; border-bottom:1px solid #cecfcc; |
||||
} |
||||
.roblib-search-more{ |
||||
text-align: right; font-size: smaller; |
||||
} |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 250 B |
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,7 @@
|
||||
name = Roblib Search |
||||
configure = admin/roblib_search/configure |
||||
description = Provides a search form and fires a hook when the search is submitted. Other modules should implement the search functionality by implementing the correct hooks. |
||||
package = Roblib Search |
||||
version = 7.x-dev |
||||
core = 7.x |
||||
stylesheets[all][] = css/roblib_search.base.css |
@ -0,0 +1,198 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Implementation of Roblib search for searching several targets. |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* Implements hook_boot(). |
||||
* @global type $conf |
||||
*/ |
||||
function roblib_search_boot() { |
||||
/* below is an example from islandora_solr module for internationalization |
||||
* global $conf; |
||||
|
||||
// Allow i18n, by using multilingual variables. |
||||
if (module_exists('i18n')) { |
||||
$vars = array( |
||||
'islandora_solr_facets', |
||||
'islandora_solr_result_fields', |
||||
'islandora_solr_searchterms' |
||||
); |
||||
|
||||
if (isset($conf['i18n_variables']) && is_array($conf['i18n_variables'])) { |
||||
$conf['i18n_variables'] = array_merge($vars, $conf['i18n_variables']); |
||||
} |
||||
else { |
||||
$conf['i18n_variables'] = $vars; |
||||
} |
||||
}*/ |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_menu(). |
||||
*/ |
||||
function roblib_search_menu() { |
||||
|
||||
$items['admin/roblib_search'] = array( |
||||
'title' => 'Roblib search', |
||||
'description' => 'Configure global Roblib search settings.', |
||||
'access arguments' => array('administer site configuration'), |
||||
'type' => MENU_NORMAL_ITEM, |
||||
); |
||||
|
||||
$items['admin/roblib_search/configure'] = array( |
||||
'title' => 'Global Configuration', |
||||
'description' => 'Configure global Roblib search settings.', |
||||
'access arguments' => array('administer site configuration'), |
||||
'page callback' => 'drupal_get_form', |
||||
'page arguments' => array('roblib_search_config_form'), |
||||
'type' => MENU_NORMAL_ITEM, |
||||
); |
||||
|
||||
|
||||
return $items; |
||||
} |
||||
|
||||
|
||||
function roblib_search_config_form($form, &$form_state) { |
||||
|
||||
//variable_get('roblib_search_panel_page','/roblib/panel'); |
||||
$form['roblib_search_panel_page'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Path to the roblib search panel page'), |
||||
'#default_value' => variable_get('roblib_search_panel_page', '/roblib/panel'), |
||||
'#description' => t('The Path to the Roblib Search Panel, for example /roblib/panel'), |
||||
'#required' => TRUE, |
||||
); |
||||
|
||||
|
||||
return system_settings_form($form); |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_admin_paths(). |
||||
*/ |
||||
function roblib_search_admin_paths() { |
||||
$paths = array( |
||||
'admin/roblib/search' => TRUE, |
||||
); |
||||
return $paths; |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_permission(). |
||||
*/ |
||||
function roblib_search_permission() { |
||||
return array( |
||||
'search roblib' => array( |
||||
'title' => t('Search all configured targets'), |
||||
'description' => t('Search all Roblib configured targets. This permission exposes the search blocks and allows you to see search results.'), |
||||
), |
||||
'administer roblib search' => array( |
||||
'title' => t('Administer Roblib Search'), |
||||
'description' => t('Administer settings for the Roblib search client.'), |
||||
), |
||||
); |
||||
} |
||||
|
||||
|
||||
function roblib_search_block_info() { |
||||
|
||||
$blocks['roblib_search_form'] = array( |
||||
// info: The name of the block. |
||||
'info' => t('Roblib Global Search Form'), |
||||
// Block caching options (per role, per user, etc.) |
||||
'cache' => DRUPAL_CACHE_PER_ROLE, // default |
||||
); |
||||
|
||||
return $blocks; |
||||
} |
||||
|
||||
function roblib_search_block_view($delta = '') { |
||||
//The $delta parameter tells us which block is being requested. |
||||
switch ($delta) { |
||||
case 'roblib_search_form': |
||||
// The subject is displayed at the top of the block. Note that it |
||||
// should be passed through t() for translation. The title configured |
||||
// for the block using Drupal UI supercedes this one. |
||||
$block['subject'] = t('Bento Search'); |
||||
// The content of the block is typically generated by calling a custom |
||||
// function. |
||||
$block['content'] = drupal_get_form('roblib_search_simple_form'); |
||||
break; |
||||
} |
||||
return $block; |
||||
} |
||||
|
||||
/** |
||||
* Roblib search simple search form submit |
||||
* |
||||
* @param type $form |
||||
* @param array $form_state |
||||
*/ |
||||
function roblib_search_simple_form_submit($form, &$form_state) { |
||||
$form_state['rebuild'] = TRUE; |
||||
$search_string = $form_state['values']['roblib_search_simple_search_query']; |
||||
$redirect_url = variable_get('roblib_search_panel_page','/roblib/panel'); |
||||
|
||||
drupal_goto($redirect_url, array('query' => array('roblib_query' => $search_string))); |
||||
} |
||||
|
||||
/** |
||||
* Roblib search simple search form |
||||
* |
||||
* @param type $form |
||||
* @param type $form_state |
||||
* @return array |
||||
*/ |
||||
function roblib_search_simple_form($form, &$form_state) { |
||||
if (isset($_GET['roblib_query'])) { |
||||
$query = $_GET['roblib_query']; |
||||
} |
||||
else { |
||||
$query = ''; |
||||
} |
||||
|
||||
$form['simple'] = array( |
||||
'#type' => 'container', |
||||
'#attributes' => array( |
||||
'class' => array( |
||||
'container-inline') |
||||
) |
||||
); |
||||
$form['simple']["roblib_search_simple_search_query"] = array( |
||||
'#size' => '15', |
||||
'#type' => 'textfield', |
||||
'#title' => '', |
||||
'#default_value' => $query, |
||||
); |
||||
$form['simple']['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t('search') |
||||
); |
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_help(). |
||||
* |
||||
* @param type $path |
||||
* @param type $arg |
||||
* @return type |
||||
*/ |
||||
function roblib_search_help($path, $arg) { |
||||
switch ($path) { |
||||
case 'admin/help#roblib_search': |
||||
return t( |
||||
'<p> |
||||
The Roblib Search is a module to allow searching across multiple targets. |
||||
This module does not know how to retrieve results but fires hooks that other |
||||
modules can implement to gather and display results. |
||||
</p>' |
||||
); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,2 @@
|
||||
This folder is a container for included search targets. For consistency each |
||||
target module will be placed in it's own folder |
@ -0,0 +1,23 @@
|
||||
Drupal.behaviors.roblib_search_cufts = { |
||||
attach: function(context, settings) {
|
||||
$url = settings.roblib_search_cufts.search_url; |
||||
jQuery.getJSON($url, function(data) { |
||||
var items = [];
|
||||
if(data.length < 1){ |
||||
jQuery('#' + 'roblib-search-content-cufts').empty().append('No Results');
|
||||
} else { |
||||
jQuery.each(data.journals, function(key, val) { |
||||
items.push('<div class ="roblib-search-row">'); |
||||
items.push('<div class="roblib-title cufts">'); |
||||
items.push('<a href = "'+val.url+'">'+val.title+'</a></div>'); |
||||
items.push('</div>'); |
||||
});
|
||||
}
|
||||
jQuery('#' + 'roblib-search-content-cufts').empty().append(items.join('')); |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
name = Roblib Search Cufts |
||||
dependencies[] = roblib_search |
||||
configure = admin/roblib_search/cufts_search |
||||
description = implements the Roblib Search modules _roblib_search hook |
||||
package = Roblib Search |
||||
version = 7.x-dev |
||||
core = 7.x |
||||
stylesheets[all][] = css/roblib_search_cufts.base.css |
@ -0,0 +1,208 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Implementation of Roblib search for searching several targets. |
||||
*/ |
||||
|
||||
/** |
||||
* Implements hook_boot(). |
||||
* @global type $conf |
||||
*/ |
||||
function roblib_search_cufts_boot() { |
||||
/* below is an example from islandora_solr module for internationalization |
||||
* global $conf; |
||||
|
||||
// Allow i18n, by using multilingual variables. |
||||
if (module_exists('i18n')) { |
||||
$vars = array( |
||||
'islandora_solr_facets', |
||||
'islandora_solr_result_fields', |
||||
'islandora_solr_searchterms' |
||||
); |
||||
|
||||
if (isset($conf['i18n_variables']) && is_array($conf['i18n_variables'])) { |
||||
$conf['i18n_variables'] = array_merge($vars, $conf['i18n_variables']); |
||||
} |
||||
else { |
||||
$conf['i18n_variables'] = $vars; |
||||
} |
||||
} */ |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_menu(). |
||||
*/ |
||||
function roblib_search_cufts_menu() { |
||||
$items = array(); |
||||
|
||||
$items['admin/roblib_search/cufts_search'] = array( |
||||
'title' => 'Cufts Search Target configuration', |
||||
'description' => 'Configuration for the Roblib evergreen search target', |
||||
'page callback' => 'drupal_get_form', |
||||
'page arguments' => array('roblib_search_cufts_config_form'), |
||||
'access arguments' => array('access administration pages'), |
||||
'type' => MENU_NORMAL_ITEM, |
||||
); |
||||
|
||||
$items['roblib_search/cufts/ajax/%'] = array( |
||||
'title' => 'cufts ajax', |
||||
'page callback' => 'roblib_search_cufts_ajax', |
||||
'page arguments' => array(3), |
||||
'type' => MENU_CALLBACK, |
||||
'access arguments' => array('search roblib cufts'), |
||||
); |
||||
|
||||
return $items; |
||||
} |
||||
|
||||
function roblib_search_cufts_config_form($form, &$form_state) { |
||||
|
||||
$form['roblib_search_cufts_url'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Cufts url'), |
||||
'#default_value' => variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'), |
||||
'#description' => t('The base Cufts URL, for example http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'), |
||||
'#required' => TRUE, |
||||
); |
||||
$form['roblib_search_cufts_search_suffix'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Cufts search suffix'), |
||||
'#default_value' => variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms='), |
||||
'#description' => t('The suffix will be appended to the base url for searches, for example browse_field=title&search_type=startswith&format=json&search_terms='), |
||||
'#required' => TRUE, |
||||
); |
||||
|
||||
$form['roblib_search_cufts_num_results'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Number of results to return'), |
||||
'#default_value' => variable_get('roblib_search_cufts_num_results', '5'), |
||||
'#description' => t('The number of results to display in the Bento box'), |
||||
'#required' => TRUE, |
||||
); |
||||
|
||||
|
||||
return system_settings_form($form); |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_permission(). |
||||
*/ |
||||
function roblib_search_cufts_permission() { |
||||
return array( |
||||
'search roblib cufts' => array( |
||||
'title' => t('Search the cufts target'), |
||||
'description' => t('Search oblib cufts target. This permission exposes the search blocks and allows you to see search results.'), |
||||
), |
||||
'administer roblib search cufts' => array( |
||||
'title' => t('Administer Roblib Search Cufts'), |
||||
'description' => t('Administer settings for the Roblib cufts search client.'), |
||||
), |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_theme(). |
||||
*/ |
||||
function roblib_search_cufts_theme() { |
||||
// set path |
||||
$path = drupal_get_path('module', 'roblib_search_cufts'); |
||||
$file = 'theme.inc'; |
||||
|
||||
return array( |
||||
// results page |
||||
'roblib_search_cufts' => array( |
||||
'path' => $path . '/theme', |
||||
'file' => $file, |
||||
'template' => 'roblib-search-cufts', |
||||
'variables' => array('results' => NULL), |
||||
) |
||||
); |
||||
} |
||||
|
||||
function roblib_search_cufts_block_info() { |
||||
|
||||
$blocks['roblib_search_cufts_results'] = array( |
||||
// info: The name of the block. |
||||
'info' => t('Cufts Search Results block'), |
||||
// Block caching options (per role, per user, etc.) |
||||
'cache' => DRUPAL_CACHE_PER_ROLE, // default |
||||
); |
||||
|
||||
return $blocks; |
||||
} |
||||
|
||||
function roblib_search_cufts_block_view($delta = '') { |
||||
//The $delta parameter tells us which block is being requested. |
||||
switch ($delta) { |
||||
case 'roblib_search_cufts_results': |
||||
// The subject is displayed at the top of the block. Note that it |
||||
// should be passed through t() for translation. The title configured |
||||
// for the block using Drupal UI supercedes this one. |
||||
$block['subject'] = t('Cufts Results'); |
||||
// The content of the block is typically generated by calling a custom |
||||
// function. |
||||
// $block['content'] = roblib_search_cufts_get_results(); |
||||
$block['content'] = theme('roblib_search_cufts', array('results' => NULL)); //we will get the results via javascript |
||||
break; |
||||
} |
||||
return $block; |
||||
} |
||||
|
||||
function roblib_search_cufts_ajax($query) { |
||||
print roblib_search_cufts_get_results($query); |
||||
exit(); |
||||
} |
||||
/** |
||||
* |
||||
* @param string $query |
||||
* @return string |
||||
* json string |
||||
*/ |
||||
function roblib_search_cufts_get_results($query = NULL) { |
||||
drupal_add_css(drupal_get_path('module', 'roblib_search_cufts') . '/css/roblib_search_cufts.theme.css'); |
||||
|
||||
// Url parameters. |
||||
if (!isset($query)) { |
||||
if (isset($_GET['roblib_query'])) { |
||||
$query = $_GET['roblib_query']; |
||||
} |
||||
else { |
||||
return ''; |
||||
} |
||||
} |
||||
//http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?browse_field=title&search_type=startswith&format=json&search_terms=dog&submit=Search |
||||
$url = variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'); |
||||
$url_suffix = variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms='); |
||||
$number_of_records = variable_get('roblib_search_cufts_num_results', '5'); |
||||
$search_url = $url . $url_suffix . '"' . $query . '"' . '&submit=Search'; |
||||
|
||||
$results = drupal_http_request($search_url); |
||||
|
||||
if ($results->code == '200') { |
||||
$output = $results->data; |
||||
} |
||||
else { |
||||
$output = $results->status_message; |
||||
} |
||||
return $output; |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_help(). |
||||
* |
||||
* @param type $path |
||||
* @param type $arg |
||||
* @return type |
||||
*/ |
||||
function roblib_search_cufts_help($path, $arg) { |
||||
switch ($path) { |
||||
case 'admin/help#roblib_search_cufts': |
||||
return t( |
||||
'<p> |
||||
provides a target for the Roblib search module |
||||
</p>' |
||||
); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,24 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file islandora-solr-wrapper.tpl.php |
||||
* Islandora solr search results wrapper template |
||||
* |
||||
* Variables available: |
||||
* - $variables: all array elements of $variables can be used as a variable. e.g. $base_url equals $variables['base_url'] |
||||
* - $base_url: The base url of the current website. eg: http://example.com . |
||||
* - $user: The user object. |
||||
* |
||||
* |
||||
* - $results: Rendered search results (primary profile) |
||||
* |
||||
* |
||||
* @see template_preprocess_roblib_search_wrapper() |
||||
*/ |
||||
?> |
||||
|
||||
<div class ="roblib-search-content-cufts" id="roblib-search-content-cufts"> |
||||
<img src="<?php print $spinner_path; ?>"/>
|
||||
|
||||
</div> |
||||
<div class ="roblib-search-more">Search all Journals</div> |
@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
function roblib_search_cufts_preprocess_roblib_search_cufts(&$variables) { |
||||
global $base_url; |
||||
if (!isset($query)) { |
||||
if (isset($_GET['roblib_query'])) { |
||||
$query = $_GET['roblib_query']; |
||||
} |
||||
else { |
||||
return ''; |
||||
} |
||||
} |
||||
$spinner_path = $base_url . '/' . drupal_get_path('module', 'roblib_search') . '/img/'.'spinner.gif'; |
||||
$variables['spinner_path'] = $spinner_path; |
||||
$search_url = $base_url .'/roblib_search/cufts/ajax/'.urlencode($query); |
||||
drupal_add_js(drupal_get_path('module', 'roblib_search_cufts') . '/js/cufts_results.js'); |
||||
drupal_add_js(array('roblib_search_cufts' => array('search_url' => $search_url)), array('type' => 'setting')); |
||||
|
||||
} |
||||
?> |
@ -0,0 +1,8 @@
|
||||
name = Roblib Search Evergreen |
||||
dependencies[] = roblib_search |
||||
configure = admin/roblib_search/evergreen_search |
||||
description = implements the Roblib Search modules _roblib_search hook |
||||
package = Roblib Search |
||||
version = 7.x-dev |
||||
core = 7.x |
||||
stylesheets[all][] = css/roblib_search_evergreen.base.css |
@ -0,0 +1,225 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Implementation of Roblib search for searching several targets. |
||||
*/ |
||||
|
||||
/** |
||||
* Implements hook_boot(). |
||||
* @global type $conf |
||||
*/ |
||||
function roblib_search_evergreen_boot() { |
||||
/* below is an example from islandora_solr module for internationalization |
||||
* global $conf; |
||||
|
||||
// Allow i18n, by using multilingual variables. |
||||
if (module_exists('i18n')) { |
||||
$vars = array( |
||||
'islandora_solr_facets', |
||||
'islandora_solr_result_fields', |
||||
'islandora_solr_searchterms' |
||||
); |
||||
|
||||
if (isset($conf['i18n_variables']) && is_array($conf['i18n_variables'])) { |
||||
$conf['i18n_variables'] = array_merge($vars, $conf['i18n_variables']); |
||||
} |
||||
else { |
||||
$conf['i18n_variables'] = $vars; |
||||
} |
||||
} */ |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_menu(). |
||||
*/ |
||||
function roblib_search_evergreen_menu() { |
||||
$items = array(); |
||||
|
||||
$items['admin/roblib_search/evergreen_search'] = array( |
||||
'title' => 'Evergreen Search Target configuration', |
||||
'description' => 'Configuration for the Roblib evergreen search target', |
||||
'page callback' => 'drupal_get_form', |
||||
'page arguments' => array('roblib_search_evergreen_config_form'), |
||||
'access arguments' => array('access administration pages'), |
||||
'type' => MENU_NORMAL_ITEM, |
||||
); |
||||
|
||||
return $items; |
||||
} |
||||
|
||||
|
||||
function roblib_search_evergreen_config_form($form, &$form_state) { |
||||
/* |
||||
* $url = variable_get('roblib_search_evergreen_url', 'http://137.149.200.52'); |
||||
$url_suffix = variable_get('roblib_search_evergreen_suffix', '/opac/extras/sru?version=1.1&operation=searchRetrieve&query='); |
||||
$number_of_records = variable_get('roblib_search_evergreen_num_results', '5'); |
||||
*/ |
||||
$form['roblib_search_evergreen_url'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Evergreen url'), |
||||
'#default_value' => variable_get('roblib_search_evergreen_url', 'http://islandpines.roblib.upei.ca/'), |
||||
'#description' => t('The base Evergreen URL, for example http://islandpines.roblib.upei.ca/'), |
||||
'#required' => TRUE, |
||||
); |
||||
$form['roblib_search_evergreen_search_suffix'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Evergreen search suffix'), |
||||
'#default_value' => variable_get('roblib_search_evergreen_search_suffix', '/opac/extras/sru?version=1.1&operation=searchRetrieve&query='), |
||||
'#description' => t('The suffix will be appended to the base url for searches, for example /opac/extras/sru?version=1.1&operation=searchRetrieve&query='), |
||||
'#required' => TRUE, |
||||
); |
||||
$form['roblib_search_evergreen_detail_suffix'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Evergreen detail suffix'), |
||||
'#default_value' => variable_get('roblib_search_evergreen_detail_suffix', '/opac/en-CA/skin/default/xml/rdetail.xml?r='), |
||||
'#description' => t('The suffix will be appended to the base url when creating links to the Evergreen detail page, for example /opac/en-CA/skin/default/xml/rdetail.xml?r='), |
||||
'#required' => TRUE, |
||||
); |
||||
$form['roblib_search_evergreen_num_results'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Number of results to return'), |
||||
'#default_value' => variable_get('roblib_search_evergreen_num_results', '5'), |
||||
'#description' => t('The number of results to display in the Bento box'), |
||||
'#required' => TRUE, |
||||
); |
||||
|
||||
|
||||
return system_settings_form($form); |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_permission(). |
||||
*/ |
||||
function roblib_search_evergreen_permission() { |
||||
return array( |
||||
'search roblib evergreen' => array( |
||||
'title' => t('Search the evergreen target'), |
||||
'description' => t('Search all Roblib evergreen target. This permission exposes the search blocks and allows you to see search results.'), |
||||
), |
||||
'administer roblib search_evergreen' => array( |
||||
'title' => t('Administer Roblib Search Evergreen'), |
||||
'description' => t('Administer settings for the Roblib evergreen search client.'), |
||||
), |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_theme(). |
||||
*/ |
||||
function roblib_search_evergreen_theme() { |
||||
// set path |
||||
$path = drupal_get_path('module', 'roblib_search_evergreen'); |
||||
$file = 'theme.inc'; |
||||
|
||||
return array( |
||||
// results page |
||||
'roblib_search_evergreen' => array( |
||||
'path' => $path . '/theme', |
||||
'file' => $file, |
||||
'template' => 'roblib-search-evergreen', |
||||
'variables' => array('results' => NULL), |
||||
) |
||||
); |
||||
} |
||||
|
||||
|
||||
function roblib_search_evergreen_block_info() { |
||||
|
||||
$blocks['roblib_search_evergreen_results'] = array( |
||||
// info: The name of the block. |
||||
'info' => t('Evergreen Search Results block'), |
||||
// Block caching options (per role, per user, etc.) |
||||
'cache' => DRUPAL_CACHE_PER_ROLE, // default |
||||
); |
||||
|
||||
return $blocks; |
||||
} |
||||
|
||||
function roblib_search_evergreen_block_view($delta = '') { |
||||
//The $delta parameter tells us which block is being requested. |
||||
switch ($delta) { |
||||
case 'roblib_search_evergreen_results': |
||||
// The subject is displayed at the top of the block. Note that it |
||||
// should be passed through t() for translation. The title configured |
||||
// for the block using Drupal UI supercedes this one. |
||||
$block['subject'] = t('Evergreen Results'); |
||||
// The content of the block is typically generated by calling a custom |
||||
// function. |
||||
$block['content'] = roblib_search_evergreen_get_results(); |
||||
break; |
||||
} |
||||
return $block; |
||||
} |
||||
|
||||
function roblib_search_evergreen_get_results() { |
||||
drupal_add_css(drupal_get_path('module', 'roblib_search_evergreen') . '/css/roblib_search_evergreen.theme.css'); |
||||
|
||||
// Url parameters. |
||||
if (isset($_GET['roblib_query'])) { |
||||
$query = $_GET['roblib_query']; |
||||
} |
||||
else { |
||||
return ''; |
||||
} |
||||
|
||||
$url = variable_get('roblib_search_evergreen_url', 'http://137.149.200.52'); |
||||
$url_suffix = variable_get('roblib_search_evergreen_search_suffix', '/opac/extras/sru?version=1.1&operation=searchRetrieve&query='); |
||||
$number_of_records = variable_get('roblib_search_evergreen_num_results', '5'); |
||||
$search_url = $url . $url_suffix . '"' . urlencode($query) . '"' . '&maximumRecords=' . $number_of_records; |
||||
$results = drupal_http_request($search_url); |
||||
if ($results->code == '200') { |
||||
$output = roblib_search_evergreen_parse_results($results); |
||||
} |
||||
else { |
||||
$output = 'Error retrieving Evergreen results ' . $results->status_message; |
||||
} |
||||
|
||||
return theme('roblib_search_evergreen', array('results' => $output)); |
||||
} |
||||
|
||||
function roblib_search_evergreen_parse_results($results) { |
||||
$xml = $results->data; |
||||
if (!isset($xml)) { |
||||
return 'no results found'; |
||||
} |
||||
$sxml = simplexml_load_string(trim($results->data)); |
||||
$output = array(); |
||||
if ($sxml) { |
||||
$sxml->registerXPathNamespace('marcxml', 'http://www.loc.gov/MARC21/slim'); |
||||
$records = $sxml->xpath('//marcxml:record'); |
||||
//$records = $sxml->xpath('//marcxml:record/marcxml:recordData/marcxml:record/marcxml:datafield[@tag="245"]/marcxml:subfield[@code="a"]'); |
||||
$index = 0; |
||||
foreach ($records as $record) { |
||||
$record->registerXPathNamespace('marcxml', 'http://www.loc.gov/MARC21/slim'); |
||||
$title = $record->xpath('marcxml:datafield[@tag="245"]/marcxml:subfield[@code="a"]'); |
||||
$title = (string) $title[0]; |
||||
$id = $record->xpath('marcxml:datafield[@tag="901"]/marcxml:subfield[@code="c"]'); |
||||
$id = (string) $id[0]; |
||||
$output[$index]['title'] = $title ; |
||||
$output[$index++]['url'] = variable_get('roblib_search_evergreen_url', 'http://137.149.200.52') |
||||
. variable_get('roblib_search_evergreen_detail_suffix','/opac/en-CA/skin/default/xml/rdetail.xml?r=') |
||||
. (string) $id ; |
||||
} |
||||
} |
||||
return $output; |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_help(). |
||||
* |
||||
* @param type $path |
||||
* @param type $arg |
||||
* @return type |
||||
*/ |
||||
function roblib_search_evergreen_help($path, $arg) { |
||||
switch ($path) { |
||||
case 'admin/help#roblib_search_evergreen': |
||||
return t( |
||||
'<p> |
||||
provides a target for the Roblib search module |
||||
</p>' |
||||
); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,29 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file islandora-solr-wrapper.tpl.php |
||||
* Islandora solr search results wrapper template |
||||
* |
||||
* Variables available: |
||||
* - $variables: all array elements of $variables can be used as a variable. e.g. $base_url equals $variables['base_url'] |
||||
* - $base_url: The base url of the current website. eg: http://example.com . |
||||
* - $user: The user object. |
||||
* |
||||
* |
||||
* - $results: Rendered search results (primary profile) |
||||
* |
||||
* |
||||
* @see template_preprocess_roblib_search_wrapper() |
||||
*/ |
||||
?> |
||||
|
||||
<div class ="roblib-search-content-evergreen"> |
||||
<?php foreach($results as $result): ?> |
||||
<div class ="roblib-search-row"> |
||||
|
||||
<div class="rolib-title evergreen"><a href = "<?php print $result['url']; ?>"><?php print $result['title']; ?></a>
|
||||
</div> |
||||
</div> |
||||
<?php endforeach; ?> |
||||
<div class ="roblib-search-more">Search the Catalog</div> |
||||
</div> |
@ -0,0 +1,11 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
function roblib_search_evergreen_preprocess_roblib_search_evergreen(&$variables) { |
||||
//not yet implemented |
||||
} |
||||
?> |
@ -0,0 +1,27 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file islandora-solr-wrapper.tpl.php |
||||
* Islandora solr search results wrapper template |
||||
* |
||||
* Variables available: |
||||
* - $variables: all array elements of $variables can be used as a variable. e.g. $base_url equals $variables['base_url'] |
||||
* - $base_url: The base url of the current website. eg: http://example.com . |
||||
* - $user: The user object. |
||||
* |
||||
* |
||||
* - $results: Rendered search results (primary profile) |
||||
* |
||||
* |
||||
* @see template_preprocess_roblib_search_wrapper() |
||||
*/ |
||||
?> |
||||
|
||||
<div class ="roblib-search-content-wrapper"> |
||||
|
||||
<?php foreach($results as $result): ?> |
||||
<div><?php print $result; ?> |
||||
</div> |
||||
<?php endforeach; ?> |
||||
|
||||
</div> |
Loading…
Reference in new issue