tripal_library.views.inc 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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/library.views.inc');
  21. require_once('views/chado_library.views.inc');
  22. require_once('views/misc_tables.views.inc');
  23. function tripal_library_views_data() {
  24. $data = array();
  25. $data = array_merge($data, retrieve_library_views_data());
  26. $data = array_merge($data, retrieve_chado_library_views_data());
  27. $data = array_merge($data, retrieve_library_misc_tables_views_data());
  28. return $data;
  29. }
  30. /*************************************************************************
  31. * Implements hook_views_handlers()
  32. * Purpose: Register all custom handlers with views
  33. * where a handler describes either "the type of field",
  34. * "how a field should be filtered", "how a field should be sorted"
  35. * @return: An array of handler definitions
  36. */
  37. function tripal_library_views_handlers() {
  38. return array(
  39. 'info' => array(
  40. 'path' => drupal_get_path('module', 'tripal_library') . '/views/handlers',
  41. ),
  42. 'handlers' => array(
  43. 'views_handler_field_computed_library_nid' => array(
  44. 'parent' => 'views_handler_field_numeric',
  45. ),
  46. 'views_handler_field_tf_boolean' => array(
  47. 'parent' => 'views_handler_field',
  48. ),
  49. 'views_handler_field_readable_date' => array(
  50. 'parent' => 'views_handler_field',
  51. ),
  52. ),
  53. );
  54. }
  55. function tripal_library_views_default_views () {
  56. $views = array();
  57. // Main default view
  58. // List all cvterms based on cv
  59. $view = new view;
  60. $view->name = 'all_libraries';
  61. $view->description = 'A listing of all libraries';
  62. $view->tag = 'chado';
  63. $view->view_php = '';
  64. $view->base_table = 'library';
  65. $view->is_cacheable = FALSE;
  66. $view->api_version = 2;
  67. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  68. $handler = $view->new_display('default', 'Defaults', 'default');
  69. $handler->override_option('fields', array(
  70. 'uniquename' => array(
  71. 'label' => 'Unique Name',
  72. 'alter' => array(
  73. 'alter_text' => 0,
  74. 'text' => '',
  75. 'make_link' => 0,
  76. 'path' => '',
  77. 'link_class' => '',
  78. 'alt' => '',
  79. 'prefix' => '',
  80. 'suffix' => '',
  81. 'target' => '',
  82. 'help' => '',
  83. 'trim' => 0,
  84. 'max_length' => '',
  85. 'word_boundary' => 1,
  86. 'ellipsis' => 1,
  87. 'html' => 0,
  88. 'strip_tags' => 0,
  89. ),
  90. 'empty' => '',
  91. 'hide_empty' => 0,
  92. 'empty_zero' => 0,
  93. 'link_to_node' => 1,
  94. 'exclude' => 0,
  95. 'id' => 'uniquename',
  96. 'table' => 'library',
  97. 'field' => 'uniquename',
  98. 'relationship' => 'none',
  99. ),
  100. 'name_1' => array(
  101. 'label' => 'Name',
  102. 'alter' => array(
  103. 'alter_text' => 0,
  104. 'text' => '',
  105. 'make_link' => 0,
  106. 'path' => '',
  107. 'link_class' => '',
  108. 'alt' => '',
  109. 'prefix' => '',
  110. 'suffix' => '',
  111. 'target' => '',
  112. 'help' => '',
  113. 'trim' => 0,
  114. 'max_length' => '',
  115. 'word_boundary' => 1,
  116. 'ellipsis' => 1,
  117. 'html' => 0,
  118. 'strip_tags' => 0,
  119. ),
  120. 'empty' => '',
  121. 'hide_empty' => 0,
  122. 'empty_zero' => 0,
  123. 'link_to_node' => 1,
  124. 'exclude' => 0,
  125. 'id' => 'name_1',
  126. 'table' => 'library',
  127. 'field' => 'name',
  128. 'relationship' => 'none',
  129. ),
  130. 'common_name' => array(
  131. 'label' => 'Organism',
  132. 'alter' => array(
  133. 'alter_text' => 0,
  134. 'text' => '',
  135. 'make_link' => 0,
  136. 'path' => '',
  137. 'link_class' => '',
  138. 'alt' => '',
  139. 'prefix' => '',
  140. 'suffix' => '',
  141. 'target' => '',
  142. 'help' => '',
  143. 'trim' => 0,
  144. 'max_length' => '',
  145. 'word_boundary' => 1,
  146. 'ellipsis' => 1,
  147. 'html' => 0,
  148. 'strip_tags' => 0,
  149. ),
  150. 'empty' => '',
  151. 'hide_empty' => 0,
  152. 'empty_zero' => 0,
  153. 'link_to_node' => 1,
  154. 'exclude' => 0,
  155. 'id' => 'common_name',
  156. 'table' => 'organism',
  157. 'field' => 'common_name',
  158. 'relationship' => 'none',
  159. ),
  160. 'name' => array(
  161. 'label' => 'Type',
  162. 'alter' => array(
  163. 'alter_text' => 0,
  164. 'text' => '',
  165. 'make_link' => 0,
  166. 'path' => '',
  167. 'link_class' => '',
  168. 'alt' => '',
  169. 'prefix' => '',
  170. 'suffix' => '',
  171. 'target' => '',
  172. 'help' => '',
  173. 'trim' => 0,
  174. 'max_length' => '',
  175. 'word_boundary' => 1,
  176. 'ellipsis' => 1,
  177. 'html' => 0,
  178. 'strip_tags' => 0,
  179. ),
  180. 'empty' => '',
  181. 'hide_empty' => 0,
  182. 'empty_zero' => 0,
  183. 'exclude' => 0,
  184. 'id' => 'name',
  185. 'table' => 'cvterm',
  186. 'field' => 'name',
  187. 'relationship' => 'none',
  188. ),
  189. 'is_obsolete' => array(
  190. 'label' => 'Is Obsolete?',
  191. 'alter' => array(
  192. 'alter_text' => 0,
  193. 'text' => '',
  194. 'make_link' => 0,
  195. 'path' => '',
  196. 'link_class' => '',
  197. 'alt' => '',
  198. 'prefix' => '',
  199. 'suffix' => '',
  200. 'target' => '',
  201. 'help' => '',
  202. 'trim' => 0,
  203. 'max_length' => '',
  204. 'word_boundary' => 1,
  205. 'ellipsis' => 1,
  206. 'html' => 0,
  207. 'strip_tags' => 0,
  208. ),
  209. 'empty' => '',
  210. 'hide_empty' => 0,
  211. 'empty_zero' => 0,
  212. 'type' => 'yes-no',
  213. 'not' => 0,
  214. 'exclude' => 0,
  215. 'id' => 'is_obsolete',
  216. 'table' => 'library',
  217. 'field' => 'is_obsolete',
  218. 'relationship' => 'none',
  219. ),
  220. 'num_features' => array(
  221. 'label' => 'Number of Features',
  222. 'alter' => array(
  223. 'alter_text' => 0,
  224. 'text' => '',
  225. 'make_link' => 0,
  226. 'path' => '',
  227. 'link_class' => '',
  228. 'alt' => '',
  229. 'prefix' => '',
  230. 'suffix' => '',
  231. 'target' => '',
  232. 'help' => '',
  233. 'trim' => 0,
  234. 'max_length' => '',
  235. 'word_boundary' => 1,
  236. 'ellipsis' => 1,
  237. 'html' => 0,
  238. 'strip_tags' => 0,
  239. ),
  240. 'empty' => '',
  241. 'hide_empty' => 0,
  242. 'empty_zero' => 0,
  243. 'exclude' => 0,
  244. 'id' => 'num_features',
  245. 'table' => 'library',
  246. 'field' => 'num_features',
  247. 'relationship' => 'none',
  248. ),
  249. ));
  250. $handler->override_option('filters', array(
  251. 'common_name' => array(
  252. 'operator' => '=',
  253. 'value' => 'All',
  254. 'group' => '0',
  255. 'exposed' => TRUE,
  256. 'expose' => array(
  257. 'use_operator' => 0,
  258. 'operator' => 'common_name_op',
  259. 'identifier' => 'organism_common_name',
  260. 'label' => 'Organism',
  261. 'optional' => 1,
  262. 'remember' => 0,
  263. ),
  264. 'case' => 1,
  265. 'id' => 'common_name',
  266. 'table' => 'organism',
  267. 'field' => 'common_name',
  268. 'relationship' => 'none',
  269. ),
  270. ));
  271. $handler->override_option('access', array(
  272. 'type' => 'perm',
  273. 'perm' => 'access chado_library content',
  274. ));
  275. $handler->override_option('cache', array(
  276. 'type' => 'none',
  277. ));
  278. $handler->override_option('title', 'Libraries');
  279. $handler->override_option('empty', 'There are no libraries matching the current criteria. If you think there should be, check that all chado libraries are sync\'d with your website.');
  280. $handler->override_option('empty_format', '1');
  281. $handler->override_option('use_pager', '1');
  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. 'name' => 'name',
  290. 'timeaccessioned' => 'timeaccessioned',
  291. 'timelastmodified' => 'timelastmodified',
  292. 'is_obsolete' => 'is_obsolete',
  293. 'name_1' => 'name_1',
  294. 'uniquename' => 'uniquename',
  295. 'common_name' => 'common_name',
  296. 'num_libraries' => 'num_libraries',
  297. ),
  298. 'info' => array(
  299. 'name' => array(
  300. 'sortable' => 0,
  301. 'separator' => '',
  302. ),
  303. 'timeaccessioned' => array(
  304. 'sortable' => 0,
  305. 'separator' => '',
  306. ),
  307. 'timelastmodified' => array(
  308. 'sortable' => 0,
  309. 'separator' => '',
  310. ),
  311. 'is_obsolete' => array(
  312. 'sortable' => 0,
  313. 'separator' => '',
  314. ),
  315. 'name_1' => array(
  316. 'sortable' => 0,
  317. 'separator' => '',
  318. ),
  319. 'uniquename' => array(
  320. 'sortable' => 0,
  321. 'separator' => '',
  322. ),
  323. 'common_name' => array(
  324. 'sortable' => 0,
  325. 'separator' => '',
  326. ),
  327. 'num_libraries' => array(
  328. 'separator' => '',
  329. ),
  330. ),
  331. 'default' => '-1',
  332. ));
  333. $handler = $view->new_display('page', 'Page', 'page_1');
  334. $handler->override_option('path', 'libraries');
  335. $handler->override_option('menu', array(
  336. 'type' => 'normal',
  337. 'title' => 'Sequence Libraries',
  338. 'description' => '',
  339. 'weight' => '0',
  340. 'name' => 'primary-links',
  341. ));
  342. $handler->override_option('tab_options', array(
  343. 'type' => 'none',
  344. 'title' => '',
  345. 'description' => '',
  346. 'weight' => 0,
  347. 'name' => 'navigation',
  348. ));
  349. $views[$view->name] = $view;
  350. return $views;
  351. }