tripal_core.module 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <?php
  2. /**
  3. * @file
  4. * The Tripal Core module
  5. */
  6. /**
  7. * @defgroup tripal_core Tripal Core Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Functionality useful for all other Tripal modules including the Tripal jobs, files,
  11. * materialized views and custom table functions.
  12. * @}
  13. */
  14. // APPLICATION PROGRAMMER INTERFACE -------------
  15. // Chado API
  16. require_once 'api/tripal_core.chado_general.api.inc';
  17. require_once 'api/tripal_core.chado_query.api.inc';
  18. require_once 'api/tripal_core.chado_variables.api.inc';
  19. require_once 'api/tripal_core.chado_schema.api.inc';
  20. require_once 'api/tripal_core.chado_nodes.api.inc';
  21. require_once 'api/tripal_core.chado_nodes.title_and_path.inc';
  22. require_once 'api/tripal_core.chado_nodes.properties.api.inc';
  23. require_once 'api/tripal_core.chado_nodes.dbxrefs.api.inc';
  24. require_once 'api/tripal_core.chado_nodes.relationships.api.inc';
  25. // Table API
  26. require_once 'api/tripal_core.custom_tables.api.inc';
  27. require_once 'api/tripal_core.mviews.api.inc';
  28. // Miscellaneous API
  29. require_once 'api/tripal_core.files.api.inc';
  30. require_once 'api/tripal_core.jobs.api.inc';
  31. require_once 'api/tripal_core.tripal.api.inc';
  32. require_once 'api/tripal_core.tripal_variables.api.inc';
  33. require_once 'api/tripal_core.d3js.api.inc';
  34. require_once 'api/tripal_core.DEPRECATED.inc';
  35. // INCLUDES
  36. require_once 'includes/tripal_core.jobs.inc';
  37. require_once 'includes/tripal_core.mviews.inc';
  38. require_once 'includes/tripal_core.custom_tables.inc';
  39. require_once 'includes/tripal_core.chado_install.inc';
  40. require_once 'includes/tripal_core.form_elements.inc';
  41. tripal_core_set_globals();
  42. /**
  43. * This function is used to set the global Chado variables
  44. *
  45. * @ingroup tripal_core
  46. */
  47. function tripal_core_set_globals() {
  48. // these global variables are meant to be accessed by all Tripal
  49. // modules to find the chado version installed and if Chado is local.
  50. // these variables are stored as globals rather than using the drupal_set_variable
  51. // functions because the Drupal functions make databaes queries and for long
  52. // running loaders we don't want those queries repeatedly.
  53. $GLOBALS["chado_is_installed"] = chado_is_installed();
  54. if ($GLOBALS["chado_is_installed"]) {
  55. $GLOBALS["chado_is_local"] = chado_is_local();
  56. $GLOBALS["chado_version"] = chado_get_version();
  57. $GLOBALS["exact_chado_version"] = chado_get_version(TRUE);
  58. }
  59. }
  60. /**
  61. * Implements hook_init().
  62. * Used to set the search_path, create default content and set default variables.
  63. *
  64. * @ingroup tripal_core
  65. */
  66. function tripal_core_init() {
  67. global $base_url;
  68. // create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
  69. // only if the chado database is present.
  70. if ($GLOBALS["chado_is_installed"]) {
  71. // if the Tripal cv is missing then add
  72. $results = chado_query("SELECT * FROM {cv} WHERE name = 'tripal'");
  73. $tripal_cv = $results->fetchObject();
  74. if (!$tripal_cv) {
  75. $results = chado_query(
  76. "INSERT INTO {cv} (name,definition) " .
  77. "VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')"
  78. );
  79. }
  80. // if the Tripal db is missing then add it
  81. $results = chado_query("SELECT * FROM {db} WHERE name = 'tripal'");
  82. $tripal_db = $results->fetchObject();
  83. if (!$tripal_db) {
  84. $results = chado_query(
  85. "INSERT INTO {db} (name,description) " .
  86. "VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')"
  87. );
  88. }
  89. }
  90. // add some variables for all javasript to use for building URLs
  91. $theme_dir = drupal_get_path('theme', 'tripal');
  92. $clean_urls = variable_get('clean_url', 0);
  93. drupal_add_js(
  94. " var baseurl = '$base_url';
  95. var themedir = '$theme_dir';
  96. var isClean = $clean_urls;",
  97. 'inline', 'header');
  98. // make sure the date time settings are the way Tripal will insert them
  99. // otherwise PostgreSQL version that may have a different datestyle setting
  100. // will fail when inserting or updating a date column in a table.
  101. db_query("SET DATESTYLE TO :style", array(':style' => 'MDY'));
  102. // If we want AHAH elements on the node forms (e.g. chado_pub form) then we need to include
  103. // the node.pages file. Otherwise this error message is given:
  104. //
  105. // warning: call_user_func_array() expects parameter 1 to be a valid callback,
  106. // function 'node_form' not found or invalid function name
  107. // in /var/www/includes/form.inc on line 382.
  108. module_load_include('inc', 'node', 'node.pages');
  109. }
  110. /**
  111. * Implements hook_menu().
  112. * Defines all menu items needed by Tripal Core
  113. *
  114. * @ingroup tripal_core
  115. */
  116. function tripal_core_menu() {
  117. $items = array();
  118. // Tripal setting groups
  119. $items['admin/tripal'] = array(
  120. 'title' => 'Tripal',
  121. 'description' => t("Manage the behavior or Tripal and its various modules."),
  122. 'weight' => -8,
  123. 'page callback' => 'system_admin_menu_block_page',
  124. 'access arguments' => array('administer tripal'),
  125. 'file' => 'system.admin.inc',
  126. 'file path' => drupal_get_path('module', 'system'),
  127. );
  128. $items['admin/tripal/tripal_jobs'] = array(
  129. 'title' => 'Jobs',
  130. 'description' => t('Jobs managed by Tripal'),
  131. 'page callback' => 'tripal_jobs_admin_view',
  132. 'access arguments' => array('administer tripal'),
  133. 'type' => MENU_NORMAL_ITEM,
  134. 'weight' => 0
  135. );
  136. $items['admin/tripal/loaders'] = array(
  137. 'title' => 'Data Loaders',
  138. 'description' => t('Tools facilitating loading data. Includes a generic tab-delimited loader (Bulk Loader).'),
  139. 'access arguments' => array('administer tripal'),
  140. 'type' => MENU_NORMAL_ITEM,
  141. 'weight' => 6
  142. );
  143. $items['admin/tripal/storage'] = array(
  144. 'title' => 'Storage Backend',
  145. 'description' => t("Functionality related to data storage and tools to interact with the storage backend."),
  146. 'weight' => 8,
  147. 'access arguments' => array('administer tripal'),
  148. );
  149. $items['admin/tripal/chado'] = array(
  150. 'title' => 'Legacy Tripal',
  151. 'description' => t('Tools related to Tripal2 Legacy chado-based node types.'),
  152. 'access arguments' => array('administer tripal'),
  153. 'type' => MENU_NORMAL_ITEM,
  154. 'weight' => 20
  155. );
  156. $items['admin/tripal/extension'] = array(
  157. 'title' => 'Extensions',
  158. 'description' => t('Configuration for Tripal extensions.'),
  159. 'access arguments' => array('administer tripal'),
  160. 'type' => MENU_NORMAL_ITEM,
  161. 'weight' => 100
  162. );
  163. $items['admin/tripal/extension/import'] = array(
  164. 'title' => 'Import Extensions',
  165. 'description' => 'Provides a list of the available extensions that are registered at the tripal.info site. From this page you can easily import or install extensions to your site.',
  166. 'page callback' => 'drupal_get_form',
  167. 'page arguments' => array('tripal_core_extensions_form'),
  168. 'access arguments' => array('administer tripal'),
  169. 'type' => MENU_NORMAL_ITEM,
  170. 'file' => 'includes/tripal_core.extensions.inc',
  171. 'file path' => drupal_get_path('module', 'tripal_core'),
  172. 'weight' => -100,
  173. );
  174. // Chado Storage Backend
  175. $items['admin/tripal/storage/chado'] = array(
  176. 'title' => 'Chado Schema',
  177. 'description' => t("Tools to extend the chado schema through custom tables & materialized views."),
  178. 'weight' => -100,
  179. 'access arguments' => array('administer tripal'),
  180. );
  181. $items['admin/tripal/storage/chado/chado_install'] = array(
  182. 'title' => 'Install Chado Schema',
  183. 'description' => t('Installs the Chado database tables, views, etc., inside the current Drupal database'),
  184. 'page callback' => 'drupal_get_form',
  185. 'page arguments' => array('tripal_core_chado_load_form'),
  186. 'access arguments' => array('install chado'),
  187. 'type' => MENU_NORMAL_ITEM,
  188. 'weight' => -100
  189. );
  190. /*
  191. $items['admin/tripal/setup/customize'] = array(
  192. 'title' => 'Customize Tripal',
  193. 'description' => t('Information on how to customize tripal'),
  194. 'page callback' => 'theme',
  195. 'page arguments' => array('tripal_core_customize'),
  196. 'access arguments' => array('administer tripal'),
  197. 'weight' => 10
  198. );
  199. */
  200. // Jobs Management
  201. $items['admin/tripal/tripal_jobs/help'] = array(
  202. 'title' => 'Help',
  203. 'description' => t('Help for the tripal job management system'),
  204. 'page callback' => 'theme',
  205. 'page arguments' => array('tripal_core_job_help'),
  206. 'access arguments' => array('administer tripal'),
  207. 'type' => MENU_LOCAL_TASK,
  208. 'weight' => 10
  209. );
  210. $items['admin/tripal/tripal_jobs/cancel/%'] = array(
  211. 'title' => 'Jobs',
  212. 'description' => t('Cancel a pending job'),
  213. 'page callback' => 'tripal_cancel_job',
  214. 'page arguments' => array(4),
  215. 'access arguments' => array('administer tripal'),
  216. 'type' => MENU_CALLBACK,
  217. );
  218. $items['admin/tripal/tripal_jobs/rerun/%'] = array(
  219. 'title' => 'Jobs',
  220. 'description' => t('Re-run an existing job.'),
  221. 'page callback' => 'tripal_rerun_job',
  222. 'page arguments' => array(4),
  223. 'access arguments' => array('administer tripal'),
  224. 'type' => MENU_CALLBACK,
  225. );
  226. $items['admin/tripal/tripal_jobs/view/%'] = array(
  227. 'title' => 'Jobs Details',
  228. 'description' => t('View job details.'),
  229. 'page callback' => 'tripal_jobs_view',
  230. 'page arguments' => array(4),
  231. 'access arguments' => array('administer tripal'),
  232. 'type' => MENU_CALLBACK,
  233. );
  234. $items['admin/tripal/tripal_jobs/views/jobs/enable'] = array(
  235. 'title' => 'Enable Jobs Administrative View',
  236. 'page callback' => 'tripal_enable_view',
  237. 'page arguments' => array('tripal_core_admin_jobs', 'admin/tripal/tripal_jobs'),
  238. 'access arguments' => array('administer tripal'),
  239. 'type' => MENU_CALLBACK,
  240. );
  241. // Materialized Views
  242. $items['admin/tripal/storage/chado/mviews'] = array(
  243. 'title' => 'Materialized Views',
  244. 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
  245. 'page callback' => 'tripal_mview_admin_view',
  246. 'access arguments' => array('administer tripal'),
  247. 'type' => MENU_NORMAL_ITEM,
  248. 'weight' => -10
  249. );
  250. $items['admin/tripal/storage/chado/mviews/help'] = array(
  251. 'title' => 'Help',
  252. 'description' => t('Help for the materialized views management system'),
  253. 'page callback' => 'theme',
  254. 'page arguments' => array('tripal_core_mviews_help'),
  255. 'access arguments' => array('administer tripal'),
  256. 'type' => MENU_LOCAL_TASK,
  257. 'weight' => 10
  258. );
  259. $items['admin/tripal/storage/chado/mviews/report/%'] = array(
  260. 'title' => 'Materialized View',
  261. 'description' => t('Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.'),
  262. 'page callback' => 'tripal_mview_report',
  263. 'page arguments' => array(5),
  264. 'access arguments' => array('administer tripal'),
  265. 'type' => MENU_CALLBACK,
  266. );
  267. $items['admin/tripal/storage/chado/mviews/new'] = array(
  268. 'title' => 'Create Materialized View',
  269. 'description' => t('Create a new materialized view.'),
  270. 'page callback' => 'drupal_get_form',
  271. 'page arguments' => array('tripal_mviews_form'),
  272. 'access arguments' => array('administer tripal'),
  273. 'type' => MENU_CALLBACK,
  274. );
  275. $items['admin/tripal/storage/chado/mviews/edit/%'] = array(
  276. 'title' => 'Edit Materialized View',
  277. 'page callback' => 'drupal_get_form',
  278. 'page arguments' => array('tripal_mviews_form', 5),
  279. 'access arguments' => array('administer tripal'),
  280. 'type' => MENU_CALLBACK,
  281. );
  282. $items['admin/tripal/storage/chado/mviews/update/%'] = array(
  283. 'title' => 'Create Materialized View',
  284. 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
  285. 'page callback' => 'tripal_mviews_add_populate_job',
  286. 'page arguments' => array(5),
  287. 'access arguments' => array('administer tripal'),
  288. 'type' => MENU_CALLBACK,
  289. );
  290. $items['admin/tripal/storage/chado/mviews/delete/%'] = array(
  291. 'title' => 'Create Materialized View',
  292. 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
  293. 'page callback' => 'drupal_get_form',
  294. 'page arguments' => array('tripal_mviews_delete_form', 5),
  295. 'access arguments' => array('administer tripal'),
  296. 'type' => MENU_CALLBACK,
  297. );
  298. // TODO: complete the code for exporting and importing of MViews.
  299. // Need to address security issues of sharing SQL.
  300. $items['admin/tripal/storage/chado/mviews/import'] = array(
  301. 'title' => 'Import MView',
  302. 'description' => 'Import a materialized view from another Tripal instance.',
  303. 'page callback' => 'drupal_get_form',
  304. 'page arguments' => array('tripal_mviews_import_form'),
  305. 'access arguments' => array('administer tripal'),
  306. 'type' => MENU_CALLBACK,
  307. );
  308. $items['admin/tripal/storage/chado/mviews/%tblid/export'] = array(
  309. 'title' => 'Export MView',
  310. 'description' => 'Export a materialized view for use by another Tripal instance.',
  311. 'page callback' => 'drupal_get_form',
  312. 'page arguments' => array('tripal_mviews_export_form', 5),
  313. 'access arguments' => array('administer tripal'),
  314. 'type' => MENU_CALLBACK,
  315. );
  316. // Custom Tables
  317. $items['admin/tripal/storage/chado/custom_tables'] = array(
  318. 'title' => 'Custom Tables',
  319. 'description' => t('Creation of custom tables that are added to Chado database.'),
  320. 'page callback' => 'tripal_custom_table_admin_view',
  321. 'access arguments' => array('administer tripal'),
  322. 'type' => MENU_NORMAL_ITEM,
  323. 'weight' => -10
  324. );
  325. $items['admin/tripal/storage/chado/custom_tables/help'] = array(
  326. 'title' => 'Help',
  327. 'description' => t('Help for the tripal job management system'),
  328. 'page callback' => 'theme',
  329. 'page arguments' => array('tripal_core_job_help'),
  330. 'access arguments' => array('administer tripal'),
  331. 'type' => MENU_LOCAL_TASK,
  332. 'weight' => 10
  333. );
  334. $items['admin/tripal/storage/chado/custom_tables/view/%'] = array(
  335. 'title' => 'Custom Tables',
  336. 'description' => t('Custom tables are added to Chado.'),
  337. 'page callback' => 'tripal_custom_table_view',
  338. 'page arguments' => array(5),
  339. 'access arguments' => array('administer tripal'),
  340. 'type' => MENU_CALLBACK,
  341. );
  342. $items['admin/tripal/storage/chado/custom_tables/new'] = array(
  343. 'title' => 'Create Custom Table',
  344. 'description' => t('An interface for creating your own custom tables.'),
  345. 'page callback' => 'tripal_custom_table_new_page',
  346. 'access arguments' => array('administer tripal'),
  347. 'type' => MENU_CALLBACK,
  348. );
  349. $items['admin/tripal/storage/chado/custom_tables/edit/%'] = array(
  350. 'title' => 'Edit Custom Table',
  351. 'page callback' => 'drupal_get_form',
  352. 'page arguments' => array('tripal_custom_tables_form', 5),
  353. 'access arguments' => array('administer tripal'),
  354. 'type' => MENU_CALLBACK,
  355. );
  356. $items['admin/tripal/storage/chado/custom_tables/delete/%'] = array(
  357. 'title' => 'Create Custom Table',
  358. 'description' => t('Custom tables are added to Chado.'),
  359. 'page callback' => 'drupal_get_form',
  360. 'page arguments' => array('tripal_custom_tables_delete_form', 5),
  361. 'access arguments' => array('administer tripal'),
  362. 'type' => MENU_CALLBACK,
  363. );
  364. $items['admin/tripal/storage/chado/custom_tables/views/tables/enable'] = array(
  365. 'title' => 'Enable Custom Tables Administrative View',
  366. 'page callback' => 'tripal_enable_view',
  367. 'page arguments' => array('tripal_core_admin_custom_table', 'admin/tripal/storage/chado/custom_tables'),
  368. 'access arguments' => array('administer tripal'),
  369. 'type' => MENU_CALLBACK,
  370. );
  371. // Relationshi API autocomplete callback
  372. $items['tripal_ajax/relationship_nodeform/%/%/name_to_id'] = array(
  373. 'page callback' => 'chado_add_node_form_relationships_name_to_id_callback',
  374. 'page arguments' => array(2,3),
  375. 'access arguments' => array('access content'),
  376. 'type' => MENU_CALLBACK
  377. );
  378. // The node's TOC tab
  379. $items['node/%node/tripal_toc'] = array(
  380. 'title' => 'TOC',
  381. 'page callback' => 'drupal_get_form',
  382. 'page arguments' => array('tripal_core_node_toc_form', 1),
  383. 'access callback' => 'tripal_core_access_node_toc_form',
  384. 'access arguments' => array(1),
  385. 'type' => MENU_LOCAL_TASK,
  386. 'file' => '/includes/tripal_core.toc.inc',
  387. );
  388. // Web Services API callbacks.
  389. // $items['ws/chado/v0.1'] = array(
  390. // 'title' => 'Tripal Web Services API v0.1',
  391. // 'page callback' => 'tripal_core_chado_hal_api',
  392. // 'access arguments' => array('access content'),
  393. // 'type' => MENU_CALLBACK,
  394. // 'file' => '/includes/tripal_core.ws_hal.inc',
  395. // );
  396. return $items;
  397. }
  398. /**
  399. * An access wrapper function for editing the TOC
  400. *
  401. * @param $node
  402. * A node object
  403. * @return
  404. * Returns TRUE if the node is a Tripal-based node and the user hass
  405. * the 'administer tripal' role.
  406. */
  407. function tripal_core_access_node_toc_form($node) {
  408. $types = module_invoke_all('node_info');
  409. if (array_key_exists($node->type, $types) and
  410. array_key_exists('chado_node_api', $types[$node->type])) {
  411. return user_access('administer tripal');
  412. }
  413. return FALSE;
  414. }
  415. /**
  416. * Implements hook_permission().
  417. *
  418. * Set the permission types that the chado module uses. Essentially we
  419. * want permissionis that protect creation, editing and deleting of chado
  420. * data objects
  421. *
  422. * @ingroup tripal_core
  423. */
  424. function tripal_core_permission() {
  425. return array(
  426. 'install chado' => array(
  427. 'title' => t('Install Chado'),
  428. 'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
  429. ),
  430. 'administer tripal' => array(
  431. 'title' => t('Administer Tripal'),
  432. 'description' => t('Allow the user to access administrative pages of Tripal.')
  433. ),
  434. 'view dev helps' => array(
  435. 'title' => t('View Developer Hints'),
  436. 'description' => t('Tripal will provide blue shaded boxes that provide
  437. instructions for how to customize or setup specific pages on a
  438. site. This permission should be enabled for developers. But can
  439. be disabled once developers are accustomed to these hints.'),
  440. 'restrict access' => TRUE,
  441. ),
  442. 'view ids' => array(
  443. 'title' => t('View Internal IDs'),
  444. 'description' => t('On content pages Tripal will typically provide
  445. a table of information pulled from the Chado database but the
  446. primary key IDs for that data is typically not shown. The
  447. default Tripal templates can show the primary key ID inside of a
  448. blue shaded table row if this permission is enabled. This can
  449. be useful for site developers who might want these IDs when working
  450. with the underlying database.'),
  451. 'restrict access' => TRUE,
  452. )
  453. );
  454. }
  455. /**
  456. * Implements hook_theme().
  457. * Registers template files/functions used by this module.
  458. *
  459. * @ingroup tripal_core
  460. */
  461. function tripal_core_theme($existing, $type, $theme, $path) {
  462. return array(
  463. 'tripal_core_customize' => array(
  464. 'arguments' => array('job_id' => NULL),
  465. 'template' => 'tripal_core_customize',
  466. 'path' => "$path/theme/templates"
  467. ),
  468. 'theme_file_upload_combo' => array(
  469. 'render element' => 'element',
  470. ),
  471. 'theme_sequence_combo' => array(
  472. 'render element' => 'element',
  473. ),
  474. 'tripal_core_jobs_help' => array(
  475. 'template' => 'tripal_core_jobs_help',
  476. 'variables' => array(NULL),
  477. 'path' => "$path/theme/templates"
  478. ),
  479. 'tripal_core_customtables_help' => array(
  480. 'template' => 'tripal_core_customtables_help',
  481. 'variables' => array(NULL),
  482. 'path' => "$path/theme/templates"
  483. ),
  484. // Chado Node API Themes
  485. // --------------------------------
  486. // Properties Node Form
  487. 'chado_node_properties_form_table' => array(
  488. 'function' => 'theme_chado_add_node_form_properties',
  489. 'render element' => 'element',
  490. ),
  491. // Additional Dbxrefs Nore Form
  492. 'chado_node_additional_dbxrefs_form_table' => array(
  493. 'function' => 'theme_chado_add_node_form_dbxrefs_table',
  494. 'render element' => 'element',
  495. ),
  496. // Relationships Nore Form
  497. 'chado_node_relationships_form_table' => array(
  498. 'function' => 'theme_chado_add_node_form_relationships_table',
  499. 'render element' => 'element',
  500. ),
  501. // Admin messages theme
  502. // --------------------------------
  503. 'tripal_admin_message' => array(
  504. 'function' => 'theme_tripal_admin_message',
  505. 'variables' => array('message' => NULL),
  506. ),
  507. // Form and form element themes.
  508. // --------------------------------
  509. 'tripal_node_toc_items_table' => array(
  510. 'render element' => 'element',
  511. ),
  512. // Theme function for the extension admin page.
  513. 'tripal_core_extensions_form_tables' => array(
  514. 'render element' => 'element',
  515. )
  516. );
  517. }
  518. /**
  519. * Implements hook_job_describe_args().
  520. * Describes the arguements for the tripal_populate_mview job to allow for greater
  521. * readability in the jobs details pages.
  522. *
  523. * @param $callback
  524. * The callback of the current tripal job (this is the function that will be executed
  525. * when tripal_launch_jobs.php is run.
  526. * @param $args
  527. * An array of arguments passed in when the job was registered.
  528. *
  529. * @return
  530. * A more readable $args array
  531. *
  532. * @ingroup tripal_core
  533. */
  534. function tripal_core_job_describe_args($callback, $args) {
  535. $new_args = array();
  536. if ($callback == 'tripal_populate_mview') {
  537. // get this mview details
  538. $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
  539. $results = db_query($sql, array(':mview_id' => $args[0]));
  540. $mview = $results->fetchObject();
  541. $new_args['View Name'] = $mview->name;
  542. }
  543. elseif ($callback == 'tripal_core_install_chado') {
  544. $new_args['Action'] = $args[0];
  545. }
  546. return $new_args;
  547. }
  548. /**
  549. * this is just a wrapper for backwards compatibility with a naming mistake.
  550. * it can go away in the future as it only is useful for jobs created by v0.3b
  551. *
  552. * @todo remove this function
  553. */
  554. function tripal_core_load_gff3($gff_file, $organism_id, $analysis_id, $add_only = 0,
  555. $update = 0, $refresh = 0, $remove = 0, $job = NULL) {
  556. tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id, $add_only,
  557. $update, $refresh, $remove, $job);
  558. }
  559. /**
  560. * Implements hook_coder_ignore().
  561. * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for coder are stored
  562. */
  563. function tripal_core_coder_ignore() {
  564. return array(
  565. 'path' => drupal_get_path('module', 'tripal_core'),
  566. 'line prefix' => drupal_get_path('module', 'tripal_core'),
  567. );
  568. }
  569. /**
  570. * Implements hook_views_api()
  571. * Purpose: Essentially this hook tells drupal that there is views support for
  572. * for this module which then includes tripal_db.views.inc where all the
  573. * views integration code is
  574. *
  575. * @ingroup tripal_organism
  576. */
  577. function tripal_core_views_api() {
  578. return array(
  579. 'api' => 3.0,
  580. );
  581. }
  582. /**
  583. * Implements hook_node_view_alter()
  584. *
  585. * @param unknown $build
  586. */
  587. function tripal_core_node_view_alter(&$build) {
  588. module_load_include('inc', 'tripal_core', 'includes/tripal_core.toc');
  589. tripal_core_node_view_build_toc($build);
  590. }
  591. /**
  592. * Implements hook_node_view()
  593. *
  594. * @ingroup tripal_core
  595. */
  596. function tripal_core_node_view($node, $view_mode, $langcode) {
  597. // if this node type is a chado-based node (i.e. Tripal node)
  598. // the we want to add a table of contents to it's content list
  599. // this table of contents will be an empty
  600. if (preg_match('/^chado_/', $node->type)) {
  601. // Show feature browser and counts
  602. if ($view_mode == 'full') {
  603. if (!isset($node->content['#tripal_generic_node_template'])) {
  604. $node->content['#tripal_generic_node_template'] = TRUE;
  605. }
  606. }
  607. }
  608. }
  609. /**
  610. * Implements hook_exclude_type_by_default()
  611. *
  612. * This hooks allows fields of a specified type that match a specified criteria to be excluded by
  613. * default from any table when chado_generate_var() is called. Keep in mind that if
  614. * fields are excluded by default they can always be expanded at a later date using
  615. * chado_expand_var().
  616. *
  617. * Criteria are php strings that evaluate to either TRUE or FALSE. These strings are evaluated using
  618. * drupal_eval() which suppresses syntax errors and throws watchdog entries of type php. There are
  619. * also watchdog entries of type tripal_core stating the exact criteria evaluated. Criteria can
  620. * contain the following tokens:
  621. * - <field_name>
  622. * Replaced by the name of the field to be excluded
  623. * - <field_value>
  624. * Replaced by the value of the field in the current record
  625. * Also keep in mind that if your criteria doesn't contain the &gt;field_value&lt; token then it will be
  626. * evaluated before the query is executed and if the field is excluded it won't be included in the
  627. * query.
  628. *
  629. * @return
  630. * An array of type => criteria where the type is excluded if the criteria evaluates to TRUE
  631. *
  632. * @ingroup tripal_core
  633. */
  634. function tripal_core_exclude_type_by_default() {
  635. return array('text' => 'strlen("<field_value> ") > 250');
  636. }