tripal_analysis.views.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal analysis tables. Supplementary functions can be found in
  6. * ./views/
  7. *
  8. * Documentation on views integration can be found at
  9. * http://views2.logrus.com/doc/html/index.html.
  10. */
  11. /**
  12. * @defgroup tripal_analysis_views Analysis Views Integration
  13. * @ingroup views
  14. * @ingroup tripal_analysis
  15. */
  16. require('views/analysis.views.inc');
  17. require('views/chado_analysis.views.inc');
  18. require('views/misc_tables.views.inc');
  19. /**
  20. * Implements hook_views_data()
  21. *
  22. * Purpose: Describe chado/tripal tables & fields to views
  23. *
  24. * @return: a data array which follows the structure outlined in the
  25. * views2 documentation for this hook. Essentially, it's an array of table
  26. * definitions keyed by chado/tripal table name. Each table definition
  27. * includes basic details about the table, fields in that table and
  28. * relationships between that table and others (joins)
  29. *
  30. * @ingroup tripal_analysis_views
  31. */
  32. function tripal_analysis_views_data() {
  33. $data = array();
  34. if (module_exists('tripal_views')) {
  35. // Base Table: Analysis
  36. $tablename = 'analysis';
  37. if (!tripal_views_is_integrated($tablename, 10)) {
  38. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
  39. tripal_views_integration_add_entry($table_integration_array);
  40. }
  41. $tables = array(
  42. 'analysisfeature',
  43. 'analysisprop'
  44. );
  45. foreach ($tables as $tablename) {
  46. if (!tripal_views_is_integrated($tablename, 10)) {
  47. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
  48. tripal_views_integration_add_entry($table_integration_array);
  49. }
  50. }
  51. // Old Style Views Integration
  52. } else {
  53. $data = array_merge($data, retrieve_analysis_views_data());
  54. $data = array_merge($data, retrieve_chado_analysis_views_data());
  55. $data = array_merge($data, retrieve_analysis_misc_tables_views_data());
  56. }
  57. return $data;
  58. }
  59. /**
  60. * Implements hook_views_handlers()
  61. *
  62. * Purpose: Register all custom handlers with views
  63. * where a handler describes either "the type of field",
  64. * "how a field should be filtered", "how a field should be sorted"
  65. *
  66. * @return
  67. * An array of handler definitions
  68. *
  69. * @ingroup tripal_analysis_views
  70. */
  71. function tripal_analysis_views_views_handlers() {
  72. return array(
  73. 'info' => array(
  74. 'path' => drupal_get_path('module', 'tripal_analysis') . '/views/handlers',
  75. ),
  76. 'handlers' => array(
  77. 'views_handler_field_computed_analysis_nid' => array(
  78. 'parent' => 'views_handler_field_numeric',
  79. ),
  80. 'views_handler_field_readable_date' => array(
  81. 'parent' => 'views_handler_field',
  82. ),
  83. ),
  84. );
  85. }
  86. /**
  87. * Implementation of hook_views_data_alter().
  88. */
  89. function tripal_analysis_views_data_alter(&$data) {
  90. if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
  91. // Add featuer relationship to node
  92. $data['node']['analysis_chado_nid'] = array(
  93. 'group' => 'Analysis',
  94. 'title' => 'Analysis Node',
  95. 'help' => 'Links Chado analysis Fields/Data to the Nodes in the current View.',
  96. 'real field' => 'nid',
  97. 'relationship' => array(
  98. 'handler' => 'views_handler_relationship',
  99. 'title' => t('Node => Chado'),
  100. 'label' => t('Node => Chado'),
  101. 'real field' => 'nid',
  102. 'base' => 'chado_analysis',
  103. 'base field' => 'nid'
  104. ),
  105. );
  106. }
  107. }
  108. /**
  109. *
  110. *
  111. * @ingroup tripal_analysis_views
  112. */
  113. function tripal_analysis_views_default_views () {
  114. $views = array();
  115. // Main default view
  116. // List all cvterms based on cv
  117. $view = new view;
  118. $view->name = 'all_analysis';
  119. $view->description = 'A listing of all analysis\'';
  120. $view->tag = 'chado';
  121. $view->view_php = '';
  122. $view->base_table = 'analysis';
  123. $view->is_cacheable = FALSE;
  124. $view->api_version = 2;
  125. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  126. $handler = $view->new_display('default', 'Defaults', 'default');
  127. $handler->override_option('fields', array(
  128. 'name' => array(
  129. 'label' => 'Name',
  130. 'alter' => array(
  131. 'alter_text' => 0,
  132. 'text' => '',
  133. 'make_link' => 0,
  134. 'path' => '',
  135. 'link_class' => '',
  136. 'alt' => '',
  137. 'prefix' => '',
  138. 'suffix' => '',
  139. 'target' => '',
  140. 'help' => '',
  141. 'trim' => 0,
  142. 'max_length' => '',
  143. 'word_boundary' => 1,
  144. 'ellipsis' => 1,
  145. 'html' => 0,
  146. 'strip_tags' => 0,
  147. ),
  148. 'empty' => '',
  149. 'hide_empty' => 0,
  150. 'empty_zero' => 0,
  151. 'link_to_node' => 1,
  152. 'exclude' => 0,
  153. 'id' => 'name',
  154. 'table' => 'analysis',
  155. 'field' => 'name',
  156. 'relationship' => 'none',
  157. ),
  158. 'algorithm' => array(
  159. 'label' => 'Algorithm',
  160. 'alter' => array(
  161. 'alter_text' => 0,
  162. 'text' => '',
  163. 'make_link' => 0,
  164. 'path' => '',
  165. 'link_class' => '',
  166. 'alt' => '',
  167. 'prefix' => '',
  168. 'suffix' => '',
  169. 'target' => '',
  170. 'help' => '',
  171. 'trim' => 0,
  172. 'max_length' => '',
  173. 'word_boundary' => 1,
  174. 'ellipsis' => 1,
  175. 'html' => 0,
  176. 'strip_tags' => 0,
  177. ),
  178. 'empty' => '',
  179. 'hide_empty' => 0,
  180. 'empty_zero' => 0,
  181. 'exclude' => 0,
  182. 'id' => 'algorithm',
  183. 'table' => 'analysis',
  184. 'field' => 'algorithm',
  185. 'relationship' => 'none',
  186. ),
  187. 'program' => array(
  188. 'label' => 'Program',
  189. 'alter' => array(
  190. 'alter_text' => 0,
  191. 'text' => '',
  192. 'make_link' => 0,
  193. 'path' => '',
  194. 'link_class' => '',
  195. 'alt' => '',
  196. 'prefix' => '',
  197. 'suffix' => '',
  198. 'target' => '',
  199. 'help' => '',
  200. 'trim' => 0,
  201. 'max_length' => '',
  202. 'word_boundary' => 1,
  203. 'ellipsis' => 1,
  204. 'html' => 0,
  205. 'strip_tags' => 0,
  206. ),
  207. 'empty' => '',
  208. 'hide_empty' => 0,
  209. 'empty_zero' => 0,
  210. 'exclude' => 0,
  211. 'id' => 'program',
  212. 'table' => 'analysis',
  213. 'field' => 'program',
  214. 'relationship' => 'none',
  215. ),
  216. 'programversion' => array(
  217. 'label' => 'Program Version',
  218. 'alter' => array(
  219. 'alter_text' => 0,
  220. 'text' => '',
  221. 'make_link' => 0,
  222. 'path' => '',
  223. 'link_class' => '',
  224. 'alt' => '',
  225. 'prefix' => '',
  226. 'suffix' => '',
  227. 'target' => '',
  228. 'help' => '',
  229. 'trim' => 0,
  230. 'max_length' => '',
  231. 'word_boundary' => 1,
  232. 'ellipsis' => 1,
  233. 'html' => 0,
  234. 'strip_tags' => 0,
  235. ),
  236. 'empty' => '',
  237. 'hide_empty' => 0,
  238. 'empty_zero' => 0,
  239. 'exclude' => 0,
  240. 'id' => 'programversion',
  241. 'table' => 'analysis',
  242. 'field' => 'programversion',
  243. 'relationship' => 'none',
  244. ),
  245. 'description' => array(
  246. 'label' => 'Description',
  247. 'alter' => array(
  248. 'alter_text' => 0,
  249. 'text' => '',
  250. 'make_link' => 0,
  251. 'path' => '',
  252. 'link_class' => '',
  253. 'alt' => '',
  254. 'prefix' => '',
  255. 'suffix' => '',
  256. 'target' => '',
  257. 'help' => '',
  258. 'trim' => 0,
  259. 'max_length' => '',
  260. 'word_boundary' => 1,
  261. 'ellipsis' => 1,
  262. 'html' => 0,
  263. 'strip_tags' => 0,
  264. ),
  265. 'empty' => '',
  266. 'hide_empty' => 0,
  267. 'empty_zero' => 0,
  268. 'exclude' => 0,
  269. 'id' => 'description',
  270. 'table' => 'analysis',
  271. 'field' => 'description',
  272. 'relationship' => 'none',
  273. ),
  274. 'sourcename' => array(
  275. 'label' => 'Source Name',
  276. 'alter' => array(
  277. 'alter_text' => 0,
  278. 'text' => '',
  279. 'make_link' => 0,
  280. 'path' => '',
  281. 'link_class' => '',
  282. 'alt' => '',
  283. 'prefix' => '',
  284. 'suffix' => '',
  285. 'target' => '',
  286. 'help' => '',
  287. 'trim' => 0,
  288. 'max_length' => '',
  289. 'word_boundary' => 1,
  290. 'ellipsis' => 1,
  291. 'html' => 0,
  292. 'strip_tags' => 0,
  293. ),
  294. 'empty' => '',
  295. 'hide_empty' => 0,
  296. 'empty_zero' => 0,
  297. 'exclude' => 0,
  298. 'id' => 'sourcename',
  299. 'table' => 'analysis',
  300. 'field' => 'sourcename',
  301. 'relationship' => 'none',
  302. ),
  303. 'sourceuri' => array(
  304. 'label' => 'Source URL',
  305. 'alter' => array(
  306. 'alter_text' => 0,
  307. 'text' => '',
  308. 'make_link' => 0,
  309. 'path' => '',
  310. 'link_class' => '',
  311. 'alt' => '',
  312. 'prefix' => '',
  313. 'suffix' => '',
  314. 'target' => '',
  315. 'help' => '',
  316. 'trim' => 0,
  317. 'max_length' => '',
  318. 'word_boundary' => 1,
  319. 'ellipsis' => 1,
  320. 'html' => 0,
  321. 'strip_tags' => 0,
  322. ),
  323. 'empty' => '',
  324. 'hide_empty' => 0,
  325. 'empty_zero' => 0,
  326. 'exclude' => 0,
  327. 'id' => 'sourceuri',
  328. 'table' => 'analysis',
  329. 'field' => 'sourceuri',
  330. 'relationship' => 'none',
  331. ),
  332. 'sourceversion' => array(
  333. 'label' => 'Source Version',
  334. 'alter' => array(
  335. 'alter_text' => 0,
  336. 'text' => '',
  337. 'make_link' => 0,
  338. 'path' => '',
  339. 'link_class' => '',
  340. 'alt' => '',
  341. 'prefix' => '',
  342. 'suffix' => '',
  343. 'target' => '',
  344. 'help' => '',
  345. 'trim' => 0,
  346. 'max_length' => '',
  347. 'word_boundary' => 1,
  348. 'ellipsis' => 1,
  349. 'html' => 0,
  350. 'strip_tags' => 0,
  351. ),
  352. 'empty' => '',
  353. 'hide_empty' => 0,
  354. 'empty_zero' => 0,
  355. 'exclude' => 0,
  356. 'id' => 'sourceversion',
  357. 'table' => 'analysis',
  358. 'field' => 'sourceversion',
  359. 'relationship' => 'none',
  360. ),
  361. 'num_features' => array(
  362. 'label' => 'Number of Features',
  363. 'alter' => array(
  364. 'alter_text' => 0,
  365. 'text' => '',
  366. 'make_link' => 0,
  367. 'path' => '',
  368. 'link_class' => '',
  369. 'alt' => '',
  370. 'prefix' => '',
  371. 'suffix' => '',
  372. 'target' => '',
  373. 'help' => '',
  374. 'trim' => 0,
  375. 'max_length' => '',
  376. 'word_boundary' => 1,
  377. 'ellipsis' => 1,
  378. 'html' => 0,
  379. 'strip_tags' => 0,
  380. ),
  381. 'empty' => '',
  382. 'hide_empty' => 0,
  383. 'empty_zero' => 0,
  384. 'exclude' => 0,
  385. 'id' => 'num_features',
  386. 'table' => 'analysis',
  387. 'field' => 'num_features',
  388. 'relationship' => 'none',
  389. ),
  390. 'timeexecuted' => array(
  391. 'label' => 'Time Executed',
  392. 'alter' => array(
  393. 'alter_text' => 0,
  394. 'text' => '',
  395. 'make_link' => 0,
  396. 'path' => '',
  397. 'link_class' => '',
  398. 'alt' => '',
  399. 'prefix' => '',
  400. 'suffix' => '',
  401. 'target' => '',
  402. 'help' => '',
  403. 'trim' => 0,
  404. 'max_length' => '',
  405. 'word_boundary' => 1,
  406. 'ellipsis' => 1,
  407. 'html' => 0,
  408. 'strip_tags' => 0,
  409. ),
  410. 'empty' => '',
  411. 'hide_empty' => 0,
  412. 'empty_zero' => 0,
  413. 'date_format' => 'large',
  414. 'custom_date_format' => '',
  415. 'exclude' => 0,
  416. 'id' => 'timeexecuted',
  417. 'table' => 'analysis',
  418. 'field' => 'timeexecuted',
  419. 'relationship' => 'none',
  420. ),
  421. ));
  422. $handler->override_option('filters', array(
  423. 'program' => array(
  424. 'operator' => '=',
  425. 'value' => 'All',
  426. 'group' => '0',
  427. 'exposed' => TRUE,
  428. 'expose' => array(
  429. 'use_operator' => 0,
  430. 'operator' => 'program_op',
  431. 'identifier' => 'program',
  432. 'label' => 'Program',
  433. 'optional' => 1,
  434. 'remember' => 0,
  435. ),
  436. 'case' => 0,
  437. 'id' => 'program',
  438. 'table' => 'analysis',
  439. 'field' => 'program',
  440. 'relationship' => 'none',
  441. ),
  442. 'sourcename' => array(
  443. 'operator' => 'contains',
  444. 'value' => '',
  445. 'group' => '0',
  446. 'exposed' => TRUE,
  447. 'expose' => array(
  448. 'use_operator' => 0,
  449. 'operator' => 'sourcename_op',
  450. 'identifier' => 'sourcename',
  451. 'label' => 'Source Name Contains',
  452. 'optional' => 1,
  453. 'remember' => 0,
  454. ),
  455. 'case' => 0,
  456. 'id' => 'sourcename',
  457. 'table' => 'analysis',
  458. 'field' => 'sourcename',
  459. 'relationship' => 'none',
  460. ),
  461. ));
  462. $handler->override_option('access', array(
  463. 'type' => 'perm',
  464. 'perm' => 'access chado_analysis content',
  465. ));
  466. $handler->override_option('cache', array(
  467. 'type' => 'none',
  468. ));
  469. $handler->override_option('title', 'Analysis');
  470. $handler->override_option('empty', 'No analysis match the supplied criteria.');
  471. $handler->override_option('empty_format', '1');
  472. $handler->override_option('items_per_page', 50);
  473. $handler->override_option('use_pager', '1');
  474. $handler->override_option('style_plugin', 'table');
  475. $handler->override_option('style_options', array(
  476. 'grouping' => '',
  477. 'override' => 1,
  478. 'sticky' => 0,
  479. 'order' => 'asc',
  480. 'columns' => array(
  481. 'algorithm' => 'algorithm',
  482. 'description' => 'description',
  483. 'name' => 'name',
  484. 'num_features' => 'num_features',
  485. 'program' => 'program',
  486. 'programversion' => 'programversion',
  487. 'sourcename' => 'sourcename',
  488. 'sourceuri' => 'sourceuri',
  489. 'sourceversion' => 'sourceversion',
  490. 'timeexecuted' => 'timeexecuted',
  491. ),
  492. 'info' => array(
  493. 'algorithm' => array(
  494. 'sortable' => 1,
  495. 'separator' => '',
  496. ),
  497. 'description' => array(
  498. 'sortable' => 1,
  499. 'separator' => '',
  500. ),
  501. 'name' => array(
  502. 'sortable' => 1,
  503. 'separator' => '',
  504. ),
  505. 'num_features' => array(
  506. 'separator' => '',
  507. ),
  508. 'program' => array(
  509. 'sortable' => 1,
  510. 'separator' => '',
  511. ),
  512. 'programversion' => array(
  513. 'sortable' => 1,
  514. 'separator' => '',
  515. ),
  516. 'sourcename' => array(
  517. 'sortable' => 1,
  518. 'separator' => '',
  519. ),
  520. 'sourceuri' => array(
  521. 'sortable' => 1,
  522. 'separator' => '',
  523. ),
  524. 'sourceversion' => array(
  525. 'sortable' => 1,
  526. 'separator' => '',
  527. ),
  528. 'timeexecuted' => array(
  529. 'sortable' => 1,
  530. 'separator' => '',
  531. ),
  532. ),
  533. 'default' => 'timeexecuted',
  534. ));
  535. $handler = $view->new_display('page', 'Page', 'page_1');
  536. $handler->override_option('path', 'analyses');
  537. $handler->override_option('menu', array(
  538. 'type' => 'normal',
  539. 'title' => 'Analyses',
  540. 'description' => '',
  541. 'weight' => '0',
  542. 'name' => 'primary-links',
  543. ));
  544. $handler->override_option('tab_options', array(
  545. 'type' => 'none',
  546. 'title' => '',
  547. 'description' => '',
  548. 'weight' => 0,
  549. 'name' => 'navigation',
  550. ));
  551. $views[$view->name] = $view;
  552. return $views;
  553. }