tripal_project.views.inc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. * @defgroup tripal_project_views Project Views Integration
  13. * @ingroup views
  14. */
  15. /**
  16. *
  17. *
  18. * @ingroup tripal_project_views
  19. */
  20. function tripal_project_views_default_views() {
  21. $views = array();
  22. if (!module_exists('tripal_views')) {
  23. return $views;
  24. }
  25. $values = array('name' => 'project_description');
  26. $description_type_id = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
  27. $description_type_id = $description_type_id[0]->cvterm_id;
  28. // Main default view
  29. $view = new view;
  30. $view->name = 'project_listing';
  31. $view->description = 'A listing of chado projects';
  32. $view->tag = 'chado default';
  33. $view->base_table = 'project';
  34. $view->core = 6;
  35. $view->api_version = '2';
  36. $view->disabled = FALSE;
  37. $handler = $view->new_display('default', 'Defaults', 'default');
  38. $handler->override_option('fields', array(
  39. 'name' => array(
  40. 'label' => 'Name',
  41. 'alter' => array(
  42. 'alter_text' => 0,
  43. 'text' => '',
  44. 'make_link' => 0,
  45. 'path' => '',
  46. 'absolute' => 0,
  47. 'link_class' => '',
  48. 'alt' => '',
  49. 'rel' => '',
  50. 'prefix' => '',
  51. 'suffix' => '',
  52. 'target' => '',
  53. 'help' => '',
  54. 'trim' => 0,
  55. 'max_length' => '',
  56. 'word_boundary' => 1,
  57. 'ellipsis' => 1,
  58. 'html' => 0,
  59. 'strip_tags' => 0,
  60. ),
  61. 'empty' => '',
  62. 'hide_empty' => 0,
  63. 'empty_zero' => 0,
  64. 'hide_alter_empty' => 1,
  65. 'type' => 'separator',
  66. 'separator' => ', ',
  67. 'exclude' => 0,
  68. 'id' => 'name',
  69. 'table' => 'project',
  70. 'field' => 'name',
  71. 'relationship' => 'none',
  72. ),
  73. 'value' => array(
  74. 'label' => 'Description',
  75. 'alter' => array(
  76. 'alter_text' => 0,
  77. 'text' => '',
  78. 'make_link' => 0,
  79. 'path' => '',
  80. 'absolute' => 0,
  81. 'link_class' => '',
  82. 'alt' => '',
  83. 'rel' => '',
  84. 'prefix' => '',
  85. 'suffix' => '',
  86. 'target' => '',
  87. 'help' => '',
  88. 'trim' => 0,
  89. 'max_length' => '',
  90. 'word_boundary' => 1,
  91. 'ellipsis' => 1,
  92. 'html' => 0,
  93. 'strip_tags' => 0,
  94. ),
  95. 'empty' => '',
  96. 'hide_empty' => 0,
  97. 'empty_zero' => 0,
  98. 'hide_alter_empty' => 1,
  99. 'type' => 'separator',
  100. 'separator' => ', ',
  101. 'exclude' => 0,
  102. 'id' => 'value',
  103. 'table' => 'projectprop',
  104. 'field' => 'value',
  105. 'override' => array(
  106. 'button' => 'Override',
  107. ),
  108. 'relationship' => 'none',
  109. ),
  110. ));
  111. $handler->override_option('filters', array(
  112. 'name' => array(
  113. 'operator' => '~',
  114. 'value' => '',
  115. 'group' => '0',
  116. 'exposed' => TRUE,
  117. 'expose' => array(
  118. 'use_operator' => 0,
  119. 'operator' => 'name_op',
  120. 'identifier' => 'name',
  121. 'label' => 'Name Contains',
  122. 'remember' => 0,
  123. ),
  124. 'case' => 0,
  125. 'id' => 'name',
  126. 'table' => 'project',
  127. 'field' => 'name',
  128. 'relationship' => 'none',
  129. 'agg' => array(
  130. 'records_with' => 1,
  131. 'aggregates_with' => 1,
  132. ),
  133. ),
  134. 'type_id' => array(
  135. 'operator' => '=',
  136. 'value' => $description_type_id,
  137. 'group' => '0',
  138. 'exposed' => FALSE,
  139. 'expose' => array(
  140. 'operator' => FALSE,
  141. 'label' => '',
  142. 'optional' => FALSE,
  143. ),
  144. 'case' => 1,
  145. 'id' => 'type_id',
  146. 'table' => 'projectprop',
  147. 'field' => 'type_id',
  148. 'override' => array(
  149. 'button' => 'Override',
  150. ),
  151. 'relationship' => 'none',
  152. 'values_form_type' => 'select',
  153. 'multiple' => 0,
  154. 'optional' => 0,
  155. 'show_all' => 0,
  156. 'agg' => array(
  157. 'records_with' => 0,
  158. 'aggregates_with' => 1,
  159. ),
  160. ),
  161. 'value' => array(
  162. 'operator' => '~',
  163. 'value' => '',
  164. 'group' => '0',
  165. 'exposed' => TRUE,
  166. 'expose' => array(
  167. 'use_operator' => 0,
  168. 'operator' => 'value_op',
  169. 'identifier' => 'description',
  170. 'label' => 'Description Contains',
  171. 'remember' => 0,
  172. ),
  173. 'case' => 0,
  174. 'id' => 'value',
  175. 'table' => 'projectprop',
  176. 'field' => 'value',
  177. 'override' => array(
  178. 'button' => 'Override',
  179. ),
  180. 'relationship' => 'none',
  181. 'agg' => array(
  182. 'records_with' => 1,
  183. 'aggregates_with' => 1,
  184. ),
  185. ),
  186. ));
  187. $handler->override_option('access', array(
  188. 'type' => 'perm',
  189. 'perm' => 'access chado_projects',
  190. ));
  191. $handler->override_option('cache', array(
  192. 'type' => 'none',
  193. ));
  194. $handler->override_option('title', 'Projects');
  195. $handler->override_option('empty', 'No projects match the supplied criteria.');
  196. $handler->override_option('empty_format', '2');
  197. $handler->override_option('items_per_page', 50);
  198. $handler->override_option('use_pager', '1');
  199. $handler->override_option('style_plugin', 'table');
  200. $handler->override_option('style_options', array(
  201. 'grouping' => '',
  202. 'override' => 1,
  203. 'sticky' => 0,
  204. 'order' => 'asc',
  205. 'summary' => '',
  206. 'columns' => array(
  207. 'name' => 'name',
  208. 'description' => 'description',
  209. ),
  210. 'info' => array(
  211. 'name' => array(
  212. 'sortable' => 1,
  213. 'separator' => '',
  214. ),
  215. 'description' => array(
  216. 'sortable' => 0,
  217. 'separator' => '',
  218. ),
  219. ),
  220. 'default' => 'name',
  221. ));
  222. $default_handler = $handler;
  223. $handler = $view->new_display('page', 'Page', 'page_1');
  224. $handler->override_option('path', 'chado/projects');
  225. $handler->override_option('menu', array(
  226. 'type' => 'normal',
  227. 'title' => 'Projects',
  228. 'description' => 'A project is a collection of data resulting from a biological experiment.',
  229. 'weight' => '10',
  230. 'name' => 'navigation',
  231. ));
  232. $handler->override_option('tab_options', array(
  233. 'type' => 'none',
  234. 'title' => '',
  235. 'description' => '',
  236. 'weight' => 0,
  237. 'name' => 'navigation',
  238. ));
  239. // Add code specific to a local chado installation
  240. // NOTE: Edit $handler above to $default_handler for the default display
  241. if (tripal_core_chado_schema_exists()) {
  242. // Add nid field
  243. $fields = $view->get_items('field', 'default');
  244. $new_fields = array(
  245. 'nid' => array(
  246. 'label' => 'Nid',
  247. 'alter' => array(
  248. 'alter_text' => 0,
  249. 'text' => '',
  250. 'make_link' => 0,
  251. 'path' => '',
  252. 'absolute' => 0,
  253. 'link_class' => '',
  254. 'alt' => '',
  255. 'rel' => '',
  256. 'prefix' => '',
  257. 'suffix' => '',
  258. 'target' => '',
  259. 'help' => '',
  260. 'trim' => 0,
  261. 'max_length' => '',
  262. 'word_boundary' => 1,
  263. 'ellipsis' => 1,
  264. 'html' => 0,
  265. 'strip_tags' => 0,
  266. ),
  267. 'empty' => '',
  268. 'hide_empty' => 0,
  269. 'empty_zero' => 0,
  270. 'hide_alter_empty' => 1,
  271. 'link_to_node' => 0,
  272. 'exclude' => 1,
  273. 'id' => 'nid',
  274. 'table' => 'node',
  275. 'field' => 'nid',
  276. 'relationship' => 'none',
  277. )
  278. );
  279. $fields = $new_fields + $fields;
  280. // Adds project => Node relationship
  281. $default_handler->override_option('relationships', array(
  282. 'nid' => array(
  283. 'label' => 'Project to Node',
  284. 'required' => 0,
  285. 'id' => 'nid',
  286. 'table' => 'chado_project',
  287. 'field' => 'nid',
  288. 'relationship' => 'none',
  289. ),
  290. ));
  291. // Change project.name to have a link to the node
  292. $fields['name']['alter']['link_to_node'] = 1;
  293. $default_handler->override_option('fields', $fields);
  294. // Only show records with published nodes
  295. /**
  296. $filters = $view->get_items('filter', 'default');
  297. $filters['status'] = array(
  298. 'operator' => '=',
  299. 'value' => '1',
  300. 'group' => '0',
  301. 'exposed' => FALSE,
  302. 'expose' => array(
  303. 'operator' => FALSE,
  304. 'label' => '',
  305. ),
  306. 'id' => 'status',
  307. 'table' => 'node',
  308. 'field' => 'status',
  309. 'relationship' => 'none',
  310. );
  311. $default_handler->override_option('filters', $filters);
  312. */
  313. }
  314. $views[$view->name] = $view;
  315. return $views;
  316. }