tripal_project.views_default.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. /**
  3. * @file
  4. * Project Default Views
  5. */
  6. /**
  7. * Implements hook_views_default_views().
  8. *
  9. * @ingroup tripal_legacy_project
  10. */
  11. function tripal_project_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_project_search_biological_data_views()
  16. $view = tripal_project_defaultvalue_user_projects();
  17. $view = tripal_make_view_compatible_with_external($view);
  18. $views[$view->name] = $view;
  19. // Admin view
  20. $view = tripal_project_defaultview_admin_projects();
  21. $view = tripal_make_view_compatible_with_external($view);
  22. $views[$view->name] = $view;
  23. return $views;
  24. }
  25. /**
  26. * Defines the project user search default view.
  27. *
  28. * @ingroup tripal_legacy_project
  29. */
  30. function tripal_project_defaultvalue_user_projects() {
  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_project_defaultview_admin_projects();
  34. // change some view admin stuff
  35. $view->name = 'tripal_project_user_projects';
  36. $view->human_name = 'Project User Search';
  37. $view->description = 'Allows users to search project data';
  38. $view->tag = 'tripal search';
  39. // Change the path
  40. $view->display['page']->display_options['path'] = 'chado/project';
  41. $view->display['page']->display_options['menu'] = [
  42. 'type' => 'normal',
  43. 'title' => 'Projects',
  44. 'description' => 'A project. Can be used for grouping data such as with the natural diversity module data.',
  45. 'weight' => '-10',
  46. ];
  47. unset($view->display['page']->display_options['tab_options']);
  48. // Change the permission
  49. $view->display['default']->display_options['access']['perm'] = 'access chado_project 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. * Project administration view
  62. *
  63. * @ingroup tripal_legacy_project
  64. */
  65. function tripal_project_defaultview_admin_projects() {
  66. $view = new view();
  67. $view->name = 'tripal_project_admin_projects';
  68. $view->description = 'DO NOT DISABLE';
  69. $view->tag = 'tripal admin';
  70. $view->base_table = 'project';
  71. $view->human_name = 'Project Admin';
  72. $view->core = 7;
  73. $view->api_version = '3.0';
  74. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  75. /* Display: Master */
  76. $handler = $view->new_display('default', 'Master', 'default');
  77. $handler->display->display_options['title'] = 'Projects';
  78. $handler->display->display_options['use_more_always'] = FALSE;
  79. $handler->display->display_options['access']['type'] = 'perm';
  80. $handler->display->display_options['access']['perm'] = 'administer tripal project';
  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 projects that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of projects or to find a specific project.';
  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['style_plugin'] = 'table';
  90. $handler->display->display_options['style_options']['columns'] = [
  91. 'nid' => 'nid',
  92. 'name' => 'name',
  93. 'description' => 'description',
  94. 'delete_node' => 'delete_node',
  95. 'edit_node' => 'edit_node',
  96. 'nothing' => 'nothing',
  97. ];
  98. $handler->display->display_options['style_options']['default'] = 'name';
  99. $handler->display->display_options['style_options']['info'] = [
  100. 'nid' => [
  101. 'sortable' => 0,
  102. 'default_sort_order' => 'asc',
  103. 'align' => '',
  104. 'separator' => '',
  105. 'empty_column' => 0,
  106. ],
  107. 'name' => [
  108. 'sortable' => 1,
  109. 'default_sort_order' => 'asc',
  110. 'align' => '',
  111. 'separator' => '',
  112. 'empty_column' => 0,
  113. ],
  114. 'description' => [
  115. 'sortable' => 0,
  116. 'default_sort_order' => 'asc',
  117. 'align' => '',
  118. 'separator' => '',
  119. 'empty_column' => 0,
  120. ],
  121. 'delete_node' => [
  122. 'align' => '',
  123. 'separator' => '',
  124. 'empty_column' => 0,
  125. ],
  126. 'edit_node' => [
  127. 'align' => '',
  128. 'separator' => '',
  129. 'empty_column' => 0,
  130. ],
  131. 'nothing' => [
  132. 'align' => '',
  133. 'separator' => '',
  134. 'empty_column' => 0,
  135. ],
  136. ];
  137. /* Header: Global: Action Links */
  138. $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
  139. $handler->display->display_options['header']['action_links_area']['table'] = 'views';
  140. $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
  141. $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
  142. $handler->display->display_options['header']['action_links_area']['link-1'] = [
  143. 'label-1' => 'Add Project',
  144. 'path-1' => 'node/add/tripal-project',
  145. ];
  146. $handler->display->display_options['header']['action_links_area']['link-2'] = [
  147. 'label-2' => '',
  148. 'path-2' => '',
  149. ];
  150. $handler->display->display_options['header']['action_links_area']['link-3'] = [
  151. 'label-3' => '',
  152. 'path-3' => '',
  153. ];
  154. $handler->display->display_options['header']['action_links_area']['link-4'] = [
  155. 'label-4' => '',
  156. 'path-4' => '',
  157. ];
  158. /* Relationship: Project: Project => Node */
  159. $handler->display->display_options['relationships']['project_id']['id'] = 'project_id';
  160. $handler->display->display_options['relationships']['project_id']['table'] = 'chado_project';
  161. $handler->display->display_options['relationships']['project_id']['field'] = 'project_id';
  162. /* Field: Content: Nid */
  163. $handler->display->display_options['fields']['nid']['id'] = 'nid';
  164. $handler->display->display_options['fields']['nid']['table'] = 'node';
  165. $handler->display->display_options['fields']['nid']['field'] = 'nid';
  166. $handler->display->display_options['fields']['nid']['exclude'] = TRUE;
  167. /* Field: Node URL */
  168. $handler->display->display_options['fields']['nid_1']['id'] = 'nid_1';
  169. $handler->display->display_options['fields']['nid_1']['table'] = 'node';
  170. $handler->display->display_options['fields']['nid_1']['field'] = 'nid';
  171. $handler->display->display_options['fields']['nid_1']['relationship'] = 'feature_id';
  172. $handler->display->display_options['fields']['nid_1']['ui_name'] = 'Node URL';
  173. $handler->display->display_options['fields']['nid_1']['label'] = '';
  174. $handler->display->display_options['fields']['nid_1']['exclude'] = TRUE;
  175. $handler->display->display_options['fields']['nid_1']['alter']['alter_text'] = TRUE;
  176. $handler->display->display_options['fields']['nid_1']['alter']['text'] = 'node/[nid]';
  177. $handler->display->display_options['fields']['nid_1']['element_label_colon'] = FALSE;
  178. /* Field: Chado Project: Name */
  179. $handler->display->display_options['fields']['name']['id'] = 'name';
  180. $handler->display->display_options['fields']['name']['table'] = 'project';
  181. $handler->display->display_options['fields']['name']['field'] = 'name';
  182. $handler->display->display_options['fields']['name']['alter']['make_link'] = TRUE;
  183. $handler->display->display_options['fields']['name']['alter']['path'] = '[nid_1]';
  184. /* Field: Chado Project: Description */
  185. $handler->display->display_options['fields']['description']['id'] = 'description';
  186. $handler->display->display_options['fields']['description']['table'] = 'project';
  187. $handler->display->display_options['fields']['description']['field'] = 'description';
  188. $handler->display->display_options['fields']['description']['element_class'] = 'wide-column';
  189. $handler->display->display_options['fields']['description']['element_label_class'] = 'wide-column';
  190. /* Field: Content: Delete link */
  191. $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
  192. $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
  193. $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
  194. $handler->display->display_options['fields']['delete_node']['relationship'] = 'project_id';
  195. $handler->display->display_options['fields']['delete_node']['exclude'] = TRUE;
  196. /* Field: Content: Edit link */
  197. $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
  198. $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
  199. $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
  200. $handler->display->display_options['fields']['edit_node']['relationship'] = 'project_id';
  201. $handler->display->display_options['fields']['edit_node']['exclude'] = TRUE;
  202. /* Field: Global: Custom text */
  203. $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
  204. $handler->display->display_options['fields']['nothing']['table'] = 'views';
  205. $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
  206. $handler->display->display_options['fields']['nothing']['label'] = '';
  207. $handler->display->display_options['fields']['nothing']['alter']['text'] = '[edit_node] [delete_node]';
  208. $handler->display->display_options['fields']['nothing']['element_class'] = 'short-column';
  209. $handler->display->display_options['fields']['nothing']['element_label_class'] = 'short-column';
  210. $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
  211. /* Sort criterion: Chado Project: Id */
  212. $handler->display->display_options['sorts']['project_id']['id'] = 'project_id';
  213. $handler->display->display_options['sorts']['project_id']['table'] = 'project';
  214. $handler->display->display_options['sorts']['project_id']['field'] = 'project_id';
  215. $handler->display->display_options['sorts']['project_id']['order'] = 'DESC';
  216. /* Filter criterion: Chado Project: Name */
  217. $handler->display->display_options['filters']['name']['id'] = 'name';
  218. $handler->display->display_options['filters']['name']['table'] = 'project';
  219. $handler->display->display_options['filters']['name']['field'] = 'name';
  220. $handler->display->display_options['filters']['name']['operator'] = 'contains';
  221. $handler->display->display_options['filters']['name']['group'] = 1;
  222. $handler->display->display_options['filters']['name']['exposed'] = TRUE;
  223. $handler->display->display_options['filters']['name']['expose']['operator_id'] = '';
  224. $handler->display->display_options['filters']['name']['expose']['label'] = 'Name Contains';
  225. $handler->display->display_options['filters']['name']['expose']['identifier'] = 'name';
  226. $handler->display->display_options['filters']['name']['expose']['remember_roles'] = [
  227. 2 => '2',
  228. 1 => 0,
  229. 3 => 0,
  230. ];
  231. /* Filter criterion: Chado Project: Description */
  232. $handler->display->display_options['filters']['description']['id'] = 'description';
  233. $handler->display->display_options['filters']['description']['table'] = 'project';
  234. $handler->display->display_options['filters']['description']['field'] = 'description';
  235. $handler->display->display_options['filters']['description']['operator'] = 'contains';
  236. $handler->display->display_options['filters']['description']['group'] = 1;
  237. $handler->display->display_options['filters']['description']['exposed'] = TRUE;
  238. $handler->display->display_options['filters']['description']['expose']['operator_id'] = 'description_op';
  239. $handler->display->display_options['filters']['description']['expose']['label'] = 'Description Contains';
  240. $handler->display->display_options['filters']['description']['expose']['operator'] = 'description_op';
  241. $handler->display->display_options['filters']['description']['expose']['identifier'] = 'description';
  242. $handler->display->display_options['filters']['description']['expose']['remember_roles'] = [
  243. 2 => '2',
  244. 1 => 0,
  245. 3 => 0,
  246. ];
  247. /* Display: Page */
  248. $handler = $view->new_display('page', 'Page', 'page');
  249. $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_project/projects';
  250. $handler->display->display_options['menu']['type'] = 'default tab';
  251. $handler->display->display_options['menu']['title'] = 'Projects';
  252. $handler->display->display_options['menu']['weight'] = '0';
  253. $handler->display->display_options['menu']['name'] = 'management';
  254. $handler->display->display_options['menu']['context'] = 0;
  255. $handler->display->display_options['menu']['context_only_inline'] = 0;
  256. $handler->display->display_options['tab_options']['weight'] = '0';
  257. return $view;
  258. }