Project

General

Profile

Download (49.1 KB) Statistics
| Branch: | Tag: | Revision:
1 806baeb2 Andreas Kohlbecker
<?php
2
// $Id$
3
4
/**
5 35eafafb f.revilla
 * Copyright (C) 2007 EDIT
6
 * European Distributed Institute of Taxonomy
7
 * http://www.e-taxonomy.eu
8
 *
9
 * The contents of this file are subject to the Mozilla Public License Version 1.1
10
 * See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
11
 */
12 806baeb2 Andreas Kohlbecker
13 c2c8970d Andreas Kohlbecker
14 806baeb2 Andreas Kohlbecker
function theme_cdm_feature_nodesTOC($featureNodes){
15
16 0364559b Andreas Kohlbecker
  $out .= '<ul>';
17 92f7d0a0 Andreas Kohlbecker
18 0364559b Andreas Kohlbecker
  foreach($featureNodes as $node){
19 294bea51 Andreas Kohlbecker
20
    if(hasFeatureNodeDescriptionElements($node)){
21 0364559b Andreas Kohlbecker
22
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
23
      // HACK to implement images for taxa, should be removed
24
      if($node->feature->uuid != UUID_IMAGE){
25
        $out .= '<li>'.l(t(theme('cdm_feature_name', $featureRepresentation)), $_GET['q'], array("class"=>"toc"), NULL, generalizeString($featureRepresentation)).'</li>';
26
      }
27
    }
28
  }
29 92f7d0a0 Andreas Kohlbecker
30 0364559b Andreas Kohlbecker
  $out .= '</ul>';
31
  return $out;
32 806baeb2 Andreas Kohlbecker
}
33
34
function theme_cdm_feature_name($feature_name){
35 0364559b Andreas Kohlbecker
  //TODO replace by using translations ?
36
  switch($feature_name){
37
    default: return t(ucfirst($feature_name));
38
  }
39 806baeb2 Andreas Kohlbecker
}
40
41 16f9664d Andreas Kohlbecker
/**
42
 * Renders the taxon profile. The taxon profile consists of description elements
43
 * which are ordered by the structure defined by specific FeatureTree. The chosen
44
 * FeatureTree is merged with the list of desctiprion elements prior to using this
45
 * method (see function cdm_ws_descriptions_by_featuretree() ).
46
 *
47
 * @param unknown_type $mergedTrees
48
 * @param unknown_type $taxon The taxon whose sprofile to show
49
 */
50 806baeb2 Andreas Kohlbecker
function theme_cdm_featureTrees($mergedTrees, $taxon){
51 0364559b Andreas Kohlbecker
  if(!$mergedTrees){
52
    return;
53
  }
54
  foreach($mergedTrees as &$mTree){
55 7e510a5a Andreas Kohlbecker
    //TODO display title and reference in case of multiple $mergedTrees -> theme
56 0364559b Andreas Kohlbecker
    $out .= theme('cdm_feature_nodes', $mTree->root->children, $taxon);
57
  }
58 92f7d0a0 Andreas Kohlbecker
59 0364559b Andreas Kohlbecker
  return $out;
60 806baeb2 Andreas Kohlbecker
}
61
62
63
function theme_cdm_featureTreeTOCs($mergedTrees){
64
65 0364559b Andreas Kohlbecker
  if(!$mergedTrees){
66
    return;
67
  }
68
  //FIXME
69 447f45e7 Andreas Kohlbecker
  $out = '<div id="featureTOC">';
70 0364559b Andreas Kohlbecker
  $out .= '<h2>' . t('Content') .'</h2>';
71 806baeb2 Andreas Kohlbecker
72 0364559b Andreas Kohlbecker
  //TODO diplay title and reference in case of multiple $mergedTrees -> theme
73 806baeb2 Andreas Kohlbecker
74 0364559b Andreas Kohlbecker
  foreach($mergedTrees as &$mTree){
75
    $out .= theme('cdm_feature_nodesTOC', $mTree->root->children);
76
  }
77 806baeb2 Andreas Kohlbecker
78 0364559b Andreas Kohlbecker
  $out .= '</div>';
79
  return $out;
80 806baeb2 Andreas Kohlbecker
}
81
82
83 3467d3b2 Andreas Kohlbecker
/**
84 7e510a5a Andreas Kohlbecker
 * Renders the $mergedFeatureNodes for the given $taxon.
85 3467d3b2 Andreas Kohlbecker
 * The merged nodes can be obtained by making use of the
86
 * function cdm_ws_descriptions_by_featuretree()
87
 *
88
 * @param unknown_type $featureNodes
89
 * @param unknown_type $taxon
90
 */
91
function theme_cdm_feature_nodes($mergedFeatureNodes, $taxon){
92 806baeb2 Andreas Kohlbecker
93 0364559b Andreas Kohlbecker
  RenderHints::pushToRenderStack('feature_nodes');
94
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
95 92f7d0a0 Andreas Kohlbecker
  //Creating an array to place the description elements in
96
97 afc363df Andreas Kohlbecker
  foreach($mergedFeatureNodes as $node){
98 7e510a5a Andreas Kohlbecker
99 294bea51 Andreas Kohlbecker
    if(hasFeatureNodeDescriptionElements($node)) {
100 95944919 Andreas Kohlbecker
101 0364559b Andreas Kohlbecker
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
102
      $block->module = 'cdm_dataportal';
103 95944919 Andreas Kohlbecker
      $media_list = array();
104
105 7e3ad261 Andreas Kohlbecker
      if($node->feature->uuid != UUID_IMAGE) {
106 afc363df Andreas Kohlbecker
107 0364559b Andreas Kohlbecker
        $block->delta = generalizeString($featureRepresentation);
108 54e498e3 Andreas Kohlbecker
        $block->subject = '<span class="'. html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name', $featureRepresentation) . '</span>';
109 0364559b Andreas Kohlbecker
        $block->module = "cdm_dataportal-feature";
110
        $block->content = '';
111
112 afc363df Andreas Kohlbecker
        /*
113
         * Content/DISTRIBUTION
114
         */
115 0364559b Andreas Kohlbecker
        if($node->feature->uuid == UUID_DISTRIBUTION){
116
117
          if(variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)){
118
            $distributionTextDataList = array();
119
            $distributionElementsList = array();
120
            foreach($node->descriptionElements as $descriptionElement){
121
              if($descriptionElement->class == "TextData"){
122
                $distributionTextDataList[] = $descriptionElement;
123
              } else {
124
                $distributionElementsList[] = $descriptionElement;
125
              }
126
            }
127
            if(count($distributionTextDataList) > 0){
128
              $node->descriptionElements = $distributionElementsList;
129
              $block->content .= theme('cdm_descriptionElements', $distributionTextDataList, $node->feature->uuid, $taxon->uuid);
130
            }
131
          }
132 ecc6714f f.revilla
133 0364559b Andreas Kohlbecker
          // Display cdm distribution map TODO this is a HACK to a proper generic implementation?
134
          $block->content .= theme('cdm_distribution_map', $taxon);
135 7e3ad261 Andreas Kohlbecker
          $block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid);
136 0364559b Andreas Kohlbecker
        }
137
138 afc363df Andreas Kohlbecker
        /*
139
         * Content/COMMON_NAME
140
         */
141
        else if ($node->feature->uuid == UUID_COMMON_NAME){
142 3371526f Andreas Kohlbecker
          //TODO why is theme_cdm_descriptionElement_CommonTaxonName not beeing used???
143 0364559b Andreas Kohlbecker
          $block->content .= theme('cdm_common_names', $node->descriptionElements);
144
        /*
145
        }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
146
          $block->content .= theme('cdm_image_sources', $node->descriptionElements);
147
        */
148 afc363df Andreas Kohlbecker
        }
149
150
        /*
151
         * Content/ALL OTHER FEATURES
152
         */
153
        else {
154 0364559b Andreas Kohlbecker
          $block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid);
155 afc363df Andreas Kohlbecker
156
          /*
157
           *  Content/ALL OTHER FEATURES/Subordinate Features
158
           *
159
           *  subordinate features are printed inline in one floating text,
160
           *  it is expected that supordinate features only "contain" TextData elements
161
           */
162
          // TODO move into own theme
163
          if(count($node->children) > 0){
164
165
            //TODO support more than one level of childen http://dev.e-taxonomy.eu/trac/ticket/2393
166
            $text = '';
167
            foreach ($node->children as $child){
168
169
             if (is_array($child->descriptionElements)){
170
               foreach ($child->descriptionElements as $element) {
171
172
                 if(is_array($element->media)){
173
                   // append media of supordinate emelents to list of main feature
174
                   $media_list = array_merge($media_list, $element->media);
175
                 }
176
177
                 $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
178
                //TODO use localized version of feature name, the locale must match the locale of the multilanguage text (http://dev.e-taxonomy.eu/trac/ticket/2394)
179
                 $description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
180
               }
181
               $text .= " " . $description;
182
               $description = '';
183
             }
184
185
            }
186
            $block->content .= $text;
187
          }
188
189 0364559b Andreas Kohlbecker
        }
190
191 afc363df Andreas Kohlbecker
        /*
192
         * Media/ALL FEATURES
193
         */
194
        $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
195 0364559b Andreas Kohlbecker
        $captionElements = array('title', 'rights');
196 7e510a5a Andreas Kohlbecker
197
        $gallery = theme('cdm_media_gallerie', $media_list, CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME.'_'.$node->feature->uuid,
198
              $gallery_settings['cdm_dataportal_media_maxextend'],
199
              $gallery_settings['cdm_dataportal_media_cols'],
200
              $gallery_settings['cdm_dataportal_media_maxRows'],
201
              $captionElements
202 0364559b Andreas Kohlbecker
        );
203
204 7e510a5a Andreas Kohlbecker
        $block->content .= $gallery;
205 0364559b Andreas Kohlbecker
        $block->content .= theme('cdm_footnotes', $node->feature->uuid);
206
        $block->content .= theme('cdm_annotation_footnotes', $node->feature->uuid);
207 92f7d0a0 Andreas Kohlbecker
208
209
210
        // add anchor to subject
211 294bea51 Andreas Kohlbecker
        $block->subject = '<a name="'.$block->delta.'"></a>'.  $block->subject;
212 92f7d0a0 Andreas Kohlbecker
213
214 294bea51 Andreas Kohlbecker
        $out .= theme('block', $block);
215 92f7d0a0 Andreas Kohlbecker
216 0364559b Andreas Kohlbecker
      }
217 92f7d0a0 Andreas Kohlbecker
218
219
220
221 0364559b Andreas Kohlbecker
    }
222 92f7d0a0 Andreas Kohlbecker
223 0364559b Andreas Kohlbecker
  }
224
  RenderHints::popFromRenderStack();
225
  return $out;
226 806baeb2 Andreas Kohlbecker
}
227
228 ff59ee31 Andreas Kohlbecker
function theme_FeatureTree_hierarchy($FeatureTreeUuid){
229
230 0364559b Andreas Kohlbecker
  if(!is_uuid($FeatureTreeUuid)){
231
    return;
232
  }
233 ff59ee31 Andreas Kohlbecker
  $out = '';
234 0364559b Andreas Kohlbecker
  $featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array($FeatureTreeUuid));
235
  if($featureTree && $featureTree->root){
236
    $out = '<ul class="'.$featureTree->class.'">';
237
    $out .= theme('FeatureTree_hierarchy_children', $featureTree->root);
238
    $out .= '</ul>';
239
  }
240
  return $out;
241 ff59ee31 Andreas Kohlbecker
}
242
243
function theme_FeatureTree_hierarchy_children($node){
244
245 0364559b Andreas Kohlbecker
  $out = '';
246
  if($node->children){
247 ff59ee31 Andreas Kohlbecker
248 0364559b Andreas Kohlbecker
    foreach($node->children as $childNode){
249 ff59ee31 Andreas Kohlbecker
      $out .= '<li>'.check_plain($childNode->feature->representation_L10n);
250 7e510a5a Andreas Kohlbecker
      if($childNode->children && count($childNode->children) > 0){
251 0364559b Andreas Kohlbecker
        $out .= '<ul>'.theme('FeatureTree_hierarchy_children', $childNode).'</ul>';
252 ff59ee31 Andreas Kohlbecker
      }
253
      $out .= '</li>';
254 0364559b Andreas Kohlbecker
    }
255
  }
256
  return $out;
257 ff59ee31 Andreas Kohlbecker
}
258
259 806baeb2 Andreas Kohlbecker
260
261 7e510a5a Andreas Kohlbecker
/**
262
 *
263
 * Join the texts in $elementArray and enclose with a HTML tag
264
 * @param unknown_type $elementArray
265
 * @param unknown_type $feature the feature to which the elements given in $elementArray are belonging to
266
 * @param unknown_type $glue defaults to empty string
267
 * @param unknown_type $sortArray whether to sort the $elementArray alphabetically
268
 * @param unknown_type $enclosingHtml
269
 */
270 806baeb2 Andreas Kohlbecker
function theme_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){
271 0364559b Andreas Kohlbecker
  $out = '<'.$enclosingHtml.' class="description" id="'.$feature->representation_L10n.'">';
272 806baeb2 Andreas Kohlbecker
273 0364559b Andreas Kohlbecker
  if($sortArray) sort($elementArray);
274 806baeb2 Andreas Kohlbecker
275 0364559b Andreas Kohlbecker
  $out .= join($elementArray, $glue);
276 806baeb2 Andreas Kohlbecker
277 0364559b Andreas Kohlbecker
  $out .= '</'.$enclosingHtml.'>';
278
  return $out;
279 806baeb2 Andreas Kohlbecker
}
280
281 35eafafb f.revilla
282
function theme_cdm_descriptionElement_CommonTaxonName($element){
283 3371526f Andreas Kohlbecker
  $out = '<span class="' .  html_class_atttibute_ref($element). '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name .'</span>';
284 0364559b Andreas Kohlbecker
  return $out;
285 35eafafb f.revilla
}
286 e742cf3b f.revilla
287 2264b60d Andreas Kohlbecker
288 806baeb2 Andreas Kohlbecker
/**
289 35eafafb f.revilla
 * TODO: assign a new name to the function? because it is used for the citations
290 806baeb2 Andreas Kohlbecker
 *       textdata elements and not for all text data description elements
291
 * @param $element The description element which contains the text information
292 35eafafb f.revilla
 * @param $asListElement A boolean which determines whether the citations should
293
 *                       be renderer as a list or not
294 806baeb2 Andreas Kohlbecker
 * @return unknown_type Html to be renderized in drupal
295
 */
296 0a579fac f.revilla
function theme_cdm_descriptionElementTextData($element, $asListElement, $feature_uuid = null){
297 7e3ad261 Andreas Kohlbecker
298 0364559b Andreas Kohlbecker
  $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
299
  $sourceRefs = '';
300
  $result = array();
301
  $out;
302
  $res_author;
303
  $res_date;
304 ab145ca2 a.theys
  
305 0364559b Andreas Kohlbecker
  if(is_array($element->sources)){
306
    foreach($element->sources as $source){
307
      $referenceCitation = theme('cdm_DescriptionElementSource', $source);
308 2264b60d Andreas Kohlbecker
      if($description && strlen($description) > 0 && $referenceCitation ){
309
        $sourceRefs .= ' ('.$referenceCitation.')' ;
310
      }else if ($referenceCitation){
311
        $sourceRefs = $referenceCitation;
312
      }
313 90713556 Andreas Kohlbecker
314 2264b60d Andreas Kohlbecker
      if(strlen($sourceRefs) > 0){
315
        $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
316
      }
317 90713556 Andreas Kohlbecker
318 2264b60d Andreas Kohlbecker
      if ($source->nameUsedInSource->uuid){ //do a link to name page
319
        $name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
320 dc69d2dc Andreas Kohlbecker
	        path_to_name($source->nameUsedInSource->uuid),
321
	        array(), NULL, NULL, FALSE ,TRUE);
322 2264b60d Andreas Kohlbecker
      }else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
323
        $name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
324
      }
325 90713556 Andreas Kohlbecker
326 2264b60d Andreas Kohlbecker
      if ($asListElement){
327 80b26cb9 Andreas Kohlbecker
        $out = '<li class="descriptionText DescriptionElement">' . $name_used_in_source_link_to_show;
328 2264b60d Andreas Kohlbecker
        //adding ":" if necesary
329
        if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
330
          $out .= ': ';
331
        }
332 c8b3ae89 Andreas Kohlbecker
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element, $feature_uuid) . '</li>';
333 2264b60d Andreas Kohlbecker
      }else{
334
        if ($name_used_in_source_link_to_show){
335
          $name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
336
        }
337 80b26cb9 Andreas Kohlbecker
        $out = '<span class="DescriptionElement DescriptionElement-' . $element->class .'">' . $description . $sourceRefs . $name_used_in_source_link_to_show . '</span>';
338 2264b60d Andreas Kohlbecker
      }
339 0364559b Andreas Kohlbecker
    }
340
  }
341
  //if no sources, print the description
342
  if(!isset($out)) {
343
    $out = $description;
344
  }
345 c8b3ae89 Andreas Kohlbecker
346 0364559b Andreas Kohlbecker
  return $out;
347 806baeb2 Andreas Kohlbecker
}
348
349 2264b60d Andreas Kohlbecker
350 35eafafb f.revilla
function theme_cdm_common_names($elements){
351 0364559b Andreas Kohlbecker
  $text_data_out = '';
352
  $common_name_out = '';
353
  $separator = ',';
354
  $textData_commonNames = array();
355
356
357
  if (is_array($elements)){
358
    foreach ($elements as $element){
359
      if ($element->class == 'CommonTaxonName'){
360
        //$key = '<b>' . $element->language->representation_L10n . '</b> (' . $element->area->titleCache . ')';
361
        if ($element->language->representation_L10n){
362
          $key = '<b>' . $element->language->representation_L10n . '</b>';
363
          $key .= (strlen($element->area->titleCache)>0) ? ' (' . $element->area->titleCache . ')' : '';
364
        }
365
        $common_names[$key][] = $element;
366
      }else if ($element->class == 'TextData'){
367
     //else if ($element->class == 'TextData' && $element->feature->uuid == UUID_COMMON_NAME){
368
        $textData_commonNames[] = $element;
369
      }
370
    }
371
  }
372
  //handling common names
373
374
  if (count($common_names) > 0){
375
    //sorting the a-array based on the area (key)
376
    ksort($common_names);
377
    //creating the output to be render by drupal
378
    foreach ($common_names as $key => $elements){
379
      $rendered_element_list = '';
380
      foreach($elements as $element){
381
        $sourcesFootnoteKeyList = '';
382
        // adding footnotes sources
383
        foreach($element->sources as $source){
384
          if(_is_original_source_type($source)){
385
            $_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', $source, false));
386
            $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, ($sourcesFootnoteKeyList ? $separator : ''));
387
          }
388
        }
389
        if($element->name){
390 3371526f Andreas Kohlbecker
          $rendered_element_list .= '<span class="' .  html_class_atttibute_ref($element). '">' . (strlen($rendered_element_list) > 0 ? ', ': '') . $element->name . $sourcesFootnoteKeyList . '</span>';
391 0364559b Andreas Kohlbecker
        }
392
      }
393
      if ($key){
394
       $common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $key . ': ' . $rendered_element_list;
395
      }else{
396
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $rendered_element_list;
397
      }
398
    }
399
  }
400
  //handling commons names as text data
401
  foreach($textData_commonNames as $text_data_element){
402
    $text_data_out .= theme('cdm_descriptionElementTextData', $text_data_element, true, $text_data_element->feature->uuid);
403
  }
404 2ad9878b Andreas Kohlbecker
405 0364559b Andreas Kohlbecker
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
406 e742cf3b f.revilla
    $out_array[] = $text_data_out;
407 0364559b Andreas Kohlbecker
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', $out_array, $element->feature) . '</div>';
408 2ad9878b Andreas Kohlbecker
409 0364559b Andreas Kohlbecker
  return $common_name_out . $common_name_out_text_data;
410
  //return $common_name_out . theme('cdm_descriptionElementArray', $out_array, $element->feature);
411
  //return "<div class=common_names> $common_name_out $common_name_out_text_data";
412 35eafafb f.revilla
}
413
414 806baeb2 Andreas Kohlbecker
/**
415
 * Theme a list of description elements, usually of a specific feature type
416
 * @param $descriptionElements
417
 * @return unknown_type
418
 */
419 4ed510e8 f.revilla
function theme_cdm_descriptionElements($descriptionElements, $featureUuid, $taxon_uuid){
420 0364559b Andreas Kohlbecker
421
  $outArray = array();
422
423
/*
424
  $userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
425
  if(variable_get('distribution_sort', 'NO_SORT')  != 'NO_SORT'){
426
    $glue = '';
427
    $enclosingTag = 'dl';
428
    $entryEnclosingTag = null;
429
  } else if($userDefined && $userDefined['enabled']){
430
      $glue = $userDefined['glue'];
431
      $enclosingTag = $userDefined['enclosingTag'];
432
      $entryEnclosingTag = $userDefined['entryEnclosingTag'];
433
  } else {
434
    // TODO remove once LAYOUT_SETTING_PREFIX-{uuid} seeting are confired to work for all portals (selenium test still missing!!!)
435
    $glue = '';
436
    $enclosingTag = 'ul';
437
    $entryEnclosingTag = null ;
438
  }
439
*/
440
441 f609dfdb Andreas Kohlbecker
	if(variable_get('distribution_sort', 'NO_SORT')  != 'NO_SORT'){
442 16718c52 Andreas Kohlbecker
		$glue = '';
443 bd9dd43a Andreas Kohlbecker
		$enclosingTag = 'dl';
444 16718c52 Andreas Kohlbecker
	} else {
445
		$glue = '';
446 bd9dd43a Andreas Kohlbecker
		$enclosingTag = 'ul';
447 16718c52 Andreas Kohlbecker
	}
448 adb8c38b Andreas Kohlbecker
449 0364559b Andreas Kohlbecker
  $sortOutArray = false;
450
  $distributionElements = array();
451
452
  RenderHints::pushToRenderStack('cdm_descriptionElements');
453
454
  if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
455
    foreach($descriptionElements as $descriptionElement) {
456
457
      // --- DISTRIBUTION ---- //
458
      if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){
459
        if($descriptionElement->class == 'Distribution'){
460
          $sortKey = $descriptionElement->area->representation_L10n;
461
          $distributionElements[$sortKey]= $descriptionElement;
462
        } else if($descriptionElement->class == 'TextData'){
463
          $asListElement = false;
464
          $repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
465
466
          if( !array_search($repr, $outArray)){
467 3467d3b2 Andreas Kohlbecker
          	$outArray[] = $repr;
468 0364559b Andreas Kohlbecker
            //TODO HINT: sorting in theme_cdm_descriptionElementArray will not work since this array contains html attributes with uuids !!!!
469
            $sortOutArray = true;
470
            $glue = '<br/> ';
471
            $enclosingTag = 'p';
472
          }
473
        }
474
      }
475
476
       // --- IMAGE_SOURCES --- //
477
      else if($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES){
478
        $image_sources[] = $descriptionElement;
479
      }
480 d1c92afc a.theys
      // --- USE TEXTDATA --- //
481
      else if($descriptionElement->feature->uuid == UUID_USE){
482
      	//Do nothing to avoid rendering	
483
      }
484 0364559b Andreas Kohlbecker
485
      // ---- class == TextData ---- //
486
      else if($descriptionElement->class == 'TextData'){
487
        $asListElement = true;
488
        $outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
489
      }else if ($descriptionElement->class == 'CommonTaxonName') {
490
        $outArray[] = theme('cdm_descriptionElement_CommonTaxonName', $descriptionElement);
491 92f7d0a0 Andreas Kohlbecker
      }else if ($descriptionElement->class == 'Uses') {
492
          $outArray[] = theme('cdm_descriptionElement_Uses', $descriptionElement);
493
        }else {
494 0364559b Andreas Kohlbecker
        $outArray[] = '<li>No method for rendering unknown description class: '.$descriptionElement->classType.'</li>';
495
      }
496 94bb9048 f.revilla
    }
497 0364559b Andreas Kohlbecker
  }
498
499
  //if feature = NAME USAGE sort the list of sources
500
  //this is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE
501
  if($descriptionElement->feature->uuid == UUID_NAME_USAGE){
502
    sort($outArray);
503
  }
504 7e3ad261 Andreas Kohlbecker
505
506 0364559b Andreas Kohlbecker
  if($image_sources){
507
      $outArray[] = theme('cdm_description_element_image_source', $image_sources, true);
508 35eafafb f.revilla
509 0364559b Andreas Kohlbecker
  }
510 7fc77599 f.revilla
511 0364559b Andreas Kohlbecker
  if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
512
    $outArray[] = theme('cdm_description_ordered_distributions', $taxon_uuid, $distributionElements);
513
  }else{
514
    ksort($distributionElements);
515
    $outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements); // TODO , $entryEnclosingTag);
516
  }
517
518
  // take the feature of the last $descriptionElement
519
  $feature = $descriptionElement->feature;
520
  $out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingTag);
521
522
  RenderHints::popFromRenderStack();
523
  return $out;
524 806baeb2 Andreas Kohlbecker
}
525
526 ecdc2421 Andreas Kohlbecker
527
528 0364559b Andreas Kohlbecker
/**
529
 *
530
 * Enter description here ...
531
 * @param unknown_type $a
532
 * @param unknown_type $b
533
 */
534 94bb9048 f.revilla
function compare_image_sources($a, $b){
535
    if($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text){
536 0364559b Andreas Kohlbecker
      return 0;
537 94bb9048 f.revilla
    }
538
    return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
539
}
540
541
/**
542 adb8c38b Andreas Kohlbecker
 *
543 94bb9048 f.revilla
 */
544
function theme_cdm_description_element_image_source($image_sources, $asListElement) {
545
    $out = '';
546
    $separator = ',';
547
    RenderHints::pushToRenderStack('descriptionElementImageSource');
548
    RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
549 adb8c38b Andreas Kohlbecker
550 94bb9048 f.revilla
    //sorting the image sources
551
    usort($image_sources, "compare_image_sources");
552
    //generate the footnotes
553
    foreach($image_sources as $image_source){
554
        $footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
555
        foreach($image_source->sources as $source){
556
            if(_is_original_source_type($source)){
557
                $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
558
                cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
559
            }
560 adb8c38b Andreas Kohlbecker
        }
561 94bb9048 f.revilla
        //sort and render footnote keys
562
        $footnoteKeyListStr = '';
563
        asort($footNoteKeys);
564
        foreach($footNoteKeys as $footNoteKey){
565
            $footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
566
        }
567
        //return value!
568 a92c0aa5 f.revilla
        $out .= '<span class="descriptionElement descriptionElement-'.$image_source->uuid.'">'.$image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
569
570 94bb9048 f.revilla
    }
571 adb8c38b Andreas Kohlbecker
572 94bb9048 f.revilla
    RenderHints::popFromRenderStack();
573
    return $out;
574
}
575
576 806baeb2 Andreas Kohlbecker
/**
577 35eafafb f.revilla
 *
578 806baeb2 Andreas Kohlbecker
 * @param unknown_type $descriptionElements
579 0364559b Andreas Kohlbecker
 * @param String $enclosingTag
580 806baeb2 Andreas Kohlbecker
 */
581 0364559b Andreas Kohlbecker
function theme_cdm_descriptionElementDistribution($descriptionElements, $enclosingTag = "span"){
582 35eafafb f.revilla
583 cc84321f Andreas Kohlbecker
584
	if(!$enclosingTag){
585
		$enclosingTag = "span";
586
	}
587
588 0364559b Andreas Kohlbecker
  $out = '';
589
  $separator = ',';
590
  RenderHints::pushToRenderStack('descriptionElementDistribution');
591
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
592
593
  foreach($descriptionElements as $descriptionElement){
594
595
    // annotations as footnotes
596
    $footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
597
    // source references as footnotes
598
    foreach($descriptionElement->sources as $source){
599
      if(_is_original_source_type($source)){
600
        $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
601
        cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
602
      }
603
    }
604
    // sort and render footnote keys
605
    $footnoteKeyListStr = '';
606
    asort($footNoteKeys);
607
    foreach($footNoteKeys as $footNoteKey){
608
      $footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
609
    }
610 35eafafb f.revilla
611 0364559b Andreas Kohlbecker
    $out .= '<'. $enclosingTag .' class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'
612
      . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </'. $enclosingTag .'>';
613
  }
614
615
  RenderHints::popFromRenderStack();
616
  return $out;
617 806baeb2 Andreas Kohlbecker
}
618 0364559b Andreas Kohlbecker
619 dd268826 f.revilla
/**
620
 * Function target is to compare two different foootnotes objects.
621 adb8c38b Andreas Kohlbecker
 * The comparation is based on the footnote key. The one which is
622 dd268826 f.revilla
 * displayed as footnote number.
623 adb8c38b Andreas Kohlbecker
 *
624 dd268826 f.revilla
 * @param footnote object $a
625
 * @param footnote object $b
626
 */
627
function footnotes_key_compare($a, $b){
628 0364559b Andreas Kohlbecker
  $res = 0;
629
  if ($a->keyStr < $b->keyStr){
630
    $res = -1;
631
  }elseif ($a->keyStr > $b->keyStr){
632
    $res = 1;
633
  }
634
  return $res;
635 dd268826 f.revilla
}
636 39efe1be f.revilla
637 636be34b f.revilla
function theme_cdm_description_ordered_distributions($taxon_uuid, $descriptionElements){
638 0364559b Andreas Kohlbecker
  //returning null if no description elements
639
  if ($descriptionElements == null){
640
    return '';
641
  }
642
  //initialization some variables
643
  $out = '';
644
  $separator = ',';
645
  RenderHints::pushToRenderStack('descriptionElementDistribution');
646
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
647
  //getting all the taxon description for a given taxon
648 ab145ca2 a.theys
  $markerTypesEmpty = array();
649 fa79eacf a.theys
  //$markerTypesEmpty['markerTypes'] = 'af9860ff-08f5-4b4d-863c-49ae96985115';
650
  $markerTypesEmpty['markerTypes'] = '';
651
  $taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid, queryString($markerTypesEmpty));
652 0364559b Andreas Kohlbecker
  foreach ($taxonDescriptions as $description){
653
    $descriptions_uuids[] = $description->uuid;
654
  }
655
  //getting the sortered distributions (omiting level ??)
656
  $request_params = array();
657
  $request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
658
  $ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',',$descriptions_uuids), queryString($request_params));
659
  $ordered_areas = $ordered_areas->rootElement->children;
660
661
  //printing the distributions
662
  foreach ($ordered_areas as $element_level1){
663
    //level1
664
    if ($element_level1->data){
665
      $out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
666
    }
667
    $out .= '<dd>';
668
669
    //level3
670
    foreach ($element_level1->children as $element_level3){
671
      if ($element_level3->data){
672
        $text_l3 = $element_level3->data->area->representation_L10n;
673
      }
674
      $fnKeysLevel3Str = '';
675
      $fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
676
      foreach($element_level3->data->sources as $source){
677
        if(_is_original_source_type($source)){
678
          $fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
679
          cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
680
        }
681
      }
682
      //level4
683
      $l4_regions = array();
684
      foreach ($element_level3->children as $element_level4){
685
        if ($element_level4->data){
686
          $text_l4 = $element_level4->data->area->representation_L10n;
687
          $l4_regions[$element_level3->data->area->representation_L10n] = '';
688
          $fnKeysLevel4Str = '';
689
          $fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
690
          foreach($element_level4->data->sources as $source){
691
            if(_is_original_source_type($source)){
692
              $fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
693
              cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
694
            }
695
          }
696
          usort($fnKeysLevel4, "footnotes_key_compare");
697
          $l4_regions[$text_l4] = $fnKeysLevel4;
698
        }
699
      }//level4
700
      //managing level3 and level4 for generating the right output
701
      usort($fnKeysLevel3, "footnotes_key_compare");
702
      foreach ($fnKeysLevel3 as $key3){
703
        foreach ($l4_regions as $key4 => $value4){
704
          cdm_add_footnote_to_array($l4_regions[$key4], $key3);
705
        }
706
      }
707
      if ($element_level3->numberOfChildren == 1 &&
708
       $text_l3 == $element_level3->children[0]->data->area->representation_L10n){
709
        //var_dump($element_level3->children[0]->data->area->representation_L10n);
710
        $fnStr = '';
711
        $region = array_pop($l4_regions);
712
        foreach($region as $key){
713
          $fnStr .= theme('cdm_footnote_key', $key, ($fnStr ? $separator : ''));
714
        }
715
        $out .= "$text_l3 $fnStr; ";
716
              //removing whitespaces when &fnStr is empty
717
        if(substr($out, -3) == ' ; '){
718
          $out = substr($out, 0, -3) . '; ';
719
        }
720
      }else{
721
        $fnKeysLevel3Str = '';
722
        foreach($fnKeysLevel3 as $key){
723
          $fnKeysLevel3Str .= theme('cdm_footnote_key', $key, ($fnKeysLevel3Str ? $separator : ''));
724
        }
725
        $text_l4_aux = '';
726
        foreach ($l4_regions as $key => $value){
727
          $fnKeysLevel4Str = '';
728
          if (is_array($l4_regions[$key])) {
729
            foreach ($l4_regions[$key] as $fnkey){//warning why?
730
              $fnKeysLevel4Str .= theme('cdm_footnote_key', $fnkey, ($fnKeysLevel4Str ? $separator : ''));
731
            }
732
          }
733
          //if ($key != $text_l3 || sizeof($l4_regions > 1)){
734
          if ($key != $text_l3){
735
            $text_l4_aux .= "$key $fnKeysLevel4Str, ";
736
          }
737
        }
738
        $text_l4_aux = substr($text_l4_aux, 0, -2);
739
740
        if (strlen($text_l4_aux) > 0){
741
          $out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
742
        }else{
743
          $out .= "$text_l3 $fnKeysLevel3Str; ";
744
        }
745
746
      }
747
    }//level3
748
    $out = substr($out, 0, -2);
749
    $out .= '.</dd>';
750
  }//level1
751
752
  RenderHints::popFromRenderStack();
753
  return $out;
754 39efe1be f.revilla
}
755
756 806baeb2 Andreas Kohlbecker
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
757 e70c228f f.revilla
758 0364559b Andreas Kohlbecker
  if(isset($descriptionElementSource->citation)){
759 ecdc2421 Andreas Kohlbecker
  	$out = theme('cdm_reference', $descriptionElementSource->citation, $descriptionElementSource->citationMicroReference, $doLink);
760 0364559b Andreas Kohlbecker
  }
761
  return $out;
762 806baeb2 Andreas Kohlbecker
}
763 16718c52 Andreas Kohlbecker
764 2264b60d Andreas Kohlbecker
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
765
766
  if(isset($source->citation)){
767
    $out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink);
768
  }
769
  return $out;
770
}
771
772
773
774
775 16718c52 Andreas Kohlbecker
776 e63edd95 f.revilla
/*
777
 function theme_cdm_descriptionElementDistribution($descriptionElements){
778
779
 $out = '';
780
 $separator = ',';
781
 RenderHints::pushToRenderStack('descriptionElementDistribution');
782
 RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
783
 foreach($descriptionElements as $descriptionElement){
784
 // annotations as footnotes
785
 $annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
786
 // source references as footnotes
787
 $sourcesFootnoteKeyList = '';
788
 foreach($descriptionElement->sources as $source){
789
 if(_is_original_source_type($source)){
790
 $_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_DescriptionElementSource', $source, false));
791
 $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : ''));
792
 }
793
 }
794
 if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
795
 $annotationFootnoteKeys .= $separator;
796
 }
797
 $out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList . ' ';
798
 }
799
800
 $out = substr($out, 0, strlen($out)-strlen($separator) );
801
802
 RenderHints::popFromRenderStack();
803
 return $out;
804
805
 }
806
 */
807
808 806baeb2 Andreas Kohlbecker
809
/**
810
 * TODO
811
 * Quick-and-dirty solution to show distribution service to exemplar groups
812
 *
813
 * @param unknown_type $featureTo
814
 * @return unknown
815
 */
816 a973da5b Andreas Kohlbecker
function theme_cdm_distribution_map($taxon){
817 806baeb2 Andreas Kohlbecker
818 0364559b Andreas Kohlbecker
  $server = getEDITMapServiceURI();
819
820
  if(!$server){
821
    //warning message
822
    drupal_set_message('No \'Geoservice Access Point\' has been set so far. '
823
    . 'Please configure the variable \'Geoservice Access Point\' here '
824
    . l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/geo'), 'warning');
825
    //message to render
826
    return "<p>No geoservice specified</p>";
827 fd04f921 Andreas Kohlbecker
  }
828
829
830
  $fontStyles = array(0 => "plane", 1 => "italic");
831
832
  // query cdm server for map service uri parameters
833
  $map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
834
  $out .= "<!-- map_data_parameters:". print_r($map_data_parameters, true) . " -->";
835
  $query_string = $map_data_parameters->String;
836
  if(!$query_string){
837
    // the $query_string is empty if there are no distribution areas defined
838
    return ;
839
  }
840 0364559b Andreas Kohlbecker
841 fd04f921 Andreas Kohlbecker
  // some cleaning of the URI paramters, TODO is this still needed?
842
  $query_string = str_replace('%3A', ":", $query_string);
843 0364559b Andreas Kohlbecker
844
845 fd04f921 Andreas Kohlbecker
  /* ------ choose the display mode, either openlayers or static image ------ */
846 0364559b Andreas Kohlbecker
847 fd04f921 Andreas Kohlbecker
  if(variable_get('cdm_dataportal_map_openlayers', 1)){
848 0364559b Andreas Kohlbecker
849 fd04f921 Andreas Kohlbecker
    /* =========== display distributions using the openlayers map viewer =========== */
850 0364559b Andreas Kohlbecker
851 fd04f921 Andreas Kohlbecker
    $legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
852
    $legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
853
    $legend_url_font_style = $fontStyles[$legend_url_font_style];
854
    $legend_url_icon_width  = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
855
    $legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
856 0364559b Andreas Kohlbecker
857 fd04f921 Andreas Kohlbecker
    $legendFormatQueryStr  = "format=image".urlencode('/')."png&TRANSPARENT=TRUE";
858
    $legendFormatQueryStr .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
859
    //TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
860
    $legendFormatQueryStr .="layer=topp".urlencode(':')."tdwg_level_4&LEGEND_OPTIONS=forceLabels".urlencode(':')."on;fontStyle".urlencode(':').$legend_url_font_style.";fontSize".urlencode(':').$legend_url_font_size."&SLD=".urlencode($sldLegend);
861 0364559b Andreas Kohlbecker
862 fd04f921 Andreas Kohlbecker
    $out .= get_openlayers_map(
863
      variable_get('cdm_dataportal_geoservice_display_width', 300),
864
      variable_get('cdm_dataportal_geoservice_bounding_box', false),
865
      null,
866
      $query_string,
867
      $legendFormatQueryStr,
868
      variable_get('cdm_dataportal_geoservice_map_caption', '')
869
    );
870 0364559b Andreas Kohlbecker
871 fd04f921 Andreas Kohlbecker
  } else {
872 0364559b Andreas Kohlbecker
873 fd04f921 Andreas Kohlbecker
    return get_image_map(
874
        variable_get('cdm_dataportal_geoservice_display_width', 300),
875
        variable_get('cdm_dataportal_geoservice_bounding_box', false),
876 0364559b Andreas Kohlbecker
        null,
877
        $query_string,
878
        $legendFormatQueryStr,
879
        variable_get('cdm_dataportal_geoservice_map_caption', '')
880
      );
881
882
883 fd04f921 Andreas Kohlbecker
    // simple image
884
    $mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
885 0364559b Andreas Kohlbecker
886
887 fd04f921 Andreas Kohlbecker
    $query_string .= '&img=true';
888
    $query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
889 0364559b Andreas Kohlbecker
890 fd04f921 Andreas Kohlbecker
    $map_service_script_name = "areas.php";
891 0364559b Andreas Kohlbecker
892 fd04f921 Andreas Kohlbecker
    // apply Plain Image map settings
893
    if (getEDITMapServiceVersionNumber() >= 1.1){
894
      /*
895
       * example : title=a:Naturalized++non-invasive
896
       * &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
897
       * &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
898
       * &mc_s=Georgia,15,blue&mc=&recalculate=false
899
       *
900
       * http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
901
       * l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
902
       * &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
903
       * &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
904
       * &mlp=3&ms=500&recalculate=false&title=a%3Aindigenous
905
       */
906 0364559b Andreas Kohlbecker
907 fd04f921 Andreas Kohlbecker
      $map_service_script_name = "rest_gen.php";
908 0364559b Andreas Kohlbecker
909 fd04f921 Andreas Kohlbecker
      $bgcolor_areaStyleId= "y";
910
      $baselayer_areaStyleId= "z";
911
      $bgcolor_layer='';
912
      $additional_area_styles = array();
913 0364559b Andreas Kohlbecker
914 fd04f921 Andreas Kohlbecker
      // background color:
915
      if(variable_get('map_bg_color', '')){
916
        $bgcolor_layer = "background_gis:".$bgcolor_areaStyleId;
917
        $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
918
      }
919 b22c2561 Andreas Kohlbecker
920 fd04f921 Andreas Kohlbecker
      //TODO HACK to replace the default base layer which currently is tdwg4 !!!
921
      if(strpos($query_string, "?l=") !== FALSE){
922
        $layer_param_token = "?l=";
923
      } else {
924
        $layer_param_token = "&l=";
925
      }
926
      if(strpos($query_string, "?as=") !== FALSE){
927
        $areystyle_param_token = "?as=";
928
      } else {
929
        $areystyle_param_token = "&as=";
930
      }
931 0364559b Andreas Kohlbecker
932 fd04f921 Andreas Kohlbecker
      if(variable_get('map_base_layer', '')){
933
        $query_string = str_replace($layer_param_token."tdwg4", "$layer_param_token".variable_get('map_base_layer', ''). ":" . $baselayer_areaStyleId, $query_string);
934
      } else {
935
        $query_string = str_replace($layer_param_token."tdwg4", $layer_param_token."tdwg4:".$baselayer_areaStyleId . ",", $query_string);
936
      }
937 0364559b Andreas Kohlbecker
938 fd04f921 Andreas Kohlbecker
      if($bgcolor_layer){
939
        $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
940
      }
941 0364559b Andreas Kohlbecker
942 fd04f921 Andreas Kohlbecker
      if(variable_get('map_base_layer_style', '')){
943
        $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
944
      }
945 0364559b Andreas Kohlbecker
946 fd04f921 Andreas Kohlbecker
      foreach ($additional_area_styles as $as) {
947
        $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
948 0364559b Andreas Kohlbecker
      }
949
950
    }
951 fd04f921 Andreas Kohlbecker
952
    $mapUri = url("$server/$map_service_script_name?$query_string");
953
    $out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
954 0364559b Andreas Kohlbecker
  }
955 fd04f921 Andreas Kohlbecker
  return $out;
956
957 806baeb2 Andreas Kohlbecker
}
958 2d284a25 Andreas Kohlbecker
959
/**
960
 * Returns a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
961
 * @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
962
 *          valid values are : PolytomousKey, MediaKey, MultiAccessKey
963
 * @param $taxonUuid if given this parameter restrict the listed keys to
964
 *          those which have the taxon identified be this uuid in scope.
965
 */
966
function _list_IdentificationKeys($type, $taxonUuid = null, $pageSize = null, $pageNumber = null){
967
968
  if(!$type){
969
    drupal_set_message("Type parameter is missing", "error");
970
    return;
971
  }
972
  $cdm_ws_pasepath = null;
973
  switch($type){
974
    case "PolytomousKey" : $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY; break;
975
    case "MediaKey" : $cdm_ws_pasepath = CDM_WS_MEDIAKEY; break;
976
    case "MultiAccessKey" : $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY; break;
977
  }
978
979
  if(!$cdm_ws_pasepath){
980
    drupal_set_message("Type parameter is not valid: ".$type, "error");
981
  }
982
983
  $queryParameters  = '';
984
  if(is_numeric($pageSize)){
985 0364559b Andreas Kohlbecker
    $queryParameters  = "pageSize=".$pageSize;
986 2d284a25 Andreas Kohlbecker
  } else {
987 0364559b Andreas Kohlbecker
    $queryParameters  = "pageSize=0";
988 2d284a25 Andreas Kohlbecker
  }
989
990
  if(is_numeric($pageNumber)){
991
    $queryParameters  = "pageNumber=".$pageNumber;
992
  } else {
993
    $queryParameters  = "pageNumber=0";
994
  }
995
  $queryParameters  = null;
996
  if($taxonUuid){
997
    $queryParameters = "findByTaxonomicScope=$taxonUuid";
998
  }
999
  $pager = cdm_ws_get($cdm_ws_pasepath, null, $queryParameters);
1000
1001
  if(!$pager || $pager->count == 0){
1002
      return array();
1003
  }
1004
  return $pager->records;
1005
}
1006
1007 cafc7c3b Andreas Kohlbecker
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
1008 2264b60d Andreas Kohlbecker
1009 0364559b Andreas Kohlbecker
   $parentRenderPath = RenderHints::getRenderPath();
1010
   RenderHints::pushToRenderStack("IdentificationKey");
1011
1012
   if($showIdentificationKeyTitle){
1013
     if($doLinkToKeyPage) {
1014
       $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
1015
     } else {
1016
       $out = $identificationKey->titleCache;
1017
     }
1018
   }
1019
   if(is_array($identificationKey->sources)){
1020
     // display sources
1021
     $i = 0;
1022
     $out .= '<div>';
1023
     foreach($identificationKey->sources as $source){
1024 cafc7c3b Andreas Kohlbecker
      $out .= ($i++ > 0 ? ', ' : '' ) . theme("cdm_IdentifieableSource", $source);
1025 0364559b Andreas Kohlbecker
     }
1026
     $out .= '</div>';
1027
   }
1028
     // display annotations
1029 cafc7c3b Andreas Kohlbecker
   $out .= theme('cdm_annotations', cdm_ws_getAnnotationsFor($identificationKey), 'div');
1030 0364559b Andreas Kohlbecker
   RenderHints::popFromRenderStack();
1031
   return $out;
1032 2264b60d Andreas Kohlbecker
}
1033
1034
function theme_cdm_polytomousKey(&$polytomousKey){
1035
1036 0364559b Andreas Kohlbecker
  $keyStyle = "linkedStyle"; // TODO settings needed
1037 2264b60d Andreas Kohlbecker
1038 0364559b Andreas Kohlbecker
  RenderHints::pushToRenderStack("polytomousKey");
1039 2264b60d Andreas Kohlbecker
  // key nodes in linked style
1040
  $out = '<table class="polytomousKey polytomousKey_'.$keyStyle.'">';
1041
  $out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root);
1042
  $out .= '</table>';
1043
  RenderHints::popFromRenderStack();
1044
  return $out;
1045
}
1046
1047
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
1048
1049
  static $statementCountCharacter = '\'';
1050
1051
  $out = "";
1052
1053
  if(is_array($polytomousKeyNode->children)){
1054
1055 c1974583 Andreas Kohlbecker
    $childIndex = 0;
1056 2264b60d Andreas Kohlbecker
1057
    // render edges of the current node
1058
    foreach($polytomousKeyNode->children as &$child){
1059 96634aa3 Andreas Kohlbecker
1060 0364559b Andreas Kohlbecker
      if(!isset($child->statement)){
1061
        // skip node with empty statements (see below for explanation: "Special case")
1062
        continue;
1063
      }
1064 96634aa3 Andreas Kohlbecker
1065
      /*
1066
       * Special case:
1067
       * Child nodes with empty statements but taxa as leaf are to
1068
       * treated as if all those taxa where direct children of the source node.
1069
       */
1070
      $islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
1071
      $islinkToTaxon = isset($child->taxon->uuid);
1072
      $islinkToSubKey = isset($child->subkey->uuid);
1073
      $islinkToOtherNode = isset($child->otherNode);
1074
      $islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode; // either null or 0
1075 c1974583 Andreas Kohlbecker
      $hasQuestion = isset($polytomousKeyNode->question->label_l10n);
1076 76108c5a Andreas Kohlbecker
      $hasFeature = isset($polytomousKeyNode->feature);
1077 c1974583 Andreas Kohlbecker
1078
      //$indentEdge = $hasQuestion && $childIndex > 0;
1079
1080 76108c5a Andreas Kohlbecker
      // Question
1081 c1974583 Andreas Kohlbecker
      if($hasQuestion && $childIndex == 0){
1082
          // place question, as extra table row
1083
          $out .= '<tr class="question new_section">';
1084
          $out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
1085
          $out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
1086
          $out .= '</tr>';
1087
      }
1088 96634aa3 Andreas Kohlbecker
1089 c1974583 Andreas Kohlbecker
      $out .= '<tr class="childCount_' . $childIndex . (!$hasQuestion && $childIndex == 0 ? ' new_section':''). '">';
1090
1091
      if($hasQuestion){
1092
        $out .= '<td class="nodeNumber"></td>';
1093
      } else {
1094
        $out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex , $statementCountCharacter)) . "</td>";
1095 2264b60d Andreas Kohlbecker
      }
1096 c1974583 Andreas Kohlbecker
1097
      $out .= '<td ' . RenderHints::getHtmlElementID($child) . '  class="edge'.($hasQuestion? ' edge-indent': '').'">';
1098
1099 76108c5a Andreas Kohlbecker
      // Feature
1100
      if($hasFeature){
1101 3d526ffb Andreas Kohlbecker
        $out .= $polytomousKeyNode->feature->representation_L10n . ": ";
1102 76108c5a Andreas Kohlbecker
      }
1103 c1974583 Andreas Kohlbecker
1104 76108c5a Andreas Kohlbecker
      // Statement
1105 c1974583 Andreas Kohlbecker
      $out .=  $child->statement->label_l10n;
1106 2264b60d Andreas Kohlbecker
1107 96634aa3 Andreas Kohlbecker
      // --- links to nodes taxa and subkeys
1108
      $out .= '<div class="nodeLink">';
1109
1110
     // link to a PolytomousKeyNode
1111
      if($islinkToNode){
1112 8a571837 Andreas Kohlbecker
        $out .= '<div class="nodeLinkToNode">';
1113
        if(is_object($child->modifyingText)){
1114
            $out .= theme('cdm_poytomousKeyNode_modifyingText', $child->modifyingText);
1115
        }
1116
        $out .= l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</div>';
1117 96634aa3 Andreas Kohlbecker
      }
1118
1119
      // link to a PolytomousKeyNode
1120
      if($islinkToOtherNode){
1121 8a571837 Andreas Kohlbecker
        $out .= '<div class="nodeLinkToOtherNode">';
1122
        if(is_object($child->modifyingText)){
1123
            $out .= theme('cdm_poytomousKeyNode_modifyingText', $child->modifyingText);
1124
        }
1125
        $out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], null, null, $child->otherNode->uuid) . '</div>';
1126 96634aa3 Andreas Kohlbecker
      }
1127
1128
      // link to one or many taxa
1129
      if($islinkToTaxon || $islinkToManyTaxa){
1130
1131 0364559b Andreas Kohlbecker
        if($islinkToManyTaxa){
1132 96634aa3 Andreas Kohlbecker
          $taxonChildren = $child->children;
1133 0364559b Andreas Kohlbecker
        } else {
1134 96634aa3 Andreas Kohlbecker
          $taxonChildren = array($child);
1135 0364559b Andreas Kohlbecker
        }
1136 96634aa3 Andreas Kohlbecker
1137 0364559b Andreas Kohlbecker
        foreach($taxonChildren as $taxonChild){
1138
          // TODO many taxa $child->children->taxon
1139
          $out .= '<div class="nodeLinkToTaxon">';
1140
          if(is_object($taxonChild->modifyingText)){
1141 8a571837 Andreas Kohlbecker
            $out .= theme('cdm_poytomousKeyNode_modifyingText', $taxonChild->modifyingText);
1142 0364559b Andreas Kohlbecker
          }
1143 89b7d4bd Andreas Kohlbecker
          $out .=  theme("cdm_taxonName", $taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
1144 0364559b Andreas Kohlbecker
          $out .=  '</div>';
1145
        }
1146 96634aa3 Andreas Kohlbecker
1147
        // link to a subkey
1148 0364559b Andreas Kohlbecker
        if($islinkToSubKey){
1149
          $out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', $child->subkey) . '</div>';
1150
        }
1151 96634aa3 Andreas Kohlbecker
1152 2264b60d Andreas Kohlbecker
      }
1153
1154 0364559b Andreas Kohlbecker
      $out .= '</div>'; // end node link
1155 96634aa3 Andreas Kohlbecker
      $out .= '</td>'; // end edge
1156 2264b60d Andreas Kohlbecker
      $out .= '</tr>';
1157
1158 c1974583 Andreas Kohlbecker
      $childIndex++;
1159 2264b60d Andreas Kohlbecker
    }
1160
1161
    // recurse into child nodes
1162
    foreach($polytomousKeyNode->children as &$child){
1163
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
1164
    }
1165
1166
  }
1167 c1974583 Andreas Kohlbecker
1168 2264b60d Andreas Kohlbecker
  return $out;
1169
}
1170
1171 8a571837 Andreas Kohlbecker
function theme_cdm_poytomousKeyNode_modifyingText($modifyingText){
1172
  if(is_object($modifyingText)){
1173
    $i = 0;
1174
    foreach(get_object_vars($modifyingText) as $language=>$languageString){
1175
      $out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">'. $languageString->text . '</span> ';
1176
    }
1177
  }
1178
  return $out;
1179
}
1180
1181 2d284a25 Andreas Kohlbecker
/**
1182
 * Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
1183
 * @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
1184
 *          valid values are : PolytomousKey, MediaKey, MultiAccessKey
1185
 * @param $taxonUuid if given this parameter restrict the listed keys to
1186
 *          those which have the taxon identified be this uuid in scope.
1187
 */
1188
function theme_cdm_list_IdentificationKeys($type, $taxonUuid = null, $pageSize, $pageNumber){
1189
1190
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
1191
  if(!$keyList || count ($keyList) == 0){
1192 0364559b Andreas Kohlbecker
    return;
1193 2d284a25 Andreas Kohlbecker
  }
1194
1195
  RenderHints::pushToRenderStack('list_IdentificationKeys');
1196
  $out = '<ul>';
1197
  foreach ($keyList as $key){
1198 2264b60d Andreas Kohlbecker
    $out .= '<li>';
1199
    $out .= theme('cdm_IdentificationKey', $key);
1200
    $out .= '</li>';
1201 2d284a25 Andreas Kohlbecker
  }
1202
  $out .= '</ul>';
1203 2264b60d Andreas Kohlbecker
  $out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
1204 2d284a25 Andreas Kohlbecker
  RenderHints::popFromRenderStack();
1205
1206
  return $out;
1207
}
1208
1209
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
1210
1211 0364559b Andreas Kohlbecker
  static $types = array("PolytomousKey"=>"Polytomous", "MediaKey"=>"Media", "MultiAccessKey"=>"Multiaccess");
1212 2d284a25 Andreas Kohlbecker
  RenderHints::pushToRenderStack('block_IdentificationKeys');
1213 0364559b Andreas Kohlbecker
  $out = '';
1214
  foreach($types as $type=>$label){
1215
    $keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid, $pageSize, $pageNumber);
1216
    if(!$keylist){
1217
      continue;
1218
    }
1219
    $out .= '<div class="'.$type.'">';
1220
    $out .= '<h3>'.t($label)."</h3>";
1221
    $out .= $keylist;
1222
    $out .= '</div>';
1223
  }
1224 2d284a25 Andreas Kohlbecker
  RenderHints::popFromRenderStack();
1225 0364559b Andreas Kohlbecker
  return $out;
1226
}
1227 97cd2e7f a.theys
1228 f79ad3b5 a.theys
1229 bc8a4f7c a.theys
//this theming function formats the use description and use record list for these descriptions 
1230 7ea461ec a.theys
function theme_cdm_UseDescription($descriptions = null, $taxonUuid = null, $pageSize, $pageNumber) {
1231 97cd2e7f a.theys
	$out = '<div id="content"><ul id="Description" class ="description">';
1232
	if ($descriptions == null) {
1233
		return;
1234
	}
1235 ab145ca2 a.theys
	$descriptionSynonyms;
1236
	$descriptionOut = "";
1237
	$synonymOut = "";
1238 7ea461ec a.theys
	$currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
1239 97cd2e7f a.theys
	foreach($descriptions as $description) {
1240 d1c92afc a.theys
		$useSummary = "";
1241 f79ad3b5 a.theys
		$serializedSynonyms = serialize($synonyms);
1242
		foreach ($description->elements as $element) {
1243
			
1244 d1c92afc a.theys
			if($element->feature->uuid == UUID_USE && !(strlen($useSummary)> 0)){
1245 f79ad3b5 a.theys
				$useSummary = $element->multilanguageText_L10n->text;
1246
			}
1247
		}
1248 b8f451b5 a.theys
		foreach ($description->sources as $source) {
1249 ab145ca2 a.theys
			$isSynonym = false;
1250 7ea461ec a.theys
			$originalTaxonUsedInSource = null;
1251 2507347f a.theys
			$originalTaxonPager = null;
1252 b8f451b5 a.theys
			if($source->originalNameString) {
1253 2507347f a.theys
				$request_params = array();
1254
				$request_params['query'] = $source->originalNameString;
1255
				$request_params['matchMode'] = "EXACT";
1256
				$originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME,  null, queryString($request_params));
1257
				if ($originalTaxonPager->count >0) {
1258
					$originalTaxonUsedInSource = $originalTaxonPager->records[0]; 
1259
					
1260
				} else {
1261 fbfbff5e a.theys
					$originalTaxonUsedInSource = $currentTaxon->name;
1262
				}
1263 2507347f a.theys
				
1264 7ea461ec a.theys
				if($currentTaxon->name->uuid != $originalTaxonUsedInSource->uuid){
1265 f79ad3b5 a.theys
					$isSynonym = true;
1266 ab145ca2 a.theys
				}
1267 f79ad3b5 a.theys
				
1268 ab145ca2 a.theys
				if (!$isSynonym) {
1269
					$descriptionOut .='<li class="descriptionText DescriptionElement">';
1270
					$name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid),array(), NULL, NULL, FALSE ,TRUE);
1271
					$descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
1272 f79ad3b5 a.theys
					$descriptionOut .= $useSummary;
1273 ab145ca2 a.theys
					foreach ($description->sources as $source) {
1274
						if($source->originalNameString) {
1275
							//$out = $source->originalNameString . ':' . $out;
1276
						}
1277
						$descriptionOut .= " (" . theme('cdm_DescriptionElementSource', $source, true) . ")";
1278
					}
1279
					$descriptionOut .= '<ul>';
1280
					foreach ($description->elements as $descriptionElement) {
1281 f79ad3b5 a.theys
						if($descriptionElement->feature->uuid == UUID_USE_RECORD){
1282
							$useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
1283 d1c92afc a.theys
							$descriptionOut .= '<li class="use_record_list">- ' . $useRecordTags[0] . '[' . $useRecordTags[1] . ']'  . ' - ' . $useRecordTags[3]. ' - ' . $useRecordTags[4]. '[' .   $useRecordTags[5] . ']' .  ' - ' . $useRecordTags[2] . '</li>';
1284 f79ad3b5 a.theys
						}
1285 ab145ca2 a.theys
					}
1286
					$descriptionOut .= '</ul></li>';
1287
					
1288
					
1289
				}
1290
				else {
1291 f79ad3b5 a.theys
					
1292 ab145ca2 a.theys
					$synonymOut .='<li class="descriptionText DescriptionElement">';
1293
					$name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid),array(), NULL, NULL, FALSE ,TRUE);
1294
						
1295
					//$out .= $source->originalNameString . ': ';
1296
					$synonymOut .= $name_used_in_source_link_to_show_use . ': ';
1297 f79ad3b5 a.theys
					$synonymOut .= $useSummary;
1298 ab145ca2 a.theys
					foreach ($description->sources as $source) {
1299
						if($source->originalNameString) {
1300
							//$out = $source->originalNameString . ':' . $out;
1301
						}
1302
						$synonymOut .= " (" . theme('cdm_DescriptionElementSource', $source, true) . ")";
1303
					}
1304
					$synonymOut .= '<ul>';
1305
					foreach ($description->elements as $descriptionElement) {
1306 f79ad3b5 a.theys
						if($descriptionElement->feature->uuid == UUID_USE_RECORD){
1307
							$useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
1308 d1c92afc a.theys
							$synonymOut .='<li class="use_record_list">- ' . $useRecordTags[0] . '[' . $useRecordTags[1] . ']'  . ' - ' . $useRecordTags[3]. ' - ' . $useRecordTags[4]. '[' .   $useRecordTags[5] . ']' .  ' - ' . $useRecordTags[2] . '</li>';
1309 f79ad3b5 a.theys
						}
1310 ab145ca2 a.theys
					}
1311
					$synonymOut .= '</ul></li>';
1312 7ea461ec a.theys
					$isSynonym = false;
1313 ab145ca2 a.theys
					
1314
				}
1315 f79ad3b5 a.theys
1316 b8f451b5 a.theys
			}
1317
		}
1318 97cd2e7f a.theys
	}
1319 ab145ca2 a.theys
	$out .= $descriptionOut . $synonymOut;
1320 97cd2e7f a.theys
	$out .= "</ul></div>";
1321
	return $out;
1322
}
1323
1324 bc8a4f7c a.theys
//The Use theming function here will handle the display of the Use Descriptions 
1325 97cd2e7f a.theys
function theme_cdm_block_Uses ($taxonUuid = null, $pageSize = null) {
1326
	RenderHints::pushToRenderStack('block_Uses');
1327
	
1328
	if ($taxonUuid == null) {
1329
		return;
1330
	}
1331
	$out = '';
1332
	$markerTypes = array();
1333 b8f451b5 a.theys
	$markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
1334 97cd2e7f a.theys
	$useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
1335 b8f451b5 a.theys
	if(!empty($useDescriptions)) {
1336 ab145ca2 a.theys
		$out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><H2><a name="userecords"> </a> Uses </H2>';
1337 7ea461ec a.theys
  		$formatUseDescriptions = theme('cdm_UseDescription', $useDescriptions, $taxonUuid, $pageSize, $pageNumber);
1338 bc8a4f7c a.theys
		$out .= $formatUseDescriptions;
1339
		$out .="</div>";
1340
  	}
1341 97cd2e7f a.theys
	
1342
	return $out;
1343
}