Project

General

Profile

« Previous | Next » 

Revision e7f3789b

Added by Andreas Kohlbecker over 3 years ago

refactoring theme_cdm_reference to cdm_reference_markup

View differences:

modules/cdm_dataportal/includes/name.inc
937 937

  
938 938
      if (!empty($specimen_type_designation->citation)) {
939 939

  
940
        $citation_footnote_str = theme('cdm_reference', array('reference' => $specimen_type_designation->citation, 'doIconLink' => true));
940
        $citation_footnote_str = cdm_reference_markup($specimen_type_designation->citation, null, false, true);
941 941
        $author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $specimen_type_designation->citation->uuid);
942 942

  
943 943
        if (!empty($author_team->titleCache)) {
modules/cdm_dataportal/includes/occurrences.inc
905 905
                case 'citation':
906 906
                    @_description_list_group_add($groups,
907 907
                        cdm_occurrence_field_name_label($field),
908
                        theme('cdm_reference', array('reference' => $value, 'microReference' => $sequence->microReference)),
908
                        cdm_reference_markup($value, $sequence->microReference),
909 909
                        NULL,
910 910
                        8
911 911
                    );
modules/cdm_dataportal/includes/references.inc
85 85
      // FIXME remove hack.
86 86
      $reference->fullCitation = $reference->titleCache;
87 87
      // For matching cdm entity to STO.
88
      $out .= '<li>' . theme('cdm_reference', array(
89
          'reference' => $reference,
90
          'microReference' => NULL,
91
          'doTextLink' => TRUE,
92
        )) . '</li>';
88
      $out .= '<li>' . cdm_reference_markup($reference,NULL, TRUE) . '</li>';
93 89
    }
94 90
    $out .= '</ul>';
95 91
    $out .= theme('cdm_pager', array(
modules/cdm_dataportal/includes/taxon.inc
143 143
        drupal_set_message("Problem fetching sensu reference with uuid " . $sensu_uuid, 'error');
144 144
      }
145 145
      if($sensu_strings['order_by_key'] != $sensu_reference->titleCache){
146
        $sensu_reference_markup = theme('cdm_reference', array(
147
          'reference' => $sensu_reference,
148
          'microReference' => NULL,
149
          'doLink' => false,
150
        ));
146
        $sensu_reference_markup = cdm_reference_markup($sensu_reference);
151 147
        $footnote_key = FootnoteManager::addNewFootnote($footnote_list_key, $sensu_reference_markup);
152 148
        $footnote_key = theme('cdm_footnote_key', array('footnoteKey' => $footnote_key));
153 149
        $joined_refs[$ref_key]['markup'] = '<span class="sensu">' . $sensu_strings['markup'] . $footnote_key . '</span>';
modules/cdm_dataportal/theme/cdm_dataportal.references.theme
32 32
 *   - doIconLink:
33 33
 *      Append an icon to the citation string which links to the reference page, links to the reference URI or DOI are always
34 34
 *      created when this data is available
35
 *   - referenceStyle: the value "zoology" will cause a specific rendeting of the
36
 *      reference suitable for zoological publications.
37 35
 *
38 36
 * @return string
39 37
 *    the markup for the reference
40 38
 *
41 39
 * @ingroup themeable
42 40
 */
43
function theme_cdm_reference($variables) {
44
  $reference = $variables['reference'];
45
  $microReference = $variables['microReference'];
46
  $doTextLink = $variables['doTextLink'];
47
  $doIconLink = $variables['doIconLink'];
48
  $referenceStyle = $variables['referenceStyle'];
49

  
50
  if (!isset($reference->authorship)) {
51
    $author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
52
  }
53
  else {
54
    $author_team = $reference->authorship;
55
  }
56
  if ($referenceStyle == "zoology") {
57
    $year = '';
58
    if (isset($reference->datePublished)) {
59
      $year = timePeriodToString($reference->datePublished, true, 'YYYY');
60
    }
61
    $citation = $author_team->titleCache . (!empty($year) ? '. ' . $year : '');
62
  }
63
  else {
64
    $citation = $reference->titleCache;
65
  }
41
function cdm_reference_markup($reference, $microReference = NULL, $doTextLink = FALSE, $doIconLink = FALSE) {
66 42

  
67
  $citation = trim($citation);
43
  $citation = trim($reference->titleCache);
68 44
  $iconlink = "";
69 45
  if((isset($doIconLink) && $doIconLink === TRUE)) {
70 46
    $iconlink = l(custom_icon_font_markup('icon-interal-link-alt-solid', array('class' => array('superscript'))), path_to_reference($reference->uuid), array('html' => true));
......
174 150
  $out = '';
175 151

  
176 152
  if (isset($source->citation)) {
177
    $out .= theme('cdm_reference', [
178
      'reference' => $source->citation,
179
      'microReference' => $source->citationMicroReference,
180
      'doIconLink' => $do_link_to_reference,
181
    ]);
153
    $out .= cdm_reference_markup($source->citation, $source->citationMicroReference, false, $do_link_to_reference);
182 154
  }
183 155
  if(isset($source->cdmSource)){
184 156
    $out .= render_cdm_entity_link($source->cdmSource);
modules/cdm_dataportal/theme/theme_registry.inc
109 109
    )),
110 110
    'cdm_polytomousKey_page' => array('variables' => array('polytomousKey' => NULL)),
111 111

  
112
    // Themes in cdm_dataportal.references.theme.
113
    'cdm_reference' => array('variables' => array(
114
        'reference' => NULL,
115
        'microReference' => NULL,
116
        'doTextLink' => FALSE,
117
        'doIconLink' => FALSE,
118
        'referenceStyle' => NULL,
119
    )),
120

  
121 112
    // Themes in cdm_dataportal.taxon.theme.
122 113
    'cdm_search_taxa_results' => array('variables' => array(
123 114
        'pager' => NULL,

Also available in: Unified diff