From 9bb075c111afad0a4dc12d6b9bee8b21b532500c Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Thu, 25 Nov 2010 05:12:48 +0100 Subject: [PATCH] Various fixes and new module-wide config page. --- mkdru.admin.inc | 6 ++++-- mkdru.client.js | 8 ++++---- mkdru.install | 2 ++ mkdru.module | 28 ++++++++++++++++++++++------ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/mkdru.admin.inc b/mkdru.admin.inc index 47a2524..994cd36 100644 --- a/mkdru.admin.inc +++ b/mkdru.admin.inc @@ -2,8 +2,10 @@ function mkdru_admin_settings() { $form['pz2_js_path']=array( '#type' => 'textfield', - '#title' => t('Path to Pazpar2 client library, pz2.js'), - '#default_value' => variable_get('pz2_js_path', '/pazpar2/pz2.js'), + '#title' => t('Path to Pazpar2 client library'), + '#description' => t('Absolute path to the directory containing pz2.js within the current domain. Do not include leading slash.'), + '#default_value' => variable_get('pz2_js_path', 'pazpar2/js'), + '#required' => TRUE ); return system_settings_form($form); diff --git a/mkdru.client.js b/mkdru.client.js index 1eb7ece..2cf70cb 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -91,7 +91,7 @@ mkdru.pz2ByTarget = function (data) { // UI functions: mkdru.submitQuery = function () { mkdru.submitted = true; -// mkdru.resetPage(); + mkdru.resetPage(); // mkdru.pollDropDowns(); mkdru.search(); return false; @@ -106,8 +106,8 @@ mkdru.pollDropDowns = function () { mkdru.recPerPage = $('#mkdru-perpage').value; mkdru.curSort = $('#mkdru-sort').value; if (!mkdru.submitted) return false; - mkdru.resetPage(); - mkdru.pz2.show(0, mkdru.recPerPage, mkdru.curSort); +// mkdru.resetPage(); +// mkdru.pz2.show(0, mkdru.recPerPage, mkdru.curSort); }; mkdru.limitQuery = function (field, value) { @@ -125,7 +125,7 @@ mkdru.limitTarget = function (id, name) { navi.innerHTML += '
'; mkdru.curFilter = 'pz:id=' + id; mkdru.resetPage(); - mkdru.pollDropDowns(); +// mkdru.pollDropDowns(); mkdru.search(); return false; }; diff --git a/mkdru.install b/mkdru.install index a2d828a..15f5568 100644 --- a/mkdru.install +++ b/mkdru.install @@ -79,5 +79,7 @@ function mkdru_install() { function mkdru_uninstall() { // Drop table. drupal_uninstall_schema('mkdru'); + // Delete variables + variable_del('pz2_js_path'); } ?> diff --git a/mkdru.module b/mkdru.module index a89db52..8158bb0 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( @@ -19,14 +19,14 @@ function mkdru_node_info() { } /** -* 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 +47,26 @@ 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; +} // Node config /** -* Implementation of hook_form(). +* Implementation of hook_form() */ function mkdru_form(&$node, $form_state) { $type = node_get_types('type', $node); @@ -137,7 +152,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); } @@ -214,7 +229,8 @@ function mkdru_theme() { */ function theme_mkdru_page_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'); -- 1.7.10.4