tripal_project.admin.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * @file
  4. * Administration of projects
  5. */
  6. /**
  7. * Admin launchpad
  8. *
  9. * @ingroup tripal_project
  10. */
  11. function tripal_project_admin_project_view() {
  12. $output = '';
  13. // set the breadcrumb
  14. $breadcrumb = array();
  15. $breadcrumb[] = l('Home', '<front>');
  16. $breadcrumb[] = l('Administration', 'admin');
  17. $breadcrumb[] = l('Tripal', 'admin/tripal');
  18. $breadcrumb[] = l('Chado', 'admin/tripal/chado');
  19. $breadcrumb[] = l('Projects', 'admin/tripal/chado/tripal_project');
  20. drupal_set_breadcrumb($breadcrumb);
  21. // Add the view
  22. $view = views_embed_view('tripal_project_admin_projects','default');
  23. if (isset($view)) {
  24. $output .= $view;
  25. }
  26. else {
  27. $output .= '<p>The Project module uses primarily views to provide an '
  28. . 'administrative interface. Currently one or more views needed for this '
  29. . 'administrative interface are disabled. <strong>Click each of the following links to '
  30. . 'enable the pertinent views</strong>:</p>';
  31. $output .= '<ul>';
  32. $output .= '<li>'.l('Projects View', 'admin/tripal/chado/tripal_project/views/projects/enable').'</li>';
  33. $output .= '</ul>';
  34. }
  35. return $output;
  36. }
  37. /**
  38. * Project settings
  39. *
  40. * @ingroup tripal_project
  41. */
  42. function tripal_project_admin($form, $form_state) {
  43. $form = array();
  44. // project URL PATHS
  45. $form['url'] = array(
  46. '#type' => 'fieldset',
  47. '#title' => t('Project URL Path'),
  48. '#collapsible' => TRUE,
  49. '#collapsed' => FALSE,
  50. );
  51. $options = array(
  52. 'project' => 'project:' . t('Chado table name'),
  53. 'SID[id]' => '[id]:' . t('The Chado project_id'),
  54. '[name]' => '[name]:' . t('The project name'),
  55. );
  56. $form['url']['options'] = array(
  57. '#type' => 'item',
  58. '#title' => 'Available Tokens',
  59. '#markup' => '<ul><li>' . implode('</li><li>', $options) . '</li></ul>'
  60. );
  61. $form['url']['chado_project_url_string'] = array(
  62. '#title' => 'URL Syntax',
  63. '#type' => 'textfield',
  64. '#description' => t('You may rearrange elements in this text box to '.
  65. 'customize the URLs. The available tags are listed below. You can separate or '.
  66. 'include any text between the tags. Click the "Set project URLs" button to '.
  67. 'reset the URLs for all project pages. Click the "Save Configuration" button to '.
  68. 'simply save this setup. <b>Important</b>: be sure that whatever you choose will '.
  69. 'always be unique even considering future data that may be added. If you include '.
  70. 'the Chado table name and id you are guaranteed to have a unique URL. For example project/[id]'),
  71. '#size' => 150,
  72. '#default_value' => variable_get('chado_project_url_string', '/project/[id]'),
  73. );
  74. $form['url']['button'] = array(
  75. '#type' => 'submit',
  76. '#value' => t('Set Project URLs'),
  77. );
  78. return system_settings_form($form);
  79. }
  80. /**
  81. * Validate project settings
  82. *
  83. * @ingroup tripal_project
  84. */
  85. function tripal_project_admin_validate($form, &$form_state) {
  86. global $user; // we need access to the user info
  87. $job_args = array();
  88. switch ($form_state['values']['op']) {
  89. case t('Set Project URLs') :
  90. variable_set('chado_project_url', $form_state['values']['chado_project_url_string']);
  91. tripal_add_job('Set Project URLs', 'tripal_project',
  92. 'tripal_project_set_urls', $job_args, $user->uid);
  93. break;
  94. }
  95. }