tripal_project.views.inc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal_project 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. *
  15. * @return: a data array which follows the structure outlined in the
  16. * views2 documentation for this hook. Essentially, it's an array of table
  17. * definitions keyed by chado/tripal table name. Each table definition
  18. * includes basic details about the table, fields in that table and
  19. * relationships between that table and others (joins)
  20. */
  21. function tripal_project_views_data() {
  22. $data = array();
  23. if (module_exists('tripal_views')) {
  24. $tables = array(
  25. 'project'
  26. );
  27. foreach ($tables as $tablename) {
  28. if (!tripal_views_is_integrated($tablename, 9)) {
  29. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
  30. tripal_views_integration_add_entry($table_integration_array);
  31. }
  32. }
  33. $tables = array(
  34. );
  35. foreach ($tables as $tablename) {
  36. if (!tripal_views_is_integrated($tablename, 9)) {
  37. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
  38. tripal_views_integration_add_entry($table_integration_array);
  39. }
  40. }
  41. }
  42. return $data;
  43. }
  44. /*************************************************************************
  45. * Implements hook_views_handlers()
  46. * Purpose: Register all custom handlers with views
  47. * where a handler describes either "the type of field",
  48. * "how a field should be filtered", "how a field should be sorted"
  49. *
  50. * @return: An array of handler definitions
  51. */
  52. function tripal_project_views_handlers() {
  53. return array(
  54. 'info' => array(
  55. 'path' => drupal_get_path('module', 'tripal_project') . '/views/handlers',
  56. ),
  57. 'handlers' => array(
  58. ),
  59. );
  60. }
  61. /**
  62. *
  63. * @ingroup tripal_feature_views
  64. */
  65. function tripal_project_views_default_views() {
  66. $views = array();
  67. // Main default view
  68. $view = new view;
  69. $view->name = 'project_listing';
  70. $view->description = 'A listing of chado projects';
  71. $view->tag = 'chado default';
  72. $view->base_table = 'project';
  73. $view->core = 6;
  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. 'name' => array(
  79. 'label' => 'Name',
  80. 'alter' => array(
  81. 'alter_text' => 0,
  82. 'text' => '',
  83. 'make_link' => 0,
  84. 'path' => '',
  85. 'absolute' => 0,
  86. 'link_class' => '',
  87. 'alt' => '',
  88. 'rel' => '',
  89. 'prefix' => '',
  90. 'suffix' => '',
  91. 'target' => '',
  92. 'help' => '',
  93. 'trim' => 0,
  94. 'max_length' => '',
  95. 'word_boundary' => 1,
  96. 'ellipsis' => 1,
  97. 'html' => 0,
  98. 'strip_tags' => 0,
  99. ),
  100. 'empty' => '',
  101. 'hide_empty' => 0,
  102. 'empty_zero' => 0,
  103. 'hide_alter_empty' => 1,
  104. 'type' => 'separator',
  105. 'separator' => ', ',
  106. 'exclude' => 0,
  107. 'id' => 'name',
  108. 'table' => 'project',
  109. 'field' => 'name',
  110. 'relationship' => 'none',
  111. ),
  112. 'description' => array(
  113. 'label' => 'Description',
  114. 'alter' => array(
  115. 'alter_text' => 0,
  116. 'text' => '',
  117. 'make_link' => 0,
  118. 'path' => '',
  119. 'absolute' => 0,
  120. 'link_class' => '',
  121. 'alt' => '',
  122. 'rel' => '',
  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. 'hide_alter_empty' => 1,
  138. 'type' => 'separator',
  139. 'separator' => ', ',
  140. 'exclude' => 0,
  141. 'id' => 'description',
  142. 'table' => 'project',
  143. 'field' => 'description',
  144. 'relationship' => 'none',
  145. ),
  146. ));
  147. $handler->override_option('filters', array(
  148. 'name' => array(
  149. 'operator' => 'contains',
  150. 'value' => '',
  151. 'group' => '0',
  152. 'exposed' => TRUE,
  153. 'expose' => array(
  154. 'use_operator' => 0,
  155. 'operator' => 'name_op',
  156. 'identifier' => 'name',
  157. 'label' => 'Name Contains',
  158. 'remember' => 0,
  159. ),
  160. 'case' => 0,
  161. 'id' => 'name',
  162. 'table' => 'project',
  163. 'field' => 'name',
  164. 'relationship' => 'none',
  165. 'agg' => array(
  166. 'records_with' => 1,
  167. 'aggregates_with' => 1,
  168. ),
  169. ),
  170. 'description' => array(
  171. 'operator' => 'contains',
  172. 'value' => '',
  173. 'group' => '0',
  174. 'exposed' => TRUE,
  175. 'expose' => array(
  176. 'use_operator' => 0,
  177. 'operator' => 'description_op',
  178. 'identifier' => 'description',
  179. 'label' => 'Description Contains',
  180. 'remember' => 0,
  181. ),
  182. 'case' => 1,
  183. 'id' => 'description',
  184. 'table' => 'project',
  185. 'field' => 'description',
  186. 'relationship' => 'none',
  187. 'agg' => array(
  188. 'records_with' => 1,
  189. 'aggregates_with' => 1,
  190. ),
  191. ),
  192. ));
  193. $handler->override_option('access', array(
  194. 'type' => 'perm',
  195. 'perm' => 'access chado_projects',
  196. ));
  197. $handler->override_option('cache', array(
  198. 'type' => 'none',
  199. ));
  200. $handler->override_option('title', 'Projects');
  201. $handler->override_option('empty', 'There are currently no projects available.');
  202. $handler->override_option('empty_format', '2');
  203. $handler->override_option('items_per_page', 50);
  204. $handler->override_option('use_pager', '1');
  205. $handler->override_option('style_plugin', 'table');
  206. $handler->override_option('style_options', array(
  207. 'grouping' => '',
  208. 'override' => 1,
  209. 'sticky' => 0,
  210. 'order' => 'asc',
  211. 'summary' => '',
  212. 'columns' => array(
  213. 'name' => 'name',
  214. 'description' => 'description',
  215. ),
  216. 'info' => array(
  217. 'name' => array(
  218. 'sortable' => 1,
  219. 'separator' => '',
  220. ),
  221. 'description' => array(
  222. 'sortable' => 0,
  223. 'separator' => '',
  224. ),
  225. ),
  226. 'default' => 'name',
  227. ));
  228. $handler = $view->new_display('page', 'Page', 'page_1');
  229. $handler->override_option('path', 'chado/projects');
  230. $handler->override_option('menu', array(
  231. 'type' => 'normal',
  232. 'title' => 'Projects',
  233. 'description' => 'A project is a collection of data resulting from a biological experiment.',
  234. 'weight' => '10',
  235. 'name' => 'navigation',
  236. ));
  237. $handler->override_option('tab_options', array(
  238. 'type' => 'none',
  239. 'title' => '',
  240. 'description' => '',
  241. 'weight' => 0,
  242. 'name' => 'navigation',
  243. ));
  244. $views[$view->name] = $view;
  245. return $views;
  246. }