tripal_library.module 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /**
  3. * @file
  4. * Integrates the Chado Library module with Drupal Nodes & Views
  5. */
  6. /**
  7. * @defgroup tripal_legacy_library Library Module
  8. * @ingroup tripal_legacy_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_legacy_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_legacy_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. return $items;
  117. }
  118. /**
  119. * Implements hook_search_biological_data_views().
  120. *
  121. * Adds the described views to the "Search Data" Page created by Tripal Views
  122. */
  123. function tripal_library_search_biological_data_views() {
  124. return array(
  125. 'tripal_library_user_library' => array(
  126. 'machine_name' => 'tripal_library_user_library',
  127. 'human_name' => 'Libraries',
  128. 'description' => 'Biological library including BAC, cDNA, FOSMID, etc.',
  129. 'link' => 'chado/library'
  130. ),
  131. );
  132. }
  133. /**
  134. * Implements hook_views_api().
  135. *
  136. * Essentially this hook tells drupal that there is views support for
  137. * for this module which then includes tripal_db.views.inc where all the
  138. * views integration code is
  139. *
  140. * @ingroup tripal_legacy_library
  141. */
  142. function tripal_library_views_api() {
  143. return array(
  144. 'api' => 3.0,
  145. );
  146. }
  147. /**
  148. * Implements hook_theme().
  149. *
  150. * We need to let drupal know about our theme functions and their arguments.
  151. * We create theme functions to allow users of the module to customize the
  152. * look and feel of the output generated in this module
  153. *
  154. * @ingroup tripal_legacy_library
  155. */
  156. function tripal_library_theme($existing, $type, $theme, $path) {
  157. $core_path = drupal_get_path('module', 'tripal_core');
  158. $items = array(
  159. 'node__chado_library' => array(
  160. 'template' => 'node--chado-generic',
  161. 'render element' => 'node',
  162. 'base hook' => 'node',
  163. 'path' => "$core_path/theme/templates",
  164. ),
  165. // tripal_library templates
  166. 'tripal_library_base' => array(
  167. 'variables' => array('node' => NULL),
  168. 'template' => 'tripal_library_base',
  169. 'path' => "$path/theme/templates",
  170. ),
  171. 'tripal_library_features' => array(
  172. 'variables' => array('node' => NULL),
  173. 'template' => 'tripal_library_features',
  174. 'path' => "$path/theme/templates",
  175. ),
  176. 'tripal_library_properties' => array(
  177. 'variables' => array('node' => NULL),
  178. 'template' => 'tripal_library_properties',
  179. 'path' => "$path/theme/templates",
  180. ),
  181. 'tripal_library_publications' => array(
  182. 'variables' => array('node' => NULL),
  183. 'template' => 'tripal_library_publications',
  184. 'path' => "$path/theme/templates",
  185. ),
  186. 'tripal_library_references' => array(
  187. 'variables' => array('node' => NULL),
  188. 'template' => 'tripal_library_references',
  189. 'path' => "$path/theme/templates",
  190. ),
  191. 'tripal_library_synonyms' => array(
  192. 'variables' => array('node' => NULL),
  193. 'template' => 'tripal_library_synonyms',
  194. 'path' => "$path/theme/templates",
  195. ),
  196. 'tripal_library_terms' => array(
  197. 'variables' => array('node' => NULL),
  198. 'template' => 'tripal_library_terms',
  199. 'path' => "$path/theme/templates",
  200. ),
  201. 'tripal_library_help' => array(
  202. 'template' => 'tripal_library_help',
  203. 'variables' => array(NULL),
  204. 'path' => "$path/theme/templates",
  205. ),
  206. // teaser
  207. 'tripal_library_teaser' => array(
  208. 'variables' => array('node' => NULL),
  209. 'template' => 'tripal_library_teaser',
  210. 'path' => "$path/theme/templates",
  211. ),
  212. // tripal_organism templates
  213. 'tripal_organism_libraries' => array(
  214. 'variables' => array('node' => NULL),
  215. 'template' => 'tripal_organism_libraries',
  216. 'path' => "$path/theme/templates",
  217. ),
  218. // tripal_feature templates
  219. 'tripal_feature_libraries' => array(
  220. 'variables' => array('node' => NULL),
  221. 'template' => 'tripal_feature_libraries',
  222. 'path' => "$path/theme/templates",
  223. ),
  224. );
  225. return $items;
  226. }
  227. /**
  228. * Implements hook_help().
  229. * Adds a help page to the module list
  230. *
  231. * @ingroup tripal_legacy_library
  232. */
  233. function tripal_library_help ($path, $arg) {
  234. if ($path == 'admin/help#tripal_library') {
  235. return theme('tripal_library_help', array());
  236. }
  237. }
  238. /**
  239. * Implementation of hook_form_alter().
  240. *
  241. * @param $form
  242. * @param $form_state
  243. * @param $form_id
  244. *
  245. * @ingroup tripal_legacy_library
  246. */
  247. function tripal_library_form_alter(&$form, &$form_state, $form_id) {
  248. if ($form_id == "chado_library_node_form") {
  249. // turn of preview button for insert/updates
  250. $form['actions']['preview']['#access'] = FALSE;
  251. //remove the body field
  252. unset($form['body']);
  253. }
  254. }