tripal_core.module 24 KB

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