From 2e2e8b3b68f53f8aaf784bc60432c36443011314 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Thu, 24 Feb 2011 13:11:55 +0100 Subject: [PATCH] Implement drupal search module hooks This is for the Ding D7 integration which uses standard drupal hooks to integrate new search sources. --- mkdru.module | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/mkdru.module b/mkdru.module index 9bc03b4..e477eab 100644 --- a/mkdru.module +++ b/mkdru.module @@ -10,15 +10,53 @@ 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')); @@ -27,11 +65,17 @@ function mkdru_ting_search_show($params) { 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(); } /** -- 1.7.10.4