tripal_analysis.views.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. */
  15. /**
  16. * Implements hook_views_default_views().
  17. *
  18. * @ingroup tripal_analysis_views
  19. */
  20. function tripal_analysis_views_default_views() {
  21. $views = array();
  22. if (!module_exists('tripal_views')) {
  23. return $views;
  24. }
  25. // Main default view
  26. $view = new view;
  27. $view->name = 'analysis_listing';
  28. $view->description = 'A default listing of analyses provided by Tripal';
  29. $view->tag = 'chado default';
  30. $view->base_table = 'analysis';
  31. $view->core = 0;
  32. $view->api_version = '2';
  33. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  34. $handler = $view->new_display('default', 'Defaults', 'default');
  35. $handler->override_option('fields', array(
  36. 'name' => array(
  37. 'label' => 'Name',
  38. 'alter' => array(
  39. 'alter_text' => 0,
  40. 'text' => '',
  41. 'make_link' => 0,
  42. 'path' => '',
  43. 'absolute' => 0,
  44. 'link_class' => '',
  45. 'alt' => '',
  46. 'rel' => '',
  47. 'prefix' => '',
  48. 'suffix' => '',
  49. 'target' => '',
  50. 'help' => '',
  51. 'trim' => 0,
  52. 'max_length' => '',
  53. 'word_boundary' => 1,
  54. 'ellipsis' => 1,
  55. 'html' => 0,
  56. 'strip_tags' => 0,
  57. ),
  58. 'empty' => '',
  59. 'hide_empty' => 0,
  60. 'empty_zero' => 0,
  61. 'hide_alter_empty' => 1,
  62. 'type' => 'separator',
  63. 'separator' => ', ',
  64. 'exclude' => 0,
  65. 'link_to_node' => 1,
  66. 'id' => 'name',
  67. 'table' => 'analysis',
  68. 'field' => 'name',
  69. 'relationship' => 'none',
  70. ),
  71. 'program' => array(
  72. 'label' => 'Program',
  73. 'alter' => array(
  74. 'alter_text' => 0,
  75. 'text' => '',
  76. 'make_link' => 0,
  77. 'path' => '',
  78. 'absolute' => 0,
  79. 'link_class' => '',
  80. 'alt' => '',
  81. 'rel' => '',
  82. 'prefix' => '',
  83. 'suffix' => '',
  84. 'target' => '',
  85. 'help' => '',
  86. 'trim' => 0,
  87. 'max_length' => '',
  88. 'word_boundary' => 1,
  89. 'ellipsis' => 1,
  90. 'html' => 0,
  91. 'strip_tags' => 0,
  92. ),
  93. 'empty' => '',
  94. 'hide_empty' => 0,
  95. 'empty_zero' => 0,
  96. 'hide_alter_empty' => 1,
  97. 'exclude' => 0,
  98. 'id' => 'program',
  99. 'table' => 'analysis',
  100. 'field' => 'program',
  101. 'relationship' => 'none',
  102. ),
  103. 'sourcename' => array(
  104. 'label' => 'Source',
  105. 'alter' => array(
  106. 'alter_text' => 0,
  107. 'text' => '',
  108. 'make_link' => 0,
  109. 'path' => '',
  110. 'absolute' => 0,
  111. 'link_class' => '',
  112. 'alt' => '',
  113. 'rel' => '',
  114. 'prefix' => '',
  115. 'suffix' => '',
  116. 'target' => '',
  117. 'help' => '',
  118. 'trim' => 0,
  119. 'max_length' => '',
  120. 'word_boundary' => 1,
  121. 'ellipsis' => 1,
  122. 'html' => 0,
  123. 'strip_tags' => 0,
  124. ),
  125. 'empty' => '',
  126. 'hide_empty' => 0,
  127. 'empty_zero' => 0,
  128. 'hide_alter_empty' => 1,
  129. 'exclude' => 0,
  130. 'id' => 'sourcename',
  131. 'table' => 'analysis',
  132. 'field' => 'sourcename',
  133. 'relationship' => 'none',
  134. ),
  135. 'timeexecuted' => array(
  136. 'label' => 'Time Executed',
  137. 'alter' => array(
  138. 'alter_text' => 0,
  139. 'text' => '',
  140. 'make_link' => 0,
  141. 'path' => '',
  142. 'absolute' => 0,
  143. 'link_class' => '',
  144. 'alt' => '',
  145. 'rel' => '',
  146. 'prefix' => '',
  147. 'suffix' => '',
  148. 'target' => '',
  149. 'help' => '',
  150. 'trim' => 0,
  151. 'max_length' => '',
  152. 'word_boundary' => 1,
  153. 'ellipsis' => 1,
  154. 'html' => 0,
  155. 'strip_tags' => 0,
  156. ),
  157. 'empty' => '',
  158. 'hide_empty' => 0,
  159. 'empty_zero' => 0,
  160. 'hide_alter_empty' => 1,
  161. 'date_format' => 'custom',
  162. 'custom_date_format' => 'F j, Y',
  163. 'exclude' => 0,
  164. 'id' => 'timeexecuted',
  165. 'table' => 'analysis',
  166. 'field' => 'timeexecuted',
  167. 'override' => array(
  168. 'button' => 'Override',
  169. ),
  170. 'relationship' => 'none',
  171. ),
  172. ));
  173. $handler->override_option('filters', array(
  174. 'search_results' => array(
  175. 'operator' => '=',
  176. 'value' => '',
  177. 'group' => '0',
  178. 'exposed' => FALSE,
  179. 'expose' => array(
  180. 'operator' => FALSE,
  181. 'label' => '',
  182. ),
  183. 'id' => 'search_results',
  184. 'table' => 'views',
  185. 'field' => 'search_results',
  186. 'relationship' => 'none',
  187. 'apply_button' => 'Show ',
  188. 'no_results_text' => 'Click "Show" to see a list of all analysis matching the entered criteria. If you leave a any of the criteria blank then the analysis will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all analysis will be listed.',
  189. ),
  190. 'program' => array(
  191. 'operator' => '=',
  192. 'value' => '',
  193. 'group' => '0',
  194. 'exposed' => TRUE,
  195. 'expose' => array(
  196. 'use_operator' => 0,
  197. 'operator' => 'program_op',
  198. 'identifier' => 'program',
  199. 'label' => 'Program',
  200. 'remember' => 0,
  201. ),
  202. 'case' => 1,
  203. 'id' => 'program',
  204. 'table' => 'analysis',
  205. 'field' => 'program',
  206. 'relationship' => 'none',
  207. 'values_form_type' => 'select',
  208. 'multiple' => 1,
  209. 'optional' => 0,
  210. 'agg' => array(
  211. 'records_with' => 1,
  212. 'aggregates_with' => 0,
  213. ),
  214. ),
  215. 'timeexecuted' => array(
  216. 'operator' => '>',
  217. 'value' => array(
  218. 'type' => 'date',
  219. 'value' => '',
  220. 'min' => '',
  221. 'max' => '',
  222. ),
  223. 'group' => '0',
  224. 'exposed' => TRUE,
  225. 'expose' => array(
  226. 'use_operator' => 1,
  227. 'operator' => 'timeexecuted_op',
  228. 'identifier' => 'timeexecuted',
  229. 'label' => 'Time Executed',
  230. 'optional' => 1,
  231. 'remember' => 0,
  232. ),
  233. 'id' => 'timeexecuted',
  234. 'table' => 'analysis',
  235. 'field' => 'timeexecuted',
  236. 'relationship' => 'none',
  237. 'agg' => array(
  238. 'records_with' => 1,
  239. 'aggregates_with' => 0,
  240. ),
  241. ),
  242. 'name' => array(
  243. 'operator' => '~',
  244. 'value' => '',
  245. 'group' => '0',
  246. 'exposed' => TRUE,
  247. 'expose' => array(
  248. 'use_operator' => 0,
  249. 'operator' => 'name_op',
  250. 'identifier' => 'name',
  251. 'label' => 'Name Contains',
  252. 'bef_filter_description' => '',
  253. 'remember' => 0,
  254. ),
  255. 'case' => 0,
  256. 'id' => 'name',
  257. 'table' => 'analysis',
  258. 'field' => 'name',
  259. 'relationship' => 'none',
  260. 'values_form_type' => 'textfield',
  261. 'multiple' => 0,
  262. 'optional' => 0,
  263. ),
  264. 'sourcename' => array(
  265. 'operator' => '~',
  266. 'value' => '',
  267. 'group' => '0',
  268. 'exposed' => TRUE,
  269. 'expose' => array(
  270. 'use_operator' => 0,
  271. 'operator' => 'sourcename_op',
  272. 'identifier' => 'sourcename',
  273. 'label' => 'Source Contains',
  274. 'bef_filter_description' => '',
  275. 'remember' => 0,
  276. ),
  277. 'case' => 0,
  278. 'id' => 'sourcename',
  279. 'table' => 'analysis',
  280. 'field' => 'sourcename',
  281. 'relationship' => 'none',
  282. ),
  283. ));
  284. $handler->override_option('access', array(
  285. 'type' => 'perm',
  286. 'perm' => 'access chado_analysis content',
  287. ));
  288. $handler->override_option('cache', array(
  289. 'type' => 'none',
  290. ));
  291. $handler->override_option('title', 'Analysis');
  292. $handler->override_option('header', 'Click "Show" to see a list of all analysis matching the entered criteria. If you leave a any of the criteria blank then the analysis will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all analysis will be listed.');
  293. $handler->override_option('header_format', '2');
  294. $handler->override_option('header_empty', 1);
  295. $handler->override_option('empty', 'No analyses match the supplied criteria.');
  296. $handler->override_option('empty_format', '1');
  297. $handler->override_option('items_per_page', 50);
  298. $handler->override_option('use_pager', '1');
  299. $handler->override_option('style_plugin', 'table');
  300. $handler->override_option('style_options', array(
  301. 'grouping' => '',
  302. 'override' => 1,
  303. 'sticky' => 0,
  304. 'order' => 'asc',
  305. 'summary' => '',
  306. 'columns' => array(
  307. 'name' => 'name',
  308. 'program' => 'program',
  309. 'sourcename' => 'sourcename',
  310. 'num_features' => 'num_features',
  311. 'timeexecuted' => 'timeexecuted',
  312. ),
  313. 'info' => array(
  314. 'name' => array(
  315. 'sortable' => 1,
  316. 'separator' => '',
  317. ),
  318. 'program' => array(
  319. 'sortable' => 1,
  320. 'separator' => '',
  321. ),
  322. 'sourcename' => array(
  323. 'sortable' => 1,
  324. 'separator' => '',
  325. ),
  326. 'num_features' => array(
  327. 'separator' => '',
  328. ),
  329. 'timeexecuted' => array(
  330. 'sortable' => 1,
  331. 'separator' => '',
  332. ),
  333. ),
  334. 'default' => 'name',
  335. ));
  336. // this is needed so that fields/filters can be added to the default display later
  337. $default_handler = $handler;
  338. $handler = $view->new_display('page', 'Page', 'page_1');
  339. $handler->override_option('path', 'chado/analyses');
  340. $handler->override_option('menu', array(
  341. 'type' => 'normal',
  342. 'title' => 'Analyses',
  343. 'description' => 'An analysis is a particular type of a computational analysis; it may be a blast of one sequence against another, or an all by all blast, or a different kind of analysis altogether. It is a single unit of computation.',
  344. 'weight' => '10',
  345. 'name' => 'navigation',
  346. ));
  347. $handler->override_option('tab_options', array(
  348. 'type' => 'none',
  349. 'title' => '',
  350. 'description' => '',
  351. 'weight' => 0,
  352. 'name' => 'navigation',
  353. ));
  354. // Add code specific to a local chado installation
  355. // NOTE: Edit $handler above to $default_handler for the default display
  356. if (tripal_core_chado_schema_exists()) {
  357. // Add nid field
  358. $fields = $view->get_items('field', 'default');
  359. $new_fields = array(
  360. 'nid' => array(
  361. 'label' => 'Nid',
  362. 'alter' => array(
  363. 'alter_text' => 0,
  364. 'text' => '',
  365. 'make_link' => 0,
  366. 'path' => '',
  367. 'absolute' => 0,
  368. 'link_class' => '',
  369. 'alt' => '',
  370. 'rel' => '',
  371. 'prefix' => '',
  372. 'suffix' => '',
  373. 'target' => '',
  374. 'help' => '',
  375. 'trim' => 0,
  376. 'max_length' => '',
  377. 'word_boundary' => 1,
  378. 'ellipsis' => 1,
  379. 'html' => 0,
  380. 'strip_tags' => 0,
  381. ),
  382. 'empty' => '',
  383. 'hide_empty' => 0,
  384. 'empty_zero' => 0,
  385. 'hide_alter_empty' => 1,
  386. 'link_to_node' => 0,
  387. 'exclude' => 1,
  388. 'id' => 'nid',
  389. 'table' => 'node',
  390. 'field' => 'nid',
  391. 'relationship' => 'none',
  392. )
  393. );
  394. $fields = $new_fields + $fields;
  395. // Adds analysis => Node relationship
  396. $default_handler->override_option('relationships', array(
  397. 'nid' => array(
  398. 'label' => 'Analysis to Node',
  399. 'required' => 0,
  400. 'id' => 'nid',
  401. 'table' => 'chado_analysis',
  402. 'field' => 'nid',
  403. 'relationship' => 'none',
  404. ),
  405. ));
  406. // Change analysis.name to have a link to the node
  407. $fields['name']['link_to_node'] = 1;
  408. $default_handler->override_option('fields', $fields);
  409. // Only show records with published nodes
  410. /**
  411. $filters = $view->get_items('filter', 'default');
  412. $filters['status'] = array(
  413. 'operator' => '=',
  414. 'value' => '1',
  415. 'group' => '0',
  416. 'exposed' => FALSE,
  417. 'expose' => array(
  418. 'operator' => FALSE,
  419. 'label' => '',
  420. ),
  421. 'id' => 'status',
  422. 'table' => 'node',
  423. 'field' => 'status',
  424. 'relationship' => 'none',
  425. );
  426. $default_handler->override_option('filters', $filters);
  427. */
  428. }
  429. $views[$view->name] = $view;
  430. return $views;
  431. }