tripal_analysis.views.inc.orig 14 KB

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