tripal_organism.views.inc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal organism 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_organism_views Organism Views Integration
  13. * @ingroup views
  14. */
  15. /**
  16. *
  17. * @ingroup tripal_organism_views
  18. */
  19. function tripal_organism_views_default_views() {
  20. $views = array();
  21. if (!module_exists('tripal_views')) {
  22. return $views;
  23. }
  24. // Main default view
  25. $view = new view;
  26. $view->name = 'organism_listing';
  27. $view->description = 'A listing of all organism in chado';
  28. $view->tag = 'chado default';
  29. $view->base_table = 'organism';
  30. $view->core = 0;
  31. $view->api_version = '2';
  32. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  33. $handler = $view->new_display('default', 'Defaults', 'default');
  34. $handler->override_option('fields', array(
  35. 'common_name' => array(
  36. 'label' => 'Common Name',
  37. 'alter' => array(
  38. 'alter_text' => 0,
  39. 'text' => '',
  40. 'make_link' => 0,
  41. 'path' => '',
  42. 'link_class' => '',
  43. 'alt' => '',
  44. 'prefix' => '',
  45. 'suffix' => '',
  46. 'target' => '',
  47. 'help' => '',
  48. 'trim' => 0,
  49. 'max_length' => '',
  50. 'word_boundary' => 1,
  51. 'ellipsis' => 1,
  52. 'html' => 0,
  53. 'strip_tags' => 0,
  54. ),
  55. 'empty' => '',
  56. 'hide_empty' => 0,
  57. 'empty_zero' => 0,
  58. 'link_to_node' => 1,
  59. 'exclude' => 0,
  60. 'id' => 'common_name',
  61. 'table' => 'organism',
  62. 'field' => 'common_name',
  63. 'relationship' => 'none',
  64. ),
  65. 'genus' => array(
  66. 'label' => 'Genus',
  67. 'alter' => array(
  68. 'alter_text' => 0,
  69. 'text' => '',
  70. 'make_link' => 0,
  71. 'path' => '',
  72. 'link_class' => '',
  73. 'alt' => '',
  74. 'prefix' => '',
  75. 'suffix' => '',
  76. 'target' => '',
  77. 'help' => '',
  78. 'trim' => 0,
  79. 'max_length' => '',
  80. 'word_boundary' => 1,
  81. 'ellipsis' => 1,
  82. 'html' => 0,
  83. 'strip_tags' => 0,
  84. ),
  85. 'empty' => '',
  86. 'hide_empty' => 0,
  87. 'empty_zero' => 0,
  88. 'exclude' => 0,
  89. 'id' => 'genus',
  90. 'table' => 'organism',
  91. 'field' => 'genus',
  92. 'relationship' => 'none',
  93. ),
  94. 'species' => array(
  95. 'label' => 'Species',
  96. 'alter' => array(
  97. 'alter_text' => 0,
  98. 'text' => '',
  99. 'make_link' => 0,
  100. 'path' => '',
  101. 'link_class' => '',
  102. 'alt' => '',
  103. 'prefix' => '',
  104. 'suffix' => '',
  105. 'target' => '',
  106. 'help' => '',
  107. 'trim' => 0,
  108. 'max_length' => '',
  109. 'word_boundary' => 1,
  110. 'ellipsis' => 1,
  111. 'html' => 0,
  112. 'strip_tags' => 0,
  113. ),
  114. 'empty' => '',
  115. 'hide_empty' => 0,
  116. 'empty_zero' => 0,
  117. 'exclude' => 0,
  118. 'id' => 'species',
  119. 'table' => 'organism',
  120. 'field' => 'species',
  121. 'relationship' => 'none',
  122. ),
  123. 'abbreviation' => array(
  124. 'label' => 'Abbreviation',
  125. 'alter' => array(
  126. 'alter_text' => 0,
  127. 'text' => '',
  128. 'make_link' => 0,
  129. 'path' => '',
  130. 'link_class' => '',
  131. 'alt' => '',
  132. 'prefix' => '',
  133. 'suffix' => '',
  134. 'target' => '',
  135. 'help' => '',
  136. 'trim' => 0,
  137. 'max_length' => '',
  138. 'word_boundary' => 1,
  139. 'ellipsis' => 1,
  140. 'html' => 0,
  141. 'strip_tags' => 0,
  142. ),
  143. 'empty' => '',
  144. 'hide_empty' => 0,
  145. 'empty_zero' => 0,
  146. 'link_to_node' => 0,
  147. 'exclude' => 0,
  148. 'id' => 'abbreviation',
  149. 'table' => 'organism',
  150. 'field' => 'abbreviation',
  151. 'relationship' => 'none',
  152. ),
  153. ));
  154. $handler->override_option('sorts', array(
  155. 'genus' => array(
  156. 'order' => 'ASC',
  157. 'id' => 'genus',
  158. 'table' => 'organism',
  159. 'field' => 'genus',
  160. 'relationship' => 'none',
  161. ),
  162. 'species' => array(
  163. 'order' => 'ASC',
  164. 'id' => 'species',
  165. 'table' => 'organism',
  166. 'field' => 'species',
  167. 'relationship' => 'none',
  168. ),
  169. ));
  170. $handler->override_option('access', array(
  171. 'type' => 'perm',
  172. 'perm' => 'access chado_organism content',
  173. ));
  174. $handler->override_option('cache', array(
  175. 'type' => 'none',
  176. ));
  177. $handler->override_option('title', 'Organisms');
  178. $handler->override_option('empty', 'No organisms matched the supplied criteria.');
  179. $handler->override_option('empty_format', '1');
  180. $handler->override_option('items_per_page', 0);
  181. $handler->override_option('style_plugin', 'table');
  182. $handler->override_option('style_options', array(
  183. 'grouping' => '',
  184. 'override' => 1,
  185. 'sticky' => 0,
  186. 'order' => 'asc',
  187. 'summary' => '',
  188. 'columns' => array(
  189. 'common_name' => 'common_name',
  190. 'genus' => 'genus',
  191. 'species' => 'species',
  192. 'abbreviation' => 'abbreviation',
  193. ),
  194. 'info' => array(
  195. 'common_name' => array(
  196. 'sortable' => 1,
  197. 'separator' => '',
  198. ),
  199. 'genus' => array(
  200. 'sortable' => 1,
  201. 'separator' => '',
  202. ),
  203. 'species' => array(
  204. 'sortable' => 1,
  205. 'separator' => '',
  206. ),
  207. 'abbreviation' => array(
  208. 'sortable' => 1,
  209. 'separator' => '',
  210. ),
  211. ),
  212. 'default' => '-1',
  213. ));
  214. $default_handler = $handler;
  215. $handler = $view->new_display('page', 'Page', 'page_1');
  216. $handler->override_option('path', 'chado/organisms');
  217. $handler->override_option('menu', array(
  218. 'type' => 'normal',
  219. 'title' => 'Organisms',
  220. 'description' => 'A biological organism.',
  221. 'weight' => '10',
  222. 'name' => 'navigation',
  223. ));
  224. $handler->override_option('tab_options', array(
  225. 'type' => 'none',
  226. 'title' => '',
  227. 'description' => '',
  228. 'weight' => 0,
  229. 'name' => 'navigation',
  230. ));
  231. // Add code specific to a local chado installation
  232. // NOTE: Edit $handler above to $default_handler for the default display
  233. if (tripal_core_chado_schema_exists()) {
  234. // Add nid field
  235. $fields = $view->get_items('field', 'default');
  236. $new_fields = array(
  237. 'nid' => array(
  238. 'label' => 'Nid',
  239. 'alter' => array(
  240. 'alter_text' => 0,
  241. 'text' => '',
  242. 'make_link' => 0,
  243. 'path' => '',
  244. 'absolute' => 0,
  245. 'link_class' => '',
  246. 'alt' => '',
  247. 'rel' => '',
  248. 'prefix' => '',
  249. 'suffix' => '',
  250. 'target' => '',
  251. 'help' => '',
  252. 'trim' => 0,
  253. 'max_length' => '',
  254. 'word_boundary' => 1,
  255. 'ellipsis' => 1,
  256. 'html' => 0,
  257. 'strip_tags' => 0,
  258. ),
  259. 'empty' => '',
  260. 'hide_empty' => 0,
  261. 'empty_zero' => 0,
  262. 'hide_alter_empty' => 1,
  263. 'link_to_node' => 0,
  264. 'exclude' => 1,
  265. 'id' => 'nid',
  266. 'table' => 'node',
  267. 'field' => 'nid',
  268. 'relationship' => 'none',
  269. )
  270. );
  271. $fields = $new_fields + $fields;
  272. // Adds organism => Node relationship
  273. $default_handler->override_option('relationships', array(
  274. 'nid' => array(
  275. 'label' => 'Organism to Node',
  276. 'required' => 0,
  277. 'id' => 'nid',
  278. 'table' => 'chado_organism',
  279. 'field' => 'nid',
  280. 'relationship' => 'none',
  281. ),
  282. ));
  283. // Change analysis.name to have a link to the node
  284. $fields['common_name']['alter']['link_to_node'] = 1;
  285. $default_handler->override_option('fields', $fields);
  286. // Only show records with published nodes
  287. /**
  288. $filters = $view->get_items('filter', 'default');
  289. $filters['status'] = array(
  290. 'operator' => '=',
  291. 'value' => '1',
  292. 'group' => '0',
  293. 'exposed' => FALSE,
  294. 'expose' => array(
  295. 'operator' => FALSE,
  296. 'label' => '',
  297. ),
  298. 'id' => 'status',
  299. 'table' => 'node',
  300. 'field' => 'status',
  301. 'relationship' => 'none',
  302. );
  303. $default_handler->override_option('filters', $filters);
  304. */
  305. }
  306. $views[$view->name] = $view;
  307. return $views;
  308. }