commit 053a92ec8ea850273091a771477230297f3d2009
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Wed Jun 12 15:05:56 2013 +0000

    replacing theme_cdm_preferred_image() function by generic base functionality for all portals

diff --git a/7.x/modules/cdm_dataportal/settings.php b/7.x/modules/cdm_dataportal/settings.php
index cd770888..4243a8e7 100644
--- a/7.x/modules/cdm_dataportal/settings.php
+++ b/7.x/modules/cdm_dataportal/settings.php
@@ -85,6 +85,7 @@ define('CDM_TAXON_PROFILE_IMAGE_DEFAULT', serialize(
     array(
         'show' => 1,
         'maxextend' => 184,
+        'media_uri_query' => '',
         'custom_placeholder_image_on' => 0,
         'custom_placeholder_image_fid' => ''
     )
@@ -1063,6 +1064,7 @@ function cdm_settings_layout_taxon() {
   /*
    * 'show' => 1,
    * 'maxextend' => 184,
+   * 'media_uri_query' => ''
    * 'custom_placeholder_image_on' => 1,
    * 'custom_placeholder_image_fid' => ''
    */
@@ -1084,6 +1086,19 @@ function cdm_settings_layout_taxon() {
       '#description' => t('The maximum extend in either dimension, width or height, of the profil picture in pixels.')
   );
 
+  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['media_uri_query'] = array(
+      '#type' => 'textfield',
+      '#tree' => TRUE,
+      '#title' => t('Additional URI query parameter'),
+      '#default_value' =>  $taxon_profile_image_settings['media_uri_query'],
+      '#maxlength' => 1024,
+      '#size' => 60,
+      '#description' => t('Additional query parameters to be used when requesting for the '
+          . 'profile image. E.g.: <code>width=400&height=300&quality=95&format=jpeg</code>.'
+          . 'The query parameters will be appendend to the uri of the media representation part'
+          . ' as stored in the cdm. The query parameter string must not start with a \'&\' or  \'?\'')
+  );
+
   $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_on'] = array(
       '#type' => 'checkbox',
       '#title' => t('Use a custom placeholder image'),
diff --git a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.media.theme b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.media.theme
index 73a27e74..4fe7dbe9 100644
--- a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.media.theme
+++ b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.media.theme
@@ -771,38 +771,3 @@ jQuery(document).ready(function(){
   return $out;
 }
 
-/**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
- */
-function theme_cdm_preferredImage($variables) {
-
-  $media = $variables['media'];
-  $defaultRepresentationPart = $variables['defaultRepresentationPart'];
-  $imageMaxExtend = $variables['imageMaxExtend'];
-  $parameters = $variables['parameters'];
-
-  $out = '';
-
-  if (isset($media[0])) {
-    $representationPart = $media[0]->representations[0]->parts[0];
-    if ($parameters) {
-      $representationPart->uri . $parameters;
-    }
-  }
-  else {
-    $representationPart = $defaultRepresentationPart;
-  }
-
-  $attributes = array(
-    'alt' => (isset($media->representations[0]->parts[0]->uri) ? $media->representations[0]->parts[0]->uri : "no image available"),
-  );
-  $out .= theme('cdm_media_gallerie_image', array(
-    'mediaRepresentationPart' => $representationPart,
-    'maxExtend' => $imageMaxExtend,
-    'addPassePartout' => FALSE,
-    'attributes' => $attributes,
-  ));
-
-  return $out;
-}
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 410861d8..8acdd0b4 100644
--- a/7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
+++ b/7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
@@ -294,27 +294,44 @@ function theme_cdm_taxon_page_profile($variables) {
   $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
   if ($taxon_profile_image_settings['show'] && !$hideImages) {
 
-    $defaultRepresentationPart = new stdClass();
-    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);
-      $defaultRepresentationPart->width = $image_info['width'];
-      $defaultRepresentationPart->height = $image_info['height'];
-      $defaultRepresentationPart->uri = $url;
-    } else {
-      // use the hardcoded default
-      $defaultRepresentationPart->width = 184;
-      $defaultRepresentationPart->height = 144;
-      $defaultRepresentationPart->uri = base_path() .  drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png';
-     }
-
-    $out .= '<div id="taxonProfileImage">' . theme('cdm_preferredImage', array(
-      'media' => $media,
-      'defaultRepresentationPart' => $defaultRepresentationPart,
-      'imageMaxExtend' => $taxon_profile_image_settings['maxextend'],
-      )) . '</div>';
+    $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,
+    ));
+    $out .= '<div id="taxonProfileImage">' . $profile_image. '</div>';
   }
 
   // Description TOC.
diff --git a/7.x/modules/cdm_dataportal/theme/theme_registry.inc b/7.x/modules/cdm_dataportal/theme/theme_registry.inc
index e14ee55e..6db050f7 100644
--- a/7.x/modules/cdm_dataportal/theme/theme_registry.inc
+++ b/7.x/modules/cdm_dataportal/theme/theme_registry.inc
@@ -169,13 +169,6 @@ function cdm_dataportal_theme() {
           'attributes' => NULL,
       )),
       'cdm_openlayers_image' => array('variables' => array('mediaRepresentationPart' => NULL, 'maxExtend' => NULL)),
-      'cdm_preferredImage' => array('variables' => array(
-          'media' => NULL,
-          'defaultRepresentationPart' => NULL,
-          'imageMaxExtend' => NULL,
-          'parameters' => '',
-      )),
-
       // Themes in cdm_dataportal.name.theme.
       'cdm_taxonName' => array('variables' => array(
           'taxonName' => NULL,
diff --git a/7.x/themes/garland_cichorieae/template.php b/7.x/themes/garland_cichorieae/template.php
index 2e31c30c..9edacddc 100755
--- a/7.x/themes/garland_cichorieae/template.php
+++ b/7.x/themes/garland_cichorieae/template.php
@@ -4,65 +4,6 @@
  * Overrides of generic themeing functions in cdm_dataportal.theme.php.
  */
 
-/**
- * Returns HTML for a cdm_taxon_page_profile.
- *
- * The description page is supposed to be the front page for a taxon.
- *
- * @param array $variables
- *   An associative array containing:
- *   - taxon: The taxon object displayed on the taxon page.
- *   - mergedTrees
- *   - media:
- *   - hideImages: boolean, FALSE if images should be hided.
- *
- * @ingroup themeable
- */
-function garland_cichorieae_cdm_taxon_page_profile($variables) {
-  $taxon = $variables['taxon'];
-  $mergedTrees = $variables['mergedTrees'];
-  $media = $variables['media'];
-  $hideImages = $variables['hideImages'];
-
-  $out = '';
-  global $base_url;
-
-  RenderHints::pushToRenderStack('taxon_page_description');
-  // Description TOC.
-  $out = theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees));
-
-  // Preferred image.
-  // 2 lines hard coded for testing.
-  if (variable_get('cdm_dataportal_show_default_image', FALSE) && !$hideImages) {
-
-    // $defaultPreferredImage = drupal_get_path('theme',
-    // 'garland_cichorieae').'/images/nopic_400x300.jpg';
-    $defaultRepresentationPart = new stdClass();
-    $defaultRepresentationPart->width = 400;
-    $defaultRepresentationPart->height = 300;
-    $defaultRepresentationPart->uri = base_path() . drupal_get_path('theme', 'garland_cichorieae') . '/images/nopic_400x300_4x3cm.jpg';
-
-    $imageUriParams = '&width=400&height=300&quality=95&format=jpeg';
-
-    $imageMaxExtend = 400;
-    $out .= '<div id="taxonProfileImage">' . theme('cdm_preferredImage', array(
-      'media' => $media,
-      'defaultRepresentationPart' => $defaultRepresentationPart,
-      'imageMaxExtend' => $imageMaxExtend,
-      'parameters' => $imageUriParams,
-      )) . '</div>';
-  }
-
-  // Description.
-  $out .= theme('cdm_featureTrees', array(
-    'mergedTrees' => $mergedTrees,
-    'taxon' => $taxon,
-  ));
-  RenderHints::popFromRenderStack();
-
-  return $out;
-}
-
 /**
  * @todo Please document this function.
  * @see http://drupal.org/node/1354
diff --git a/7.x/themes/palmweb_2/template.php b/7.x/themes/palmweb_2/template.php
index 36b8ede3..a4894202 100755
--- a/7.x/themes/palmweb_2/template.php
+++ b/7.x/themes/palmweb_2/template.php
@@ -4,57 +4,6 @@
  * Overrides of generic themeing functions in cdm_dataportal.theme.php.
  */
 
-/**
- * Returns HTML for a cdm_taxon_page_profile.
- *
- * The description page is supposed to be the front page for a taxon.
- *
- * @param array $variables
- *   An associative array containing:
- *   - taxon: The taxon object displayed on the taxon page.
- *   - mergedTrees
- *   - media:
- *   - hideImages: boolean, FALSE if images should be hided.
- *
- * @ingroup themeable
- */
-function palmweb_2_cdm_taxon_page_profile($variables){
-
-  $taxon = $variables['taxon'];
-  $mergedTrees = $variables['mergedTrees'];
-  $media = $variables['media'];
-  $hideImages = $variables['hideImages'];
-
-  $out = '';
-
-  if (!$hideImages) {
-    // Preferred image.
-    // Hardcoded for testing.
-    $defaultRepresentationPart = new stdClass();
-    $defaultRepresentationPart->width = 184;
-    $defaultRepresentationPart->height = 144;
-    $defaultRepresentationPart->uri = base_path() .drupal_get_path('theme', 'palmweb_2') . '/images/no_picture.png';
-
-    // Preferred image size 184px × 144.
-    $imageMaxExtend = 184;
-    $out .= '<div id="taxonProfileImage">';
-    $out .= theme('cdm_preferredImage', array(
-      'media' => $media,
-      'defaultRepresentationPart' => $defaultRepresentationPart,
-      'imageMaxExtend' => $imageMaxExtend,
-    ));
-    $out .= '</div>';
-  }
-
-  // Description TOC.
-  $out .= theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees));
-
-  // Description.
-  $out .= theme('cdm_featureTrees', array('mergedTrees' => $mergedTrees, 'taxon' => $taxon));
-
-  return $out;
-}
-
 /**
  * @todo Please document this function.
  * @see http://drupal.org/node/1354
