tripal_chado.module 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <?php
  2. //
  3. // APPLICATION PROGRAMMER INTERFACE
  4. //
  5. // Generic Chado API functions
  6. require_once "api/tripal_chado.api.inc";
  7. require_once 'api/tripal_chado.property.api.inc';
  8. require_once 'api/tripal_chado.query.api.inc';
  9. require_once 'api/tripal_chado.entity.api.inc';
  10. require_once 'api/tripal_chado.variables.api.inc';
  11. require_once 'api/tripal_chado.schema.api.inc';
  12. require_once 'api/tripal_chado.custom_tables.api.inc';
  13. require_once 'api/tripal_chado.mviews.api.inc';
  14. require_once 'api/tripal_chado.schema_v1.3.api.inc';
  15. require_once 'api/tripal_chado.schema_v1.2.api.inc';
  16. require_once 'api/tripal_chado.schema_v1.11.api.inc';
  17. require_once 'api/tripal_chado.semweb.api.inc';
  18. // Chado module specific API functions
  19. require_once 'api/modules/tripal_chado.analysis.api.inc';
  20. require_once 'api/modules/tripal_chado.contact.api.inc';
  21. require_once 'api/modules/tripal_chado.cv.api.inc';
  22. require_once 'api/modules/tripal_chado.db.api.inc';
  23. require_once 'api/modules/tripal_chado.feature.api.inc';
  24. require_once 'api/modules/tripal_chado.organism.api.inc';
  25. require_once 'api/modules/tripal_chado.pub.api.inc';
  26. require_once 'api/modules/tripal_chado.stock.api.inc';
  27. require_once 'api/modules/tripal_chado.phylotree.api.inc';
  28. //
  29. // REQUIRED INCLUDE FILES
  30. //
  31. // These require files implement hooks and therefore must
  32. // ways be included when the module is interpreted.
  33. require_once "includes/tripal_chado.entity.inc";
  34. require_once "includes/tripal_chado.schema.inc";
  35. require_once "includes/tripal_chado.vocab_storage.inc";
  36. require_once "includes/tripal_chado.field_storage.inc";
  37. require_once "includes/tripal_chado.bundle.inc";
  38. require_once "includes/tripal_chado.fields.inc";
  39. require_once "includes/tripal_chado.mapping.inc";
  40. require_once "includes/TripalFields/ChadoField.inc";
  41. require_once "includes/TripalFields/ChadoFieldWidget.inc";
  42. require_once "includes/TripalFields/ChadoFieldFormatter.inc";
  43. require_once "includes/ChadoDatabaseConnection.inc";
  44. tripal_chado_set_globals();
  45. /**
  46. * This function is used to set the global Chado variables
  47. *
  48. * @ingroup tripal_chado
  49. */
  50. function tripal_chado_set_globals() {
  51. // these global variables are meant to be accessed by all Tripal
  52. // modules to find the chado version installed and if Chado is local.
  53. // these variables are stored as globals rather than using the drupal_set_variable
  54. // functions because the Drupal functions make databaes queries and for long
  55. // running loaders we don't want those queries repeatedly.
  56. $GLOBALS["chado_is_installed"] = chado_is_installed();
  57. if ($GLOBALS["chado_is_installed"]) {
  58. $GLOBALS["chado_is_local"] = chado_is_local();
  59. $GLOBALS["chado_version"] = chado_get_version();
  60. $GLOBALS["exact_chado_version"] = chado_get_version(TRUE);
  61. }
  62. }
  63. /**
  64. * Implements hook_init().
  65. *
  66. * @ingroup tripal_chado
  67. */
  68. function tripal_chado_init() {
  69. if (user_access('administer tripal')) {
  70. if ($GLOBALS["chado_is_installed"]) {
  71. // Check to see if the Chado and Drupal have been prepared
  72. if (!variable_get('tripal_chado_is_prepared', FALSE)) {
  73. drupal_set_message('Chado is installed but Tripal has not yet prepared Drupal and Chado. Please ' .
  74. l('prepare both Drupal and Chado', 'admin/tripal/storage/chado/prepare') .
  75. ' before continuing.', 'warning');
  76. }
  77. }
  78. else {
  79. drupal_set_message('Tripal cannot find a Chado installation. Please ' .
  80. l('install Chado', 'admin/tripal/storage/chado/install') .
  81. ' before continuing.', 'warning');
  82. }
  83. }
  84. }
  85. /**
  86. * Implements hook_views_api().
  87. *
  88. * Essentially this hook tells drupal that there is views support for
  89. * for this module which then includes tripal_db.views.inc where all the
  90. * views integration code is
  91. *
  92. * @ingroup tripal_feature
  93. */
  94. function tripal_chado_views_api() {
  95. return array(
  96. 'api' => 3.0,
  97. );
  98. }
  99. /**
  100. * Implements hook_menu().
  101. */
  102. function tripal_chado_menu() {
  103. $items = array();
  104. //////////////////////////////////////////////////////////////////////////////
  105. // Chado Storage Backend
  106. //////////////////////////////////////////////////////////////////////////////
  107. $items['admin/tripal/storage/chado'] = array(
  108. 'title' => 'Chado',
  109. 'description' => t("Integrates Chado with Tripal and includes tools to
  110. load data, and extend the chado schema through custom tables &
  111. materialized views."),
  112. 'weight' => -100,
  113. 'access arguments' => array('administer tripal'),
  114. );
  115. $items['admin/tripal/storage/chado/install'] = array(
  116. 'title' => 'Install Chado',
  117. 'description' => t('Installs the Chado database tables, views, etc., inside the current Drupal database'),
  118. 'page callback' => 'drupal_get_form',
  119. 'page arguments' => array('tripal_chado_load_form'),
  120. 'type' => MENU_NORMAL_ITEM,
  121. 'access arguments' => array('install chado'),
  122. 'file' => 'includes/tripal_chado.install.inc',
  123. 'file path' => drupal_get_path('module', 'tripal_chado'),
  124. 'weight' => -100
  125. );
  126. $items['admin/tripal/storage/chado/prepare'] = array(
  127. 'title' => 'Prepare Chado',
  128. 'description' => t('Prepares Drupal to use Chado.'),
  129. 'page callback' => 'drupal_get_form',
  130. 'page arguments' => array('tripal_chado_prepare_form'),
  131. 'type' => MENU_NORMAL_ITEM,
  132. 'access arguments' => array('install chado'),
  133. 'file' => 'includes/setup/tripal_chado.setup.inc',
  134. 'file path' => drupal_get_path('module', 'tripal_chado'),
  135. 'weight' => -99
  136. );
  137. $items['admin/tripal/storage/chado/publish'] = array(
  138. 'title' => 'Publish',
  139. 'description' => t('Publish data that is present in Chado but which does
  140. not yet have a page on this site for viewing. In Tripal v2.0 or
  141. earlier this was refered to as "syncing".'),
  142. 'page callback' => 'drupal_get_form',
  143. 'page arguments' => array('tripal_chado_publish_form'),
  144. 'type' => MENU_NORMAL_ITEM,
  145. 'access arguments' => array('administer tripal'),
  146. 'file' => 'includes/tripal_chado.publish.inc',
  147. 'file path' => drupal_get_path('module', 'tripal_chado'),
  148. 'weight' => -99
  149. );
  150. // Adds a +Publish Chado Content link on the 'Tripal Content Types' page.
  151. $items['admin/structure/bio_data/publish'] = array(
  152. 'title' => 'Publish Chado Content',
  153. 'description' => t('Publish data that is present in Chado but which does
  154. not yet have a page on this site for viewing. In Tripal v2.0 or
  155. earlier this was refered to as "syncing".'),
  156. 'page callback' => 'drupal_get_form',
  157. 'page arguments' => array('tripal_chado_publish_form'),
  158. 'access arguments' => array('administer tripal'),
  159. 'file' => 'includes/tripal_chado.publish.inc',
  160. 'file path' => drupal_get_path('module', 'tripal_chado'),
  161. 'type' => MENU_LOCAL_ACTION,
  162. 'weight' => 2
  163. );
  164. //////////////////////////////////////////////////////////////////////////////
  165. // Materialized Views
  166. //////////////////////////////////////////////////////////////////////////////
  167. $items['admin/tripal/storage/chado/mviews'] = array(
  168. 'title' => 'Materialized Views',
  169. 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
  170. 'page callback' => 'tripal_mview_admin_view',
  171. 'access arguments' => array('administer tripal'),
  172. 'type' => MENU_NORMAL_ITEM,
  173. 'file' => 'includes/tripal_chado.mviews.inc',
  174. 'file path' => drupal_get_path('module', 'tripal_chado'),
  175. 'weight' => -10
  176. );
  177. $items['admin/tripal/storage/chado/mviews/help'] = array(
  178. 'title' => 'Help',
  179. 'description' => t('Help for the materialized views management system'),
  180. 'page callback' => 'theme',
  181. 'page arguments' => array('tripal_mviews_help'),
  182. 'access arguments' => array('administer tripal'),
  183. 'type' => MENU_LOCAL_TASK,
  184. 'file' => 'includes/tripal_chado.mviews.inc',
  185. 'file path' => drupal_get_path('module', 'tripal_chado'),
  186. 'weight' => 10
  187. );
  188. $items['admin/tripal/storage/chado/mviews/report/%'] = array(
  189. 'title' => 'Materialized View',
  190. 'description' => t('Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.'),
  191. 'page callback' => 'tripal_mview_report',
  192. 'page arguments' => array(6),
  193. 'access arguments' => array('administer tripal'),
  194. 'type' => MENU_CALLBACK,
  195. 'file' => 'includes/tripal_chado.mviews.inc',
  196. 'file path' => drupal_get_path('module', 'tripal_chado'),
  197. );
  198. $items['admin/tripal/storage/chado/mviews/new'] = array(
  199. 'title' => 'Create Materialized View',
  200. 'description' => t('Create a new materialized view.'),
  201. 'page callback' => 'drupal_get_form',
  202. 'page arguments' => array('tripal_mviews_form'),
  203. 'access arguments' => array('administer tripal'),
  204. 'type' => MENU_CALLBACK,
  205. 'file' => 'includes/tripal_chado.mviews.inc',
  206. 'file path' => drupal_get_path('module', 'tripal_chado'),
  207. );
  208. $items['admin/tripal/storage/chado/mviews/edit/%'] = array(
  209. 'title' => 'Edit Materialized View',
  210. 'page callback' => 'drupal_get_form',
  211. 'page arguments' => array('tripal_mviews_form', 6),
  212. 'access arguments' => array('administer tripal'),
  213. 'type' => MENU_CALLBACK,
  214. 'file' => 'includes/tripal_chado.mviews.inc',
  215. 'file path' => drupal_get_path('module', 'tripal_chado'),
  216. );
  217. $items['admin/tripal/storage/chado/mviews/update/%'] = array(
  218. 'title' => 'Create Materialized View',
  219. 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
  220. 'page callback' => 'tripal_mviews_add_populate_job',
  221. 'page arguments' => array(6),
  222. 'access arguments' => array('administer tripal'),
  223. 'type' => MENU_CALLBACK,
  224. 'file' => 'includes/tripal_chado.mviews.inc',
  225. 'file path' => drupal_get_path('module', 'tripal_chado'),
  226. );
  227. $items['admin/tripal/storage/chado/mviews/delete/%'] = array(
  228. 'title' => 'Create Materialized View',
  229. 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
  230. 'page callback' => 'drupal_get_form',
  231. 'page arguments' => array('tripal_mviews_delete_form', 5),
  232. 'access arguments' => array('administer tripal'),
  233. 'type' => MENU_CALLBACK,
  234. 'file' => 'includes/tripal_chado.mviews.inc',
  235. 'file path' => drupal_get_path('module', 'tripal_chado'),
  236. );
  237. // TODO: complete the code for exporting and importing of MViews.
  238. // Need to address security issues of sharing SQL.
  239. $items['admin/tripal/storage/chado/mviews/import'] = array(
  240. 'title' => 'Import MView',
  241. 'description' => 'Import a materialized view from another Tripal instance.',
  242. 'page callback' => 'drupal_get_form',
  243. 'page arguments' => array('tripal_mviews_import_form'),
  244. 'access arguments' => array('administer tripal'),
  245. 'type' => MENU_CALLBACK,
  246. 'file' => 'includes/tripal_chado.mviews.inc',
  247. 'file path' => drupal_get_path('module', 'tripal_chado'),
  248. );
  249. $items['admin/tripal/storage/chado/mviews/%tblid/export'] = array(
  250. 'title' => 'Export MView',
  251. 'description' => 'Export a materialized view for use by another Tripal instance.',
  252. 'page callback' => 'drupal_get_form',
  253. 'page arguments' => array('tripal_mviews_export_form', 5),
  254. 'access arguments' => array('administer tripal'),
  255. 'type' => MENU_CALLBACK,
  256. 'file' => 'includes/tripal_chado.mviews.inc',
  257. 'file path' => drupal_get_path('module', 'tripal_chado'),
  258. );
  259. //////////////////////////////////////////////////////////////////////////////
  260. // Custom Tables
  261. //////////////////////////////////////////////////////////////////////////////
  262. $items['admin/tripal/storage/chado/custom_tables'] = array(
  263. 'title' => 'Custom Tables',
  264. 'description' => t('Creation of custom tables that are added to Chado database.'),
  265. 'page callback' => 'tripal_custom_table_admin_view',
  266. 'access arguments' => array('administer tripal'),
  267. 'type' => MENU_NORMAL_ITEM,
  268. 'file' => 'includes/tripal_chado.custom_tables.inc',
  269. 'file path' => drupal_get_path('module', 'tripal_chado'),
  270. 'weight' => -10
  271. );
  272. $items['admin/tripal/storage/chado/custom_tables/help'] = array(
  273. 'title' => 'Help',
  274. 'description' => t('Help for the tripal job management system'),
  275. 'page callback' => 'theme',
  276. 'page arguments' => array('tripal_job_help'),
  277. 'access arguments' => array('administer tripal'),
  278. 'type' => MENU_LOCAL_TASK,
  279. 'file' => 'includes/tripal_chado.custom_tables.inc',
  280. 'file path' => drupal_get_path('module', 'tripal_chado'),
  281. 'weight' => 10
  282. );
  283. $items['admin/tripal/storage/chado/custom_tables/view/%'] = array(
  284. 'title' => 'Custom Tables',
  285. 'description' => t('Custom tables are added to Chado.'),
  286. 'page callback' => 'tripal_custom_table_view',
  287. 'page arguments' => array(6),
  288. 'access arguments' => array('administer tripal'),
  289. 'file' => 'includes/tripal_chado.custom_tables.inc',
  290. 'file path' => drupal_get_path('module', 'tripal_chado'),
  291. 'type' => MENU_CALLBACK,
  292. );
  293. $items['admin/tripal/storage/chado/custom_tables/new'] = array(
  294. 'title' => 'Create Custom Table',
  295. 'description' => t('An interface for creating your own custom tables.'),
  296. 'page callback' => 'tripal_custom_table_new_page',
  297. 'access arguments' => array('administer tripal'),
  298. 'file' => 'includes/tripal_chado.custom_tables.inc',
  299. 'file path' => drupal_get_path('module', 'tripal_chado'),
  300. 'type' => MENU_CALLBACK,
  301. );
  302. $items['admin/tripal/storage/chado/custom_tables/edit/%'] = array(
  303. 'title' => 'Edit Custom Table',
  304. 'page callback' => 'drupal_get_form',
  305. 'page arguments' => array('tripal_custom_tables_form', 6),
  306. 'access arguments' => array('administer tripal'),
  307. 'file' => 'includes/tripal_chado.custom_tables.inc',
  308. 'file path' => drupal_get_path('module', 'tripal_chado'),
  309. 'type' => MENU_CALLBACK,
  310. );
  311. $items['admin/tripal/storage/chado/custom_tables/delete/%'] = array(
  312. 'title' => 'Create Custom Table',
  313. 'description' => t('Custom tables are added to Chado.'),
  314. 'page callback' => 'drupal_get_form',
  315. 'page arguments' => array('tripal_custom_tables_delete_form', 6),
  316. 'access arguments' => array('administer tripal'),
  317. 'file' => 'includes/tripal_chado.custom_tables.inc',
  318. 'file path' => drupal_get_path('module', 'tripal_chado'),
  319. 'type' => MENU_CALLBACK,
  320. );
  321. $items['admin/tripal/storage/chado/custom_tables/views/tables/enable'] = array(
  322. 'title' => 'Enable Custom Tables Administrative View',
  323. 'page callback' => 'tripal_enable_view',
  324. 'page arguments' => array('tripal_admin_custom_table', 'admin/tripal/storage/chado/custom_tables'),
  325. 'access arguments' => array('administer tripal'),
  326. 'file' => 'includes/tripal_chado.custom_tables.inc',
  327. 'file path' => drupal_get_path('module', 'tripal_chado'),
  328. 'type' => MENU_CALLBACK,
  329. );
  330. //////////////////////////////////////////////////////////////////////////////
  331. // Data Loaders
  332. //////////////////////////////////////////////////////////////////////////////
  333. $items['admin/tripal/loaders'] = array(
  334. 'title' => 'Data Loaders',
  335. 'description' => t('Tools facilitating data import.'),
  336. 'access arguments' => array('administer tripal'),
  337. 'type' => MENU_NORMAL_ITEM,
  338. 'weight' => 6
  339. );
  340. $items['admin/tripal/loaders/ncbi_taxonomy_loader'] = array(
  341. 'title' => 'Chado NCBI Taxonomy Loader',
  342. 'description' => 'Loads taxonomic details about installed organisms.',
  343. 'page callback' => 'drupal_get_form',
  344. 'page arguments' => array('tripal_chado_taxonomy_load_form'),
  345. 'access arguments' => array('administer tripal'),
  346. 'file' => 'includes/loaders/tripal_chado.taxonomy_importer.inc',
  347. 'file path' => drupal_get_path('module', 'tripal_chado'),
  348. 'type' => MENU_NORMAL_ITEM,
  349. );
  350. // Data Loaders
  351. $items['admin/tripal/loaders/newic_phylotree_loader'] = array(
  352. 'title' => 'Chado Phylogenetic Trees (Newic format)',
  353. 'description' => 'Loads phylogenetic trees in Newic format.',
  354. 'page callback' => 'drupal_goto',
  355. 'page arguments' => array('node/add/chado-phylotree'),
  356. 'access arguments' => array('administer tripal'),
  357. 'type' => MENU_NORMAL_ITEM,
  358. );
  359. $items['admin/tripal/loaders/pub'] = array(
  360. 'title' => t('Chado Publication Importers'),
  361. 'description' => t('Create and modify importers that can connect to and retreive publications from remote databases.'),
  362. 'page callback' => 'tripal_pub_importers_list',
  363. 'access arguments' => array('administer tripal'),
  364. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  365. 'file path' => drupal_get_path('module', 'tripal_chado'),
  366. 'type' => MENU_NORMAL_ITEM,
  367. 'weight' => 0
  368. );
  369. $items['admin/tripal/loaders/pub/new'] = array(
  370. 'title' => t('Add an Importer'),
  371. 'description' => t('Add a new publication importer.'),
  372. 'page callback' => 'tripal_pub_importer_setup_page',
  373. 'access arguments' => array('administer tripal'),
  374. 'type ' => MENU_CALLBACK,
  375. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  376. 'file path' => drupal_get_path('module', 'tripal_chado'),
  377. );
  378. $items['admin/tripal/loaders/pub/edit/%'] = array(
  379. 'page callback' => 'tripal_pub_importer_setup_page',
  380. 'page arguments' => array(5),
  381. 'access arguments' => array('administer tripal'),
  382. 'type ' => MENU_CALLBACK,
  383. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  384. 'file path' => drupal_get_path('module', 'tripal_chado'),
  385. );
  386. $items['admin/tripal/loaders/pub/raw/%'] = array(
  387. 'page callback' => 'tripal_get_remote_pub_raw_page',
  388. 'page arguments' => array(5),
  389. 'access arguments' => array('administer tripal'),
  390. 'type ' => MENU_CALLBACK,
  391. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  392. 'file path' => drupal_get_path('module', 'tripal_chado'),
  393. );
  394. // add a second link for the importer on the data loaders page
  395. $items['admin/tripal/loaders/pub/import'] = array(
  396. 'page callback' => 'tripal_pub_importers_list',
  397. 'access arguments' => array('administer tripal'),
  398. 'type' => MENU_CALLBACK,
  399. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  400. 'file path' => drupal_get_path('module', 'tripal_chado'),
  401. );
  402. $items['admin/tripal/loaders/pub/submit/%'] = array(
  403. 'page callback' => 'tripal_pub_importer_submit_job',
  404. 'page arguments' => array(5),
  405. 'access arguments' => array('administer tripal'),
  406. 'type ' => MENU_CALLBACK,
  407. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  408. 'file path' => drupal_get_path('module', 'tripal_chado'),
  409. );
  410. $items['admin/tripal/loaders/pub/delete/%'] = array(
  411. 'page callback' => 'tripal_pub_importer_delete',
  412. 'page arguments' => array(5),
  413. 'access arguments' => array('administer tripal'),
  414. 'type ' => MENU_CALLBACK,
  415. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  416. 'file path' => drupal_get_path('module', 'tripal_chado'),
  417. );
  418. $items['admin/tripal/loaders/pub/changedb'] = array(
  419. 'page callback' => 'tripal_pub_importer_setup_page_update_remotedb',
  420. 'page arguments' => array(),
  421. 'access arguments' => array('administer tripal'),
  422. 'type ' => MENU_CALLBACK,
  423. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  424. 'file path' => drupal_get_path('module', 'tripal_chado'),
  425. );
  426. $items['admin/tripal/loaders/pub/criteria/%/%'] = array(
  427. 'page callback' => 'tripal_pub_importer_setup_page_update_criteria',
  428. 'page arguments' => array(5, 6),
  429. 'access arguments' => array('administer tripal'),
  430. 'type ' => MENU_CALLBACK,
  431. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  432. 'file path' => drupal_get_path('module', 'tripal_chado'),
  433. );
  434. //////////////////////////////////////////////////////////////////////////////
  435. // Migrate Content
  436. //////////////////////////////////////////////////////////////////////////////
  437. $items['admin/tripal/storage/chado/migrate'] = array(
  438. 'title' => 'Migrate',
  439. 'description' => t('Migrate Tripal v2 content to Tripal v3'),
  440. 'page callback' => 'drupal_get_form',
  441. 'page arguments' => array('tripal_chado_migrate_form'),
  442. 'type' => MENU_NORMAL_ITEM,
  443. 'access arguments' => array('administer tripal'),
  444. 'file' => 'includes/tripal_chado.migrate.inc',
  445. 'file path' => drupal_get_path('module', 'tripal_chado'),
  446. 'weight' => 10
  447. );
  448. //////////////////////////////////////////////////////////////////////////////
  449. // Semantic Web Settings
  450. //////////////////////////////////////////////////////////////////////////////
  451. $items['admin/tripal/storage/chado/semweb'] = array(
  452. 'title' => 'Semantic Web',
  453. 'description' => t('Semantic web settings. Set terms used for the web services.'),
  454. 'page callback' => 'drupal_get_form',
  455. 'page arguments' => array('tripal_chado_semweb_form'),
  456. 'type' => MENU_NORMAL_ITEM,
  457. 'access arguments' => array('administer tripal'),
  458. 'file' => 'includes/tripal_chado.semweb.inc',
  459. 'file path' => drupal_get_path('module', 'tripal_chado'),
  460. 'weight' => 10
  461. );
  462. $items['admin/tripal/storage/chado/semweb/edit/%/%'] = array(
  463. 'title' => 'Edit Semantic Web Term',
  464. 'description' => t('Edit terms used for the web services.'),
  465. 'page callback' => 'drupal_get_form',
  466. 'page arguments' => array('tripal_chado_semweb_edit_form', 6, 7),
  467. 'type' => MENU_CALLBACK,
  468. 'access arguments' => array('administer tripal'),
  469. 'file' => 'includes/tripal_chado.semweb.inc',
  470. 'file path' => drupal_get_path('module', 'tripal_chado'),
  471. );
  472. $items['admin/tripal/storage/chado/semweb/reset/%/%'] = array(
  473. 'title' => 'Reset Semantic Web Term',
  474. 'description' => t('Edit terms used for the web services.'),
  475. 'page callback' => 'drupal_get_form',
  476. 'page arguments' => array('tripal_chado_semweb_reset_form', 6, 7),
  477. 'type' => MENU_CALLBACK,
  478. 'access arguments' => array('administer tripal'),
  479. 'file' => 'includes/tripal_chado.semweb.inc',
  480. 'file path' => drupal_get_path('module', 'tripal_chado'),
  481. );
  482. //////////////////////////////////////////////////////////////////////////////
  483. // Auto Completes
  484. //////////////////////////////////////////////////////////////////////////////
  485. $items['admin/tripal/storage/chado/auto_name/dbxref/%/%'] = array(
  486. 'page callback' => 'tripal_autocomplete_dbxref',
  487. 'page arguments' => array(6, 7),
  488. 'access arguments' => array('access content'),
  489. 'file' => 'api/modules/tripal_chado.db.api.inc',
  490. 'file path' => drupal_get_path('module', 'tripal_chado'),
  491. 'type' => MENU_CALLBACK,
  492. );
  493. $items['admin/tripal/storage/chado/auto_name/cvterm/%/%'] = array(
  494. 'page callback' => 'tripal_autocomplete_cvterm',
  495. 'page arguments' => array(6, 7),
  496. 'access arguments' => array('access content'),
  497. 'file' => 'api/modules/tripal_chado.cv.api.inc',
  498. 'file path' => drupal_get_path('module', 'tripal_chado'),
  499. 'type' => MENU_CALLBACK,
  500. );
  501. $items['admin/tripal/storage/chado/auto_name/pub/%'] = array(
  502. 'page callback' => 'tripal_autocomplete_pub',
  503. 'page arguments' => array(6),
  504. 'access arguments' => array('access content'),
  505. 'file' => 'api/modules/tripal_chado.pub.api.inc',
  506. 'file path' => drupal_get_path('module', 'tripal_chado'),
  507. 'type' => MENU_CALLBACK,
  508. );
  509. $items['admin/tripal/storage/chado/auto_name/contact/%'] = array(
  510. 'page callback' => 'tripal_autocomplete_contact',
  511. 'page arguments' => array(6),
  512. 'access arguments' => array('access content'),
  513. 'file' => 'api/modules/tripal_chado.contact.api.inc',
  514. 'file path' => drupal_get_path('module', 'tripal_chado'),
  515. 'type' => MENU_CALLBACK,
  516. );
  517. $items['admin/tripal/storage/chado/auto_name/feature/%'] = array(
  518. 'page callback' => 'tripal_autocomplete_feature',
  519. 'page arguments' => array(6),
  520. 'access arguments' => array('access content'),
  521. 'file' => 'api/modules/tripal_chado.feature.api.inc',
  522. 'file path' => drupal_get_path('module', 'tripal_chado'),
  523. 'type' => MENU_CALLBACK,
  524. );
  525. $items['admin/tripal/storage/chado/auto_name/organism/%'] = array(
  526. 'page callback' => 'tripal_autocomplete_organism',
  527. 'page arguments' => array(6),
  528. 'access arguments' => array('access content'),
  529. 'file' => 'api/modules/tripal_chado.organism.api.inc',
  530. 'file path' => drupal_get_path('module', 'tripal_chado'),
  531. 'type' => MENU_CALLBACK,
  532. );
  533. //////////////////////////////////////////////////////////////////////////////
  534. // Controlled Vocabularies
  535. //////////////////////////////////////////////////////////////////////////////
  536. $items['admin/tripal/loaders/chado_cv'] = array(
  537. 'title' => 'Chado Controlled Vocabularies',
  538. 'description' => 'Controlled Vocabularies control the terms available for various chado fields.',
  539. 'page callback' => 'tripal_cv_admin_cv_listing',
  540. 'access arguments' => array('administer controlled vocabularies'),
  541. 'file' => 'includes/tripal_chado.cv.inc',
  542. 'file path' => drupal_get_path('module', 'tripal_chado'),
  543. 'type' => MENU_NORMAL_ITEM,
  544. );
  545. $items['admin/tripal/loaders/chado_cv/edit/%'] = array(
  546. 'title' => 'Edit a Controlled Vocabulary',
  547. 'description' => 'Edit the details such as name and description for an existing controlled vocabulary.',
  548. 'page callback' => 'drupal_get_form',
  549. 'page arguments' => array('tripal_cv_cv_edit_form', 5),
  550. 'access callback' => 'user_access',
  551. 'access arguments' => array('administer controlled vocabularies'),
  552. 'file' => 'includes/tripal_chado.cv.inc',
  553. 'file path' => drupal_get_path('module', 'tripal_chado'),
  554. 'type' => MENU_CALLBACK,
  555. );
  556. $items['admin/tripal/loaders/chado_cv/add'] = array(
  557. 'title' => 'Add a Controlled Vocabulary',
  558. 'description' => 'Manually a new controlled vocabulary.',
  559. 'page callback' => 'drupal_get_form',
  560. 'page arguments' => array('tripal_cv_cv_add_form'),
  561. 'access callback' => 'user_access',
  562. 'access arguments' => array('administer controlled vocabularies'),
  563. 'file' => 'includes/tripal_chado.cv.inc',
  564. 'file path' => drupal_get_path('module', 'tripal_chado'),
  565. 'type' => MENU_CALLBACK,
  566. );
  567. $items['admin/tripal/loaders/chado_cv/%/cvterm/add'] = array(
  568. 'title' => 'Add a Controlled Vocabulary Term',
  569. 'description' => 'Add a new controlled vocabulary term.',
  570. 'page callback' => 'drupal_get_form',
  571. 'page arguments' => array('tripal_cv_cvterm_add_form', 4),
  572. 'access arguments' => array('administer controlled vocabularies'),
  573. 'file' => 'includes/tripal_chado.cv.inc',
  574. 'file path' => drupal_get_path('module', 'tripal_chado'),
  575. 'type' => MENU_CALLBACK,
  576. );
  577. $items['admin/tripal/loaders/chado_cv/cvterm/add'] = array(
  578. 'title' => 'Add a Controlled Vocabulary Term',
  579. 'description' => 'Add a new controlled vocabulary term.',
  580. 'page callback' => 'drupal_get_form',
  581. 'page arguments' => array('tripal_cv_cvterm_add_form'),
  582. 'access arguments' => array('administer controlled vocabularies'),
  583. 'file' => 'includes/tripal_chado.cv.inc',
  584. 'file path' => drupal_get_path('module', 'tripal_chado'),
  585. 'type' => MENU_CALLBACK,
  586. );
  587. $items['admin/tripal/loaders/chado_cv/%/cvterm/edit/%'] = array(
  588. 'title' => 'Edit a Controlled Vocabulary Term',
  589. 'description' => 'Edit an existing controlled vocabulary term.',
  590. 'page callback' => 'drupal_get_form',
  591. 'page arguments' => array('tripal_cv_cvterm_edit_form', 4, 7),
  592. 'access arguments' => array('administer controlled vocabularies'),
  593. 'file' => 'includes/tripal_chado.cv.inc',
  594. 'file path' => drupal_get_path('module', 'tripal_chado'),
  595. 'type' => MENU_CALLBACK,
  596. );
  597. //////////////////////////////////////////////////////////////////////////////
  598. // Databases
  599. //////////////////////////////////////////////////////////////////////////////
  600. $items['admin/tripal/loaders/chado_db'] = array(
  601. 'title' => 'Chado Databases',
  602. 'description' => 'References to External Database sites such as NCBI',
  603. 'page callback' => 'tripal_chado_admin_db_listing',
  604. 'access arguments' => array('administer db cross-references'),
  605. 'file' => 'includes/tripal_chado.db.inc',
  606. 'file path' => drupal_get_path('module', 'tripal_chado'),
  607. 'type' => MENU_NORMAL_ITEM,
  608. );
  609. $items['admin/tripal/loaders/chado_db/edit/%'] = array(
  610. 'title' => 'Edit a Database Reference',
  611. 'description' => 'Edit existing Database References.',
  612. 'page callback' => 'drupal_get_form',
  613. 'page arguments' => array('tripal_chado_db_edit_form', 5),
  614. 'access callback' => 'user_access',
  615. 'access arguments' => array('administer db cross-references'),
  616. 'file' => 'includes/tripal_chado.db.inc',
  617. 'file path' => drupal_get_path('module', 'tripal_chado'),
  618. 'type' => MENU_CALLBACK,
  619. );
  620. $items['admin/tripal/loaders/chado_db/add'] = array(
  621. 'title' => 'Create a Database Reference',
  622. 'description' => 'Create a new reference to an External Database.',
  623. 'page callback' => 'drupal_get_form',
  624. 'page arguments' => array('tripal_chado_db_add_form'),
  625. 'access callback' => 'user_access',
  626. 'access arguments' => array('administer db cross-references'),
  627. 'file' => 'includes/tripal_chado.db.inc',
  628. 'file path' => drupal_get_path('module', 'tripal_chado'),
  629. 'type' => MENU_CALLBACK,
  630. );
  631. //////////////////////////////////////////////////////////////////////////////
  632. // FEATURES
  633. //////////////////////////////////////////////////////////////////////////////
  634. // the menu link for addressing any feature (by name, uniquename, synonym)
  635. $items['feature/%'] = array(
  636. 'page callback' => 'tripal_feature_match_features_page',
  637. 'page arguments' => array(1),
  638. 'access arguments' => array('access chado_feature content'),
  639. 'type' => MENU_LOCAL_TASK,
  640. );
  641. // the administative settings menu
  642. $items['find/sequences'] = array(
  643. 'title' => 'Sequence Retrieval',
  644. 'description' => 'Download a file of sequences',
  645. 'page callback' => 'drupal_get_form',
  646. 'page arguments' => array('tripal_chado_feature_seq_extract_form'),
  647. 'access arguments' => array('access chado_feature content'),
  648. 'file' => 'includes/tripal_chado.seq_extract.inc',
  649. 'file path' => drupal_get_path('module', 'tripal_chado'),
  650. 'type' => MENU_CALLBACK,
  651. );
  652. $items['find/sequences/download'] = array(
  653. 'page callback' => 'tripal_chado_feature_seq_extract_download',
  654. 'access arguments' => array('access chado_feature content'),
  655. 'file' => 'includes/tripal_chado.seq_extract.inc',
  656. 'file path' => drupal_get_path('module', 'tripal_chado'),
  657. 'type' => MENU_CALLBACK,
  658. );
  659. return $items;
  660. }
  661. /**
  662. * Implements hook_permission().
  663. *
  664. * Set the permission types that the chado module uses. Essentially we
  665. * want permissionis that protect creation, editing and deleting of chado
  666. * data objects
  667. *
  668. * @ingroup tripal
  669. */
  670. function tripal_chado_permission() {
  671. return array(
  672. 'install chado' => array(
  673. 'title' => t('Install Chado'),
  674. 'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
  675. ),
  676. 'view chado_ids' => array(
  677. 'title' => t('View Internal IDs'),
  678. 'description' => t('On content pages Tripal will typically provide
  679. a table of information pulled from the Chado database but the
  680. primary key IDs for that data is typically not shown. The
  681. default Tripal templates can show the primary key ID inside of a
  682. blue shaded table row if this permission is enabled. This can
  683. be useful for site developers who might want these IDs when working
  684. with the underlying database.'),
  685. 'restrict access' => TRUE,
  686. )
  687. );
  688. }
  689. /**
  690. * Implements hook_theme().
  691. */
  692. function tripal_chado_theme($existing, $type, $theme, $path) {
  693. $themes = array(
  694. // Themed Forms
  695. 'tripal_chado_feature_seq_extract_form' => array(
  696. 'render element' => 'form',
  697. ),
  698. 'tripal_chado_date_combo' => array(
  699. 'render element' => 'element',
  700. 'file' => 'theme/tripal_chado.theme.inc',
  701. ),
  702. // Themed forms
  703. 'tripal_pub_importer_setup_form_elements' => array(
  704. 'render element' => 'form',
  705. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  706. ),
  707. 'tripal_pub_search_setup_form_elements' => array(
  708. 'render element' => 'form',
  709. 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
  710. ),
  711. );
  712. // Override the theme for each entity to use the legacy modules
  713. // templates.
  714. if (module_exists('tripal_core')) {
  715. $core_path = drupal_get_path('module', 'tripal_core');
  716. // Get the list of node types that have legacy templates.
  717. $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
  718. // Get the list of TripalEntity bundle.
  719. $bundles = db_select('tripal_bundle', 'tb')
  720. ->fields('tb')
  721. ->execute();
  722. // Iterate through all of the TripalEntity bundles and see which ones
  723. // map to tables that used to have Tripal v2 nodes. For those, if the
  724. // legacy support is turned on then we want to use the legacy template.
  725. while ($bundle = $bundles->fetchObject()) {
  726. $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
  727. $vocab = $term->vocab;
  728. $params = array(
  729. 'vocabulary' => $vocab->vocabulary,
  730. 'accession' => $term->accession,
  731. );
  732. $mapped_table = chado_get_cvterm_mapping($params);
  733. // Do not proceed if there is not a mapped_table.
  734. if (!$mapped_table) {
  735. continue;
  736. }
  737. $chado_table = $mapped_table->chado_table;
  738. $legacy_template = 'legacy_template--chado_' . $chado_table;
  739. if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
  740. $themes['TripalEntity__' . $bundle->name] = array(
  741. 'template' => 'node--chado-generic',
  742. 'render element' => 'entity',
  743. 'base hook' => 'entity',
  744. 'path' => "$core_path/theme/templates",
  745. );
  746. }
  747. }
  748. }
  749. return $themes;
  750. }
  751. /**
  752. * Implements hook_preprocess().
  753. *
  754. * This function is used to support legacy Tripal v2 templates
  755. * for use with Tripal v3 entities.
  756. */
  757. function tripal_chado_preprocess(&$variables, $hook) {
  758. if ($hook == 'entity' and array_key_exists('TripalEntity', $variables)) {
  759. // The node--chado-generic template expets there to be a
  760. // teaser and node variables. So, we'll add them.
  761. $variables['teaser'] = FALSE;
  762. $variables['node'] = $variables['TripalEntity'];
  763. }
  764. }
  765. /**
  766. * Implements hook_exclude_type_by_default()
  767. *
  768. * This hooks allows fields of a specified type that match a specified criteria
  769. * to be excluded by default from any table when chado_generate_var() is called.
  770. * Keep in mind that if fields are excluded by default they can always be
  771. * expanded at a later date using chado_expand_var().
  772. *
  773. * Criteria are php strings that evaluate to either TRUE or FALSE. These
  774. * strings are evaluated using drupal_eval() which suppresses syntax errors and
  775. * throws watchdog entries of type php. There are also watchdog entries of type
  776. * tripal stating the exact criteria evaluated. Criteria can
  777. * contain the following tokens:
  778. * - <field_name>
  779. * Replaced by the name of the field to be excluded
  780. * - <field_value>
  781. * Replaced by the value of the field in the current record
  782. * Also keep in mind that if your criteria doesn't contain the
  783. * &gt;field_value&lt; token then it will be evaluated before the query is
  784. * executed and if the field is excluded it won't be included in the
  785. * query.
  786. *
  787. * @return
  788. * An array of type => criteria where the type is excluded if the criteria
  789. * evaluates to TRUE
  790. *
  791. * @ingroup tripal
  792. */
  793. function tripal_chado_exclude_type_by_default() {
  794. return array('text' => 'strlen("<field_value> ") > 250');
  795. }
  796. /**
  797. * Implements hook_job_describe_args().
  798. *
  799. * Describes the arguments for the tripal_populate_mview job to allow for
  800. * greater readability in the jobs details pages.
  801. *
  802. * @param $callback
  803. * The callback of the current tripal job (this is the function that will be
  804. * executed when tripal_launch_jobs.php is run.
  805. * @param $args
  806. * An array of arguments passed in when the job was registered.
  807. *
  808. * @return
  809. * A more readable $args array
  810. *
  811. * @ingroup tripal
  812. */
  813. function tripal_chado_job_describe_args($callback, $args) {
  814. $new_args = array();
  815. if ($callback == 'tripal_populate_mview') {
  816. // get this mview details
  817. $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
  818. $results = db_query($sql, array(':mview_id' => $args[0]));
  819. $mview = $results->fetchObject();
  820. $new_args['View Name'] = $mview->name;
  821. }
  822. elseif ($callback == 'tripal_install_chado') {
  823. $new_args['Action'] = $args[0];
  824. }
  825. return $new_args;
  826. }
  827. /**
  828. * Remove the nid from chado_entity if it exists when the node is deleted
  829. */
  830. function tripal_chado_node_delete($node) {
  831. $nid = $node->nid;
  832. $sql = "UPDATE chado_entity SET nid = NULL WHERE nid = :nid";
  833. //db_query($sql, array('nid' => $nid));
  834. }
  835. /**
  836. *
  837. * Implements hook_form_FORM_ID_alter().
  838. *
  839. * The field_ui_field_edit_form is used for customizing the settings of
  840. * a field attached to an entity.
  841. *
  842. * This alter function disables some of the form widgets when the storage
  843. * backend indicates they are not appropriate.
  844. */
  845. function tripal_chado_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
  846. // For entity fields added by Tripal Entities we don't want the
  847. // the end-user to change the cardinality and the required fields
  848. // such that record can't be saved in Chado.
  849. // TODO: we shouldn't check for specific field types here
  850. // (e.g. chaod_linker_prop). That should be done via the TripalField
  851. // functions.
  852. if ($form['#instance']['entity_type'] == 'TripalEntity') {
  853. if ($form['#field']['storage']['type'] == 'field_chado_storage' and
  854. $form['#field']['type'] != 'chado_linker__prop') {
  855. $form['field']['cardinality']['#access'] = FALSE;
  856. $form['instance']['required']['#access'] = FALSE;
  857. }
  858. }
  859. // TODO: don't the the maximum length be larger than the field size.
  860. }
  861. /**
  862. * Uses the value provided in the $id argument to find all features that match
  863. * that ID by name, featurename or synonym. If it matches uniquenly to a single
  864. * feature it will redirect to that feature page, otherwise, a list of matching
  865. * features is shown.
  866. *
  867. * @ingroup tripal_feature
  868. */
  869. function tripal_feature_match_features_page($id) {
  870. // first check to see if the URL (e.g. /feature/$id) is already
  871. // assigned to a node. If so, then just go there. Otherwise,
  872. // try to find the feature.
  873. $sql = "
  874. SELECT source
  875. FROM {url_alias}
  876. WHERE alias = :alias
  877. ";
  878. $match = db_query($sql, array(':alias' => "feature/$id"))->fetchObject();
  879. if ($match) {
  880. drupal_goto($match->source);
  881. return;
  882. }
  883. $sql = "
  884. SELECT
  885. F.name, F.uniquename, F.feature_id,
  886. O.genus, O.species, O.organism_id,
  887. CVT.cvterm_id, CVT.name as type_name,
  888. array_agg(S.name) as synonyms
  889. FROM {feature} F
  890. INNER JOIN {organism} O on F.organism_id = O.organism_id
  891. INNER JOIN {cvterm} CVT on CVT.cvterm_id = F.type_id
  892. LEFT JOIN {feature_synonym} FS on FS.feature_id = F.feature_id
  893. LEFT JOIN {synonym} S on S.synonym_id = FS.synonym_id
  894. WHERE
  895. F.uniquename = :uname or
  896. F.name = :fname or
  897. S.name = :sname
  898. GROUP BY F.name, F.uniquename, F.feature_id, O.genus, O.species,
  899. O.organism_id, CVT.cvterm_id, CVT.name
  900. ";
  901. $args = array(':uname' => $id, ':fname' => $id, ':sname' => $id);
  902. $results = chado_query($sql, $args);
  903. $num_matches = $results->rowCount();
  904. // If there are no matches then just return a friendly message.
  905. if ($num_matches == 0) {
  906. drupal_set_message("No features matched the given name '$id'", 'warning');
  907. return "No matches found";
  908. }
  909. // if we have more than one match then generate the table, otherwise, redirect
  910. // to the matched feature
  911. elseif ($num_matches == 1) {
  912. $curr_match = $results->fetchObject();
  913. $entity_id = chado_get_record_entity_by_table('feature', $curr_match->feature_id);
  914. if ($entity_id) {
  915. drupal_goto("bio_data/" . $entity_id);
  916. return;
  917. }
  918. // If we are here it's because we couldn't find the entity. Check if a node
  919. // exists (Tv2 backwards compatibility).
  920. if (module_exists(tripal_feature)) {
  921. $nid = chado_get_nid_from_id('feature', $curr_match->feature_id);
  922. drupal_goto("node/" . $nid);
  923. return;
  924. }
  925. // If we are here it's because we couldn't find an entity_id or an nid
  926. drupal_set_message("No published features matched the given name '$id'", 'warning');
  927. return "No matches found";
  928. }
  929. elseif ($num_matches > 1) {
  930. // iterate through the matches and build the table for showing matches
  931. $header = array('Uniquename', 'Name', 'Type', 'Species', 'Synonyms');
  932. $rows = array();
  933. $curr_match;
  934. while ($match = $results->fetchObject()) {
  935. $curr_match = $match;
  936. $synonyms = $match->synonyms;
  937. $synonyms = preg_replace('/[\"\{\}]/', '', $synonyms);
  938. // Build the link to this page.
  939. $entity_id = chado_get_record_entity_by_table('feature', $curr_match->feature_id);
  940. $link = '';
  941. if ($entity_id) {
  942. $link = "bio_data/" . $entity_id;
  943. }
  944. // If we didn't find an entity ID we need to check nodes for
  945. // backwards compatibility with Tv2.
  946. if (!$entity_id and module_exists(tripal_feature)) {
  947. $nid = chado_get_nid_from_id('feature', $curr_match->feature_id);
  948. $link = "node/" . $nid;
  949. }
  950. if (!$link) {
  951. continue;
  952. }
  953. $rows[] = array(
  954. $match->uniquename,
  955. l($match->name, $link),
  956. $match->type_name,
  957. '<i>' . $match->genus . ' ' . $match->species . '</i>',
  958. $synonyms,
  959. );
  960. $num_matches++;
  961. }
  962. $table_attrs = array('class' => 'tripal-data-table');
  963. $output = "<p>The following features match the name '$id'.</p>";
  964. $output .= theme_table($header, $rows, $table_attrs, $caption);
  965. return $output;
  966. }
  967. }