# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: contrib/millennium_cck/millennium_cck.info
--- contrib/millennium_cck/millennium_cck.info No Base Revision
+++ contrib/millennium_cck/millennium_cck.info Locally New
@@ -0,0 +1,8 @@
+; $Id$
+name = Millennium CCK
+description = "Allows Millennium module to import data into CCK fields."
+version = "$Name: $"
+dependencies[] = millennium
+dependencies[] = content
+package = Millennium Integration
+core = 6.x
Index: contrib/millennium_cck/millennium_cck.install
--- contrib/millennium_cck/millennium_cck.install No Base Revision
+++ contrib/millennium_cck/millennium_cck.install Locally New
@@ -0,0 +1,13 @@
+ 'CCK field mapping',
+ 'description' => 'Configure MARC import mapping settings.',
+ 'type' => MENU_LOCAL_TASK,
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('millennium_cck_settings_form'),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer millennium'),
+ );
+ return $items;
+}
+
+/**
+ * Callback for drupal_get_form for cck mapping settings form.
+ */
+function millennium_cck_settings_form() {
+ global $_millennium_field_labels;
+ $form = array();
+
+ // Get destination content type
+ $millennium_node_type = variable_get('millennium_marc_node_type', 'page');
+ $content_types_fields = content_types();
+ $content_type_fields = $content_types_fields[$millennium_node_type];
+
+ // Help text
+ $form['help'] = array(
+ '#type' => 'markup',
+ '#value' => t(
+ '
Select what data to import into each of the CCK text fields available for the !type-link content type. Note: only CCK text fields are currently supported.
',
+ array('!type-link' => l($millennium_node_type, 'admin/content/node-type/' . str_replace("_", "-", $millennium_node_type) . '/fields'))
+ ),
+ );
+ // Build mapping destination field options
+ $options = array(
+ -1 => t(''),
+ );
+ foreach ($_millennium_field_labels as $biblio_name => $biblio_label) {
+ $options[$biblio_name] = $biblio_label;
+ }
+
+ // Build form
+ foreach ($content_type_fields['fields'] as $fieldname => $field) {
+ if ($field['type'] == 'text') {
+ $form["millennium_cck_mapping_{$fieldname}"] = array(
+ '#type' => 'select',
+ '#title' => $field['widget']['label'],
+ '#options' => $options,
+ '#default_value' => variable_get("millennium_cck_mapping_{$fieldname}", -1),
+ );
+ }
+ }
+ return system_settings_form($form);
+}
+
+/**
+ * Implementation of hook_millennium_nodeobject_alter().
+ */
+function millennium_cck_millennium_nodeobject_alter(&$nodeobject, $marc) {
+ // Handle CCK mappings
+ millennium_cck_biblio_to_node($nodeobject, $nodeobject->millennium_biblio_data);
+}
+
+/**
+ * Map biblio data into CCK fields according to configuration
+ */
+function millennium_cck_biblio_to_node(&$node, $biblio_values) {
+ global $_millennium_field_labels;
+
+ // Get destination content type
+ $content_types_fields = content_types();
+ $content_type_fields = $content_types_fields[variable_get('millennium_marc_node_type', 'page')];
+
+ foreach ($content_type_fields['fields'] as $dest_fieldname => $dummy) {
+ // Get mapping. Skip if none assigned
+ $biblio_fieldname = variable_get("millennium_cck_mapping_{$dest_fieldname}", -1);
+ if ($biblio_fieldname === 0) {
+ // Leave untouched
+ continue;
+ }
+
+ if (empty($node->$dest_fieldname)) {
+ $node->{$dest_fieldname} = array();
+ }
+ // Clear existing values
+ foreach ($node->$dest_fieldname as $index => $dummy) {
+ $node->{$dest_fieldname}[$index]['value'] = '';
+ }
+
+ if ($biblio_fieldname == -1) {
+ // Just clear out the values (which we did already)
+ continue;
+ }
+
+ // Get max num. of values this field can hold.
+ $num_allowed_values = $content_type_fields["fields"][$dest_fieldname]["multiple"];
+ if ($num_allowed_values == 0) {
+ $num_allowed_values = 1;
+ }
+
+ // Get value to write to CCK field value
+ $value = $biblio_values[$biblio_fieldname];
+ if (is_array($value)) {
+ // Handle multi-valued (array) biblio data values
+ // map into multiple CCK values up to that field's # of values limit
+ for ($index = 0; $index < $num_allowed_values; $index++) {
+ $node->{$dest_fieldname}[$index]['value'] = $value[$index];
+ }
+ }
+ else {
+ // Handle single-valued (string) biblio data value
+ // Set CCK field's first value
+ $node->{$dest_fieldname}[0]['value'] = $value;
+ }
+ }
+}
Index: millennium.admin.inc
--- millennium.admin.inc Base (1.1.2.33)
+++ millennium.admin.inc Locally Modified (Based On 1.1.2.33)
@@ -38,7 +38,7 @@
$form['general']['millennium_action_on_last_item_deleted'] = array(
'#type' => 'radios',
'#title' => t('Action when imported records are no longer found in WebOPAC'),
- '#options' => array('delete' => "Delete node", 'unpublish' => "Unpublish node"),
+ '#options' => array('delete' => t("Delete node"), 'unpublish' => t("Unpublish node")),
'#default_value' => variable_get('millennium_action_on_last_item_deleted', 'unpublish'),
);
@@ -218,7 +218,7 @@
$form['crawl']['millennium_crawl_flag'] = array(
'#type' => 'radios',
'#title' => t('Automatic crawl enabled'),
- '#options' => array(0 => "Disabled", 1 => "Enabled"),
+ '#options' => array(0 => t("Disabled"), 1 => t("Enabled")),
'#description' => t('Enabling this will start (or continue) the automatic record import/update. Disabling this does not stop importing items queued manually for import.'),
'#default_value' => variable_get('millennium_crawl_flag', 0),
);
@@ -273,6 +273,25 @@
function millennium_admin_display() {
$form = array();
+ $form['general'] = array(
+ '#type' => 'fieldset',
+ '#collapsible' => false,
+ '#title' => t("General"),
+ );
+ $form['general']['millennium_display_biblio_data'] = array(
+ '#type' => 'radios',
+ '#title' => t('Display bibiographic data table in node'),
+ '#options' => array(0 => t('No'), "full" => t('Full view only'), "teaser" => t('Teaser & Full view')),
+ '#default_value' => variable_get('millennium_display_biblio_data', "teaser"),
+ '#description' => t('You might want to switch this off if you are mapping values into CCK fields. Recommended setting is "Teaser & Full view".'),
+ );
+ $form['general']['millennium_coverimage_baseurl'] = array(
+ '#type' => 'textfield',
+ '#title' => '('. t('Optional') .') '. t('URL for displaying cover images'),
+ '#default_value' => variable_get('millennium_coverimage_baseurl', ''),
+ '#description' => t('Use the placeholder !id in the URL where the ISBN or ISBN will be placed. You can also specify: !type (Biblio Type number), !tit (Title), !aut (Author(s))') .' '. t('For example') .': http://example.com/getimage?isbn=!id&type=!type',
+ );
+
$form['holdings'] = array(
'#type' => 'fieldset',
'#collapsible' => false,
@@ -282,7 +301,7 @@
$form['holdings']['millennium_realtime_holdings'] = array(
'#type' => 'radios',
'#title' => t('Display real-time availability information'),
- '#options' => array(0 => "No", "full" => "Full view only", "teaser" => "Teaser & Full view"),
+ '#options' => array(0 => t('No'), "full" => t('Full view only'), "teaser" => t('Teaser & Full view')),
'#default_value' => variable_get('millennium_realtime_holdings', "full"),
'#description' => t('WARNING: This option might slow down your page views, as availability information is fetched from the Millennium for each record (and kept in a Drupal cache for subsequent calls). Recommended setting is "Full view only".'),
);
@@ -301,13 +320,6 @@
'#description' => t('Comma-separated location names, as they appear on the WebOpac, that will be given priority over other locations. For example, entering "CSU" will match locations like "CSU General stacks" and "CSU Storage", showing only those in teasers and showing those above others in full record views.'),
);
- $form['millennium_coverimage_baseurl'] = array(
- '#type' => 'textfield',
- '#title' => '('. t('Optional') .') '. t('URL for displaying cover images'),
- '#default_value' => variable_get('millennium_coverimage_baseurl', ''),
- '#description' => t('Use the placeholder !id in the URL where the ISBN or ISBN will be placed. You can also specify: !type (Biblio Type number), !tit (Title), !aut (Author(s))') .' '. t('For example') .': http://example.com/getimage?isbn=!id&type=!type',
- );
-
$form['gbooks'] = array(
'#type' => 'fieldset',
'#collapsible' => false,
@@ -316,7 +328,7 @@
$form['gbooks']['millennium_googlebooks'] = array(
'#type' => 'radios',
'#title' => t('Add links to Google Book Search'),
- '#options' => array(0 => "No", "full" => "Full view only", "teaser" => "Teaser & Full view"),
+ '#options' => array(0 => t('No'), "full" => t('Full view only'), "teaser" => t('Teaser & Full view')),
'#default_value' => variable_get('millennium_googlebooks', "teaser"),
'#description' => t('This will show a link to Google Book Search whenever a limited or full view version is found on Google. Note: This setting loads a small script hosted by Google for each page of items shown.'),
);
@@ -330,7 +342,7 @@
$form['gbooks']['millennium_googlebooks_widget'] = array(
'#type' => 'radios',
'#title' => t('Show embedded Google Book Search preview in full node view'),
- '#options' => array(0 => "No", 1 => "Yes"),
+ '#options' => array(0 => t("No"), 1 => t("Yes")),
'#default_value' => variable_get('millennium_googlebooks_widget', 0),
'#description' => t('This will show an embedded Google Books viewer when the item is found on Google Book Search. Note: Only works when "Add links to Google Book Search" option is enabled. This setting loads an additional script hosted by Google.'),
);
Index: millennium.module
--- millennium.module Base (1.13.2.33.2.2.2.88)
+++ millennium.module Locally Modified (Based On 1.13.2.33.2.2.2.88)
@@ -859,10 +859,17 @@
);
}
+ // Show biblio data table
+ $biblio_table_flag = variable_get('millennium_display_biblio_data', 'teaser');
+ if (
+ (!$page && $biblio_table_flag == "teaser")
+ || ($page && $biblio_table_flag !== "0")
+ ) {
$node->content['millennium_biblio_data'] = array(
'#value' => theme("millennium_biblio_data", $node->millennium_biblio_data, $page ? "full" : "teaser"),
'#weight' => 0,
);
+ }
break;
}
@@ -912,6 +919,7 @@
return array(
'marc' => array('info' => t('Millennium: MARC')),
//'citation' => array('info' => t('Millennium: APA citation')),
+ 'biblio_data' => array('info' => t('Millennium: bibliographic data table')),
);
case 'view':
@@ -937,6 +945,13 @@
'content' => ''. $marc_text .'
',
);
break;
+ case 'biblio_data':
+ $table = theme("millennium_biblio_data", $node->millennium_biblio_data);
+ return array(
+ 'subject' => t('Millennium: bibliographic data table'),
+ 'content' => $table,
+ );
+ break;
}
return $blocks;
@@ -1530,6 +1545,13 @@
// Add OPAC name to node's taxonomy
millennium_add_taxonomy_opacname_to_node($nodeobject, $base_url);
+ // Let other modules alter the node object
+ // function signature: mymodulename_millennium_nodeobject_alter($nodeobject, $parsed_marc)
+ // where:
+ // $biblio is the biblio information array
+ // $parsed_marc is the parsed MARC record
+ drupal_alter('millennium_nodeobject', $nodeobject, $parsed_marc);
+
if (!$nodeobject) {
$result->success = false;
$result->error = "Could not create node object from parsed MARC for $recnum";