Revision de8b5b32
Added by Andreas Kohlbecker about 11 years ago
7.x/modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
1626 | 1626 |
} |
1627 | 1627 |
|
1628 | 1628 |
/** |
1629 |
* @todo Please document this function. |
|
1630 |
* @see http://drupal.org/node/1354 |
|
1629 |
* Provides the list of availbale classifications in form of an options array. |
|
1630 |
* |
|
1631 |
* The options array is suitable for drupal form API elements that allow multiple choices. |
|
1632 |
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#options |
|
1633 |
* |
|
1634 |
* The classifications are ordered alphabetically whereas the classification |
|
1635 |
* chosen as default will always appear on top of the array, followed by a |
|
1636 |
* blank line below. |
|
1637 |
* |
|
1638 |
* @return array |
|
1639 |
* classifications in an array as options for a form element that allows multiple choices. |
|
1631 | 1640 |
*/ |
1632 | 1641 |
function cdm_get_taxontrees_as_options() { |
1633 | 1642 |
$taxonTrees = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY); |
1643 |
|
|
1644 |
$default_classification_uuid = variable_get(CDM_TAXONOMICTREE_UUID, FALSE); |
|
1645 |
$default_classification_label = ''; |
|
1646 |
|
|
1647 |
// add all classifications |
|
1634 | 1648 |
$taxonomic_tree_options = array(); |
1635 | 1649 |
if ($taxonTrees) { |
1636 | 1650 |
foreach ($taxonTrees as $tree) { |
1637 |
$taxonomic_tree_options[$tree->uuid] = $tree->titleCache; |
|
1651 |
if (!$default_classification_uuid || $default_classification_uuid != $tree->uuid) { |
|
1652 |
$taxonomic_tree_options[$tree->uuid] = $tree->titleCache; |
|
1653 |
} else { |
|
1654 |
$taxonomic_tree_options[$tree->uuid] = ' '; // one Space characters to force on top, will be replaced below by titleCache |
|
1655 |
$taxonomic_tree_options[''] = ' '; // two Space characters for an empy line below |
|
1656 |
$default_classification_label = $tree->titleCache; |
|
1657 |
} |
|
1638 | 1658 |
} |
1639 | 1659 |
} |
1660 |
// oder alphabetically |
|
1661 |
asort($taxonomic_tree_options); |
|
1662 |
|
|
1663 |
// add default on top |
|
1664 |
if ($default_classification_uuid) { |
|
1665 |
$taxonomic_tree_options[$default_classification_uuid] = $default_classification_label . ' - ' . t('DEFAULT CLASSIFICATION'); |
|
1666 |
} |
|
1667 |
|
|
1640 | 1668 |
return $taxonomic_tree_options; |
1641 | 1669 |
} |
1642 | 1670 |
|
Also available in: Unified diff
fixing #3066 (Available classification select list in taxon tree: entries should be ordered)