tripal_core.module 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  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. // Custom Tables
  296. $items['admin/tripal/schema/custom_tables'] = array(
  297. 'title' => 'Custom Tables',
  298. 'description' => t('Creation of custom tables that are added to Chado database.'),
  299. 'page callback' => 'tripal_custom_table_admin_view',
  300. 'access arguments' => array('administer tripal'),
  301. 'type' => MENU_NORMAL_ITEM,
  302. 'weight' => -10
  303. );
  304. $items['admin/tripal/schema/custom_tables/help'] = array(
  305. 'title' => 'Help',
  306. 'description' => t('Help for the tripal job management system'),
  307. 'page callback' => 'theme',
  308. 'page arguments' => array('tripal_core_job_help'),
  309. 'access arguments' => array('administer tripal'),
  310. 'type' => MENU_LOCAL_TASK,
  311. 'weight' => 10
  312. );
  313. $items['admin/tripal/schema/custom_tables/view/%'] = array(
  314. 'title' => 'Custom Tables',
  315. 'description' => t('Custom tables are added to Chado.'),
  316. 'page callback' => 'tripal_custom_table_view',
  317. 'page arguments' => array(5),
  318. 'access arguments' => array('administer tripal'),
  319. 'type' => MENU_CALLBACK,
  320. );
  321. $items['admin/tripal/schema/custom_tables/new'] = array(
  322. 'title' => 'Create Custom Table',
  323. 'description' => t('An interface for creating your own custom tables.'),
  324. 'page callback' => 'tripal_custom_table_new_page',
  325. 'access arguments' => array('administer tripal'),
  326. 'type' => MENU_CALLBACK,
  327. );
  328. $items['admin/tripal/schema/custom_tables/edit/%'] = array(
  329. 'title' => 'Edit Custom Table',
  330. 'page callback' => 'drupal_get_form',
  331. 'page arguments' => array('tripal_custom_tables_form', 5),
  332. 'access arguments' => array('administer tripal'),
  333. 'type' => MENU_CALLBACK,
  334. );
  335. $items['admin/tripal/schema/custom_tables/delete/%'] = array(
  336. 'title' => 'Create Custom Table',
  337. 'description' => t('Custom tables are added to Chado.'),
  338. 'page callback' => 'drupal_get_form',
  339. 'page arguments' => array('tripal_custom_tables_delete_form', 5),
  340. 'access arguments' => array('administer tripal'),
  341. 'type' => MENU_CALLBACK,
  342. );
  343. $items['admin/tripal/schema/custom_tables/views/tables/enable'] = array(
  344. 'title' => 'Enable Custom Tables Administrative View',
  345. 'page callback' => 'tripal_enable_view',
  346. 'page arguments' => array('tripal_core_admin_custom_table', 'admin/tripal/schema/custom_tables'),
  347. 'access arguments' => array('administer tripal'),
  348. 'type' => MENU_CALLBACK,
  349. );
  350. // Relationshi API autocomplete callback
  351. $items['tripal_ajax/relationship_nodeform/%/%/name_to_id'] = array(
  352. 'page callback' => 'chado_add_node_form_relationships_name_to_id_callback',
  353. 'page arguments' => array(2,3),
  354. 'access arguments' => array('access content'),
  355. 'type' => MENU_CALLBACK
  356. );
  357. // The node's TOC tab
  358. $items['node/%node/tripal_toc'] = array(
  359. 'title' => 'TOC',
  360. 'page callback' => 'drupal_get_form',
  361. 'page arguments' => array('tripal_core_node_toc_form', 1),
  362. 'access callback' => 'tripal_core_access_node_toc_form',
  363. 'access arguments' => array(1),
  364. 'type' => MENU_LOCAL_TASK,
  365. 'file' => '/includes/tripal_core.toc.inc',
  366. );
  367. // Web Services API callbacks.
  368. // $items['ws/chado/v0.1'] = array(
  369. // 'title' => 'Tripal Web Services API v0.1',
  370. // 'page callback' => 'tripal_core_chado_hal_api',
  371. // 'access arguments' => array('access content'),
  372. // 'type' => MENU_CALLBACK,
  373. // 'file' => '/includes/tripal_core.ws_hal.inc',
  374. // );
  375. return $items;
  376. }
  377. /**
  378. * An access wrapper function for editing the TOC
  379. *
  380. * @param $node
  381. * A node object
  382. * @return
  383. * Returns TRUE if the node is a Tripal-based node and the user hass
  384. * the 'administer tripal' role.
  385. */
  386. function tripal_core_access_node_toc_form($node) {
  387. $types = module_invoke_all('node_info');
  388. if (array_key_exists($node->type, $types) and
  389. array_key_exists('chado_node_api', $types[$node->type])) {
  390. return user_access('administer tripal');
  391. }
  392. return FALSE;
  393. }
  394. /**
  395. * Implements hook_permission().
  396. *
  397. * Set the permission types that the chado module uses. Essentially we
  398. * want permissionis that protect creation, editing and deleting of chado
  399. * data objects
  400. *
  401. * @ingroup tripal_core
  402. */
  403. function tripal_core_permission() {
  404. return array(
  405. 'install chado' => array(
  406. 'title' => t('Install Chado'),
  407. 'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
  408. ),
  409. 'administer tripal' => array(
  410. 'title' => t('Administer Tripal'),
  411. 'description' => t('Allow the user to access administrative pages of Tripal.')
  412. ),
  413. 'view dev helps' => array(
  414. 'title' => t('View Developer Hints'),
  415. 'description' => t('Tripal will provide blue shaded boxes that provide
  416. instructions for how to customize or setup specific pages on a
  417. site. This permission should be enabled for developers. But can
  418. be disabled once developers are accustomed to these hints.'),
  419. 'restrict access' => TRUE,
  420. ),
  421. 'view ids' => array(
  422. 'title' => t('View Internal IDs'),
  423. 'description' => t('On content pages Tripal will typically provide
  424. a table of information pulled from the Chado database but the
  425. primary key IDs for that data is typically not shown. The
  426. default Tripal templates can show the primary key ID inside of a
  427. blue shaded table row if this permission is enabled. This can
  428. be useful for site developers who might want these IDs when working
  429. with the underlying database.'),
  430. 'restrict access' => TRUE,
  431. )
  432. );
  433. }
  434. /**
  435. * Implements hook_theme().
  436. * Registers template files/functions used by this module.
  437. *
  438. * @ingroup tripal_core
  439. */
  440. function tripal_core_theme($existing, $type, $theme, $path) {
  441. return array(
  442. 'tripal_core_customize' => array(
  443. 'arguments' => array('job_id' => NULL),
  444. 'template' => 'tripal_core_customize',
  445. 'path' => "$path/theme/templates"
  446. ),
  447. 'theme_file_upload_combo' => array(
  448. 'render element' => 'element',
  449. ),
  450. 'theme_sequence_combo' => array(
  451. 'render element' => 'element',
  452. ),
  453. 'tripal_core_jobs_help' => array(
  454. 'template' => 'tripal_core_jobs_help',
  455. 'variables' => array(NULL),
  456. 'path' => "$path/theme/templates"
  457. ),
  458. 'tripal_core_customtables_help' => array(
  459. 'template' => 'tripal_core_customtables_help',
  460. 'variables' => array(NULL),
  461. 'path' => "$path/theme/templates"
  462. ),
  463. // Chado Node API Themes
  464. // --------------------------------
  465. // Properties Node Form
  466. 'chado_node_properties_form_table' => array(
  467. 'function' => 'theme_chado_add_node_form_properties',
  468. 'render element' => 'element',
  469. ),
  470. // Additional Dbxrefs Nore Form
  471. 'chado_node_additional_dbxrefs_form_table' => array(
  472. 'function' => 'theme_chado_add_node_form_dbxrefs_table',
  473. 'render element' => 'element',
  474. ),
  475. // Relationships Nore Form
  476. 'chado_node_relationships_form_table' => array(
  477. 'function' => 'theme_chado_add_node_form_relationships_table',
  478. 'render element' => 'element',
  479. ),
  480. // Admin messages theme
  481. // --------------------------------
  482. 'tripal_admin_message' => array(
  483. 'function' => 'theme_tripal_admin_message',
  484. 'variables' => array('message' => NULL),
  485. ),
  486. // Form and form element themes.
  487. // --------------------------------
  488. 'tripal_node_toc_items_table' => array(
  489. 'render element' => 'element',
  490. ),
  491. // Theme function for the extension admin page.
  492. 'tripal_core_extensions_form_tables' => array(
  493. 'render element' => 'element',
  494. )
  495. );
  496. }
  497. /**
  498. * Implements hook_job_describe_args().
  499. * Describes the arguements for the tripal_populate_mview job to allow for greater
  500. * readability in the jobs details pages.
  501. *
  502. * @param $callback
  503. * The callback of the current tripal job (this is the function that will be executed
  504. * when tripal_launch_jobs.php is run.
  505. * @param $args
  506. * An array of arguments passed in when the job was registered.
  507. *
  508. * @return
  509. * A more readable $args array
  510. *
  511. * @ingroup tripal_core
  512. */
  513. function tripal_core_job_describe_args($callback, $args) {
  514. $new_args = array();
  515. if ($callback == 'tripal_populate_mview') {
  516. // get this mview details
  517. $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
  518. $results = db_query($sql, array(':mview_id' => $args[0]));
  519. $mview = $results->fetchObject();
  520. $new_args['View Name'] = $mview->name;
  521. }
  522. elseif ($callback == 'tripal_core_install_chado') {
  523. $new_args['Action'] = $args[0];
  524. }
  525. return $new_args;
  526. }
  527. /**
  528. * this is just a wrapper for backwards compatibility with a naming mistake.
  529. * it can go away in the future as it only is useful for jobs created by v0.3b
  530. *
  531. * @todo remove this function
  532. */
  533. function tripal_core_load_gff3($gff_file, $organism_id, $analysis_id, $add_only = 0,
  534. $update = 0, $refresh = 0, $remove = 0, $job = NULL) {
  535. tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id, $add_only,
  536. $update, $refresh, $remove, $job);
  537. }
  538. /**
  539. * Implements hook_coder_ignore().
  540. * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for coder are stored
  541. */
  542. function tripal_core_coder_ignore() {
  543. return array(
  544. 'path' => drupal_get_path('module', 'tripal_core'),
  545. 'line prefix' => drupal_get_path('module', 'tripal_core'),
  546. );
  547. }
  548. /**
  549. * Implements hook_views_api()
  550. * Purpose: Essentially this hook tells drupal that there is views support for
  551. * for this module which then includes tripal_db.views.inc where all the
  552. * views integration code is
  553. *
  554. * @ingroup tripal_organism
  555. */
  556. function tripal_core_views_api() {
  557. return array(
  558. 'api' => 3.0,
  559. );
  560. }
  561. /**
  562. * Implements hook_node_view_alter()
  563. *
  564. * @param unknown $build
  565. */
  566. function tripal_core_node_view_alter(&$build) {
  567. module_load_include('inc', 'tripal_core', 'includes/tripal_core.toc');
  568. tripal_core_node_view_build_toc($build);
  569. }
  570. /**
  571. * Implements hook_node_view()
  572. *
  573. * @ingroup tripal_core
  574. */
  575. function tripal_core_node_view($node, $view_mode, $langcode) {
  576. // if this node type is a chado-based node (i.e. Tripal node)
  577. // the we want to add a table of contents to it's content list
  578. // this table of contents will be an empty
  579. if (preg_match('/^chado_/', $node->type)) {
  580. // Show feature browser and counts
  581. if ($view_mode == 'full') {
  582. if (!isset($node->content['#tripal_generic_node_template'])) {
  583. $node->content['#tripal_generic_node_template'] = TRUE;
  584. }
  585. }
  586. }
  587. }
  588. /**
  589. * Implements hook_exclude_type_by_default()
  590. *
  591. * This hooks allows fields of a specified type that match a specified criteria to be excluded by
  592. * default from any table when chado_generate_var() is called. Keep in mind that if
  593. * fields are excluded by default they can always be expanded at a later date using
  594. * chado_expand_var().
  595. *
  596. * Criteria are php strings that evaluate to either TRUE or FALSE. These strings are evaluated using
  597. * drupal_eval() which suppresses syntax errors and throws watchdog entries of type php. There are
  598. * also watchdog entries of type tripal_core stating the exact criteria evaluated. Criteria can
  599. * contain the following tokens:
  600. * - <field_name>
  601. * Replaced by the name of the field to be excluded
  602. * - <field_value>
  603. * Replaced by the value of the field in the current record
  604. * Also keep in mind that if your criteria doesn't contain the &gt;field_value&lt; token then it will be
  605. * evaluated before the query is executed and if the field is excluded it won't be included in the
  606. * query.
  607. *
  608. * @return
  609. * An array of type => criteria where the type is excluded if the criteria evaluates to TRUE
  610. *
  611. * @ingroup tripal_core
  612. */
  613. function tripal_core_exclude_type_by_default() {
  614. return array('text' => 'strlen("<field_value> ") > 250');
  615. }