-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdh_ecology.admin.inc
377 lines (347 loc) · 11.3 KB
/
dh_ecology.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?php
/**
* @file
* Model editing UI.
*
*/
/**
* UI controller.
*/
//****************************
// Isolate Table
//****************************
class dHEcologyIsolateTypeUIController extends EntityDefaultUIController {
public function hook_menu() {
$items = parent::hook_menu();
$items[$this->path]['description'] = 'Manage dH Ecology Isolate type bundles.';
return $items;
}
}
class dHEcologyIsolateUIController extends EntityDefaultUIController {
public function hook_menu() {
$items = parent::hook_menu();
// Change the overview menu type for the list of models.
$items[$this->path]['type'] = MENU_LOCAL_TASK;
// Extend the 'add' path.
$items[$this->path . '/add'] = array(
'title callback' => 'entity_ui_get_action_title',
'title arguments' => array('add', $this->entityType),
'page callback' => 'entity_ui_bundle_add_page',
'page arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('create', $this->entityType),
'type' => MENU_LOCAL_ACTION,
);
$items[$this->path . '/add/%'] = array(
'title callback' => 'entity_ui_get_action_title',
'title arguments' => array('add', $this->entityType, $this->id_count + 1),
'page callback' => 'entity_ui_get_bundle_add_form',
'page arguments' => array($this->entityType, $this->id_count + 1),
'access callback' => 'entity_access',
'access arguments' => array('create', $this->entityType),
);
if (!empty($this->entityInfo['admin ui']['file'])) {
// Add in the include file for the entity form.
foreach (array('/add', '/add/%') as $path_end) {
$items[$this->path . $path_end]['file'] = $this->entityInfo['admin ui']['file'];
$items[$this->path . $path_end]['file path'] = isset($this->entityInfo['admin ui']['file path']) ? $this->entityInfo['admin ui']['file path'] : drupal_get_path('module', $this->entityInfo['module']);
}
}
return $items;
}
}
function dh_ecology_field_default_field_instances() {
$field_instances = array();
// Exported field_instance: 'om_data_table-om_data_table-field_om_data_starttime'
$field_instances['dh_ecology_isolate-modified'] = array(
'bundle' => 'dh_ecology_isolate',
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'date',
'settings' => array(
'format_type' => 'long',
'fromto' => 'both',
'multiple_from' => '',
'multiple_number' => '',
'multiple_to' => '',
),
'type' => 'date_default',
'weight' => 1,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'dh_ecology_isolate',
'field_name' => 'modified',
'label' => 'Time',
'required' => 0,
'settings' => array(
'default_value' => 'now',
'default_value2' => 'same',
'default_value_code' => '',
'default_value_code2' => '',
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'date',
'settings' => array(
'display_all_day' => 0,
'increment' => 15,
'input_format' => 'm/d/Y - H:i:s',
'input_format_custom' => '',
'label_position' => 'above',
'text_parts' => array(),
'year_range' => '-3:+3',
),
'type' => 'date_text',
'weight' => 1,
),
);
// Translatables
// Included for use with string extractors like potx.
t('Start Time');
return $field_instances;
}
// FORM Stuff
/**
* dH Isolate Type editing form.
*/
function dh_ecology_isolate_type_form($form, &$form_state, $dh_ecology_isolate_type, $op = 'edit') {
if ($op == 'clone') {
$dh_ecology_isolate_type->name .= ' (cloned)';
$dh_ecology_isolate_type->bundle = '';
}
$form['name'] = array(
'#title' => t('Admin Entity Name'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate_type->name,
'#description' => t('The human-readable name of this dH Feature type.'),
'#required' => TRUE,
'#size' => 30,
);
// Machine-readable type name.
$form['bundle'] = array(
'#title' => t('Bundle Name'),
'#type' => 'machine_name',
'#default_value' => isset($dh_ecology_isolate_type->bundle) ? $dh_ecology_isolate_type->bundle : '',
'#maxlength' => 32,
'#machine_name' => array(
'exists' => 'dh_ecology_isolate_get_types',
'source' => array('label'),
),
'#description' => t('A unique machine-readable name for this type. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['description'] = array(
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate_type->description,
'#description' => t('Detailed description of this dH Isolate type.'),
'#required' => FALSE,
'#size' => 255,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save dH Isolate type'),
'#weight' => 40,
);
return $form;
}
/**
* Form API submit callback for the type form.
*/
function dh_ecology_isolate_type_form_submit(&$form, &$form_state) {
$dh_ecology_isolate_type = entity_ui_form_submit_build_entity($form, $form_state);
$dh_ecology_isolate_type->save();
$form_state['redirect'] = 'admin/structure/dh_ecology_isolate_type';
}
/**
* dH Ecology editing form.
*/
function dh_ecology_isolate_form($form, &$form_state, $dh_ecology_isolate, $op = 'edit') {
if ($op == 'clone') {
$dh_ecology_isolate->name .= ' (cloned)';
$dh_ecology_isolate->bundle = '';
}
/* $form['iid'] = array(
'#title' => t('Isolate ID'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->iid,
'#description' => t('Primary key for Variables'),
'#required' => TRUE,
'#size' => 64,
);
*/
$form['isolate'] = array(
'#title' => t('Isolate Code'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->isolate,
'#description' => t('Unique Isolate Text ID code for sample.'),
'#required' => TRUE,
'#size' => 64,
);
$form['genus'] = array(
'#title' => t('Genus'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->genus,
'#description' => t('Identified Genus of sample DNA.'),
'#required' => FALSE,
'#size' => 64,
);
$form['species'] = array(
'#title' => t('Species'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->species,
'#description' => t('Identified Specific Epithet of sample DNA.'),
'#required' => FALSE,
'#size' => 64,
);
$form['ecology'] = array(
'#title' => t('Ecology'),
'#type' => 'select',
'#default_value' => $dh_ecology_isolate->ecology,
'#options' => array(
'unknown' => t('Unknown'),
'pathogen' => t('Pathogen'),
'nonpathogen' => t('Non-pathogen'),
),
'#description' => t('Ecology'),
'#required' => FALSE,
);
$form['host_organism'] = array(
'#title' => t('Host common name'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->host_organism,
'#description' => t('Common name of the host plant from which this organism was obtained.'),
'#required' => FALSE,
'#size' => 64,
);
$form['source'] = array(
'#title' => t('Sample Source'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->source,
'#description' => t('Sample Source.'),
'#required' => FALSE,
'#size' => 64,
);
$form['acquisition_num'] = array(
'#title' => t('Acquisition Number'),
'#type' => 'textfield',
'#default_value' => $dh_ecology_isolate->acquisition_num,
'#description' => t('Acquisition Number.'),
'#required' => FALSE,
'#size' => 64,
);
$form['sequence'] = array(
'#title' => t('DNA Sequence'),
'#type' => 'textarea',
'#default_value' => $dh_ecology_isolate->sequence,
'#description' => t('DNA Sequence.'),
'#required' => FALSE,
'#size' => 5,
);
if ( ($dh_ecology_isolate->sequence_location === null) or ($dh_ecology_isolate->sequence_location == '') ) {
if ($dh_ecology_isolate->bundle == 'dh_ecology_isolate') {
$dh_ecology_isolate->sequence_location = 'unknown';
} else {
$dh_ecology_isolate->sequence_location = $dh_ecology_isolate->bundle;
}
}
$locs = array(
'UNK' => 'Unknown',
'LSU' => 'LSU',
'SSU' => 'SSU',
'COX2' => 'COX2',
'ACT' => 'ACT',
'APN2' => 'APN2',
'CAL' => 'CAL',
'TUB2' => 'TUB2',
'CHS-1' => 'CHS-1',
'CO1' => 'CO1',
'GAPDH' => 'GAPDH',
'GS' => 'GS',
'TEF' => 'TEF',
'HIS3' => 'HIS3',
'SPD2' => 'SPD2',
'Ypt1' => 'Ypt1',
'MAT' => 'MAT',
'RPB1' => 'RPB1',
'RPB2' => 'RPB2',
'ITS' => 'ITS',
'IGS1' => 'IGS1',
);
$form['sequence_location'] = array(
'#title' => t('Sequence Location'),
'#type' => 'select',
'#default_value' => $dh_ecology_isolate->sequence_location,
'#description' => t("Sequence Location (use 'unknown' if unknown)."),
'#options' => $locs,
'#required' => FALSE,
'#maxlength' => 64,
);
$form['type_specimen'] = array(
'#title' => t('Type Specimen?'),
'#type' => 'select',
'#default_value' => $dh_ecology_isolate->type_specimen,
'#description' => t("When a study is published describing a species, the authors designate a single isolate as the essential member of that species, to which all other purported members of that species must be compared in order to confirm their identity."),
'#options' => array(0 => 'False', 1 => 'True'),
'#required' => FALSE,
'#maxlength' => 64,
);
// Machine-readable type name.
//$form['bundle'] = array(
// '#title' => t('Bundle Name'),
// '#type' => 'machine_name',
// '#default_value' => isset($dh_ecology_isolate->bundle) ? $dh_ecology_isolate->bundle : '',
// '#maxlength' => 32,
// '#machine_name' => array(
// 'exists' => 'dh_ecology_isolate_get_types',
// 'source' => array('label'),
// ),
// '#description' => t('A unique machine-readable name for this type. It must only contain //lowercase letters, numbers, and underscores.'),
//);
field_attach_form('dh_ecology_isolate', $dh_ecology_isolate, $form, $form_state);
$form['dh_link_isolate_mps']['#type'] = 'hidden';
$form['data']['#tree'] = TRUE;
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Isolate'),
'#weight' => 40,
);
switch ($op) {
case 'add':
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array('dh_lab_isolate_form_submit_cancel')
);
break;
case 'edit':
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array('dh_lab_isolate_form_submit_delete')
);
break;
}
return $form;
}
function dh_ecology_isolate_form_submit(&$form, &$form_state) {
// Form API submit callback for the type form.
$dh_ecology_isolate = entity_ui_form_submit_build_entity($form, $form_state);
$dh_ecology_isolate->save();
$form_state['redirect'] = 'admin/content/dh_ecology_isolate/';
}
?>