tripal_example.admin.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the functions used for administration of the module
  5. *
  6. */
  7. function tripal_example_admin_examples_listing() {
  8. $output = '';
  9. // set the breadcrumb
  10. $breadcrumb = array();
  11. $breadcrumb[] = l('Home', '<front>');
  12. $breadcrumb[] = l('Administration', 'admin');
  13. $breadcrumb[] = l('Tripal', 'admin/tripal');
  14. $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
  15. $breadcrumb[] = l('Examples', 'admin/tripal/legacy/tripal_example');
  16. drupal_set_breadcrumb($breadcrumb);
  17. // EXPLANATION: Typically for all Tripal modules the home administrative page
  18. // for the module contains a search form to help the adminstrator locate
  19. // records. The following example code adds a default View to the page
  20. /*
  21. // Add the view
  22. $view = views_embed_view('tripal_example_admin_examples','default');
  23. if (isset($view)) {
  24. $output .= $view;
  25. }
  26. else {
  27. $output .= '<p>The Tripal Example 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('Example Admin', 'admin/tripal/legacy/tripal_example/views/examples/enable').'</li>';
  33. $output .= '</ul>';
  34. }
  35. */
  36. $output = 'Typically a search view goes here';
  37. return $output;
  38. }
  39. /**
  40. * Administrative settings form
  41. *
  42. * @ingroup tripal_example
  43. */
  44. function tripal_example_admin() {
  45. $form = array();
  46. $form['nothing'] = array(
  47. '#markup' => t('There are currently no settings to configure.')
  48. );
  49. // If your module is using the Chado Node: Title & Path API to allow custom
  50. // titles for your node type then you need to add the configuration form for
  51. // this functionality. To do so, we first have to preapre a $details array
  52. // the describe our node type. Then we call the function to create the form
  53. // elements.
  54. $details = array(
  55. // the name of the MODULE implementing the content type
  56. 'module' => 'tripal_example',
  57. 'content_type' => 'chado_example',
  58. // An array of options to use under "Page Titles"
  59. // the key should be the token and the value should be the human-readable
  60. // option
  61. 'options' => array(
  62. '[example.name]' => 'Germplasm Name Only',
  63. '[example.uniquename]' => 'Germplasm Unique Name Only',
  64. // there should always be one options matching the unique constraint.
  65. // If you have a more human-readable constraint, then that is
  66. // preferable.
  67. // See the tripal feature module for a good example of this.
  68. '[example.example_id]' => 'Unique Constraint: The Chado ID for Examples'
  69. ),
  70. // the token indicating the unique constraint in the options array
  71. 'unique_option' => '[example.example_id]'
  72. );
  73. // This call adds the configuration form to your current form
  74. // This sub-form handles it's own validation & submit
  75. chado_add_admin_form_set_title($form, $form_state, $details);
  76. return system_settings_form($form);
  77. }
  78. /**
  79. *
  80. * @ingroup tripal_example
  81. */
  82. function tripal_example_admin_validate($form, &$form_state) {
  83. }