Project

General

Profile

Revision bf97c2e8

IDbf97c2e81284d656e799a8ac08cfa700b8bbdb4f
Parent 5189a8ec
Child d1eb0a8c

Added by Andreas Kohlbecker about 6 years ago

cleaning up

View differences:

7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
250 250
  return $render_array;
251 251
}
252 252

  
253
/**
254
 * compses and returns an render array containing the components of the taxon profile tab:
255
 *  - 'taxon_profile_image'
256
 *  - 'taxon_description_feature_toc'
257
 *  - 'taxon_description_features'
258
 *
259
 *
260
 * @param array $variables
261
 *   An associative array containing:
262
 *   - taxon
263
 *   - mergedTrees
264
 *   - media
265
 *
266
 * @return array
267
 *   A Drupal reder array with the following elements:
268
 *     - 'taxon_profile_image'
269
 *     - 'taxon_description_feature_toc'
270
 *     - 'taxon_description_features'
271
 *
272
 * @ingroup compose
273
 */
274
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media) {
275

  
276
  $render_array = array();
277

  
278
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
279

  
280
  $hide_taxon_profile_image = FALSE;
281
  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
282
    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
283
    $hide_taxon_profile_image = ($rankCompare > -1);
284
  }
285

  
286
  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
287

  
288
    $representationPart = new stdClass();
289
    $attributes = array();
290
    if (isset($media[0]->representations[0]->parts[0])) {
291
      $representationPart = $media[0]->representations[0]->parts[0];
292
      $attributes['alt'] = $representationPart->uri;
293

  
294
      if(!empty($taxon_profile_image_settings['media_uri_query'])){
295
        $representationPart->uri = $representationPart->uri
296
            . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
297
            . $taxon_profile_image_settings['media_uri_query'];
298
      }
299
    }
300
    else {
301
      // show placeholder image instead
302
      if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){
303
        // use the user provided image
304
        $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
305
        $url = file_create_url($profile_image_file->uri);
306
        $image_info = image_get_info($profile_image_file->uri);
307
        $representationPart->width = $image_info['width'];
308
        $representationPart->height = $image_info['height'];
309
        $representationPart->uri = $url;
310
      } else {
311
        // use the hard coded default
312
        $representationPart->width = 184;
313
        $representationPart->height = 144;
314
        $representationPart->uri = base_path() .  drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png';
315
      }
316
      $attributes['alt'] = "no image available";
317
    }
318

  
319
    $profile_image = theme('cdm_media_gallerie_image', array(
320
        'mediaRepresentationPart' => $representationPart,
321
        'maxExtend' => $taxon_profile_image_settings['maxextend'],
322
        'addPassePartout' => FALSE,
323
        'attributes' => $attributes,
324
    ));
325
    // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
326
    $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image. '</div>', -101);
327
  }
328

  
329
  $toc = array(
330
      '#theme' => 'item_list',
331
      '#items' => cdm_feature_node_toc_items($merged_tree->root->children),
332
      '#title' => t('Content'),
333
      '#weight' => -100,
334
      '#suffix' => '</div>',
335
      '#prefix'=> '<div id="featureTOC">' // reusing id featureTOC even if this is semantically not correct
336
  );
337
  $render_array['taxon_description_feature_toc'] = $toc; //markup_to_render_array($toc_html);
338

  
339
  // Description.
340
  $render_array['taxon_description_features'] = markup_to_render_array(
341
      theme(
342
          'cdm_feature_nodes',
343
          array('mergedFeatureNodes' => $merged_tree->root->children, 'taxon' => $taxon)
344
          )
345
  );
346

  
347
  return $render_array;
348
}
349 253

  
350 254

  
351 255

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)