Revision ae0a5060
Added by Andreas Kohlbecker almost 11 years ago
7.x/modules/cdm_dataportal/includes/descriptions.inc | ||
---|---|---|
46 | 46 |
} else { |
47 | 47 |
return $other_elements; |
48 | 48 |
} |
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Merge the fields 'annotations', 'markers', 'sources', 'media' from the source CDM DescriptionElement into the target. |
|
53 |
* |
|
54 |
* @param $target |
|
55 |
* The source CDM DescriptionElement |
|
56 |
* @param $source |
|
57 |
* The target CDM DescriptionElement |
|
58 |
*/ |
|
59 |
function cdm_merge_description_elements(&$target, &$source){ |
|
60 |
static $fields_to_merge = array('annotations', 'markers', 'sources', 'media'); |
|
61 |
|
|
62 |
foreach ($fields_to_merge as $field){ |
|
63 |
if(is_array($source->$field)) { |
|
64 |
if(!is_array($target->$field)){ |
|
65 |
$target->$field = $source->$field; |
|
66 |
} else { |
|
67 |
$target->$field = array_merge($target->$field, $source->$field); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
49 | 71 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_CommonNamesTest.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.dataportal.selenium.tests.cichorieae; |
11 | 11 |
|
12 |
import static org.junit.Assert.*; |
|
13 | 12 |
import static org.junit.Assert.assertEquals; |
13 |
import static org.junit.Assert.assertNotNull; |
|
14 | 14 |
|
15 | 15 |
import java.net.MalformedURLException; |
16 |
import java.util.List; |
|
17 | 16 |
import java.util.UUID; |
18 | 17 |
|
19 | 18 |
import org.junit.Test; |
20 | 19 |
|
21 | 20 |
import eu.etaxonomy.dataportal.DataPortalContext; |
22 |
import eu.etaxonomy.dataportal.elements.BaseElement; |
|
23 | 21 |
import eu.etaxonomy.dataportal.elements.FeatureBlock; |
24 |
import eu.etaxonomy.dataportal.elements.LinkElement; |
|
25 | 22 |
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase; |
26 | 23 |
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts; |
27 | 24 |
import eu.etaxonomy.dataportal.pages.TaxonProfilePage; |
28 |
import eu.etaxonomy.dataportal.pages.TaxonSynonymyPage; |
|
29 | 25 |
|
30 | 26 |
/** |
31 | 27 |
* |
... | ... | |
53 | 49 |
FeatureBlock commonNamesBlock = p.getFeatureBlockAt(3, "common_names", "div", "span"); |
54 | 50 |
assertNotNull(commonNamesBlock); |
55 | 51 |
|
56 |
// no longer valid since 2012-11-19 String expected = "Common names\nlechuguilla145, escariola145; Albanian (Albania): Ogrisht146; Arabic (Lebanon): خَسّ الزَّيْت147; Arabic (Saudi Arabia): Khass-al-Hammar148; Arabic (Syria): خَسّ الزَّيْت149; Armenian (Armenia): Կաթնուկ կողմնացույց150; Bulgarian (Bulgaria): Компасна салата151; Czech (Czech Republic): Locika kompasová152; Danish (Denmark): Tornet Salat153; English (Australia): compass plant154, Prickly Lettuce155, Prickly Lettuce156, Prickly Lettuce157, Prickly Lettuce158, compass plant159"; |
|
57 |
String expected = "Common names\nlechuguilla144, escariola144; Albanian (Albania): Ogrisht145; Arabic (Lebanon): خَسّ الزَّيْت146; Arabic (Saudi Arabia): Khass-al-Hammar147; Arabic (Syria): خَسّ الزَّيْت148; Armenian (Armenia): Կաթնուկ կողմնացույց149; Bulgarian (Bulgaria): Компасна салата150; Czech (Czech Republic): Locika kompasová151; Danish (Denmark): Tornet Salat152; English (Australia): compass plant153, Prickly Lettuce154, Prickly Lettuce155, Prickly Lettuce156, Prickly Lettuce157, compass plant158"; |
|
52 |
// no longer valid since 2012-11-19: String expected = "Common names\nlechuguilla145, escariola145; Albanian (Albania): Ogrisht146; Arabic (Lebanon): خَسّ الزَّيْت147; Arabic (Saudi Arabia): Khass-al-Hammar148; Arabic (Syria): خَسّ الزَّيْت149; Armenian (Armenia): Կաթնուկ կողմնացույց150; Bulgarian (Bulgaria): Компасна салата151; Czech (Czech Republic): Locika kompasová152; Danish (Denmark): Tornet Salat153; English (Australia): compass plant154, Prickly Lettuce155, Prickly Lettuce156, Prickly Lettuce157, Prickly Lettuce158, compass plant159"; |
|
53 |
// no longer valid since 2013-06-27, sorting and merging implemented: String expected = "Common names\nlechuguilla144, escariola144; Albanian (Albania): Ogrisht145; Arabic (Lebanon): خَسّ الزَّيْت146; Arabic (Saudi Arabia): Khass-al-Hammar147; Arabic (Syria): خَسّ الزَّيْت148; Armenian (Armenia): Կաթնուկ կողմնացույց149; Bulgarian (Bulgaria): Компасна салата150; Czech (Czech Republic): Locika kompasová151; Danish (Denmark): Tornet Salat152; English (Australia): compass plant153, Prickly Lettuce154, Prickly Lettuce155, Prickly Lettuce156, Prickly Lettuce157, compass plant158"; |
|
54 |
String expected = "Common names\nescariola144, lechuguilla144; Albanian (Albania): Ogrisht145; Arabic (Lebanon): خَسّ الزَّيْت146; Arabic (Saudi Arabia): Khass-al-Hammar147; Arabic (Syria): خَسّ الزَّيْت148; Armenian (Armenia): Կաթնուկ կողմնացույց149; Bulgarian (Bulgaria): Компасна салата150; Czech (Czech Republic): Locika kompasová151; Danish (Denmark): Tornet Salat152; English (Australia): Prickly Lettuce153,154,155,156,157,158,159, Prickly lettuce160,161, compass plant160,161, milk thistle160,161"; |
|
58 | 55 |
String firstChars = commonNamesBlock.getText().substring(0, expected.length()); |
59 | 56 |
|
60 | 57 |
assertEquals(expected, firstChars); |
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme | ||
---|---|---|
532 | 532 |
if (is_array($elements)) { |
533 | 533 |
foreach ($elements as $element) { |
534 | 534 |
if ($element->class == 'CommonTaxonName') { |
535 |
// $key = '<b>' . $element->language->representation_L10n . '</b> (' . |
|
536 |
// $element->area->titleCache . ')'; |
|
537 | 535 |
if (isset($element->language->representation_L10n)) { |
538 |
$key = '<b>' . $element->language->representation_L10n . '</b>'; |
|
539 |
$key .= (isset($element->area->titleCache) && strlen($element->area->titleCache) > 0) ? ' (' . $element->area->titleCache . ')' : ''; |
|
540 |
$common_names[$key][] = $element; |
|
536 |
$language_area_key = '<b>' . $element->language->representation_L10n . '</b>'; |
|
537 |
if(isset($element->area->titleCache) && strlen($element->area->titleCache) > 0){ |
|
538 |
$language_area_key .= ' (' . $element->area->titleCache . ')'; |
|
539 |
} |
|
541 | 540 |
} |
542 | 541 |
else { |
543 |
// @Comment WA: common name without a language, should this happen?
|
|
542 |
// common name without a language, should not happen but is possible
|
|
544 | 543 |
// example: flore_gabon/cdm_dataportal/taxon/24f36d18-a6e8-4edb-93bf-4a30f3394bf5. |
545 |
// if(!isset($key)) { // Just to mimic same behaviour as in D5. |
|
546 |
$key = ''; |
|
547 |
// } |
|
548 |
$common_names[$key][] = $element; |
|
544 |
$language_area_key = ''; |
|
545 |
} |
|
546 |
if(isset($common_names[$language_area_key][$element->name])) { |
|
547 |
// same name already exists for language and areae combination, se we merge the description elements |
|
548 |
cdm_merge_description_elements($common_names[$language_area_key][$element->name], $element); |
|
549 |
} else{ |
|
550 |
// otherwise add as new entry |
|
551 |
$common_names[$language_area_key][$element->name] = $element; |
|
549 | 552 |
} |
550 | 553 |
} |
551 | 554 |
elseif ($element->class == 'TextData') { |
552 |
// else if ($element->class == 'TextData' && $element->feature->uuid |
|
553 |
// == UUID_COMMON_NAME){ |
|
554 | 555 |
$textData_commonNames[] = $element; |
555 | 556 |
} |
556 | 557 |
} |
... | ... | |
564 | 565 |
|
565 | 566 |
// Creating the output to be render by Drupal. |
566 | 567 |
foreach ($common_names as $key => $elements) { |
568 |
ksort($elements); // sort names alphabetically |
|
567 | 569 |
$rendered_element_list = ''; |
568 | 570 |
foreach ($elements as $element) { |
569 | 571 |
$sourcesFootnoteKeyList = ''; |
... | ... | |
1485 | 1487 |
return $out; |
1486 | 1488 |
} |
1487 | 1489 |
|
1488 |
// @WA $pageSize is not used.. |
|
1489 |
// function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = |
|
1490 |
// null){ |
|
1491 | 1490 |
/** |
1492 | 1491 |
* @todo Please document this function. |
1493 | 1492 |
* @see http://drupal.org/node/1354 |
... | ... | |
1515 | 1514 |
return $out; |
1516 | 1515 |
} |
1517 | 1516 |
|
1518 |
// This theming function formats the use description and use record list for |
|
1519 |
// these descriptions. |
|
1520 |
// Comment @WA: $pageSize and $pageNumber are not used. |
|
1521 |
// function theme_cdm_UseDescription($descriptions = NULL, $taxonUuid = NULL, |
|
1522 |
// $pageSize, $pageNumber) { |
|
1523 | 1517 |
/** |
1524 |
* @todo Please document this function. |
|
1518 |
* This theming function formats the use description and use record list for |
|
1519 |
* these descriptions. |
|
1520 |
* |
|
1525 | 1521 |
* @see http://drupal.org/node/1354 |
1526 | 1522 |
*/ |
1527 | 1523 |
function theme_cdm_UseDescription($variables) { |
Also available in: Unified diff
common names orderd and merged in case of duplicates