Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / includes / references.inc @ 87b304a7

History | View | Annotate | Download (1.59 KB)

1
<?php
2

    
3
/**
4
 * @file
5
 * Functions for dealing with CDM entities from the package model.references
6
 *
7
 * @copyright
8
 *   (C) 2007-2016 EDIT
9
 *   European Distributed Institute of Taxonomy
10
 *   http://www.e-taxonomy.eu
11
 *
12
 *   The contents of this module are subject to the Mozilla
13
 *   Public License Version 1.1.
14
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
15
 *
16
 * @author
17
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
18
 */
19

    
20
/**
21
 * @defgroup compose Compose functions
22
 * @{
23
 * Functions which are composing Drupal render arrays
24
 *
25
 * The cdm_dataportal module needs to compose rather complex render arrays from
26
 * the data returned by the CDM REST service. The compose functions are
27
 * responsible for creating the render arrays.
28
 *
29
 * All these functions are also implementations of the compose_hook()
30
 * which is used in the proxy_content() function.
31
 * @}
32
 */
33

    
34
/**
35
 * Cleanup of the textual short form of an author team.
36
 *
37
 * The cdm fails to create correct representations of author teams.
38
 * The '&' gluing the authors together need to be cleaned up.
39
 *
40
 * @param $author_team
41
 *  the authorTeam string
42
 *
43
 * @return string
44

    
45
 */
46
function _short_form_of_author_team($author_team) {
47
  $number_of_authors = substr_count($author_team, ' & ') + 1;
48
  // var_dump($author_team);
49
  // var_dump($number_of_authors);
50
  switch ($number_of_authors) {
51
    case 1:
52
      $result = $author_team;
53
      break;
54

    
55
    case 2:
56
      $result = str_replace(' & ', ' and ', $author_team);
57
      break;
58

    
59
    default:
60
      $result_parts = explode(' & ', $author_team);
61
      $result = $result_parts[0] . ' et al.';
62
  }
63
  return $result;
64
}
Add picture from clipboard (Maximum size: 40 MB)