tripal_organism.views.inc 9.1 KB

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