commit bf97c2e81284d656e799a8ac08cfa700b8bbdb4f
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Aug 8 14:15:29 2013 +0000

    cleaning up

diff --git a/7.x/modules/cdm_dataportal/includes/descriptions.inc b/7.x/modules/cdm_dataportal/includes/descriptions.inc
index 538deaba..fae56fd3 100644
--- a/7.x/modules/cdm_dataportal/includes/descriptions.inc
+++ b/7.x/modules/cdm_dataportal/includes/descriptions.inc
@@ -15,6 +15,7 @@ function cdm_modifers_representations($iModifieable, $glue = ', ') {
   }
   return implode(', ', $modifiers_strings);
 }
+
 /**
  * Filters the given set of description elements and prefers computed elements over
  * others. Computed description elements are identified by the MarkerType.COMPUTED()
@@ -68,4 +69,53 @@ function cdm_merge_description_elements(&$target, &$source){
       }
     }
   }
+}
+
+/**
+ * Prepares the items for a table of content list.
+ *
+ * see also hook_cdm_feature_node_toc_items_alter()
+ *
+ * @param $feature_nodes
+ *   An array of CDM FeatureNode instances
+ *
+ * @return array
+ *   The items array is an array suitable for theme_item_list().
+ */
+function cdm_feature_node_toc_items($feature_nodes) {
+  $items = array();
+
+  // FIXME !!!!!!!!!!!!!!!!
+  // implement api hook to allow adding additional toc items for other modules,
+  // implement palmweb module to preserve funcion of palmweb_2_cdm_feature_nodesTOC()
+  //
+
+  // we better cache here since drupal_get_query_parameters has no internal static cache variable
+  $http_request_params = drupal_get_query_parameters();
+
+  foreach ($feature_nodes as $node) {
+
+    if (hasFeatureNodeDescriptionElements($node)) {
+
+      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
+      //TODO HACK to implement images for taxa, should be removed.
+      if ($node->feature->uuid != UUID_IMAGE) {
+        $items[] = array(
+            l(
+                theme('cdm_feature_name', array('feature_name' => $featureRepresentation)),
+                $_GET['q'],
+                array(
+                    'attributes' => array('class' => array('toc')),
+                    'fragment' => generalizeString($featureRepresentation),
+                    'query' => $http_request_params
+                )
+            )
+        );
+      }
+    }
+  }
+
+  $items = module_invoke_all('cdm_feature_node_toc_items_alter', $items);
+
+  return $items;
 }
\ No newline at end of file
diff --git a/7.x/modules/cdm_dataportal/includes/pages.inc b/7.x/modules/cdm_dataportal/includes/pages.inc
index 7fd43fc8..d3f7444f 100644
--- a/7.x/modules/cdm_dataportal/includes/pages.inc
+++ b/7.x/modules/cdm_dataportal/includes/pages.inc
@@ -202,6 +202,108 @@ function cdm_dataportal_taxon_page_specimens($taxon) {
   return $render_array;
 }
 
+
+/**
+ * TODO should this function really be a compose funtion?
+ *     For a compose function must there alway be a theme function with the same name? (ak 8.8.2013)
+ *
+ * composes and returns an render array containing the components of the taxon profile tab:
+ *  - 'taxon_profile_image'
+ *  - 'taxon_description_feature_toc'
+ *  - 'taxon_description_features'
+ *
+ *
+ * @param array $variables
+ *   An associative array containing:
+ *   - taxon
+ *   - mergedTrees
+ *   - media
+ *
+ * @return array
+ *   A Drupal reder array with the following elements:
+ *     - 'taxon_profile_image'
+ *     - 'taxon_description_feature_toc'
+ *     - 'taxon_description_features'
+ *
+ * @ingroup compose
+ */
+function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media) {
+
+  $render_array = array();
+
+  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
+
+  $hide_taxon_profile_image = FALSE;
+  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
+    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
+    $hide_taxon_profile_image = ($rankCompare > -1);
+  }
+
+  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
+
+    $representationPart = new stdClass();
+    $attributes = array();
+    if (isset($media[0]->representations[0]->parts[0])) {
+      $representationPart = $media[0]->representations[0]->parts[0];
+      $attributes['alt'] = $representationPart->uri;
+
+      if(!empty($taxon_profile_image_settings['media_uri_query'])){
+        $representationPart->uri = $representationPart->uri
+        . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
+        . $taxon_profile_image_settings['media_uri_query'];
+      }
+    }
+    else {
+      // show placeholder image instead
+      if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){
+        // use the user provided image
+        $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
+        $url = file_create_url($profile_image_file->uri);
+        $image_info = image_get_info($profile_image_file->uri);
+        $representationPart->width = $image_info['width'];
+        $representationPart->height = $image_info['height'];
+        $representationPart->uri = $url;
+      } else {
+        // use the hard coded default
+        $representationPart->width = 184;
+        $representationPart->height = 144;
+        $representationPart->uri = base_path() .  drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png';
+      }
+      $attributes['alt'] = "no image available";
+    }
+
+    $profile_image = theme('cdm_media_gallerie_image', array(
+        'mediaRepresentationPart' => $representationPart,
+        'maxExtend' => $taxon_profile_image_settings['maxextend'],
+        'addPassePartout' => FALSE,
+        'attributes' => $attributes,
+    ));
+    // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
+    $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image. '</div>', -101);
+  }
+
+  $toc = array(
+      '#theme' => 'item_list',
+      '#items' => cdm_feature_node_toc_items($merged_tree->root->children),
+      '#title' => t('Content'),
+      '#weight' => -100,
+      '#suffix' => '</div>',
+      '#prefix'=> '<div id="featureTOC">' // reusing id featureTOC even if this is semantically not correct
+  );
+  $render_array['taxon_description_feature_toc'] = $toc; //markup_to_render_array($toc_html);
+
+  // Description.
+  $render_array['taxon_description_features'] = markup_to_render_array(
+      theme(
+          'cdm_feature_nodes',
+          array('mergedFeatureNodes' => $merged_tree->root->children, 'taxon' => $taxon)
+      )
+  );
+
+  return $render_array;
+}
+
+
 /**
  * Manages the tab to be hidden in the taxon page.
  *
diff --git a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
index fd240ce1..ab01cd81 100644
--- a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
+++ b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
@@ -13,48 +13,6 @@
  * @see http://www.mozilla.org/MPL/MPL-1.1.html
  */
 
-/**
- *
- * @param unknown $feature_nodes
- * @return multitype:multitype:Ambigous <An, string>
- */
-function cdm_feature_node_toc_items($feature_nodes) {
-  $items = array();
-
-  // FIXME !!!!!!!!!!!!!!!!
-  // implement api hook to allow adding additional toc items for other modules,
-  // implement palmweb module to preserve funcion of palmweb_2_cdm_feature_nodesTOC()
-  //
-
-  // we better cache here since drupal_get_query_parameters has no internal static cache variable
-  $http_request_params = drupal_get_query_parameters();
-
-  foreach ($feature_nodes as $node) {
-
-    if (hasFeatureNodeDescriptionElements($node)) {
-
-      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
-      //TODO HACK to implement images for taxa, should be removed.
-      if ($node->feature->uuid != UUID_IMAGE) {
-        $items[] = array(
-          l(
-              theme('cdm_feature_name', array('feature_name' => $featureRepresentation)),
-              $_GET['q'],
-              array(
-                  'attributes' => array('class' => array('toc')),
-                  'fragment' => generalizeString($featureRepresentation),
-                  'query' => $http_request_params
-              )
-           )
-        );
-      }
-    }
-  }
-
-  $items = module_invoke_all('cdm_feature_node_toc_items_alter', $items);
-
-  return $items;
-}
 
 /**
  * Theme function to alter the feature representation.
diff --git a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
index 6beb4869..098e406f 100644
--- a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
+++ b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
@@ -250,102 +250,6 @@ function theme_cdm_taxon_page($variables) {
   return $render_array;
 }
 
-/**
- * compses and returns an render array containing the components of the taxon profile tab:
- *  - 'taxon_profile_image'
- *  - 'taxon_description_feature_toc'
- *  - 'taxon_description_features'
- *
- *
- * @param array $variables
- *   An associative array containing:
- *   - taxon
- *   - mergedTrees
- *   - media
- *
- * @return array
- *   A Drupal reder array with the following elements:
- *     - 'taxon_profile_image'
- *     - 'taxon_description_feature_toc'
- *     - 'taxon_description_features'
- *
- * @ingroup compose
- */
-function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media) {
-
-  $render_array = array();
-
-  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
-
-  $hide_taxon_profile_image = FALSE;
-  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
-    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
-    $hide_taxon_profile_image = ($rankCompare > -1);
-  }
-
-  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
-
-    $representationPart = new stdClass();
-    $attributes = array();
-    if (isset($media[0]->representations[0]->parts[0])) {
-      $representationPart = $media[0]->representations[0]->parts[0];
-      $attributes['alt'] = $representationPart->uri;
-
-      if(!empty($taxon_profile_image_settings['media_uri_query'])){
-        $representationPart->uri = $representationPart->uri
-            . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
-            . $taxon_profile_image_settings['media_uri_query'];
-      }
-    }
-    else {
-      // show placeholder image instead
-      if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){
-        // use the user provided image
-        $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
-        $url = file_create_url($profile_image_file->uri);
-        $image_info = image_get_info($profile_image_file->uri);
-        $representationPart->width = $image_info['width'];
-        $representationPart->height = $image_info['height'];
-        $representationPart->uri = $url;
-      } else {
-        // use the hard coded default
-        $representationPart->width = 184;
-        $representationPart->height = 144;
-        $representationPart->uri = base_path() .  drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png';
-      }
-      $attributes['alt'] = "no image available";
-    }
-
-    $profile_image = theme('cdm_media_gallerie_image', array(
-        'mediaRepresentationPart' => $representationPart,
-        'maxExtend' => $taxon_profile_image_settings['maxextend'],
-        'addPassePartout' => FALSE,
-        'attributes' => $attributes,
-    ));
-    // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
-    $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image. '</div>', -101);
-  }
-
-  $toc = array(
-      '#theme' => 'item_list',
-      '#items' => cdm_feature_node_toc_items($merged_tree->root->children),
-      '#title' => t('Content'),
-      '#weight' => -100,
-      '#suffix' => '</div>',
-      '#prefix'=> '<div id="featureTOC">' // reusing id featureTOC even if this is semantically not correct
-  );
-  $render_array['taxon_description_feature_toc'] = $toc; //markup_to_render_array($toc_html);
-
-  // Description.
-  $render_array['taxon_description_features'] = markup_to_render_array(
-      theme(
-          'cdm_feature_nodes',
-          array('mergedFeatureNodes' => $merged_tree->root->children, 'taxon' => $taxon)
-          )
-  );
-
-  return $render_array;
-}
 
 
 
