tripal_pub.module 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. /**
  3. * @file
  4. * Basic functionality of the pub module
  5. */
  6. /**
  7. * @defgroup tripal_legacy_pub Legacy Publication Module
  8. * @ingroup tripal_legacy_modules
  9. * @{
  10. * Integrates the Chado Publication module with Drupal Nodes & Views, as well as, provides
  11. * the ability to import publication from PubMed
  12. *
  13. * The Tripal Publication module allows you to search the PubMed database for academic articles,
  14. * that relate to user specified topic\s. As well, it allows management of publications so that
  15. * a user can enter specified details regarding a desired publication. This allows all of the important
  16. * information that is unique to a Academic Publication to be stored for access.
  17. * @}
  18. */
  19. require_once 'api/tripal_pub.DEPRECATED.inc';
  20. require_once 'theme/tripal_pub.theme.inc';
  21. require_once 'includes/tripal_pub.admin.inc';
  22. require_once 'includes/tripal_pub.chado_node.inc';
  23. /**
  24. * Implements hook_menu().
  25. *
  26. * Adds menu items for the tripal_pub module menu. This section
  27. * gives the outline for the main menu of the Tripal-Publication module
  28. *
  29. * @return
  30. * An array of menu items that is visible within the Drupal Menu, returned as soon
  31. * as the program is ran
  32. *
  33. * @ingroup tripal_legacy_pub
  34. */
  35. function tripal_pub_menu() {
  36. $items = array();
  37. // because the publication search is not views we need to manually add
  38. // it to the Search Data list in the navigation menu
  39. $items['chado/publication' ]= array(
  40. 'title' => 'Publications',
  41. 'description' => ('Publications such as journal articles, conference proceedings, or other media.'),
  42. 'page callback' => 'tripal_pub_search_page',
  43. 'access arguments' => array('access chado_pub content'),
  44. 'type' => MENU_NORMAL_ITEM
  45. );
  46. // for backwards compatibility the same chado/publications is also found
  47. // at find/publications
  48. $items['admin/tripal/legacy/tripal_pub']= array(
  49. 'title' => 'Publications',
  50. 'description' => ('A documented provenance artefact - publications, documents, personal communication.'),
  51. 'page callback' => 'tripal_pub_admin_pub_view',
  52. 'access arguments' => array('administer tripal pub'),
  53. 'type' => MENU_NORMAL_ITEM
  54. );
  55. $items['admin/tripal/legacy/tripal_pub/help']= array(
  56. 'title' => 'Help',
  57. 'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of publications'),
  58. 'page callback' => 'theme',
  59. 'page arguments' => array('tripal_pub_help'),
  60. 'access arguments' => array('administer tripal pub'),
  61. 'type' => MENU_LOCAL_TASK,
  62. 'weight' => 10
  63. );
  64. $items['admin/tripal/legacy/tripal_pub/configuration'] = array(
  65. 'title' => 'Settings',
  66. 'description' => 'Configure the Tripal publication module.',
  67. 'page callback' => 'drupal_get_form',
  68. 'page arguments' => array('tripal_pub_admin'),
  69. 'access arguments' => array('administer tripal pub'),
  70. 'type' => MENU_LOCAL_TASK,
  71. 'weight' => 5
  72. );
  73. $items['admin/tripal/legacy/tripal_pub/sync'] = array(
  74. 'title' => ' Sync',
  75. 'description' => 'Create pages on this site for libraries stored in Chado',
  76. 'page callback' => 'drupal_get_form',
  77. 'page arguments' => array('chado_node_sync_form', 'tripal_pub', 'chado_pub'),
  78. 'access arguments' => array('administer tripal pub'),
  79. 'type' => MENU_LOCAL_TASK,
  80. 'weight' => 2
  81. );
  82. $items['admin/tripal/legacy/tripal_pub/chado_pub_toc'] = array(
  83. 'title' => ' TOC',
  84. 'description' => 'Manage the table of contents for pub nodes.',
  85. 'page callback' => 'drupal_get_form',
  86. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_pub'),
  87. 'access arguments' => array('administer tripal pub'),
  88. 'type' => MENU_LOCAL_TASK,
  89. 'file' => 'includes/tripal_core.toc.inc',
  90. 'file path' => drupal_get_path('module', 'tripal_core'),
  91. 'weight' => 3
  92. );
  93. $items['admin/tripal/legacy/tripal_pub/citation'] = array(
  94. 'title' => 'Citations',
  95. 'description' => 'Update publication citations',
  96. 'page callback' => 'drupal_get_form',
  97. 'page arguments' => array('tripal_pub_citation_form'),
  98. 'access arguments' => array('administer tripal pub'),
  99. 'type' => MENU_LOCAL_TASK,
  100. 'weight' => 1
  101. );
  102. return $items;
  103. }
  104. /**
  105. * Implements hook_theme().
  106. * Register themeing functions for this module
  107. *
  108. * @return
  109. * An array of themeing functions to register
  110. *
  111. * @ingroup tripal_legacy_pub
  112. */
  113. function tripal_pub_theme($existing, $type, $theme, $path) {
  114. $core_path = drupal_get_path('module', 'tripal_core');
  115. $items = array(
  116. 'node__chado_pub' => array(
  117. 'template' => 'node--chado-generic',
  118. 'render element' => 'node',
  119. 'base hook' => 'node',
  120. 'path' => "$core_path/theme/templates",
  121. ),
  122. // node templates
  123. 'tripal_pub_authors' => array(
  124. 'variables' => array('node' => NULL),
  125. 'template' => 'tripal_pub_authors',
  126. 'path' => "$path/theme/templates",
  127. ),
  128. 'tripal_pub_base' => array(
  129. 'variables' => array('node' => NULL),
  130. 'template' => 'tripal_pub_base',
  131. 'path' => "$path/theme/templates",
  132. ),
  133. 'tripal_pub_featuremaps' => array(
  134. 'variables' => array('node' => NULL),
  135. 'template' => 'tripal_pub_featuremaps',
  136. 'path' => "$path/theme/templates",
  137. ),
  138. 'tripal_pub_features' => array(
  139. 'variables' => array('node' => NULL),
  140. 'template' => 'tripal_pub_features',
  141. 'path' => "$path/theme/templates",
  142. ),
  143. 'tripal_pub_libraries' => array(
  144. 'variables' => array('node' => NULL),
  145. 'template' => 'tripal_pub_libraries',
  146. 'path' => "$path/theme/templates",
  147. ),
  148. 'tripal_pub_projects' => array(
  149. 'variables' => array('node' => NULL),
  150. 'template' => 'tripal_pub_projects',
  151. 'path' => "$path/theme/templates",
  152. ),
  153. 'tripal_pub_properties' => array(
  154. 'variables' => array('node' => NULL),
  155. 'template' => 'tripal_pub_properties',
  156. 'path' => "$path/theme/templates",
  157. ),
  158. 'tripal_pub_references' => array(
  159. 'variables' => array('node' => NULL),
  160. 'template' => 'tripal_pub_references',
  161. 'path' => "$path/theme/templates",
  162. ),
  163. 'tripal_pub_relationships' => array(
  164. 'variables' => array('node' => NULL),
  165. 'template' => 'tripal_pub_relationships',
  166. 'path' => "$path/theme/templates",
  167. ),
  168. 'tripal_pub_stocks' => array(
  169. 'variables' => array('node' => NULL),
  170. 'template' => 'tripal_pub_stocks',
  171. 'path' => "$path/theme/templates",
  172. ),
  173. // instructions page for the pub module
  174. 'tripal_pub_help' => array(
  175. 'variables' => array(NULL),
  176. 'template' => 'tripal_pub_help',
  177. 'path' => "$path/theme/templates",
  178. ),
  179. // teaser
  180. 'tripal_pub_teaser' => array(
  181. 'variables' => array('node' => NULL),
  182. 'template' => 'tripal_pub_teaser',
  183. 'path' => "$path/theme/templates",
  184. ),
  185. );
  186. return $items;
  187. }
  188. /**
  189. * Implements hook_help().
  190. * Adds a help page to the module list
  191. *
  192. * @ingroup tripal_legacy_pub
  193. */
  194. function tripal_pub_help ($path, $arg) {
  195. if ($path == 'admin/help#tripal_pub') {
  196. return theme('tripal_pub_help', array());
  197. }
  198. }
  199. /**
  200. * Implements hook_views_api().
  201. *
  202. * Essentially this hook tells drupal that there is views support for
  203. * for this module which then includes tripal_db.views.inc where all the
  204. * views integration code is
  205. *
  206. * @ingroup tripal_legacy_pub
  207. */
  208. function tripal_pub_views_api() {
  209. return array(
  210. 'api' => 3.0,
  211. );
  212. }
  213. /**
  214. * Implement hook_permission().
  215. *
  216. * @ingroup tripal_legacy_pub
  217. */
  218. function tripal_pub_permission() {
  219. return array(
  220. 'access chado_pub content' => array(
  221. 'title' => t('View Publications'),
  222. 'description' => t('Allow users to view publication pages.'),
  223. ),
  224. 'create chado_pub content' => array(
  225. 'title' => t('Create Publication'),
  226. 'description' => t('Allow users to create new publication pages.'),
  227. ),
  228. 'delete chado_pub content' => array(
  229. 'title' => t('Delete Publication'),
  230. 'description' => t('Allow users to delete publication pages.'),
  231. ),
  232. 'edit chado_pub content' => array(
  233. 'title' => t('Edit Publications'),
  234. 'description' => t('Allow users to edit publication pages.'),
  235. ),
  236. 'administer tripal pub' => array(
  237. 'title' => t('Administer Publications'),
  238. 'description' => t('Allow users to administer all publications.'),
  239. ),
  240. );
  241. }
  242. /**
  243. * Implementation of hook_form_alter().
  244. *
  245. * @param $form
  246. * @param $form_state
  247. * @param $form_id
  248. *
  249. * @ingroup tripal_legacy_pub
  250. */
  251. function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
  252. // turn of preview button for insert/updates
  253. if ($form_id == "chado_pub_node_form") {
  254. // turn of preview button for insert/updates
  255. $form['actions']['preview']['#access'] = FALSE;
  256. //remove the body field
  257. unset($form['body']);
  258. }
  259. if ($form_id == "tripal_pub_importer_setup_form") {
  260. /* // updating the form through the ahah callback sets the action of
  261. // the form to the ahah callback URL. We need to set it back
  262. // to the normal form URL
  263. if (array_key_exists('values', $form_state) and $form_state['values']['action'] == 'edit') {
  264. $form['#action'] = url("admin/tripal/legacy/tripal_pub/import/edit/" . $form_state['values']['pub_import_id']);
  265. }
  266. if (array_key_exists('values', $form_state) and $form_state['values']['action'] == 'new') {
  267. $form['#action'] = url("admin/tripal/legacy/tripal_pub/import/new");
  268. }
  269. */
  270. }
  271. if ($form_id == "tripal_pub_search_form") {
  272. $form['#action'] = url("find/publications");
  273. }
  274. if ($form_id == "chado_pub_node_form") {
  275. }
  276. }
  277. /**
  278. * Implements hook_job_describe_args().
  279. *
  280. * @param $callback
  281. * @param $args
  282. *
  283. * @ingroup tripal_legacy_pub
  284. */
  285. function tripal_pub_job_describe_args($callback, $args) {
  286. $new_args = array();
  287. if ($callback == 'chado_execute_pub_importer') {
  288. // get all of the loaders
  289. $qargs = array(':import_id' => $args[0]);
  290. $sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :import_id ";
  291. $import = db_query($sql, $qargs)->fetchObject();
  292. $new_args['Importer'] = $import->name;
  293. }
  294. return $new_args;
  295. }
  296. /**
  297. * A simple wrapper function to put <pre> tags around the raw results
  298. * returned by the
  299. * @param unknown $dbxref
  300. * @return string
  301. */
  302. function tripal_get_remote_pub_raw_page($dbxref) {
  303. $pub = tripal_get_remote_pub($dbxref);
  304. if ($pub) {
  305. $page = "<strong>Raw results for $dbxref:</strong><br><br>";
  306. $page.= '<textarea cols=80 rows=20>' . $pub['raw'] . '</textarea>';
  307. return $page;
  308. }
  309. return "Cound not find the requested publication ($dbxref)";
  310. }
  311. /**
  312. *
  313. */
  314. function tripal_pub_search_biological_data_views() {
  315. return array(
  316. 'publications' => array(
  317. 'machine_name' => 'publications',
  318. 'human_name' => 'Publications',
  319. 'description' => 'Publications such as journal articles, conference proceedings, or other media.',
  320. 'link' => 'find/publications'
  321. ),
  322. );
  323. }