X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=mkdru.module;h=51df633b706c7cd7a73c59993559bb26f617202d;hb=aa8e1fdaaa759602a95aa4cdd9186d209ae8abe6;hp=a89db525ffd5388b4459b40b9d449993ddde1c63;hpb=858d62aff8278c4df989c93a88f14059cebfbce5;p=mkdru-moved-to-drupal.org.git diff --git a/mkdru.module b/mkdru.module index a89db52..51df633 100644 --- a/mkdru.module +++ b/mkdru.module @@ -5,7 +5,7 @@ // Module metainfo /** -* Implementation of hook_node_info(). +* Implementation of hook_node_info() */ function mkdru_node_info() { return array( @@ -13,20 +13,33 @@ function mkdru_node_info() { 'name' => t("Z39.50/SRU 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 . '/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(). +* Implementation of hook_perm() */ function mkdru_perm() { return array('create metasearch interface', 'edit any metasearch interface', 'edit own metasearch interface'); } /** -* Implementation of hook_access(). +* Implementation of hook_access() */ function mkdru_access($op, $node, $account) { @@ -47,11 +60,37 @@ function mkdru_access($op, $node, $account) { } } +/** +* Implementation of hook_menu() +*/ +function mkdru_menu() { + $items['admin/settings/mkdru'] = array( + 'title' => 'mkdru Settings', + 'description' => 'Settings for mkdru.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('mkdru_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + 'file' => 'mkdru.admin.inc', + ); + return $items; +} + +/** +* Implementation of hook_init() +*/ +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.css'); +} + // Node config /** -* Implementation of hook_form(). +* Implementation of hook_form() */ function mkdru_form(&$node, $form_state) { $type = node_get_types('type', $node); @@ -137,7 +176,7 @@ function mkdru_validate($node) { * Implementation of hook_insert(). */ function mkdru_insert($node) { - db_query("INSERT INTO {mkdru} (nid, vid, pz2_path, use_sessions, source_max, author_max, subject_max) VALUES (%d, %d, '%s', %d, %d, %d)", + db_query("INSERT INTO {mkdru} (nid, vid, pz2_path, use_sessions, source_max, author_max, subject_max) VALUES (%d, %d, '%s', %d, %d, %d, %d)", $node->nid, $node->vid, $node->pz2_path, $node->use_sessions, $node->source_max, $node->author_max, $node->subject_max); } @@ -171,8 +210,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. @@ -195,11 +232,15 @@ function mkdru_load($node) { */ function mkdru_theme() { return array( - 'mkdru_page' => array( - 'template' => 'mkdru-page', + 'mkdru_form' => array( + 'template' => 'mkdru-form', + 'arguments' => array(), + ), + 'mkdru_results' => array( + 'template' => 'mkdru-results', 'arguments' => array(), ), - 'mkdru_page_js' => array( + 'mkdru_js' => array( 'arguments' => array('node' => NULL), ), // 'mkdru_block_facet' => array( @@ -212,9 +253,10 @@ 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'); - drupal_add_js('pazpar2/js/pz2.js', 'module', 'footer'); + // 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'); drupal_add_js(array('mkdru' => $node->mkdru), 'setting'); @@ -224,14 +266,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; } @@ -266,15 +312,15 @@ 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; } }