Project

General

Profile

« Previous | Next » 

Revision 7272d19c

Added by Andreas Kohlbecker over 6 years ago

refactoring: reducing amount of theme functions, functions moved into includes

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.taxon.theme
14 14
 */
15 15

  
16 16
/**
17
 * @todo Please document this function.
18
 * @see http://drupal.org/node/1354
17
 * Creates markup for a taxon which is the accepted of another one
18
 *
19
 * @param $accepted_for_uuid
20
 *   The uuid of the accepted taxon
19 21
 */
20
function theme_cdm_acceptedFor($variables) {
21
  $accepted_for_uuid = $variables['acceptedFor'];
22
function cdm_accepted_for($accepted_for_uuid) {
22 23

  
23 24
  if(!is_uuid($accepted_for_uuid)){
24 25
    return '';
......
43 44
}
44 45

  
45 46
/**
46
 * @todo document this function.
47
 * Compose function for a list of taxa.
48
 *
49
 * This function is for example used toi display search results or the taxa for a taxon name in the name page.
50
 *
51
 * @param $taxon_list array
52
 *   The list of CDM Taxon entities. e.g. The records array as contained in a pager object.
53
 * @param $freetext_search_results array
54
 * @param $show_classification boolean
55
 *
56
 * @ingroup compose
57
 *
47 58
 */
48
function theme_cdm_list_of_taxa($variables) {
59
function compose_list_of_taxa($taxon_list, $freetext_search_results = array(), $show_classification = false) {
49 60

  
50 61
  $unclassified_snippet = '<span class="unclassified">' . t('unclassified') . '</span>';
51 62

  
52
  $records = $variables['records'];
53
  $freetextSearchResults = $variables['freetextSearchResults'];
54
  $show_classification = $variables['show_classification'];
55

  
56 63
  RenderHints::pushToRenderStack('list_of_taxa');
57 64

  
58
  $form_name = 'search_gallery';
59
  // $default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
60
  // $gallery_settings = variable_get($form_name, $default_values);
61 65
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
62 66

  
63 67
  $showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
64 68
  $showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
65
  // $showMedia_taxa =
66
  // variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
67
  // $showMedia_synonyms =
68
  // variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
69 69
  $searched_in_classification = cdm_dataportal_searched_in_classification();
70 70
  $searched_in_classification_uuid = null;
71 71
  if(isset($searched_in_classification->uuid)){
......
75 75
  // .. Well, for sure not as performant as before, but better than nothing.
76 76
  $synonym_uuids = array();
77 77
  $misappied_uuids = array();
78
  foreach ($records as $taxon) {
78
  foreach ($taxon_list as $taxon) {
79 79
    if ($taxon->class == "Synonym") {
80 80
      if (!array_key_exists($taxon->uuid, $synonym_uuids)) {
81 81
        $synonym_uuids[$taxon->uuid] = $taxon->uuid;
......
113 113

  
114 114
  $out = '<ul class="cdm_names" style="background-image: none;">';
115 115
  $itemCnt = -1;
116
  foreach ($records as $taxon) {
116
  foreach ($taxon_list as $taxon) {
117 117
    $itemCnt++;
118 118
    if (isset($table_of_accepted[$taxon->uuid])) {
119 119
      // Its a synonym or misapplied name.
......
205 205
     * WildcardQueries, since these are  constant score by default
206 206
     * since Lucene 2.9
207 207
     */
208
    if(isset($freetextSearchResults[$itemCnt]) && $freetextSearchResults[$itemCnt]->score && $freetextSearchResults[$itemCnt]->maxScore){
209
      $percentage =  ( $freetextSearchResults[$itemCnt]->score / $freetextSearchResults[$itemCnt]->maxScore ) * 100;
208
    if(isset($freetext_search_results[$itemCnt]) && $freetext_search_results[$itemCnt]->score && $freetext_search_results[$itemCnt]->maxScore){
209
      $percentage =  ( $freetext_search_results[$itemCnt]->score / $freetext_search_results[$itemCnt]->maxScore ) * 100;
210 210
      $out .= '<div class="score-bar"><div class="score-bar-indicator" style="width:' . $percentage .'% "></div></div>';
211 211
      $out .= '<div class="score-bar-value">' . number_format($percentage, 2) .'%</div>';
212 212
    }
213 213

  
214 214
    // Render highlighted fragments, these are made available by free text
215 215
    // searches.
216
    if (isset($freetextSearchResults[$itemCnt]->fieldHighlightMap)) {
217
      $field_fragments = (array) $freetextSearchResults[$itemCnt]->fieldHighlightMap;
216
    if (isset($freetext_search_results[$itemCnt]->fieldHighlightMap)) {
217
      $field_fragments = (array) $freetext_search_results[$itemCnt]->fieldHighlightMap;
218 218
      if (count($field_fragments) > 0) {
219 219
        $fragments_out = '';
220 220
        foreach ($field_fragments as $fieldName => $fragments) {
......
230 230
  $out .= '</ul>';
231 231
  RenderHints::popFromRenderStack();
232 232

  
233
  return $out;
233
  return markup_to_render_array($out); // TODO create render array of all list items in function
234 234
}
235 235

  
236 236
  /**

Also available in: Unified diff