# 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: millennium.module
--- millennium.module Base (1.13.2.33.2.2.2.105)
+++ millennium.module Locally Modified (Based On 1.13.2.33.2.2.2.105)
@@ -799,7 +799,7 @@
       if (sizeof($authors_output)) {
         $node->content['millennium_authors'] = array(
           '#value' => "<div class='millennium authors'>". t('by @authors', array('@authors' => implode('; ', $authors_output))) ."</div>\n",
-          '#weight' => -91,
+          '#weight' => millennium_element_weight('millennium_authors'),
         );
       }
 
@@ -808,7 +808,7 @@
       $year = ($year > 1400) ? " / {$year}" : "";
       $node->content['millennium_extra'] = array(
         '#value' => "<div class='millennium extra'>". _millennium_human_string($node->millennium_biblio_data, "type") . $year ."</div>\n",
-        '#weight' => -90,
+        '#weight' => millennium_element_weight('millennium_extra'),
       );
 
       // Determine ISBN for Google Books API
@@ -829,7 +829,7 @@
           drupal_add_js(array('millennium' => array('gbooks_replace_covers' => variable_get('millennium_googlebooks_covers', TRUE))), 'setting');
           $node->content['millennium_google_books'] = array(
             '#value' => "<div id='gbooks-link-$search_isbn' class='millennium gbook'></div>",
-            '#weight' => -80,
+            '#weight' => millennium_element_weight('millennium_google_books'),
           );
         }
       }
@@ -841,7 +841,7 @@
         drupal_add_js( drupal_get_path('module', 'millennium') .'/millennium_googlebooks.js');
         $node->content['millennium_googlebookswidget'] = array(
           '#value' => "<div id='gbooks-widget-$search_isbn'></div>", #'<div id="gbooks-widget-" style="width:100%; height:400px"></div>',
-          '#weight' => 100,
+          '#weight' => millennium_element_weight('millennium_googlebookswidget'),
         );
       }
 
@@ -850,7 +850,7 @@
       if ($coverimage_widget) {
         $node->content['millennium_coverimage'] = array(
           '#value' => $coverimage_widget,
-          '#weight' => -100,
+          '#weight' => millennium_element_weight('millennium_coverimage'),
         );
       }
 
@@ -860,7 +860,7 @@
       if ($holdings_widget) {
         $node->content['millennium_holdings'] = array(
           '#value' => $holdings_widget,
-          '#weight' => -50,
+          '#weight' => millennium_element_weight('millennium_holdings'),
         );
       }
 
@@ -872,7 +872,7 @@
           ) {
         $node->content['millennium_biblio_data'] = array(
           '#value' => theme("millennium_biblio_data", $node->millennium_biblio_data, $page ? "full" : "teaser"),
-          '#weight' => 0,
+          '#weight' => millennium_element_weight('millennium_biblio_data'),
         );
       }
 
@@ -2920,3 +2920,79 @@
   $user = user_load(array('uid' => 1));
   return $user->name;
 }
+
+/**
+ * Implementation of hook_content_extra_fields().
+ */
+function millennium_content_extra_fields($type_name) {
+  $type = variable_get('millennium_marc_node_type', 'page');
+  if ($type_name == $type) {
+    $fields = array(
+      'millennium_coverimage' => array(
+        'label' => 'Millennium: ' . t('Cover image'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_coverimage'),
+       ),
+      'millennium_authors' => array(
+        'label' => 'Millennium: ' . t('Authors'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_authors'),
+      ),
+      'millennium_extra' => array(
+        'label' => 'Millennium: ' . t('Item type and year published'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_extra'),
+      ),
+      'millennium_google_books' => array(
+        'label' => 'Millennium: ' . t('Link to Google Books'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_google_books'),
+      ),
+      'millennium_holdings' => array(
+        'label' => 'Millennium: ' . t('Holdings table'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_holdings'),
+      ),
+      'millennium_biblio_data' => array(
+        'label' => 'Millennium: ' . t('Biblio data table'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_biblio_data'),
+      ),
+      'millennium_googlebookswidget' => array(
+        'label' => 'Millennium: ' . t('Embedded Google Book view'),
+        'description' => '',
+        'weight' => millennium_element_weight('millennium_googlebookswidget'),
+      ),
+    );
+    return $fields;
+  }
+}
+
+/**
+ * Helper function to return the weight for elements added in
+ * millennium_nodeapi() to the render array.
+ *
+ * @param $element_name
+ *   Index of the element.
+ * @return int
+ *   The weight.
+ */
+function millennium_element_weight($element_name) {
+  static $runs = 0;
+  $defaults = array(
+    'millennium_coverimage' => -100,
+    'millennium_authors' => -91,
+    'millennium_extra' => -90,
+    'millennium_google_books' => -80,
+    'millennium_holdings' => -50,
+    'millennium_biblio_data' => 0,
+    'millennium_googlebookswidget' => 100,
+  );
+  if ($runs++ < 5 && function_exists('content_extra_field_weight')) {
+    $weight = content_extra_field_weight(variable_get('millennium_marc_node_type', 'page'), $element_name);
+    if ($weight) {
+      return $weight;
+    }
+  }
+  return $defaults[$element_name];
+}
