Revision 61b6ee11
Added by Andreas Kohlbecker about 11 years ago
7.x/modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
141 | 141 |
} |
142 | 142 |
} |
143 | 143 |
|
144 |
/** |
|
145 |
* Lists the classifications a taxon belongs to |
|
146 |
* |
|
147 |
* @param CDM type Taxon $taxon |
|
148 |
* the taxon |
|
149 |
* |
|
150 |
* @return array |
|
151 |
* aray of CDM instances of Type Classification |
|
152 |
*/ |
|
153 |
function get_classifications_for_taxon($taxon) { |
|
154 |
|
|
155 |
return cdm_ws_get(CDM_WS_TAXON_CLASSIFICATIONS, $taxon->uuid);; |
|
156 |
} |
|
157 |
|
|
144 | 158 |
/** |
145 | 159 |
* Returns the chosen FeatureTree for the taxon profile. |
146 | 160 |
* |
... | ... | |
1711 | 1725 |
* chosen as default will always appear on top of the array, followed by a |
1712 | 1726 |
* blank line below. |
1713 | 1727 |
* |
1728 |
* @param bool $add_none_option |
|
1729 |
* is true an addtional 'none' option will be added, optional parameter, defaults to FALSE |
|
1730 |
* |
|
1714 | 1731 |
* @return array |
1715 | 1732 |
* classifications in an array as options for a form element that allows multiple choices. |
1716 | 1733 |
*/ |
1717 |
function cdm_get_taxontrees_as_options() { |
|
1734 |
function cdm_get_taxontrees_as_options($add_none_option = FALSE) { |
|
1735 |
|
|
1718 | 1736 |
$taxonTrees = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY); |
1719 | 1737 |
|
1720 | 1738 |
$default_classification_uuid = variable_get(CDM_TAXONOMICTREE_UUID, FALSE); |
... | ... | |
1722 | 1740 |
|
1723 | 1741 |
// add all classifications |
1724 | 1742 |
$taxonomic_tree_options = array(); |
1743 |
if ($add_none_option) { |
|
1744 |
$taxonomic_tree_options['NONE'] = ' '; // one Space character at beginning to force on top; |
|
1745 |
} |
|
1725 | 1746 |
if ($taxonTrees) { |
1726 | 1747 |
foreach ($taxonTrees as $tree) { |
1727 | 1748 |
if (!$default_classification_uuid || $default_classification_uuid != $tree->uuid) { |
1728 | 1749 |
$taxonomic_tree_options[$tree->uuid] = $tree->titleCache; |
1729 | 1750 |
} else { |
1730 |
$taxonomic_tree_options[$tree->uuid] = ' '; // one Space characters to force on top, will be replaced below by titleCache
|
|
1751 |
$taxonomic_tree_options[$tree->uuid] = ' '; // two Space characters to force on top but below 'none' option , will be replaced below by titleCache
|
|
1731 | 1752 |
if (count($taxonTrees) > 1) { |
1732 |
$taxonomic_tree_options[''] = ' '; // two Space characters for an empy line below
|
|
1753 |
$taxonomic_tree_options[''] = ' '; // three Space characters for an empy line below
|
|
1733 | 1754 |
} |
1734 | 1755 |
$default_classification_label = $tree->titleCache; |
1735 | 1756 |
} |
1736 | 1757 |
} |
1737 | 1758 |
} |
1738 |
// oder alphabetically |
|
1759 |
// oder alphabetically the space
|
|
1739 | 1760 |
asort($taxonomic_tree_options); |
1740 | 1761 |
|
1741 |
// add default on top |
|
1762 |
// now set the labels |
|
1763 |
// for none |
|
1764 |
if ($add_none_option) { |
|
1765 |
$taxonomic_tree_options['NONE'] = t('-- None --'); |
|
1766 |
} |
|
1767 |
|
|
1768 |
// for default_classification |
|
1742 | 1769 |
if (is_uuid($default_classification_uuid)) { |
1743 | 1770 |
$taxonomic_tree_options[$default_classification_uuid] = |
1744 | 1771 |
$default_classification_label ? $default_classification_label : '--- INVALID CHOICE ---' |
Also available in: Unified diff
searching on all classifications now possible and fixing some bugs related to #2896