Index: millennium.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/millennium/millennium.module,v
retrieving revision 1.13.2.33.2.2.2.29
diff -u -r1.13.2.33.2.2.2.29 millennium.module
--- millennium.module	15 Oct 2009 20:14:12 -0000	1.13.2.33.2.2.2.29
+++ millennium.module	15 Oct 2009 21:33:26 -0000
@@ -243,10 +252,7 @@
   $output .= "<td><h3>" .t('Conversion results') ."</h3>";
 
   $output .= "<h4>" . $GLOBALS["_millennium_field_labels"]["type"] ."</h4>";
-  $output .= sprintf("%s (%d)",
-    $tmp_node->millennium_biblio_data["type"],
-    $tmp_node->millennium_biblio_data["type_num"]
-    );
+  $output .= $tmp_node->millennium_biblio_data["type"];
 
   $output .= "<h4>" .t('Fields') ."</h4>";
   $output .= theme("millennium_biblio_data", $tmp_node->millennium_biblio_data, 'full');
@@ -743,8 +749,8 @@
   $biblio["item_description"] = $item_description;
 
   // Item type
-  $biblio["type_num"] = millennium_marcleader_to_bibtype($marc["LEADER"]);
-  $biblio["type"] = millennium_marcleader_to_mattypename($marc["LEADER"]);
+  #$biblio["type_num"] = millennium_marcleader_to_bibtype($marc["LEADER"]);
+  $biblio["type"] = millennium_marcleader_to_mattypename($marc);
 
   // Title
   $data = millennium_getFields($marc, "245..");
@@ -1072,7 +1078,7 @@
   );
 
   // Material type
-  $term_mat_type = millennium_marcleader_to_mattypename($record["LEADER"]);
+  $term_mat_type = millennium_marcleader_to_mattypename($record);
   if ($term_mat_type) {
     millennium_add_node_taxonomy_terms($nodeobject, variable_get('millennium_marc_vid_leader_item_type', -1) , array($term_mat_type));
   }
@@ -2618,36 +2624,75 @@
 
 /**
  * Returns the material type name from the MARC leader
- * @param leader a string containing the MARC leader (e.g. "LEADER 00000pam  2200000   4500")
+ * @param array $marc A parsed marc record
  */
-function millennium_marcleader_to_mattypename($leader) {
-  $code6 = drupal_substr($leader, 6, 1);
-  $code7 = drupal_substr($leader, 7, 1);
+function millennium_marcleader_to_mattypename($marc) {
   // http://www.loc.gov/marc/bibliographic/bdleader.html
   // TODO: extract PO
-  static $mattyype = array(
-    "a" => "Book",
-    "c" => "Sheet music", #"Notated music",
-    "d" => "Sheet music", #"Manuscript notated music",
-    "e" => "Map", #"Cartographic material",
-    "g" => "Projected medium",
-    "i" => "Sound Recording", #"Nonmusical sound recording",
-    "j" => "Music", #"Musical sound recording",
-    "k" => "Graphic", #"Two-dimensional nonprojectable graphic",
-    "m" => "Computer file",
-    "o" => "Kit",
-    "p" => "Other", #"Mixed material",
-    "r" => "Object", #"Three-dimensional artifact or naturally occurring object",
-    "t" => "Manuscript" #"Manuscript language material",
-  );
-  if ($code7 == "s") return "Periodicals";
-  return (isset($mattyype[$code6]) ? $mattyype[$code6] : false);
+  $marc007 = millennium_getFields($marc, "007..");
+  $record_type = substr($marc['LEADER'], 6, 1);
+  $bibliographic_level = substr($marc['LEADER'], 7, 1);
+  $material_category = substr($marc007[0], 0, 1);
+  $material_designation = substr($marc007[0], 1, 1);
+  $video_format = substr($marc007[0], 4, 1);
+  switch ($record_type) {
+    case 'r':
+      $format = 'Object';
+      break;
+    case 'k':
+      $format = 'Photo';
+      break;
+    case 'g':
+      $format = 'Projected medium';
+      break;
+    case 'o':
+    case 'p':
+      $format = 'Kit';
+      break;
+    case 'e':
+    case 'f':
+      $format = 'Map';
+      break;
+    case 'm':
+      $format = 'Computer file';
+      break;
+    case 'c':
+    case 'd':
+      $format = 'Sheet music';
+      break;
+    case 'a':
+    default:
+      if ($bibliographic_level == 's'){
+        $format = 'Periodical';
+      }
+      else {
+        $format = 'Book';
+      }
+  }
+  if ($material_category == 'v'){
+    if ($video_format == 'v'){
+      $format = 'DVD';
+    }
+  else {
+    $format = 'VHS';
+  }
+  if ($material_category == 's'){
+      if ($material_designation == 's'){
+        $format = 'cassette';
+      }
+      elseif ($material_designation == 's'){
+         $format = 'CD';
+      }
+    }
+  }
+  return $format;
 }
 
 /**
  * Returns the material type ID from the MARC leader
  * @param leader a string containing the MARC leader (e.g. "LEADER 00000pam  2200000   4500")
  */
+  /*
 function millennium_marcleader_to_bibtype($leader) {
   $code6 = drupal_substr($leader, 6, 1);
   $code7 = drupal_substr($leader, 7, 1);
@@ -2679,6 +2724,7 @@
   }
   return ( isset($mattyype[$code6]) ? $mattyype[$code6] : 129); #129 = "Miscellaneous"
 }
+*/
 
 /**
  * Shows realtime holdings information, called via AJAX from a node or teaser view

