tripal_analysis.views.inc 13 KB

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