tripal_organism.views.inc 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. * Implements hook_views_data()
  13. * Purpose: Describe chado/tripal tables & fields to views
  14. * @return: a data array which follows the structure outlined in the
  15. * views2 documentation for this hook. Essentially, it's an array of table
  16. * definitions keyed by chado/tripal table name. Each table definition
  17. * includes basic details about the table, fields in that table and
  18. * relationships between that table and others (joins)
  19. */
  20. require_once('views/organism.views.inc');
  21. require_once('views/chado_organism.views.inc');
  22. function tripal_organism_views_data() {
  23. $data = array();
  24. $data = array_merge($data, retrieve_organism_views_data());
  25. $data = array_merge($data, retrieve_chado_organism_views_data());
  26. return $data;
  27. }
  28. /*************************************************************************
  29. * Implements hook_views_handlers()
  30. * Purpose: Register all custom handlers with views
  31. * where a handler describes either "the type of field",
  32. * "how a field should be filtered", "how a field should be sorted"
  33. * @return: An array of handler definitions
  34. */
  35. function tripal_organism_views_handlers() {
  36. return array(
  37. 'info' => array(
  38. 'path' => drupal_get_path('module', 'tripal_organism') . '/views/handlers',
  39. ),
  40. 'handlers' => array(
  41. 'views_handler_field_computed_organism_nid' => array(
  42. 'parent' => 'views_handler_field_numeric',
  43. ),
  44. 'views_handler_filter_organism_common_name' => array(
  45. 'parent' => 'views_handler_filter_string',
  46. ),
  47. ),
  48. );
  49. }
  50. function tripal_organism_views_default_views () {
  51. $views = array();
  52. // Main default view
  53. // List all cvterms based on cv
  54. $view = new view;
  55. $view->name = 'all_organisms';
  56. $view->description = 'A listing of all organism in chado';
  57. $view->tag = 'chado';
  58. $view->view_php = '';
  59. $view->base_table = 'organism';
  60. $view->is_cacheable = FALSE;
  61. $view->api_version = 2;
  62. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  63. $handler = $view->new_display('default', 'Defaults', 'default');
  64. $handler->override_option('fields', array(
  65. 'common_name' => array(
  66. 'label' => 'Common Name',
  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. 'link_to_node' => 1,
  89. 'exclude' => 0,
  90. 'id' => 'common_name',
  91. 'table' => 'organism',
  92. 'field' => 'common_name',
  93. 'relationship' => 'none',
  94. ),
  95. 'abbreviation' => array(
  96. 'label' => 'Abbreviation',
  97. 'alter' => array(
  98. 'alter_text' => 0,
  99. 'text' => '',
  100. 'make_link' => 0,
  101. 'path' => '',
  102. 'link_class' => '',
  103. 'alt' => '',
  104. 'prefix' => '',
  105. 'suffix' => '',
  106. 'target' => '',
  107. 'help' => '',
  108. 'trim' => 0,
  109. 'max_length' => '',
  110. 'word_boundary' => 1,
  111. 'ellipsis' => 1,
  112. 'html' => 0,
  113. 'strip_tags' => 0,
  114. ),
  115. 'empty' => '',
  116. 'hide_empty' => 0,
  117. 'empty_zero' => 0,
  118. 'link_to_node' => 0,
  119. 'exclude' => 0,
  120. 'id' => 'abbreviation',
  121. 'table' => 'organism',
  122. 'field' => 'abbreviation',
  123. 'relationship' => 'none',
  124. ),
  125. 'genus' => array(
  126. 'label' => 'Genus',
  127. 'alter' => array(
  128. 'alter_text' => 0,
  129. 'text' => '',
  130. 'make_link' => 0,
  131. 'path' => '',
  132. 'link_class' => '',
  133. 'alt' => '',
  134. 'prefix' => '',
  135. 'suffix' => '',
  136. 'target' => '',
  137. 'help' => '',
  138. 'trim' => 0,
  139. 'max_length' => '',
  140. 'word_boundary' => 1,
  141. 'ellipsis' => 1,
  142. 'html' => 0,
  143. 'strip_tags' => 0,
  144. ),
  145. 'empty' => '',
  146. 'hide_empty' => 0,
  147. 'empty_zero' => 0,
  148. 'exclude' => 0,
  149. 'id' => 'genus',
  150. 'table' => 'organism',
  151. 'field' => 'genus',
  152. 'relationship' => 'none',
  153. ),
  154. 'species' => array(
  155. 'label' => 'Species',
  156. 'alter' => array(
  157. 'alter_text' => 0,
  158. 'text' => '',
  159. 'make_link' => 0,
  160. 'path' => '',
  161. 'link_class' => '',
  162. 'alt' => '',
  163. 'prefix' => '',
  164. 'suffix' => '',
  165. 'target' => '',
  166. 'help' => '',
  167. 'trim' => 0,
  168. 'max_length' => '',
  169. 'word_boundary' => 1,
  170. 'ellipsis' => 1,
  171. 'html' => 0,
  172. 'strip_tags' => 0,
  173. ),
  174. 'empty' => '',
  175. 'hide_empty' => 0,
  176. 'empty_zero' => 0,
  177. 'exclude' => 0,
  178. 'id' => 'species',
  179. 'table' => 'organism',
  180. 'field' => 'species',
  181. 'relationship' => 'none',
  182. ),
  183. 'num_features' => array(
  184. 'label' => 'Number of Features',
  185. 'alter' => array(
  186. 'alter_text' => 0,
  187. 'text' => '',
  188. 'make_link' => 0,
  189. 'path' => '',
  190. 'link_class' => '',
  191. 'alt' => '',
  192. 'prefix' => '',
  193. 'suffix' => '',
  194. 'target' => '',
  195. 'help' => '',
  196. 'trim' => 0,
  197. 'max_length' => '',
  198. 'word_boundary' => 1,
  199. 'ellipsis' => 1,
  200. 'html' => 0,
  201. 'strip_tags' => 0,
  202. ),
  203. 'empty' => '',
  204. 'hide_empty' => 0,
  205. 'empty_zero' => 0,
  206. 'exclude' => 0,
  207. 'id' => 'num_features',
  208. 'table' => 'organism',
  209. 'field' => 'num_features',
  210. 'relationship' => 'none',
  211. ),
  212. 'num_stocks' => array(
  213. 'label' => 'Number of Stocks',
  214. 'alter' => array(
  215. 'alter_text' => 0,
  216. 'text' => '',
  217. 'make_link' => 0,
  218. 'path' => '',
  219. 'link_class' => '',
  220. 'alt' => '',
  221. 'prefix' => '',
  222. 'suffix' => '',
  223. 'target' => '',
  224. 'help' => '',
  225. 'trim' => 0,
  226. 'max_length' => '',
  227. 'word_boundary' => 1,
  228. 'ellipsis' => 1,
  229. 'html' => 0,
  230. 'strip_tags' => 0,
  231. ),
  232. 'empty' => '',
  233. 'hide_empty' => 0,
  234. 'empty_zero' => 0,
  235. 'exclude' => 0,
  236. 'id' => 'num_stocks',
  237. 'table' => 'organism',
  238. 'field' => 'num_stocks',
  239. 'relationship' => 'none',
  240. ),
  241. 'num_libraries' => array(
  242. 'label' => 'Number of Libraries',
  243. 'alter' => array(
  244. 'alter_text' => 0,
  245. 'text' => '',
  246. 'make_link' => 0,
  247. 'path' => '',
  248. 'link_class' => '',
  249. 'alt' => '',
  250. 'prefix' => '',
  251. 'suffix' => '',
  252. 'target' => '',
  253. 'help' => '',
  254. 'trim' => 0,
  255. 'max_length' => '',
  256. 'word_boundary' => 1,
  257. 'ellipsis' => 1,
  258. 'html' => 0,
  259. 'strip_tags' => 0,
  260. ),
  261. 'empty' => '',
  262. 'hide_empty' => 0,
  263. 'empty_zero' => 0,
  264. 'exclude' => 0,
  265. 'id' => 'num_libraries',
  266. 'table' => 'organism',
  267. 'field' => 'num_libraries',
  268. 'relationship' => 'none',
  269. ),
  270. ));
  271. $handler->override_option('access', array(
  272. 'type' => 'perm',
  273. 'perm' => 'access chado_organism content',
  274. ));
  275. $handler->override_option('cache', array(
  276. 'type' => 'none',
  277. ));
  278. $handler->override_option('title', 'Organisms');
  279. $handler->override_option('empty', 'No organism currently in your chado database.');
  280. $handler->override_option('empty_format', '1');
  281. $handler->override_option('items_per_page', 0);
  282. $handler->override_option('style_plugin', 'table');
  283. $handler->override_option('style_options', array(
  284. 'grouping' => '',
  285. 'override' => 1,
  286. 'sticky' => 0,
  287. 'order' => 'asc',
  288. 'columns' => array(
  289. 'abbreviation' => 'abbreviation',
  290. 'common_name' => 'common_name',
  291. 'genus' => 'genus',
  292. 'species' => 'species',
  293. ),
  294. 'info' => array(
  295. 'abbreviation' => array(
  296. 'sortable' => 0,
  297. 'separator' => '',
  298. ),
  299. 'common_name' => array(
  300. 'sortable' => 0,
  301. 'separator' => '',
  302. ),
  303. 'genus' => array(
  304. 'sortable' => 0,
  305. 'separator' => '',
  306. ),
  307. 'species' => array(
  308. 'sortable' => 0,
  309. 'separator' => '',
  310. ),
  311. ),
  312. 'default' => '-1',
  313. ));
  314. $handler = $view->new_display('page', 'Page', 'page_1');
  315. $handler->override_option('path', 'organisms');
  316. $handler->override_option('menu', array(
  317. 'type' => 'normal',
  318. 'title' => 'Organisms',
  319. 'description' => '',
  320. 'weight' => '0',
  321. 'name' => 'primary-links',
  322. ));
  323. $handler->override_option('tab_options', array(
  324. 'type' => 'none',
  325. 'title' => '',
  326. 'description' => '',
  327. 'weight' => 0,
  328. 'name' => 'navigation',
  329. ));
  330. $views[$view->name] = $view;
  331. return $views;
  332. }