tripal_library.module 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /**
  3. * @file
  4. * Integrates the Chado Library module with Drupal Nodes & Views
  5. */
  6. /**
  7. * @defgroup tripal_library Library Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Integrates the Chado Library module with Drupal Nodes & Views
  11. * @}
  12. */
  13. require_once 'api/tripal_library.DEPRECATED.inc';
  14. require_once 'theme/tripal_library.theme.inc';
  15. require_once 'includes/tripal_library.admin.inc';
  16. require_once 'includes/tripal_library.chado_node.inc';
  17. /**
  18. * Implements hook_permission().
  19. *
  20. * Set the permission types that the chado module uses. Essentially we
  21. * want permissionis that protect creation, editing and deleting of chado
  22. * data objects
  23. *
  24. * @ingroup tripal_library
  25. */
  26. function tripal_library_permission() {
  27. return array(
  28. /*
  29. 'access chado_library content' => array(
  30. 'title' => t('View Libraries'),
  31. 'description' => t('Allow users to view library pages.'),
  32. ),
  33. 'create chado_library content' => array(
  34. 'title' => t('Create Libraries'),
  35. 'description' => t('Allow users to create new library pages.'),
  36. ),
  37. 'delete chado_library content' => array(
  38. 'title' => t('Delete Libraries'),
  39. 'description' => t('Allow users to delete library pages.'),
  40. ),
  41. 'edit chado_library content' => array(
  42. 'title' => t('Edit Libraries'),
  43. 'description' => t('Allow users to edit library pages.'),
  44. ),
  45. 'administer tripal library' => array(
  46. 'title' => t('Administer Libraries'),
  47. 'description' => t('Allow users to administer all libraries.'),
  48. ),
  49. */
  50. );
  51. }
  52. /**
  53. * Implements hook_menu().
  54. *
  55. * Menu items are automatically added for the new node types created
  56. * by this module to the 'Create Content' Navigation menu item. This function
  57. * adds more menu items needed for this module.
  58. *
  59. * @ingroup tripal_library
  60. */
  61. function tripal_library_menu() {
  62. $items = array();
  63. // The administative settings menu
  64. $items['admin/tripal/legacy/tripal_library'] = array(
  65. 'title' => 'Libraries',
  66. 'description' => 'Any biological library. Examples of genomic libraries include BAC, cDNA, FOSMID, etc.',
  67. 'page callback' => 'tripal_library_admin_libraries_listing',
  68. 'access arguments' => array('administer tripal library'),
  69. 'type' => MENU_NORMAL_ITEM,
  70. );
  71. $items['admin/tripal/legacy/tripal_library/help'] = array(
  72. 'title' => 'Help',
  73. 'description' => 'Basic Description of Tripal Library Module Functionality',
  74. 'page callback' => 'theme',
  75. 'page arguments' => array('tripal_library_help'),
  76. 'access arguments' => array('administer tripal library'),
  77. 'type' => MENU_LOCAL_TASK,
  78. 'weight' => 10
  79. );
  80. $items['admin/tripal/legacy/tripal_library/configuration'] = array(
  81. 'title' => 'Settings',
  82. 'description' => 'Configure the Tripal Library module',
  83. 'page callback' => 'drupal_get_form',
  84. 'page arguments' => array('tripal_library_admin'),
  85. 'access arguments' => array('administer tripal library'),
  86. 'type' => MENU_LOCAL_TASK,
  87. 'weight' => 5
  88. );
  89. $items['admin/tripal/legacy/tripal_library/sync'] = array(
  90. 'title' => ' Sync',
  91. 'description' => 'Create pages on this site for libraries stored in Chado',
  92. 'page callback' => 'drupal_get_form',
  93. 'page arguments' => array('chado_node_sync_form', 'tripal_library', 'chado_library'),
  94. 'access arguments' => array('administer tripal library'),
  95. 'type' => MENU_LOCAL_TASK,
  96. 'weight' => 2
  97. );
  98. $items['admin/tripal/legacy/tripal_library/chado_library_toc'] = array(
  99. 'title' => ' TOC',
  100. 'description' => 'Manage the table of contents for library nodes.',
  101. 'page callback' => 'drupal_get_form',
  102. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_library'),
  103. 'access arguments' => array('administer tripal library'),
  104. 'type' => MENU_LOCAL_TASK,
  105. 'file' => 'includes/tripal_core.toc.inc',
  106. 'file path' => drupal_get_path('module', 'tripal_core'),
  107. 'weight' => 3
  108. );
  109. $items['admin/tripal/legacy/tripal_library/views/libraries/enable'] = array(
  110. 'title' => 'Enable Library Administrative View',
  111. 'page callback' => 'tripal_enable_view',
  112. 'page arguments' => array('tripal_library_admin_libraries', 'admin/tripal/legacy/tripal_library'),
  113. 'access arguments' => array('administer tripal library'),
  114. 'type' => MENU_CALLBACK,
  115. );
  116. */
  117. return $items;
  118. }
  119. /**
  120. * Implements hook_search_biological_data_views().
  121. *
  122. * Adds the described views to the "Search Data" Page created by Tripal Views
  123. */
  124. function tripal_library_search_biological_data_views() {
  125. return array(
  126. 'tripal_library_user_library' => array(
  127. 'machine_name' => 'tripal_library_user_library',
  128. 'human_name' => 'Libraries',
  129. 'description' => 'Biological library including BAC, cDNA, FOSMID, etc.',
  130. 'link' => 'chado/library'
  131. ),
  132. );
  133. }
  134. /**
  135. * Implements hook_views_api().
  136. *
  137. * Essentially this hook tells drupal that there is views support for
  138. * for this module which then includes tripal_db.views.inc where all the
  139. * views integration code is
  140. *
  141. * @ingroup tripal_library
  142. */
  143. function tripal_library_views_api() {
  144. return array(
  145. 'api' => 3.0,
  146. );
  147. }
  148. /**
  149. * Implements hook_theme().
  150. *
  151. * We need to let drupal know about our theme functions and their arguments.
  152. * We create theme functions to allow users of the module to customize the
  153. * look and feel of the output generated in this module
  154. *
  155. * @ingroup tripal_library
  156. */
  157. function tripal_library_theme($existing, $type, $theme, $path) {
  158. $core_path = drupal_get_path('module', 'tripal_core');
  159. $items = array(
  160. 'node__chado_library' => array(
  161. 'template' => 'node--chado-generic',
  162. 'render element' => 'node',
  163. 'base hook' => 'node',
  164. 'path' => "$core_path/theme/templates",
  165. ),
  166. // tripal_library templates
  167. 'tripal_library_base' => array(
  168. 'variables' => array('node' => NULL),
  169. 'template' => 'tripal_library_base',
  170. 'path' => "$path/theme/templates",
  171. ),
  172. 'tripal_library_features' => array(
  173. 'variables' => array('node' => NULL),
  174. 'template' => 'tripal_library_features',
  175. 'path' => "$path/theme/templates",
  176. ),
  177. 'tripal_library_properties' => array(
  178. 'variables' => array('node' => NULL),
  179. 'template' => 'tripal_library_properties',
  180. 'path' => "$path/theme/templates",
  181. ),
  182. 'tripal_library_publications' => array(
  183. 'variables' => array('node' => NULL),
  184. 'template' => 'tripal_library_publications',
  185. 'path' => "$path/theme/templates",
  186. ),
  187. 'tripal_library_references' => array(
  188. 'variables' => array('node' => NULL),
  189. 'template' => 'tripal_library_references',
  190. 'path' => "$path/theme/templates",
  191. ),
  192. 'tripal_library_synonyms' => array(
  193. 'variables' => array('node' => NULL),
  194. 'template' => 'tripal_library_synonyms',
  195. 'path' => "$path/theme/templates",
  196. ),
  197. 'tripal_library_terms' => array(
  198. 'variables' => array('node' => NULL),
  199. 'template' => 'tripal_library_terms',
  200. 'path' => "$path/theme/templates",
  201. ),
  202. 'tripal_library_help' => array(
  203. 'template' => 'tripal_library_help',
  204. 'variables' => array(NULL),
  205. 'path' => "$path/theme/templates",
  206. ),
  207. // teaser
  208. 'tripal_library_teaser' => array(
  209. 'variables' => array('node' => NULL),
  210. 'template' => 'tripal_library_teaser',
  211. 'path' => "$path/theme/templates",
  212. ),
  213. // tripal_organism templates
  214. 'tripal_organism_libraries' => array(
  215. 'variables' => array('node' => NULL),
  216. 'template' => 'tripal_organism_libraries',
  217. 'path' => "$path/theme/templates",
  218. ),
  219. // tripal_feature templates
  220. 'tripal_feature_libraries' => array(
  221. 'variables' => array('node' => NULL),
  222. 'template' => 'tripal_feature_libraries',
  223. 'path' => "$path/theme/templates",
  224. ),
  225. );
  226. return $items;
  227. }
  228. /**
  229. * Implements hook_help().
  230. * Adds a help page to the module list
  231. *
  232. * @ingroup tripal_library
  233. */
  234. function tripal_library_help ($path, $arg) {
  235. if ($path == 'admin/help#tripal_library') {
  236. return theme('tripal_library_help', array());
  237. }
  238. }
  239. /**
  240. * Implementation of hook_form_alter().
  241. *
  242. * @param $form
  243. * @param $form_state
  244. * @param $form_id
  245. *
  246. * @ingroup tripal_library
  247. */
  248. function tripal_library_form_alter(&$form, &$form_state, $form_id) {
  249. if ($form_id == "chado_library_node_form") {
  250. // turn of preview button for insert/updates
  251. $form['actions']['preview']['#access'] = FALSE;
  252. //remove the body field
  253. unset($form['body']);
  254. }
  255. }