tripal_analysis.views.inc 14 KB

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