tripal_analysis.views.inc 14 KB

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