Project

General

Profile

Download (2.62 KB) Statistics
| Branch: | Tag: | Revision:
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
}
65

    
66
/**
67
 * Creates a pager widget for the given CDM Pager containing CDM Reference entities.
68
 *
69
 * @param $referencePager object
70
 *    A CDM Pager  containing CDM Reference entities
71
 * @param $path
72
 *    The base path to be used when generating the pager item links
73
 * @$parameters
74
 *
75
 * @return string
76
 *   Markup
77
 */
78
function cdm_reference_pager($referencePager, $path, $parameters) {
79

    
80
  drupal_set_title(t('Bibliographic index'), PASS_THROUGH);
81
  $out = '';
82
  if (count($referencePager->records) > 0) {
83
    $out .= '<ul>';
84
    foreach ($referencePager->records as $reference) {
85
      // FIXME remove hack.
86
      $reference->fullCitation = $reference->titleCache;
87
      // For matching cdm entity to STO.
88
      $out .= '<li>' . cdm_reference_markup($reference,NULL, TRUE) . '</li>';
89
    }
90
    $out .= '</ul>';
91
    $out .= theme('cdm_pager', array(
92
      'pager' => $referencePager,
93
      'path' => $path,
94
      'parameters' => $parameters,
95
    ));
96
  }
97
  else {
98
    $out = '<h4 class="error">Sorry, this page contains not entries.</h4>';
99
  }
100
  return $out;
101
}
(11-11/14)