Project

General

Profile

« Previous | Next » 

Revision 65a94441

Added by Patrick Plitzner almost 8 years ago

#5890 Add taxon filter to csv export

View differences:

modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
81 81
 *
82 82
 */
83 83
function cdm_csv_export_my_form($form_state) {
84
  $form['combobox'] = array(
85
    '#type' => 'select',
86
    '#title' => t('Classification').':',
87
    '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
88
    '#options' => cdm_get_taxontrees_as_options(),
89
    '#attributes' => array(
90
         'name' => 'classification',
91
          'onchange' => 'return validateForm()'),
92
  );
84
    $form['combobox'] = array(
85
        '#type' => 'select',
86
        '#title' => t('Classification').':',
87
        '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
88
        '#options' => cdm_get_taxontrees_as_options(),
89
        '#attributes' => array(
90
            'name' => 'classification',
91
            'onchange' => 'return validateForm()'),
92
    );
93
    $form['taxon_select'] = array(
94
        '#title' => t('Taxon'),
95
        '#type' => 'textfield',
96
    );
97
    if(variable_get('cdm_dataportal_taxon_auto_suggest')){
98
        $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest';
99
    }
93 100

  
94
  $form['redListField'] = array(
95
      '#type' => 'fieldset',
96
      '#title'	=>t('Redlist Attributes'),
97
      '#collapsible' => TRUE,
98
      '#collapsed' => TRUE,
101
    $form['redListField'] = array(
102
        '#type' => 'fieldset',
103
        '#title'	=>t('Redlist Attributes'),
104
        '#collapsible' => TRUE,
105
        '#collapsed' => TRUE,
99 106
    );
100 107

  
101
  $form['redListField']['csvExportOptions'] = array(
102
      '#type'=>'checkboxes',
103
      '#options' => array(),
104
  );
108
    $form['redListField']['csvExportOptions'] = array(
109
        '#type'=>'checkboxes',
110
        '#options' => array(),
111
    );
105 112

  
106
   // ---- LAYOUT PER FEATURE ---- //
107
$feature_tree = get_csv_featureTree();
108
  if (isset($feature_tree->root->childNodes)) {
109
    foreach ($feature_tree->root->childNodes as $featureNode) {
110
      if (isset($featureNode->feature)) {
111

  
112
       // Must not exceed 45 characters !!!
113
        $subform_id =  $featureNode->feature->uuid; //LAYOUT_SETTING_PREFIX .
114
//        $settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
115
//        $systemDefaults = unserialize(FEATURE_TREE_LAYOUT_DEFAULTS);
116
        $form['redListField']['csvExportOptions'][$subform_id] = array(
117
          '#type' => 'checkbox',
118
          '#title' => $featureNode->feature->representation_L10n,
119
          '#default_value' => $featureNode->feature->uuid,//$settings,
120
          '#attributes' => array('value' => $featureNode->feature->uuid,
121
                                  'name' => 'features'
122
            ),
123
        );
124
      }
113
    // ---- LAYOUT PER FEATURE ---- //
114
    $feature_tree = get_csv_featureTree();
115
    if (isset($feature_tree->root->childNodes)) {
116
        foreach ($feature_tree->root->childNodes as $featureNode) {
117
            if (isset($featureNode->feature)) {
118

  
119
                // Must not exceed 45 characters !!!
120
                $subform_id =  $featureNode->feature->uuid; //LAYOUT_SETTING_PREFIX .
121
                //        $settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
122
                //        $systemDefaults = unserialize(FEATURE_TREE_LAYOUT_DEFAULTS);
123
                $form['redListField']['csvExportOptions'][$subform_id] = array(
124
                    '#type' => 'checkbox',
125
                    '#title' => $featureNode->feature->representation_L10n,
126
                    '#default_value' => $featureNode->feature->uuid,//$settings,
127
                    '#attributes' => array('value' => $featureNode->feature->uuid,
128
                        'name' => 'features'
129
                    ),
130
                );
131
            }
132
        }
125 133
    }
126
  }
127 134

  
128
  $form['downloadTokenValueId'] = array(
129
    '#type' => 'hidden',
130
    '#attributes' => array('name' => 'downloadTokenValueId',
131
                           'id' => 'downloadTokenValueId',
132
      ),
135
    $form['downloadTokenValueId'] = array(
136
        '#type' => 'hidden',
137
        '#attributes' => array('name' => 'downloadTokenValueId',
138
            'id' => 'downloadTokenValueId',
139
        ),
133 140
    );
134 141

  
135
  $form['dialogMessage'] = array(
136
    '#type' => 'hidden',
137
    '#attributes' => array(
138
      'name' => 'dialogMessage',
139
      'id' => 'dialogMessage',
140
    ),
141
  );
142
    $form['dialogMessage'] = array(
143
        '#type' => 'hidden',
144
        '#attributes' => array(
145
            'name' => 'dialogMessage',
146
            'id' => 'dialogMessage',
147
        ),
148
    );
142 149

  
143
  $country = variable_get('area_filter_country');
144
  $state = variable_get('area_filter_state');
145
if($country != null || $state != null){
146
  $form['regionFilter'] = array(
147
    '#type' => 'fieldset',
148
    '#title' => t('Geographical filter'),
149
    '#collapsible' => TRUE,
150
    '#collapsed' => TRUE,
151
  );
152
 }
150
    $country = variable_get('area_filter_country');
151
    $state = variable_get('area_filter_state');
152
    if($country != null || $state != null){
153
        $form['regionFilter'] = array(
154
            '#type' => 'fieldset',
155
            '#title' => t('Geographical filter'),
156
            '#collapsible' => TRUE,
157
            '#collapsed' => TRUE,
158
        );
159
    }
153 160

  
154
  $term = cdm_ws_get(CDM_WS_TERM, $country);
155
  $cdmRepresentationTitleCache = cdm_term_representation($term);
156
  if($country != null){
157
  $form['regionFilter']['country'] = array (
158
    '#type' => 'checkbox',
159
    '#title' => t($cdmRepresentationTitleCache),
160
    '#attributes' => array('name' => 'area',
161
                            'id' => 'checkall',
162
                            'value' =>  $country
163
     ),
164
    );
165
  }
161
    $term = cdm_ws_get(CDM_WS_TERM, $country);
162
    $cdmRepresentationTitleCache = cdm_term_representation($term);
163
    if($country != null){
164
        $form['regionFilter']['country'] = array (
165
            '#type' => 'checkbox',
166
            '#title' => t($cdmRepresentationTitleCache),
167
            '#attributes' => array('name' => 'area',
168
                'id' => 'checkall',
169
                'value' =>  $country
170
            ),
171
        );
172
    }
166 173

  
167
  //GermanFederalStates
168
  if($state != null){
169
  $nameRelationshipTypeOptions = cdm_vocabulary_as_option($state);
170
  asort($nameRelationshipTypeOptions);
171
  $form['regionFilter']['area'] = array(
172
    '#type' => 'checkboxes',
173
    '#description' =>t('Select an area to filter the list of taxa'),
174
    '#options' => $nameRelationshipTypeOptions,
175
    '#attributes' => array('name' => 'area',
176
                            'id' => 'area',
177
      ),
178
    );
179
  }
174
    //GermanFederalStates
175
    if($state != null){
176
        $nameRelationshipTypeOptions = cdm_vocabulary_as_option($state);
177
        asort($nameRelationshipTypeOptions);
178
        $form['regionFilter']['area'] = array(
179
            '#type' => 'checkboxes',
180
            '#description' =>t('Select an area to filter the list of taxa'),
181
            '#options' => $nameRelationshipTypeOptions,
182
            '#attributes' => array('name' => 'area',
183
                'id' => 'area',
184
            ),
185
        );
186
    }
180 187

  
181 188
  $form['button'] = array(
182
    '#type'  => 'submit',
183
    '#value' => 'Export',
189
        '#type'  => 'submit',
190
        '#value' => 'Export',
184 191
    );
185 192

  
186
  $form['#action'] = url(variable_get('cdm_csv_export_webservice_url'));
187
  $form['#attributes'] = array(
188
                 'name' => 'exportForm',
189
                 'onsubmit' => 'return blockUIForDownload()');
190
 return $form;
193
    $form['#action'] = url(variable_get('cdm_csv_export_webservice_url'));
194
    $form['#attributes'] = array(
195
        'name' => 'exportForm',
196
        'onsubmit' => 'return blockUIForDownload()');
197
    return $form;
191 198
}
192 199

  
193 200

  

Also available in: Unified diff