tripal_core.module 24 KB

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