tripal_example.module 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. /**
  3. * @file
  4. * This file contains all Drupal hooks for the module other than any
  5. * node hooks and block hooks. Those go in the [module name].chado_node.inc file
  6. * and [module_name].blocks.inc respectively
  7. *
  8. */
  9. /*
  10. // include any files that might be required
  11. require('api/tripal_example.api.inc');
  12. require('theme/tripal_example.theme.inc');
  13. require('includes/tripal_example.admin.inc');
  14. require('includes/tripal_example.chado_node.inc');
  15. */
  16. /**
  17. * Set the permission types that the chado module uses. Essentially we
  18. * want permissionis that protect creation, editing and deleting of chado
  19. * data objects
  20. *
  21. * @ingroup tripal_example
  22. */
  23. function tripal_example_permisssions() {
  24. /*
  25. return array(
  26. 'access chado_example content' => array(
  27. 'title' => t('View Examples'),
  28. 'description' => t('Allow users to view example pages.'),
  29. ),
  30. 'create chado_example content' => array(
  31. 'title' => t('Create Examples'),
  32. 'description' => t('Allow users to create new example pages.'),
  33. ),
  34. 'delete chado_example content' => array(
  35. 'title' => t('Delete Examples'),
  36. 'description' => t('Allow users to delete example pages.'),
  37. ),
  38. 'edit chado_example content' => array(
  39. 'title' => t('Edit Examples'),
  40. 'description' => t('Allow users to edit example pages.'),
  41. ),
  42. 'adminster tripal example' => array(
  43. 'title' => t('Administer Examples'),
  44. 'description' => t('Allow users to administer all examples.'),
  45. ),
  46. );
  47. */
  48. }
  49. /**
  50. * Menu items are automatically added for the new node types created
  51. * by this module to the 'Create Content' Navigation menu item. This function
  52. * adds more menu items needed for this module.
  53. *
  54. * @ingroup tripal_example
  55. */
  56. function tripal_example_menu() {
  57. $items = array();
  58. /*
  59. // The administative settings menu
  60. $items['admin/tripal/chado/tripal_example'] = array(
  61. 'title' => 'Examples',
  62. 'description' => 'Any example.',
  63. 'page callback' => 'tripal_example_admin_examples_listing',
  64. 'access arguments' => array('administer tripal example'),
  65. 'type' => MENU_NORMAL_ITEM,
  66. );
  67. $items['admin/tripal/chado/tripal_example/help'] = array(
  68. 'title' => 'Help',
  69. 'description' => 'Basic Description of Tripal Library Module Functionality',
  70. 'page callback' => 'theme',
  71. 'page arguments' => array('tripal_example_help'),
  72. 'access arguments' => array('administer tripal example'),
  73. 'type' => MENU_LOCAL_TASK,
  74. 'weight' => 10
  75. );
  76. $items['admin/tripal/chado/tripal_example/configuration'] = array(
  77. 'title' => 'Settings',
  78. 'description' => 'Configure the Tripal Library module',
  79. 'page callback' => 'drupal_get_form',
  80. 'page arguments' => array('tripal_example_admin'),
  81. 'access arguments' => array('administer tripal example'),
  82. 'type' => MENU_LOCAL_TASK,
  83. 'weight' => 5
  84. );
  85. $items['admin/tripal/chado/tripal_example/sync'] = array(
  86. 'title' => ' Sync',
  87. 'description' => 'Create pages on this site for examples stored in Chado',
  88. 'page callback' => 'drupal_get_form',
  89. 'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_example', 'chado_example'),
  90. 'access arguments' => array('administer tripal example'),
  91. 'type' => MENU_LOCAL_TASK,
  92. 'weight' => 2
  93. );
  94. $items['admin/tripal/chado/tripal_example/views/examples/enable'] = array(
  95. 'title' => 'Enable Library Administrative View',
  96. 'page callback' => 'tripal_views_admin_enable_view',
  97. 'page arguments' => array('tripal_example_admin_examples', 'admin/tripal/chado/tripal_example'),
  98. 'access arguments' => array('administer tripal example'),
  99. 'type' => MENU_CALLBACK,
  100. );
  101. */
  102. return $items;
  103. }
  104. /**
  105. * Implements hook_views_api()
  106. * Purpose: Essentially this hook tells drupal that there is views support for
  107. * for this module which then includes tripal_db.views.inc where all the
  108. * views integration code is
  109. *
  110. * @ingroup tripal_example
  111. */
  112. function tripal_example_views_api() {
  113. return array(
  114. 'api' => 3.0,
  115. );
  116. }
  117. /**
  118. * We need to let drupal know about our theme functions and their arguments.
  119. * We create theme functions to allow users of the module to customize the
  120. * look and feel of the output generated in this module
  121. *
  122. * @ingroup tripal_example
  123. */
  124. function tripal_example_theme($existing, $type, $theme, $path) {
  125. $core_path = drupal_get_path('module', 'tripal_core');
  126. /*
  127. $items = array(
  128. 'node__chado_example' => array(
  129. 'template' => 'node--chado-generic',
  130. 'render element' => 'node',
  131. 'base hook' => 'node',
  132. 'path' => "$core_path/theme",
  133. ),
  134. // tripal_example templates
  135. 'tripal_example_base' => array(
  136. 'variables' => array('node' => NULL),
  137. 'template' => 'tripal_example_base',
  138. 'path' => "$path/theme/tripal_example",
  139. ),
  140. 'tripal_example_properties' => array(
  141. 'variables' => array('node' => NULL),
  142. 'template' => 'tripal_example_properties',
  143. 'path' => "$path/theme/tripal_example",
  144. ),
  145. 'tripal_example_publications' => array(
  146. 'variables' => array('node' => NULL),
  147. 'template' => 'tripal_example_publications',
  148. 'path' => "$path/theme/tripal_example",
  149. ),
  150. 'tripal_example_references' => array(
  151. 'variables' => array('node' => NULL),
  152. 'template' => 'tripal_example_references',
  153. 'path' => "$path/theme/tripal_example",
  154. ),
  155. 'tripal_example_synonyms' => array(
  156. 'variables' => array('node' => NULL),
  157. 'template' => 'tripal_example_synonyms',
  158. 'path' => "$path/theme/tripal_example",
  159. ),
  160. 'tripal_example_terms' => array(
  161. 'variables' => array('node' => NULL),
  162. 'template' => 'tripal_example_terms',
  163. 'path' => "$path/theme/tripal_example",
  164. ),
  165. 'tripal_example_help' => array(
  166. 'template' => 'tripal_example_help',
  167. 'variables' => array(NULL),
  168. 'path' => "$path/theme",
  169. ),
  170. // teaser
  171. 'tripal_example_teaser' => array(
  172. 'variables' => array('node' => NULL),
  173. 'template' => 'tripal_example_teaser',
  174. 'path' => "$path/theme/tripal_example",
  175. ),
  176. // tripal_organism templates
  177. 'tripal_organism_examples' => array(
  178. 'variables' => array('node' => NULL),
  179. 'template' => 'tripal_organism_examples',
  180. 'path' => "$path/theme/tripal_organism",
  181. ),
  182. // tripal_feature templates
  183. 'tripal_feature_examples' => array(
  184. 'variables' => array('node' => NULL),
  185. 'template' => 'tripal_feature_examples',
  186. 'path' => "$path/theme/tripal_feature",
  187. ),
  188. );
  189. */
  190. return $items;
  191. }
  192. /**
  193. * Implements hook_help()
  194. * Purpose: Adds a help page to the module list
  195. */
  196. function tripal_example_help ($path, $arg) {
  197. if ($path == 'admin/help#tripal_example') {
  198. return theme('tripal_example_help', array());
  199. }
  200. }
  201. /**
  202. *
  203. * @ingroup tripal_example
  204. */
  205. function tripal_example_cron() {
  206. }
  207. /**
  208. * Implementation of hook_form_alter()
  209. *
  210. * @param $form
  211. * @param $form_state
  212. * @param $form_id
  213. */
  214. function tripal_example_form_alter(&$form, &$form_state, $form_id) {
  215. // turn of preview button for insert/updates
  216. if ($form_id == "chado_example_node_form") {
  217. $form['actions']['preview']['#access'] = FALSE;
  218. }
  219. }