Project

General

Profile

« Previous | Next » 

Revision ef686dd8

Added by Andreas Kohlbecker over 4 years ago

fix #7975 fix #8196 name relationships list representation implemented

View differences:

modules/cdm_dataportal/cdm_api/cdm_api.module
1242 1242
 *   An additional element do be placed at the beginning og the list. This element will be the default option.
1243 1243
 *
1244 1244
 * @return array
1245
 *   the terms in an array as options for a form element that allows multiple choices.
1245
 *   the terms in an array (key: uuid => value: label) as options for a form element that allows multiple choices.
1246

  
1246 1247
 */
1247 1248
function cdm_terms_as_options($terms, $term_label_callback = NULL, $empty_option = FALSE){
1248 1249
  $options = array();
......
1279 1280
 *   so a boolean 'true' can be matched by '/true/'
1280 1281
 * @param string $order_by
1281 1282
 *   One of the order by constants defined in this file
1282
 * @return mixed
1283
 * @return array
1284
 *   the terms in an array (key: uuid => value: label) as options for a form element that allows multiple choices.
1283 1285
 */
1284 1286
function cdm_vocabulary_as_option($vocabulary_uuid, $term_label_callback = NULL, $empty_option = FALSE,
1285 1287
                                  array $include_filter = null, $order_by = CDM_ORDER_BY_ORDER_INDEX_ASC) {
......
1374 1376
 * @param bool $empty_option
1375 1377
 *   An additional element do be placed at the beginning og the list. This element will be the default option.
1376 1378
 * @return array
1377
 *    the terms in an array as options for a form element that allows multiple choices.
1379
 *    the terms in an array (key: uuid => value: label) as options for a form element that allows multiple choices.
1378 1380
 */
1379 1381
function cdm_terms_by_type_as_option($term_type, $order_by = CDM_ORDER_BY_TITLE_CACHE_ASC, $term_label_callback = NULL, $empty_option = FALSE){
1380 1382
  $terms = cdm_ws_fetch_all(
......
1456 1458
  }
1457 1459
}
1458 1460

  
1461
/**
1462
 * Returns the localized abbreviated label of the relationship term.
1463
 *
1464
 * In case the abbreviated label is not set the normal representation is returned.
1465
 *
1466
 * @param $term
1467
 * @param bool $is_inverse_relation
1468
 * @return string
1469
 *   The abbreviated label
1470
 */
1471
function cdm_relationship_type_term_abbreviated_label($term, $is_inverse_relation = false){
1472

  
1473
  if($is_inverse_relation) {
1474
    if (isset($term->inverseRepresentation_L10n_abbreviatedLabel) && $term->inverseRepresentation_L10n_abbreviatedLabel) {
1475
      $abbr_label = $term->inverseResentation_L10n_abbreviatedLabel;
1476
    } else {
1477
      $abbr_label = $term->inverseRepresentation_L10n;
1478
    }
1479
  } else {
1480
    if (isset($term->representation_L10n_abbreviatedLabel) && $term->representation_L10n_abbreviatedLabel) {
1481
      $abbr_label = $term->representation_L10n_abbreviatedLabel;
1482
    } else {
1483
      $abbr_label = $term->representation_L10n;
1484
    }
1485
  }
1486
  return $abbr_label;
1487
}
1488

  
1489
/**
1490
 * Returns the symbol of the relationship term.
1491
 *
1492
 * In case the symbol is not set the function falls back to use the abbreviated label or
1493
 * the normal representation..
1494
 *
1495
 * @param $term
1496
 * @param bool $is_inverse_relation
1497
 * @return string
1498
 *   The abbreviated label
1499
 */
1500
function cdm_relationship_type_term_symbol($term, $is_inverse_relation = false){
1501

  
1502
  if($is_inverse_relation) {
1503
    if (isset($term->inverseSymbol) && $term->inverseSymbol) {
1504
      $symbol = $term->inverseSymbol;
1505
    } else if (isset($term->inverseRepresentation_L10n_abbreviatedLabel) && $term->inverseRepresentation_L10n_abbreviatedLabel) {
1506
      $symbol = $term->inverseResentation_L10n_abbreviatedLabel;
1507
    } else {
1508
      $symbol = $term->inverseRepresentation_L10n;
1509
    }
1510
  } else {
1511
    if (isset($term->symbol) && $term->symbol) {
1512
      $symbol = $term->symbol;
1513
    } else if (isset($term->representation_L10n_abbreviatedLabel) && $term->representation_L10n_abbreviatedLabel) {
1514
      $symbol = $term->representation_L10n_abbreviatedLabel;
1515
    } else {
1516
      $symbol = $term->representation_L10n;
1517
    }
1518
  }
1519
  return $symbol;
1520
}
1521

  
1459 1522
// ========================================================================================== //
1460 1523
/**
1461 1524
 * @todo Improve documentation of this function.

Also available in: Unified diff