tripal_analysis.views.inc 13 KB

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