tripal_contact.views_default.inc 15 KB

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