X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=mkdru.module;h=ac0609755469b25d84c865423b148c54c67f9305;hb=4b3873f962312d06553eb7ffe4e7dd1d0e56d058;hp=16442238ac630aa8f18d7b2d924b0ceaedc62ab1;hpb=368440f16fce179517479e3eed656aa5f5520dcb;p=mkdru-moved-to-drupal.org.git diff --git a/mkdru.module b/mkdru.module index 1644223..ac06097 100644 --- a/mkdru.module +++ b/mkdru.module @@ -10,14 +10,28 @@ function mkdru_node_info() { return array( 'mkdru' => array( - 'name' => t("Z39.50/SRU metasearch interface"), + 'name' => t("Pazpar2 metasearch interface"), 'module' => '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'); + // Include client library. + drupal_add_js(variable_get('pz2_js_path', 'pazpar2/js') + . '/pz2.js', 'module', 'footer'); + drupal_add_js($path . '/jquery.ba-bbq.js', 'module', 'footer'); + drupal_add_js($path . '/mkdru.theme.js', 'module', 'footer'); + drupal_add_js($path . '/mkdru.client.js', 'module', 'footer'); + $html = theme('mkdru_results'); + drupal_add_js(array('mkdru' => + array('use_sessions' => '1', 'query' => $params['keys'] + )), 'setting'); + return array("content" => $html); +} + /** * Implementation of hook_perm() */ @@ -70,7 +84,7 @@ function mkdru_init(){ // Applies our module specific CSS to all pages. This works best because // all CSS is aggregated and cached so we reduce the number of HTTP // requests and the size is negligible. - drupal_add_css(drupal_get_path('module', 'mkdru') .'/mkdru-page.css'); + drupal_add_css(drupal_get_path('module', 'mkdru') .'/mkdru.css'); } @@ -197,8 +211,6 @@ function mkdru_nodeapi(&$node, $op, $teaser, $page) { /** * Implementation of hook_delete(). - * - * When a node is deleted, we need to remove all related records from our table. */ function mkdru_delete($node) { // Deleting by nid covers all revisions. @@ -221,13 +233,21 @@ function mkdru_load($node) { */ function mkdru_theme() { return array( - 'mkdru_page' => array( - 'template' => 'mkdru-page', + 'mkdru_form' => array( + 'template' => 'mkdru-form', 'arguments' => array(), ), - 'mkdru_page_js' => array( + 'mkdru_results' => array( + 'template' => 'mkdru-results', + 'arguments' => array(), + ), + 'mkdru_js' => array( 'arguments' => array('node' => NULL), ), + 'mkdru_block_search' => array( + 'template' => 'mkdru-block-search', + 'arguments' => array('nid' => null, 'path' => NULL), + ), // 'mkdru_block_facet' => array( // 'template' => 'mkdru-block-facet', // 'arguments' => array('divId' => NULL), @@ -238,12 +258,14 @@ function mkdru_theme() { /** * Theme function to include Javascript search client and deps */ -function theme_mkdru_page_js($node) { +function theme_mkdru_js($node) { $path = drupal_get_path('module', 'mkdru'); - // Include client library. - drupal_add_js(variable_get('pz2_js_path', 'pazpar2/js') . '/pz2.js', 'module', 'footer'); - drupal_add_js($path . '/mkdru.theme.js', 'module', 'footer'); - drupal_add_js($path . '/mkdru.client.js', 'module', 'footer'); + // Pazpar2 client library. + drupal_add_js(variable_get('pz2_js_path', 'pazpar2/js') . '/pz2.js', 'module', 'footer', TRUE, TRUE, FALSE); + // jQuery plugin for query string/history manipulation. + drupal_add_js($path . '/jquery.ba-bbq.js', 'module', 'footer', TRUE, TRUE, FALSE); + drupal_add_js($path . '/mkdru.theme.js', 'module', 'footer', TRUE, TRUE, FALSE); + drupal_add_js($path . '/mkdru.client.js', 'module', 'footer', TRUE, TRUE, FALSE); drupal_add_js(array('mkdru' => $node->mkdru), 'setting'); } @@ -251,14 +273,18 @@ function theme_mkdru_page_js($node) { * Implementation of hook_view() */ function mkdru_view($node, $teaser = FALSE, $page = FALSE) { - $node->content['mkdru_page_js'] = array( - '#value' => theme('mkdru_page_js', $node), + $node->content['mkdru_js'] = array( + '#value' => theme('mkdru_js', $node), '#weight' => 0, ); - $node->content['mkdru_page'] = array( - '#value' => theme('mkdru_page'), + $node->content['mkdru_form'] = array( + '#value' => theme('mkdru_form'), '#weight' => 1, ); + $node->content['mkdru_results'] = array( + '#value' => theme('mkdru_results'), + '#weight' => 2, + ); return $node; } @@ -268,12 +294,21 @@ function mkdru_view($node, $teaser = FALSE, $page = FALSE) { function mkdru_block($op='list', $delta='sources', $edit=array()) { switch ($op) { case 'list': + // facet blocks + // NB: block caching is redundant for static content $blocks['mkdru_sources']['info'] = t('mkdru - source facets'); $blocks['mkdru_sources']['cache'] = BLOCK_NO_CACHE; $blocks['mkdru_subjects']['info'] = t('mkdru - subject facets'); $blocks['mkdru_subjects']['cache'] = BLOCK_NO_CACHE; $blocks['mkdru_authors']['info'] = t('mkdru - author facets'); $blocks['mkdru_authors']['cache'] = BLOCK_NO_CACHE; + // search blocks + $result = db_query("SELECT title, nid FROM {node} WHERE type = 'mkdru';"); + while ($node = db_fetch_object($result)) { + $blocks['mkdru_search_' . $node->nid]['info'] = + t('mkdru - search box for "' . $node->title . '"'); + $blocks['mkdru_sources']['cache'] = BLOCK_NO_CACHE; + }; return $blocks; case 'view': @@ -293,16 +328,21 @@ function mkdru_block($op='list', $delta='sources', $edit=array()) { // return $block; case 'mkdru_sources': $block['subject'] = t('Source'); - $block['content'] = '
'; + $block['content'] = '
'; return $block; case 'mkdru_subjects': $block['subject'] = t('Subject'); - $block['content'] = '
'; + $block['content'] = '
'; return $block; case 'mkdru_authors': $block['subject'] = t('Author'); - $block['content'] = '
'; + $block['content'] = '
'; return $block; } + if (substr($delta, 0, 13) == 'mkdru_search_') { + $nid = substr($delta, 13); + $block['content'] = theme('mkdru_block_search', $nid, '/node/' . $nid); + return $block; + } } }