Project

General

Profile

« Previous | Next » 

Revision 51cc509a

Added by Patrick Plitzner almost 8 years ago

#5890 pass classification root node uuid as argument to autosuggest
function

View differences:

modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
73 73
  return $block;
74 74
}
75 75

  
76
function taxon_selection_update($form, &$form_state) {
77
  unset($form_state['input']['taxon_select'], $form_state['values']['taxon_select']);
78
  $tree = $form_state['input']['taxonNode'];
79
  $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest/'.$tree.'///';
80
  $form['taxon_select']['#value'] = '';
81
  return form_builder($form['#id'], $form['taxon_select'], $form_state);
82
}
83

  
76 84
/**
77 85
 * Creates the drupal form and returns it
78 86
 *
......
81 89
 *
82 90
 */
83 91
function cdm_csv_export_my_form($form_state) {
92
    $tree = variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
84 93
    $form['combobox'] = array(
85 94
        '#type' => 'select',
86 95
        '#title' => t('Classification').':',
87
        '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
96
        '#default_value' => $tree,
88 97
        '#options' => cdm_get_taxontrees_as_options(FALSE, TRUE),
89 98
        '#attributes' => array(
90 99
            'name' => 'taxonNode',
91
            'onchange' => 'return validateForm()'),
100
            'onchange' => 'return validateForm()'
101
        ),
102
        '#ajax' => array(
103
          'callback' => 'taxon_selection_update',
104
          'wrapper' => 'taxon-selection',
105
          'progress' => array(
106
            'message' => '',
107
            'type' => 'throbber',
108
          ),
109
        )
92 110
    );
93 111
    $form['taxon_select'] = array(
94 112
        '#title' => t('Taxon'),
95 113
        '#type' => 'textfield',
114
        '#prefix' => '<div id="taxon-selection">',
115
        '#suffix' => '</div>'
96 116
    );
97 117
    if(variable_get('cdm_dataportal_taxon_auto_suggest')){
98
        $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest';
118
        $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest////';
99 119
    }
100 120

  
101 121
    $form['redListField'] = array(
modules/cdm_dataportal/cdm_dataportal.module
611 611
    , // Expected callback arguments: taxon_uuid.
612 612
    );
613 613

  
614
    $items['cdm_dataportal/taxon/autosuggest'] = array(
614
    $items['cdm_dataportal/taxon/autosuggest/%/%/%/'] = array(
615 615
        'page callback' => 'cdm_dataportal_taxon_autosuggest',
616 616
        'access arguments' => array('access taxon autosuggest'),
617
        'page arguments' => array(3,4,5),
617 618
        'type' => MENU_CALLBACK
618 619
    );
619 620
  }
modules/cdm_dataportal/cdm_dataportal.search.php
121 121
  return $form;
122 122
}
123 123

  
124
function cdm_dataportal_taxon_autosuggest($string, $treeUuid = NULL, $areaUuid = NULL, $status = NULL) {
124
function cdm_dataportal_taxon_autosuggest($treeUuid = NULL, $areaUuid = NULL, $status = NULL, $string) {
125 125
  $matches = array();
126 126

  
127 127
  $queryParams = array();
......
136 136
    $queryParams['status'] = $status ;
137 137
  }
138 138
  $queryParams['pageNumber'] = '0';
139
  $queryParams['pageSize'] = '10';
139
  $queryParams['pageSize'] = '100';
140 140
  $queryParams['doTaxa'] = true;
141 141
  $queryParams['doSynonyms'] = true;
142 142
  $queryParams['doMisappliedNames'] = true;
......
147 147
      $titleCache = $record->entity->titleCache;
148 148
      preg_match('/(.*) sec.*/', $titleCache, $trimmedTitle); //remove sec reference
149 149
      $trimmedTitle = trim($trimmedTitle[1]);
150
      $matches[$trimmedTitle] = $trimmedTitle;
150
      $matches[$trimmedTitle] = check_plain($trimmedTitle);
151 151
  }
152 152
  drupal_json_output($matches);
153 153
}

Also available in: Unified diff