Project

General

Profile

« Previous | Next » 

Revision 28c5c87a

Added by Andreas Kohlbecker over 9 years ago

refactoring the feature node blocks - 1

View differences:

7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
1210 1210
 * @return string
1211 1211
 * 	  the localized representation_L10n of the term,
1212 1212
 *    otherwise the titleCache as fall back,
1213
 *    otherwise an empty string
1213
 *    otherwise the default_representation which defaults to an empty string
1214 1214
 */
1215
function cdm_term_representation($definedTermBase) {
1215
function cdm_term_representation($definedTermBase, $default_representation = '') {
1216 1216
  if ( isset($definedTermBase->representation_L10n) ) {
1217 1217
    return $definedTermBase->representation_L10n;
1218 1218
  } elseif ( isset($definedTermBase->titleCache)) {
1219 1219
    return $definedTermBase->titleCache;
1220 1220
  }
1221
  return '';
1221
  return $default_representation;
1222 1222
}
1223 1223

  
1224 1224
/**
......
1540 1540
 * Merges the given featureNodes structure with the descriptionElements.
1541 1541
 *
1542 1542
 * This method is used in preparation for rendering the descriptionElements.
1543
 * The descriptionElements wich belong to a specific feature node are appended
1543
 * The descriptionElements which belong to a specific feature node are appended
1544 1544
 * to a the feature node by creating a new field:
1545 1545
 *  - descriptionElements: the CDM DescriptionElements which belong to this feature
1546 1546
 * The descriptionElements will be cleared in advance in order to allow reusing the
1547
 * same feature tree without the risk of mixing sets of descrition elemens.
1547
 * same feature tree without the risk of mixing sets of description elements.
1548 1548
 *
1549 1549
 * which originally is not existing in the cdm.
1550 1550
 *
1551 1551
 *
1552 1552
 *
1553 1553
 * @param array $featureNodes
1554
 *    An array of cdm FeatureNodes which may be hierachical since feature nodes
1554
 *    An array of cdm FeatureNodes which may be hierarchical since feature nodes
1555 1555
 *    may have children.
1556 1556
 * @param array $descriptionElements
1557 1557
 *    An flat array of cdm DescriptionElements
1558 1558
 * @return array
1559
 *    The $featureNodes structure enriched with the accoding $descriptionElements
1559
 *    The $featureNodes structure enriched with the according $descriptionElements
1560 1560
 */
1561 1561
function _mergeFeatureTreeDescriptions($featureNodes, $descriptionElements) {
1562 1562

  
1563 1563
  foreach ($featureNodes as &$node) {
1564 1564
    // since the $featureNodes array is reused for each description
1565
    // it is nessecary to clear the custom node fields in advance
1565
    // it is necessary to clear the custom node fields in advance
1566 1566
    if(isset($node->descriptionElements)){
1567 1567
      unset($node->descriptionElements);
1568 1568
    }

Also available in: Unified diff