tripal_library.views.inc 9.9 KB

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