Project

General

Profile

Revision bf97c2e8

IDbf97c2e81284d656e799a8ac08cfa700b8bbdb4f
Parent 5189a8ec
Child d1eb0a8c

Added by Andreas Kohlbecker almost 6 years ago

cleaning up

View differences:

7.x/modules/cdm_dataportal/includes/descriptions.inc
15 15
  }
16 16
  return implode(', ', $modifiers_strings);
17 17
}
18

  
18 19
/**
19 20
 * Filters the given set of description elements and prefers computed elements over
20 21
 * others. Computed description elements are identified by the MarkerType.COMPUTED()
......
68 69
      }
69 70
    }
70 71
  }
72
}
73

  
74
/**
75
 * Prepares the items for a table of content list.
76
 *
77
 * see also hook_cdm_feature_node_toc_items_alter()
78
 *
79
 * @param $feature_nodes
80
 *   An array of CDM FeatureNode instances
81
 *
82
 * @return array
83
 *   The items array is an array suitable for theme_item_list().
84
 */
85
function cdm_feature_node_toc_items($feature_nodes) {
86
  $items = array();
87

  
88
  // FIXME !!!!!!!!!!!!!!!!
89
  // implement api hook to allow adding additional toc items for other modules,
90
  // implement palmweb module to preserve funcion of palmweb_2_cdm_feature_nodesTOC()
91
  //
92

  
93
  // we better cache here since drupal_get_query_parameters has no internal static cache variable
94
  $http_request_params = drupal_get_query_parameters();
95

  
96
  foreach ($feature_nodes as $node) {
97

  
98
    if (hasFeatureNodeDescriptionElements($node)) {
99

  
100
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
101
      //TODO HACK to implement images for taxa, should be removed.
102
      if ($node->feature->uuid != UUID_IMAGE) {
103
        $items[] = array(
104
            l(
105
                theme('cdm_feature_name', array('feature_name' => $featureRepresentation)),
106
                $_GET['q'],
107
                array(
108
                    'attributes' => array('class' => array('toc')),
109
                    'fragment' => generalizeString($featureRepresentation),
110
                    'query' => $http_request_params
111
                )
112
            )
113
        );
114
      }
115
    }
116
  }
117

  
118
  $items = module_invoke_all('cdm_feature_node_toc_items_alter', $items);
119

  
120
  return $items;
71 121
}
7.x/modules/cdm_dataportal/includes/pages.inc
202 202
  return $render_array;
203 203
}
204 204

  
205

  
206
/**
207
 * TODO should this function really be a compose funtion?
208
 *     For a compose function must there alway be a theme function with the same name? (ak 8.8.2013)
209
 *
210
 * composes and returns an render array containing the components of the taxon profile tab:
211
 *  - 'taxon_profile_image'
212
 *  - 'taxon_description_feature_toc'
213
 *  - 'taxon_description_features'
214
 *
215
 *
216
 * @param array $variables
217
 *   An associative array containing:
218
 *   - taxon
219
 *   - mergedTrees
220
 *   - media
221
 *
222
 * @return array
223
 *   A Drupal reder array with the following elements:
224
 *     - 'taxon_profile_image'
225
 *     - 'taxon_description_feature_toc'
226
 *     - 'taxon_description_features'
227
 *
228
 * @ingroup compose
229
 */
230
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media) {
231

  
232
  $render_array = array();
233

  
234
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
235

  
236
  $hide_taxon_profile_image = FALSE;
237
  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
238
    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
239
    $hide_taxon_profile_image = ($rankCompare > -1);
240
  }
241

  
242
  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
243

  
244
    $representationPart = new stdClass();
245
    $attributes = array();
246
    if (isset($media[0]->representations[0]->parts[0])) {
247
      $representationPart = $media[0]->representations[0]->parts[0];
248
      $attributes['alt'] = $representationPart->uri;
249

  
250
      if(!empty($taxon_profile_image_settings['media_uri_query'])){
251
        $representationPart->uri = $representationPart->uri
252
        . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
253
        . $taxon_profile_image_settings['media_uri_query'];
254
      }
255
    }
256
    else {
257
      // show placeholder image instead
258
      if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){
259
        // use the user provided image
260
        $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
261
        $url = file_create_url($profile_image_file->uri);
262
        $image_info = image_get_info($profile_image_file->uri);
263
        $representationPart->width = $image_info['width'];
264
        $representationPart->height = $image_info['height'];
265
        $representationPart->uri = $url;
266
      } else {
267
        // use the hard coded default
268
        $representationPart->width = 184;
269
        $representationPart->height = 144;
270
        $representationPart->uri = base_path() .  drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png';
271
      }
272
      $attributes['alt'] = "no image available";
273
    }
274

  
275
    $profile_image = theme('cdm_media_gallerie_image', array(
276
        'mediaRepresentationPart' => $representationPart,
277
        'maxExtend' => $taxon_profile_image_settings['maxextend'],
278
        'addPassePartout' => FALSE,
279
        'attributes' => $attributes,
280
    ));
281
    // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
282
    $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image. '</div>', -101);
283
  }
284

  
285
  $toc = array(
286
      '#theme' => 'item_list',
287
      '#items' => cdm_feature_node_toc_items($merged_tree->root->children),
288
      '#title' => t('Content'),
289
      '#weight' => -100,
290
      '#suffix' => '</div>',
291
      '#prefix'=> '<div id="featureTOC">' // reusing id featureTOC even if this is semantically not correct
292
  );
293
  $render_array['taxon_description_feature_toc'] = $toc; //markup_to_render_array($toc_html);
294

  
295
  // Description.
296
  $render_array['taxon_description_features'] = markup_to_render_array(
297
      theme(
298
          'cdm_feature_nodes',
299
          array('mergedFeatureNodes' => $merged_tree->root->children, 'taxon' => $taxon)
300
      )
301
  );
302

  
303
  return $render_array;
304
}
305

  
306

  
205 307
/**
206 308
 * Manages the tab to be hidden in the taxon page.
207 309
 *
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
13 13
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14 14
 */
15 15

  
16
/**
17
 *
18
 * @param unknown $feature_nodes
19
 * @return multitype:multitype:Ambigous <An, string>
20
 */
21
function cdm_feature_node_toc_items($feature_nodes) {
22
  $items = array();
23

  
24
  // FIXME !!!!!!!!!!!!!!!!
25
  // implement api hook to allow adding additional toc items for other modules,
26
  // implement palmweb module to preserve funcion of palmweb_2_cdm_feature_nodesTOC()
27
  //
28

  
29
  // we better cache here since drupal_get_query_parameters has no internal static cache variable
30
  $http_request_params = drupal_get_query_parameters();
31

  
32
  foreach ($feature_nodes as $node) {
33

  
34
    if (hasFeatureNodeDescriptionElements($node)) {
35

  
36
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
37
      //TODO HACK to implement images for taxa, should be removed.
38
      if ($node->feature->uuid != UUID_IMAGE) {
39
        $items[] = array(
40
          l(
41
              theme('cdm_feature_name', array('feature_name' => $featureRepresentation)),
42
              $_GET['q'],
43
              array(
44
                  'attributes' => array('class' => array('toc')),
45
                  'fragment' => generalizeString($featureRepresentation),
46
                  'query' => $http_request_params
47
              )
48
           )
49
        );
50
      }
51
    }
52
  }
53

  
54
  $items = module_invoke_all('cdm_feature_node_toc_items_alter', $items);
55

  
56
  return $items;
57
}
58 16

  
59 17
/**
60 18
 * Theme function to alter the feature representation.
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)