Tripal Plant PopGen Submit
front.php
Go to the documentation of this file.
1 <?php
2 
27 function tpps_front_create_form(array &$form, array $form_state) {
28 
29  global $base_url;
30  global $user;
31 
32  if (isset($user->mail)) {
33  // Logged in.
34  $options_arr = array();
35  $options_arr['new'] = 'Create new TPPS Submission';
36 
37  $states = tpps_load_submission_multiple(array('status' => 'Incomplete', 'uid' => $user->uid));
38 
39  foreach ($states as $state) {
40  if (empty($state['tpps_type']) or $state['tpps_type'] != 'tppsc') {
41  if ($state != NULL and isset($state['saved_values'][TPPS_PAGE_1]['publication']['title'])) {
42  $title = ($state['saved_values'][TPPS_PAGE_1]['publication']['title'] != NULL) ? $state['saved_values'][TPPS_PAGE_1]['publication']['title'] : "No Title";
43  $tgdr_id = $state['accession'];
44  $options_arr["$tgdr_id"] = "$title";
45  }
46  else {
47  if (isset($state) and !isset($state['saved_values'][TPPS_PAGE_1])) {
48  tpps_delete_submission($state['accession'], FALSE);
49  }
50  }
51  }
52  }
53 
54  if (count($options_arr) > 1) {
55  // Has submissions.
56  $form['accession'] = array(
57  '#type' => 'select',
58  '#title' => t('Would you like to load an old TPPS submission, or create a new one?'),
59  '#options' => $options_arr,
60  '#default_value' => isset($form_state['saved_values']['frontpage']['accession']) ? $form_state['saved_values']['frontpage']['accession'] : 'new',
61  );
62  }
63  }
64 
65  $form['Next'] = array(
66  '#type' => 'submit',
67  '#value' => t('Continue to TPPS'),
68  );
69 
70  $image_path = drupal_get_path('module', 'tpps') . '/images/';
71  $prefix_text = "<div>Welcome to TPPS!<br><br>The Tripal PopGen Submit (TPPS) workflow provides researchers with a streamlined submission interface for studies resulting from any combination of genotype, phenotype, and environmental data for georeferenced forest trees. ";
72  $prefix_text .= "You can <a href='/tpps_details/main'><b>view completed studies here</b></a> or pick up where you left off by using the dropdown box found <a href='#tpps_begin_options'><b>here</b></a> (below). Visit the <a href='https://tpps.readthedocs.io/en/latest/index.html'><b>full manual</b></a> for more details and help.<br />";
73  $prefix_text .= "<figure style=\"text-align:center;\"><img style=\"max-height:100%;max-width:100%;\" src=\"{$image_path}TPPS_front_diagram.png\"></figure>";
74  $prefix_text .= "TPPS has documentation to assist users with the process of creating a submission, which can be accessed <a target=\"blank\" href=\"https://tpps.readthedocs.io/en/latest/user.html\">here</a>.<br><br></div>";
75  $prefix_text .= "<div id='tpps_begin_options'>";
76  $suffix_text = "</div>";
77  if (isset($form['accession'])) {
78  $form['accession']['#prefix'] = $prefix_text;
79  $form['accession']['#suffix'] = $suffix_text;
80  }
81  else {
82  $form['Next']['#prefix'] = $prefix_text;
83  }
84 
85  return $form;
86 }
const TPPS_PAGE_1
Definition: tpps.module:10
tpps_front_create_form(array &$form, array $form_state)
Definition: front.php:27
tpps_delete_submission($accession, $redirect=TRUE)
tpps_load_submission_multiple(array $conditions=array(), $state=TRUE)
Definition: submissions.inc:68