function mkdru_node_info() {
return array(
'mkdru' => array(
- 'name' => t("Pazpar2 metasearch interface"),
- 'base' => 'mkdru',
+ 'name' => t("Pazpar2 metasearch interface"),
+ 'base' => 'mkdru',
'description' => t("Metasearch interface for Z39.50/SRU and other targets via a Pazpar2/Service Proxy backend"),
)
);
}
-function mkdru_ting_search_show($params) {
- $path = drupal_get_path('module', 'mkdru');
+/**
+ * Implements hook_search_info()
+ */
+function mkdru_search_info() {
+ return array(
+ 'title' => 'Meta search',
+ 'path' => 'meta',
+ 'conditions_callback' => 'mkdru_search_conditions_callback',
+ );
+}
+
+/**
+ * Implements hook_search_page()
+ */
+function mkdru_search_page($results) {
+ $output['prefix']['#markup'] = theme('mkdru_results');
+ $output['suffix']['#markup'] = '';
+ return $output;
+}
+
+/**
+ * Implements hook_ding_facetbrowser()
+ */
+function mkdru_ding_facetbrowser() {
+ $results = new stdClass();
+ $results->facets = array();
+ $results->show_empty = TRUE; # Show an empty facetbrowser block, even if search didn't return any results
+ return $results;
+}
+
+/**
+ * Search callback function that is invoked by search_view()
+ */
+function mkdru_search_conditions_callback($keys) {}
+
+/**
+ * Implement hook_search_execute()
+ */
+function mkdru_search_execute($keys = NULL, $conditions = NULL) {
+ $path = drupal_get_path('module', 'mkdru');
// Include client library.
drupal_add_js(variable_get('pz2_js_path', 'pazpar2/js') . '/pz2.js',
array('type' => 'file', 'scope' => 'footer'));
array('type' => 'file', 'scope' => 'footer'));
drupal_add_js($path . '/mkdru.client.js',
array('type' => 'file', 'scope' => 'footer'));
- $html = theme('mkdru_results');
- drupal_add_js(array('mkdru' =>
- array('use_sessions' => '1', 'query' => $params['keys']
- )), 'setting');
- return array("content" => $html);
+ drupal_add_js(array('mkdru' =>
+ array(
+ 'use_sessions' => variable_get('use_sessions', '1'),
+ 'pz2_path' => variable_get('pz2_path', '/pazpar2/search.pz2'),
+ 'sp_user' => variable_get('sp_user', ''),
+ 'sp_pass' => variable_get('sp_pass', ''),
+ 'query' => $keys,
+ )
+ ), 'setting');
+
+ return array();
}
/**
function mkdru_delete($node) {
// Deleting by nid covers all revisions.
db_delete('mkdru')
- ->condition('nid', $nid->nid)
+ ->condition('nid', $node->nid)
->execute();
}
drupal_add_js(variable_get('pz2_js_path', 'pazpar2/js') . '/pz2.js', array(
'type' => 'file', 'scope' => 'footer', 'defer' => TRUE, 'preprocess' => FALSE));
// jQuery plugin for query string/history manipulation.
- drupal_add_library('overlay', 'jquery-bbq');
+ drupal_add_library('system', 'jquery.bbq');
drupal_add_js($path . '/mkdru.theme.js', array(
'type' => 'file', 'scope' => 'footer', 'defer' => TRUE, 'preprocess' => FALSE));
drupal_add_js($path . '/mkdru.client.js', array(
* Implements hook_block_info()
*/
function mkdru_block_info() {
- // NB: block caching is redundant for static content
- $blocks['mkdru_sources']['info'] = t('mkdru - source facets');
- $blocks['mkdru_sources']['cache'] = DRUPAL_NO_CACHE;
- $blocks['mkdru_subjects']['info'] = t('mkdru - subject facets');
- $blocks['mkdru_subjects']['cache'] = DRUPAL_NO_CACHE;
- $blocks['mkdru_authors']['info'] = t('mkdru - author facets');
- $blocks['mkdru_authors']['cache'] = DRUPAL_NO_CACHE;
+ // facet blocks
+ $facets = variable_get('mkdru_facets');
+ foreach ($facets as $facet) {
+ // NB: block caching is redundant for static content
+ $blocks['mkdru_facet_' . $facet]['info'] = "mkdru - $facet " . t('facet');
+ $blocks['mkdru_facet_' . $facet]['cache'] = DRUPAL_NO_CACHE;
+ }
// search blocks
$result = db_query("SELECT title, nid FROM {node} WHERE type = 'mkdru';");
t('mkdru - search box for "' . $node->title . '"');
$blocks['mkdru_sources']['cache'] = DRUPAL_NO_CACHE;
};
+
return $blocks;
}
* Implements hook_block_view()
*/
function mkdru_block_view($delta) {
- switch ($delta) {
- case 'mkdru_sources':
- $block['subject'] = t('Source');
- $block['content'] = theme('mkdru_block_facet',
- array('class' => 'mkdru-facet-source'));
- return $block;
- case 'mkdru_subjects':
- $block['subject'] = t('Subject');
- $block['content'] = theme('mkdru_block_facet',
- array('class' => 'mkdru-facet-subject'));
- return $block;
- case 'mkdru_authors':
- $block['subject'] = t('Author');
- $block['content'] = theme('mkdru_block_facet',
- array('class' => 'mkdru-facet-author'));
- return $block;
- }
- if (substr($delta, 0, 13) == 'mkdru_search_') {
+ if (substr($delta, 0, 12) == 'mkdru_facet_') {
+ $facet = substr($delta, 12);
+ $block['subject'] = t(ucwords($facet));
+ $block['content'] = theme('mkdru_block_facet',
+ array('class' => 'mkdru-facet-' . $facet));
+ return $block;
+ }
+ elseif (substr($delta, 0, 13) == 'mkdru_search_') {
$nid = substr($delta, 13);
$block['content'] = theme('mkdru_block_search',
array('nid' => $nid, 'path' => '/node/' . $nid));