tripal_analysis.views.inc 14 KB

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