tripal_project.views_default.inc 7.9 KB

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