tripal_library.views_default.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <?php
  2. /**
  3. * @file
  4. * Describes library default views
  5. */
  6. /**
  7. * Implements hook_views_default_views().
  8. *
  9. * @ingroup tripal_legacy_library
  10. */
  11. function tripal_library_views_default_views() {
  12. $views = [];
  13. // User View ("Search Biological Content")
  14. // Remember, if you change the name/path of this view,
  15. // you also want to change it's description in tripal_library_search_biological_data_views()
  16. $view = tripal_library_defaultvalue_user_library();
  17. $view = tripal_make_view_compatible_with_external($view);
  18. $views[$view->name] = $view;
  19. // Admin view
  20. $view = tripal_library_admin_defaultviews_library();
  21. $view = tripal_make_view_compatible_with_external($view);
  22. $views[$view->name] = $view;
  23. return $views;
  24. }
  25. /**
  26. * Defines the library user search default view.
  27. *
  28. * @ingroup tripal_legacy_library
  29. */
  30. function tripal_library_defaultvalue_user_library() {
  31. // As a shortcut, currently I am copying the admin view and then tweaking it
  32. // In thie future this should be replaced by a views export
  33. $view = tripal_library_admin_defaultviews_library();
  34. // change some view admin stuff
  35. $view->name = 'tripal_library_user_library';
  36. $view->human_name = 'Library User Search';
  37. $view->description = 'Allows users to search library data';
  38. $view->tag = 'tripal search';
  39. // Change the path
  40. $view->display['page_1']->display_options['path'] = 'chado/library';
  41. $view->display['page_1']->display_options['menu'] = [
  42. 'type' => 'normal',
  43. 'title' => 'Libraries',
  44. 'description' => 'Biological library including BAC, cDNA, FOSMID, etc.',
  45. 'weight' => '-10',
  46. ];
  47. unset($view->display['page_1']->display_options['tab_options']);
  48. // Change the permission
  49. $view->display['default']->display_options['access']['perm'] = 'access chado_library content';
  50. // Remove edit/delete node
  51. unset(
  52. $view->display['default']->display_options['fields']['delete_node'],
  53. $view->display['default']->display_options['fields']['edit_node'],
  54. $view->display['default']->display_options['fields']['nothing']
  55. );
  56. // Remove the admin action links
  57. unset($view->display['default']->display_options['header']['action_links_area']);
  58. return $view;
  59. }
  60. /**
  61. * Default administration library view
  62. *
  63. * @ingroup tripal_legacy_library
  64. */
  65. function tripal_library_admin_defaultviews_library() {
  66. $view = new view();
  67. $view->name = 'tripal_library_admin_libraries';
  68. $view->description = 'DO NOT DISABLE';
  69. $view->tag = 'tripal admin';
  70. $view->base_table = 'library';
  71. $view->human_name = 'Library Admin';
  72. $view->core = 0;
  73. $view->api_version = '3.0';
  74. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  75. /* Display: Defaults */
  76. $handler = $view->new_display('default', 'Defaults', 'default');
  77. $handler->display->display_options['title'] = 'Libraries';
  78. $handler->display->display_options['use_more_always'] = FALSE;
  79. $handler->display->display_options['access']['type'] = 'perm';
  80. $handler->display->display_options['access']['perm'] = 'access chado_library content';
  81. $handler->display->display_options['cache']['type'] = 'none';
  82. $handler->display->display_options['query']['type'] = 'views_query';
  83. $handler->display->display_options['exposed_form']['type'] = 'input_required';
  84. $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
  85. $handler->display->display_options['exposed_form']['options']['text_input_required'] = 'Click search to see a listing of libraries that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of libraries or to find a specific library.';
  86. $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'full_html';
  87. $handler->display->display_options['pager']['type'] = 'full';
  88. $handler->display->display_options['pager']['options']['items_per_page'] = '25';
  89. $handler->display->display_options['pager']['options']['offset'] = '0';
  90. $handler->display->display_options['pager']['options']['id'] = '0';
  91. $handler->display->display_options['pager']['options']['quantity'] = '9';
  92. $handler->display->display_options['style_plugin'] = 'table';
  93. $handler->display->display_options['style_options']['grouping'] = '';
  94. $handler->display->display_options['style_options']['columns'] = [
  95. 'uniquename' => 'uniquename',
  96. 'name_1' => 'name_1',
  97. 'common_name' => 'common_name',
  98. 'name' => 'name',
  99. 'is_obsolete' => 'is_obsolete',
  100. ];
  101. $handler->display->display_options['style_options']['default'] = 'uniquename';
  102. $handler->display->display_options['style_options']['info'] = [
  103. 'uniquename' => [
  104. 'sortable' => 1,
  105. 'separator' => '',
  106. ],
  107. 'name_1' => [
  108. 'sortable' => 1,
  109. 'separator' => '',
  110. ],
  111. 'common_name' => [
  112. 'sortable' => 1,
  113. 'separator' => '',
  114. ],
  115. 'name' => [
  116. 'sortable' => 1,
  117. 'separator' => '',
  118. ],
  119. 'is_obsolete' => [
  120. 'sortable' => 1,
  121. 'separator' => '',
  122. ],
  123. ];
  124. /* Header: Global: Action Links */
  125. $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
  126. $handler->display->display_options['header']['action_links_area']['table'] = 'views';
  127. $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
  128. $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
  129. $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
  130. $handler->display->display_options['header']['action_links_area']['link-1'] = [
  131. 'label-1' => 'Add Library',
  132. 'path-1' => 'node/add/tripal-library',
  133. ];
  134. $handler->display->display_options['header']['action_links_area']['link-2'] = [
  135. 'label-2' => '',
  136. 'path-2' => '',
  137. ];
  138. $handler->display->display_options['header']['action_links_area']['link-3'] = [
  139. 'label-3' => '',
  140. 'path-3' => '',
  141. ];
  142. $handler->display->display_options['header']['action_links_area']['link-4'] = [
  143. 'label-4' => '',
  144. 'path-4' => '',
  145. ];
  146. /* No results behavior: Global: Text area */
  147. $handler->display->display_options['empty']['text']['id'] = 'area';
  148. $handler->display->display_options['empty']['text']['table'] = 'views';
  149. $handler->display->display_options['empty']['text']['field'] = 'area';
  150. $handler->display->display_options['empty']['text']['content'] = 'No libraries match the supplied criteria.';
  151. $handler->display->display_options['empty']['text']['format'] = '1';
  152. /* Relationship: Library: Library => Node */
  153. $handler->display->display_options['relationships']['library_id']['id'] = 'library_id';
  154. $handler->display->display_options['relationships']['library_id']['table'] = 'chado_library';
  155. $handler->display->display_options['relationships']['library_id']['field'] = 'library_id';
  156. /* Field: Content: Nid */
  157. $handler->display->display_options['fields']['nid']['id'] = 'nid';
  158. $handler->display->display_options['fields']['nid']['table'] = 'node';
  159. $handler->display->display_options['fields']['nid']['field'] = 'nid';
  160. $handler->display->display_options['fields']['nid']['relationship'] = 'library_id';
  161. $handler->display->display_options['fields']['nid']['exclude'] = TRUE;
  162. /* Field: Node URL */
  163. $handler->display->display_options['fields']['nid_1']['id'] = 'nid_1';
  164. $handler->display->display_options['fields']['nid_1']['table'] = 'node';
  165. $handler->display->display_options['fields']['nid_1']['field'] = 'nid';
  166. $handler->display->display_options['fields']['nid_1']['relationship'] = 'feature_id';
  167. $handler->display->display_options['fields']['nid_1']['ui_name'] = 'Node URL';
  168. $handler->display->display_options['fields']['nid_1']['label'] = '';
  169. $handler->display->display_options['fields']['nid_1']['exclude'] = TRUE;
  170. $handler->display->display_options['fields']['nid_1']['alter']['alter_text'] = TRUE;
  171. $handler->display->display_options['fields']['nid_1']['alter']['text'] = 'node/[nid]';
  172. $handler->display->display_options['fields']['nid_1']['element_label_colon'] = FALSE;
  173. /* Field: Chado Library: Uniquename */
  174. $handler->display->display_options['fields']['uniquename']['id'] = 'uniquename';
  175. $handler->display->display_options['fields']['uniquename']['table'] = 'library';
  176. $handler->display->display_options['fields']['uniquename']['field'] = 'uniquename';
  177. $handler->display->display_options['fields']['uniquename']['label'] = 'Unique Name';
  178. $handler->display->display_options['fields']['uniquename']['alter']['make_link'] = TRUE;
  179. $handler->display->display_options['fields']['uniquename']['alter']['path'] = '[nid_1]';
  180. /* Field: Chado Library: Name */
  181. $handler->display->display_options['fields']['name_1']['id'] = 'name_1';
  182. $handler->display->display_options['fields']['name_1']['table'] = 'library';
  183. $handler->display->display_options['fields']['name_1']['field'] = 'name';
  184. $handler->display->display_options['fields']['name']['alter']['make_link'] = TRUE;
  185. $handler->display->display_options['fields']['name']['alter']['path'] = '[nid_1]';
  186. /* Field: Chado Organism: Common Name */
  187. $handler->display->display_options['fields']['common_name']['id'] = 'common_name';
  188. $handler->display->display_options['fields']['common_name']['table'] = 'organism';
  189. $handler->display->display_options['fields']['common_name']['field'] = 'common_name';
  190. $handler->display->display_options['fields']['common_name']['label'] = 'Organism';
  191. /* Field: Chado Cvterm: Name */
  192. $handler->display->display_options['fields']['name']['id'] = 'name';
  193. $handler->display->display_options['fields']['name']['table'] = 'cvterm';
  194. $handler->display->display_options['fields']['name']['field'] = 'name';
  195. $handler->display->display_options['fields']['name']['label'] = 'Type';
  196. /* Field: Chado Library: Is Obsolete */
  197. $handler->display->display_options['fields']['is_obsolete']['id'] = 'is_obsolete';
  198. $handler->display->display_options['fields']['is_obsolete']['table'] = 'library';
  199. $handler->display->display_options['fields']['is_obsolete']['field'] = 'is_obsolete';
  200. $handler->display->display_options['fields']['is_obsolete']['label'] = 'Obsolete?';
  201. $handler->display->display_options['fields']['is_obsolete']['alter']['alter_text'] = TRUE;
  202. $handler->display->display_options['fields']['is_obsolete']['alter']['text'] = 'Yes';
  203. $handler->display->display_options['fields']['is_obsolete']['empty'] = 'No';
  204. $handler->display->display_options['fields']['is_obsolete']['empty_zero'] = TRUE;
  205. $handler->display->display_options['fields']['is_obsolete']['separator'] = '';
  206. /* Field: Content: Delete link */
  207. $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
  208. $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
  209. $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
  210. $handler->display->display_options['fields']['delete_node']['relationship'] = 'library_id';
  211. $handler->display->display_options['fields']['delete_node']['exclude'] = TRUE;
  212. /* Field: Content: Edit link */
  213. $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
  214. $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
  215. $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
  216. $handler->display->display_options['fields']['edit_node']['relationship'] = 'library_id';
  217. $handler->display->display_options['fields']['edit_node']['exclude'] = TRUE;
  218. /* Field: Global: Custom text */
  219. $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
  220. $handler->display->display_options['fields']['nothing']['table'] = 'views';
  221. $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
  222. $handler->display->display_options['fields']['nothing']['label'] = '';
  223. $handler->display->display_options['fields']['nothing']['alter']['text'] = '[edit_node] [delete_node]';
  224. $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
  225. /* Sort criterion: Chado Library: Id */
  226. $handler->display->display_options['sorts']['library_id']['id'] = 'library_id';
  227. $handler->display->display_options['sorts']['library_id']['table'] = 'library';
  228. $handler->display->display_options['sorts']['library_id']['field'] = 'library_id';
  229. $handler->display->display_options['sorts']['library_id']['order'] = 'DESC';
  230. /* Filter criterion: Chado Organism: Common Name */
  231. $handler->display->display_options['filters']['common_name']['id'] = 'common_name';
  232. $handler->display->display_options['filters']['common_name']['table'] = 'organism';
  233. $handler->display->display_options['filters']['common_name']['field'] = 'common_name';
  234. $handler->display->display_options['filters']['common_name']['value'] = 'All';
  235. $handler->display->display_options['filters']['common_name']['group'] = '0';
  236. $handler->display->display_options['filters']['common_name']['exposed'] = TRUE;
  237. $handler->display->display_options['filters']['common_name']['expose']['operator_id'] = 'common_name_op';
  238. $handler->display->display_options['filters']['common_name']['expose']['label'] = 'Organism';
  239. $handler->display->display_options['filters']['common_name']['expose']['operator'] = 'common_name_op';
  240. $handler->display->display_options['filters']['common_name']['expose']['identifier'] = 'organism_common_name';
  241. $handler->display->display_options['filters']['common_name']['expose']['remember_roles'] = [
  242. 2 => '2',
  243. 1 => 0,
  244. 3 => 0,
  245. ];
  246. /* Filter criterion: Chado Library: Type Id */
  247. $handler->display->display_options['filters']['type_id']['id'] = 'type_id';
  248. $handler->display->display_options['filters']['type_id']['table'] = 'library';
  249. $handler->display->display_options['filters']['type_id']['field'] = 'type_id';
  250. $handler->display->display_options['filters']['type_id']['group'] = '0';
  251. $handler->display->display_options['filters']['type_id']['exposed'] = TRUE;
  252. $handler->display->display_options['filters']['type_id']['expose']['operator_id'] = 'type_id_op';
  253. $handler->display->display_options['filters']['type_id']['expose']['label'] = 'Type';
  254. $handler->display->display_options['filters']['type_id']['expose']['operator'] = 'type_id_op';
  255. $handler->display->display_options['filters']['type_id']['expose']['identifier'] = 'type_id';
  256. $handler->display->display_options['filters']['type_id']['expose']['remember_roles'] = [
  257. 2 => '2',
  258. 1 => 0,
  259. 3 => 0,
  260. ];
  261. /** MANUALLY ADD since filter handler no exporting correctly */
  262. $handler->display->display_options['filters']['common_name']['expose']['values_form_type'] = 'select';
  263. $handler->display->display_options['filters']['common_name']['expose']['select_multiple'] = FALSE;
  264. $handler->display->display_options['filters']['common_name']['expose']['select_optional'] = TRUE;
  265. $handler->display->display_options['filters']['common_name']['expose']['max_length'] = 40;
  266. /* Display: Page */
  267. $handler = $view->new_display('page', 'Page', 'page_1');
  268. $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_library/libraries';
  269. $handler->display->display_options['menu']['type'] = 'default tab';
  270. $handler->display->display_options['menu']['title'] = 'Libraries';
  271. $handler->display->display_options['menu']['description'] = 'A library is a collection of features of a given type. For example, a cDNA or BAC clone library.';
  272. $handler->display->display_options['menu']['weight'] = '0';
  273. $handler->display->display_options['menu']['name'] = 'management';
  274. $handler->display->display_options['menu']['context'] = 0;
  275. $handler->display->display_options['menu']['context_only_inline'] = 0;
  276. $handler->display->display_options['tab_options']['weight'] = '0';
  277. /** MANUALLY ADD since filter handler no exporting correctly
  278. * $handler->display->display_options['filters']['common_name']['expose']['values_form_type'] = 'select';
  279. * $handler->display->display_options['filters']['common_name']['expose']['select_multiple'] = FALSE;
  280. * $handler->display->display_options['filters']['common_name']['expose']['select_optional'] = TRUE;
  281. * $handler->display->display_options['filters']['common_name']['expose']['max_length'] = 40;
  282. */
  283. return $view;
  284. }