tripal_core.module 23 KB

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