Project

General

Profile

Revision 8a4d078d

ID8a4d078dfa6e2200f5e4b25c28d1bdcb7d82cf7b
Parent a3228c59
Child b49c60b7

Added by Andreas Kohlbecker about 2 years ago

fix #7496 cdm_taxontree can either link to taxon or reference search result pages

View differences:

modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module
17 17
 *   - Wouter Addink <w.addink@eti.uva.nl> (migration from Drupal 5 to Drupal7)
18 18
 */
19 19

  
20
const CDM_TAXONTREE_LINK_TYPE = 'cdm_taxontree_link_type';
21

  
20 22
/**
21 23
 * Implements hook_menu() 
22 24
 */
......
98 100
      // cdm tree for a drupal taxonomy
99 101
      $block['subject'] = t('Taxonomy tree');
100 102
      $term_inFocus = arg(0) == 'taxonomy' && arg(1) == 'term' ? arg(2) : 0;
101
      $tree = cdm_taxontree_build_tree($term_inFocus, TRUE, variable_get('cdm_taxontree_block_1_vid', 0));
103
      $tree = cdm_taxontree_build_tree($term_inFocus, TRUE);
102 104
      $block['content'] = theme('cdm_taxontree_block', array(
103 105
        'tree' => $tree,
104 106
        'delta' => $delta,
......
118 120
  $form = array();
119 121
    switch ($delta) {
120 122
      case 'cdm_tree':
123

  
124
        $form[CDM_TAXONTREE_LINK_TYPE] = array(
125
          '#type' => 'radios',
126
          '#title' => t('Link to '),
127
          '#default_value' => variable_get(CDM_TAXONTREE_LINK_TYPE,  'taxon_page'),
128
          '#options' => array('taxon_page' => 'Taxon pages', 'search_registrations' =>'Registration search page' ),
129
        );
130

  
121 131
        /* TODO The option to use the cdm_taxontree for drupal vocabulaties also has been removed, the below code should be
122 132
           removed, see #7565
123 133
        $vocs = taxonomy_get_vocabularies();
......
140 150
 * Implements hook_block_save().
141 151
 */
142 152
function cdm_taxontree_block_save($delta, $edit) {
143
  // TODO Rename block deltas (e.g. '1') to readable strings.
144
  if (TRUE) {
153

  
145 154
    switch ($delta) {
146
      case '1':
155
      case 'cdm_tree':
156
        variable_set(CDM_TAXONTREE_LINK_TYPE,  $edit[CDM_TAXONTREE_LINK_TYPE]);
157
        /* TODO The option to use the cdm_taxontree for drupal vocabulaties also has been removed, the below code should be
158
           removed, see #7565
147 159
        variable_set('cdm_taxontree_block_1_vid', $edit['vid']);
148 160
        return;
161
        */
149 162
    }
150
  }
163

  
151 164
}
152 165

  
153 166
/**
......
977 990

  
978 991
  $focused_taxon_uuid = get_current_taxon_uuid();
979 992

  
993
  $path = '';
994
  $query = array();
980 995
  if (isset($node->tid)) {
996
    //  TODO remove case, see #7565
981 997
    $node_name = $node->name;
982 998
    $path = "taxonomy/term/" . $node->tid;
983 999
    // disable filterswitch
......
987 1003
  }
988 1004
  elseif (module_exists('cdm_dataportal')) {
989 1005
    $node_name = cdm_dataportal_shortname_of($node);
990
    $path = path_to_taxon($node->taxonUuid);
1006
    $link_type = variable_get(CDM_TAXONTREE_LINK_TYPE,  'taxon_page');
1007
    switch($link_type){
1008
      case 'taxon_page':
1009
        $path = path_to_taxon($node->taxonUuid);
1010
        break;
1011
      case 'search_registrations':
1012
        $path = "cdm_dataportal/search/registration";
1013
        $query['taxon_name'] = $node->titleCache;
1014
        break;
1015
      default:
1016
        $path = "invalid_cdm_taxontree_linktype";
1017
    }
991 1018
  }
992 1019
  else {
993 1020
    $node_name = "module cdm_dataportal missing";
......
995 1022
  }
996 1023

  
997 1024
  if ($filterIncludes) {
998
    $name = l($node_name, $path);
1025
    $name = l($node_name, $path, array('query' => $query));
999 1026
    // No names for terms in filter widget; as discussed with A. Müller.
1000 1027
    // $name = '';
1001 1028
    $filter_class = 'filter_included';
1002 1029
  }
1003 1030
  else {
1004 1031
    if ($node->filter == 'on') {
1005
      $name = l($node_name, $path);
1032
      $name = l($node_name, $path, array('query' => $query));
1006 1033
      $filter_class = 'filter_on';
1007 1034
    }
1008 1035
    else {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)