array( '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"), ) ); } /** * Implementation of hook_perm(). */ function mkdru_perm() { return array('create metasearch interface', 'edit any metasearch interface', 'edit own metasearch interface'); } /** * Implementation of hook_access(). */ function mkdru_access($op, $node, $account) { if ($op == 'create') { // Only users with permission to do so may create this node type. return user_access('create metasearch interface', $account); } // Users who create a node may edit or delete it later, assuming they have the // necessary permissions. if ($op == 'update' || $op == 'delete') { if (user_access('edit own metasearch interface', $account) && ($account->uid == $node->uid)) { return TRUE; } else if (user_access('edit any metasearch interface', $account)) { return TRUE; } } } /** * Implementation of hook_form(). */ function mkdru_form(&$node, $form_state) { $type = node_get_types('type', $node); $form['title'] = array( '#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5 ); return $form; } /** * Implementation of hook_theme(). */ function mkdru_theme() { return array( 'mkdru_page' => array( 'template' => 'mkdru-page', 'arguments' => array(), ), 'mkdru_page_js' => array( 'arguments' => array(), ), // 'mkdru_block_facet' => array( // 'template' => 'mkdru-block-facet', // 'arguments' => array('divId' => NULL), // ), ); } /** * Theme function to include Javascript search client and deps */ function theme_mkdru_page_js() { $path = drupal_get_path('module', 'mkdru'); drupal_add_js('pazpar2/js/pz2.js', 'module', 'footer'); drupal_add_js($path . '/mkdru.theme.js', 'module', 'footer'); drupal_add_js($path . '/mkdru.client.js', 'module', 'footer'); } /** * Implementation of hook_view() */ function mkdru_view($node, $teaser = FALSE, $page = FALSE) { $node->content['mkdru_page_js'] = array( '#value' => theme('mkdru_page_js'), '#weight' => 0, ); $node->content['mkdru_page'] = array( '#value' => theme('mkdru_page'), '#weight' => 1, ); return $node; } /** * Implementation of hook_block() */ function mkdru_block($op='list', $delta='sources', $edit=array()) { switch ($op) { case 'list': $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; return $blocks; case 'view': switch ($delta) { // TODO: make the facet themable, I have no clue why this won't work // case 'mkdru_sources': // $block['subject'] = t('Source'); // $block['content'] = theme('mkdru_block_facet', 'mkdru-sources'); // return $block; // case 'mkdru_subjects': // $block['subject'] = t('Subject'); // $block['content'] = theme('mkdru_block_facet', 'mkdru-subjects'); // return $block; // case 'mkdru_authors': // $block['subject'] = t('Author'); // $block['content'] = theme('mkdru_block_facet', 'mkdru-authors'); // return $block; case 'mkdru_sources': $block['subject'] = t('Source'); $block['content'] = '
'; return $block; case 'mkdru_subjects': $block['subject'] = t('Subject'); $block['content'] = '
'; return $block; case 'mkdru_authors': $block['subject'] = t('Author'); $block['content'] = '
'; return $block; } } }