tripal_library.module

  1. 2.x tripal_library/tripal_library.module
  2. 3.x legacy/tripal_library/tripal_library.module
  3. 1.x tripal_library/tripal_library.module

Integrates the Chado Library module with Drupal Nodes & Views

File

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