Tripal Plant PopGen Submit
page_1_helper.php
Go to the documentation of this file.
1 <?php
2 
19 function tpps_user_info(array &$form, array $values) {
20  // dpm($values);
21  $form['primaryAuthor'] = array(
22  '#type' => 'textfield',
23  '#title' => t('Primary Author: *'),
24  '#autocomplete_path' => 'tpps/autocomplete/author',
25  '#attributes' => array(
26  'data-toggle' => array('tooltip'),
27  'data-placement' => array('right'),
28  'title' => array('First Author of the publication'),
29  ),
30  );
31  if(isset($values['primaryAuthor']) && $values['primaryAuthor'] != "") {
32  $form['primaryAuthor']['#value'] = $values['primaryAuthor'];
33  }
34 
35  $form['organization'] = array(
36  '#type' => 'textfield',
37  '#title' => t('Organization: *'),
38  '#autocomplete_path' => 'tpps/autocomplete/organization',
39  '#attributes' => array(
40  'data-toggle' => array('tooltip'),
41  'data-placement' => array('right'),
42  'title' => array('Organization of the Primary Author'),
43  ),
44  );
45 
46  return $form;
47 }
48 
65 function tpps_publication(array &$form, array $values, array $form_state) {
66 
67  $form['publication'] = array(
68  '#type' => 'fieldset',
69  '#title' => t('<div class="fieldset-title">Publication Information:</div>'),
70  '#tree' => TRUE,
71  '#collapsible' => TRUE,
72  );
73 
74  tpps_secondary_authors($form, $values, $form_state);
75 
76  $form['publication']['status'] = array(
77  '#type' => 'select',
78  '#title' => t('Publication Status: *'),
79  '#options' => array(
80  0 => t('- Select -'),
81  'In Preparation or Submitted' => t('In Preparation or Submitted'),
82  'In Press' => t('In Press'),
83  'Published' => t('Published'),
84  ),
85  '#ajax' => array(
86  'callback' => 'tpps_pub_status',
87  'wrapper' => 'pubyear',
88  ),
89  );
90 
91  tpps_year($form, $values, $form_state);
92 
93  $form['publication']['title'] = array(
94  '#type' => 'textfield',
95  '#title' => t('Title of Publication/Study: *'),
96  );
97  // if(isset($values['publication']['title']) && $values['publication']['title'] != "") {
98  // $form['publication']['title']['#value'] = $values['publication']['title'];
99  // }
100 
101  $form['publication']['abstract'] = array(
102  '#type' => 'textarea',
103  '#title' => t('Abstract/Description: *'),
104  );
105  // if(isset($values['publication']['abstract']) && $values['publication']['abstract'] != "") {
106  // $form['publication']['abstract']['#value'] = $values['publication']['abstract'];
107  // }
108 
109  $form['publication']['journal'] = array(
110  '#type' => 'textfield',
111  '#title' => t('Journal: *'),
112  '#autocomplete_path' => 'tpps/autocomplete/journal',
113  );
114  if(isset($values['publication']['journal']) && $values['publication']['journal'] != "") {
115  $form['publication']['journal']['#value'] = $values['publication']['journal'];
116  }
117 
118  return $form;
119 }
120 
132 function tpps_organism(array &$form, array &$form_state) {
133 
134  $field = array(
135  '#type' => 'fieldset',
136  '#title' => "Species !num",
137  'name' => array(
138  '#type' => 'textfield',
139  '#autocomplete_path' => 'tpps/autocomplete/species',
140  '#attributes' => array(
141  'data-toggle' => array('tooltip'),
142  'data-placement' => array('right'),
143  'title' => array('If your species is not in the autocomplete list, don\'t worry about it! We will create a new organism entry in the database for you.'),
144  ),
145  ),
146  'is_tree' => array(
147  '#type' => 'checkbox',
148  '#title' => t('This species is a tree.'),
149  '#default_value' => 1,
150  ),
151  );
152 
153  tpps_dynamic_list($form, $form_state, 'organism', $field, array(
154  'label' => 'Organism',
155  'default' => 1,
156  'substitute_fields' => array(
157  '#title',
158  ),
159  ));
160 
161  return $form;
162 }
163 
180 function tpps_year(array &$form, array $values, array $form_state) {
181 
182  if (isset($form_state['values']['publication']['status']) and $form_state['values']['publication']['status'] != '0') {
183  $pub_status = $form_state['values']['publication']['status'];
184  }
185  elseif (isset($form_state['saved_values'][TPPS_PAGE_1]['publication']['status']) and $form_state['saved_values'][TPPS_PAGE_1]['publication']['status'] != '0') {
186  $pub_status = $form_state['saved_values'][TPPS_PAGE_1]['publication']['status'];
187  }
188 
189  if (isset($pub_status) and $pub_status != 'Published') {
190  $yearArr = array(0 => '- Select -');
191  for ($i = 2017; $i <= date('Y') + 1; $i++) {
192  $yearArr[$i] = "$i";
193  }
194  }
195  elseif (isset($pub_status)) {
196  $yearArr = array(0 => '- Select -');
197  for ($i = 1990; $i <= date('Y'); $i++) {
198  $yearArr[$i] = "$i";
199  }
200  }
201  else {
202  $yearArr = array(0 => '- Select -');
203  }
204 
205  $form['publication']['year'] = array(
206  '#type' => 'select',
207  '#title' => t('Year of Publication: *'),
208  '#options' => $yearArr,
209  '#states' => array(
210  'invisible' => array(
211  ':input[name="publication[status]"]' => array('value' => '0'),
212  ),
213  ),
214  '#description' => t('If your publication has not been published yet, please choose the expected year of publication.'),
215  '#prefix' => '<div id="pubyear">',
216  '#suffix' => '</div>',
217  );
218  // if(isset($values['publication']['year'])) {
219  // $form['publication']['year']['#value'] = $values['publication']['year'];
220  // }
221 
222  return $form;
223 }
224 
238 function tpps_secondary_authors(array &$form, array $values, array $form_state) {
239  $field = array(
240  '#type' => 'textfield',
241  '#title' => "Secondary Author !num",
242  '#autocomplete_path' => 'tpps/autocomplete/author',
243  );
244 
245  tpps_dynamic_list($form, $form_state, 'secondaryAuthors', $field, array(
246  'label' => 'Secondary Author',
247  'callback' => 'tpps_authors_callback',
248  'substitute_fields' => array(
249  '#title',
250  ),
251  'parents' => array(
252  'publication',
253  ),
254  ));
255 
256  $form['publication']['secondaryAuthors']['#title'] = "<div class=\"fieldset-title\" style=\"font-size:.8em\">Secondary Author Information</div>";
257 
258  return $form;
259 }
const TPPS_PAGE_1
Definition: tpps.module:12
tpps_dynamic_list(array &$form, array &$form_state, $id, array $repeat, array $options=array())
Definition: form_utils.inc:29
tpps_year(array &$form, array $values, array $form_state)
tpps_secondary_authors(array &$form, array $values, array $form_state)
tpps_publication(array &$form, array $values, array $form_state)
tpps_organism(array &$form, array &$form_state)
tpps_user_info(array &$form, array $values)