tripal_stock.views_default.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?php
  2. /**
  3. * @file
  4. * Describes stock default views.
  5. */
  6. /**
  7. * Implements hook_views_default_views().
  8. *
  9. * @ingroup tripal_legacy_stock
  10. */
  11. function tripal_stock_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_stock_search_biological_data_views()
  16. $view = tripal_stock_defaultvalue_user_stocks();
  17. $view = tripal_make_view_compatible_with_external($view);
  18. $views[$view->name] = $view;
  19. // Admin view
  20. $view = tripal_stock_defaultview_admin_stocks();
  21. $view = tripal_make_view_compatible_with_external($view);
  22. $views[$view->name] = $view;
  23. return $views;
  24. }
  25. /**
  26. * Defines the stock user search default view.
  27. *
  28. * @ingroup tripal_legacy_stock
  29. */
  30. function tripal_stock_defaultvalue_user_stocks() {
  31. // As a shortcut, currently I am copying the admin view and then tweaking it
  32. // In the future this should be replaced by a views export
  33. $view = tripal_stock_defaultview_admin_stocks();
  34. // change some view admin stuff
  35. $view->name = 'tripal_stock_user_stocks';
  36. $view->human_name = 'Stock User Search';
  37. $view->description = 'Allows users to search stock data';
  38. $view->tag = 'tripal search';
  39. // Change the path
  40. $view->display['page_1']->display_options['path'] = 'chado/stock';
  41. $view->display['page_1']->display_options['menu'] = [
  42. 'type' => 'normal',
  43. 'title' => 'Stocks',
  44. 'description' => 'A stock is the physical entities of an organism, either living or preserved.',
  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_stock 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 stock administration view
  62. *
  63. * @ingroup tripal_legacy_stock
  64. */
  65. function tripal_stock_defaultview_admin_stocks() {
  66. $view = new view();
  67. $view->name = 'tripal_stock_admin_stocks';
  68. $view->description = 'DO NOT DISABLE';
  69. $view->tag = 'tripal admin';
  70. $view->base_table = 'stock';
  71. $view->human_name = 'Stock 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'] = 'Stocks';
  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_stock 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 stocks that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of stocks or to find a specific stock.';
  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_2' => 'name_2',
  97. 'name' => 'name',
  98. 'common_name' => 'common_name',
  99. 'all_dbxref' => 'all_dbxref',
  100. 'all_properties' => 'all_properties',
  101. 'all_relationships' => 'all_relationships',
  102. ];
  103. $handler->display->display_options['style_options']['default'] = '-1';
  104. $handler->display->display_options['style_options']['info'] = [
  105. 'uniquename' => [
  106. 'sortable' => 1,
  107. 'separator' => '',
  108. ],
  109. 'name_2' => [
  110. 'sortable' => 1,
  111. 'separator' => '',
  112. ],
  113. 'name' => [
  114. 'sortable' => 1,
  115. 'separator' => '',
  116. ],
  117. 'common_name' => [
  118. 'sortable' => 1,
  119. 'separator' => '',
  120. ],
  121. 'all_dbxref' => [
  122. 'separator' => '',
  123. ],
  124. 'all_properties' => [
  125. 'separator' => '',
  126. ],
  127. 'all_relationships' => [
  128. 'separator' => '',
  129. ],
  130. ];
  131. /* Header: Global: Action Links */
  132. $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
  133. $handler->display->display_options['header']['action_links_area']['table'] = 'views';
  134. $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
  135. $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
  136. $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
  137. $handler->display->display_options['header']['action_links_area']['link-1'] = [
  138. 'label-1' => 'Add Stock',
  139. 'path-1' => 'node/add/tripal-stock',
  140. ];
  141. $handler->display->display_options['header']['action_links_area']['link-2'] = [
  142. 'label-2' => '',
  143. 'path-2' => '',
  144. ];
  145. $handler->display->display_options['header']['action_links_area']['link-3'] = [
  146. 'label-3' => '',
  147. 'path-3' => '',
  148. ];
  149. $handler->display->display_options['header']['action_links_area']['link-4'] = [
  150. 'label-4' => '',
  151. 'path-4' => '',
  152. ];
  153. /* No results behavior: Global: Text area */
  154. $handler->display->display_options['empty']['text']['id'] = 'area';
  155. $handler->display->display_options['empty']['text']['table'] = 'views';
  156. $handler->display->display_options['empty']['text']['field'] = 'area';
  157. $handler->display->display_options['empty']['text']['content'] = 'No stocks match the supplied criteria.';
  158. $handler->display->display_options['empty']['text']['format'] = '1';
  159. /* Relationship: Stock: Stock => Node */
  160. $handler->display->display_options['relationships']['stock_id']['id'] = 'stock_id';
  161. $handler->display->display_options['relationships']['stock_id']['table'] = 'chado_stock';
  162. $handler->display->display_options['relationships']['stock_id']['field'] = 'stock_id';
  163. /* Field: Content: Nid */
  164. $handler->display->display_options['fields']['nid']['id'] = 'nid';
  165. $handler->display->display_options['fields']['nid']['table'] = 'node';
  166. $handler->display->display_options['fields']['nid']['field'] = 'nid';
  167. $handler->display->display_options['fields']['nid']['exclude'] = TRUE;
  168. /* Field: Node URL */
  169. $handler->display->display_options['fields']['nid_1']['id'] = 'nid_1';
  170. $handler->display->display_options['fields']['nid_1']['table'] = 'node';
  171. $handler->display->display_options['fields']['nid_1']['field'] = 'nid';
  172. $handler->display->display_options['fields']['nid_1']['relationship'] = 'feature_id';
  173. $handler->display->display_options['fields']['nid_1']['ui_name'] = 'Node URL';
  174. $handler->display->display_options['fields']['nid_1']['label'] = '';
  175. $handler->display->display_options['fields']['nid_1']['exclude'] = TRUE;
  176. $handler->display->display_options['fields']['nid_1']['alter']['alter_text'] = TRUE;
  177. $handler->display->display_options['fields']['nid_1']['alter']['text'] = 'node/[nid]';
  178. $handler->display->display_options['fields']['nid_1']['element_label_colon'] = FALSE;
  179. /* Field: Chado Stock: Uniquename */
  180. $handler->display->display_options['fields']['uniquename']['id'] = 'uniquename';
  181. $handler->display->display_options['fields']['uniquename']['table'] = 'stock';
  182. $handler->display->display_options['fields']['uniquename']['field'] = 'uniquename';
  183. $handler->display->display_options['fields']['uniquename']['label'] = 'Unique Name';
  184. $handler->display->display_options['fields']['uniquename']['alter']['make_link'] = TRUE;
  185. $handler->display->display_options['fields']['uniquename']['alter']['path'] = '[nid_1]';
  186. /* Field: Chado Stock: Name */
  187. $handler->display->display_options['fields']['name_2']['id'] = 'name_2';
  188. $handler->display->display_options['fields']['name_2']['table'] = 'stock';
  189. $handler->display->display_options['fields']['name_2']['field'] = 'name';
  190. $handler->display->display_options['fields']['name_2']['alter']['make_link'] = TRUE;
  191. $handler->display->display_options['fields']['name_2']['alter']['path'] = '[nid_1]';
  192. /* Field: Chado Cvterm: Name */
  193. $handler->display->display_options['fields']['name']['id'] = 'name';
  194. $handler->display->display_options['fields']['name']['table'] = 'cvterm';
  195. $handler->display->display_options['fields']['name']['field'] = 'name';
  196. $handler->display->display_options['fields']['name']['label'] = 'Type';
  197. /* Field: Chado Organism: Common Name */
  198. $handler->display->display_options['fields']['common_name']['id'] = 'common_name';
  199. $handler->display->display_options['fields']['common_name']['table'] = 'organism';
  200. $handler->display->display_options['fields']['common_name']['field'] = 'common_name';
  201. $handler->display->display_options['fields']['common_name']['label'] = 'Organism';
  202. /* Field: Content: Delete link */
  203. $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
  204. $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
  205. $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
  206. $handler->display->display_options['fields']['delete_node']['relationship'] = 'stock_id';
  207. $handler->display->display_options['fields']['delete_node']['exclude'] = TRUE;
  208. /* Field: Content: Edit link */
  209. $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
  210. $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
  211. $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
  212. $handler->display->display_options['fields']['edit_node']['relationship'] = 'stock_id';
  213. $handler->display->display_options['fields']['edit_node']['exclude'] = TRUE;
  214. /* Field: Global: Custom text */
  215. $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
  216. $handler->display->display_options['fields']['nothing']['table'] = 'views';
  217. $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
  218. $handler->display->display_options['fields']['nothing']['label'] = '';
  219. $handler->display->display_options['fields']['nothing']['alter']['text'] = '[edit_node] [delete_node]';
  220. $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
  221. /* Sort criterion: Chado Stock: Id */
  222. $handler->display->display_options['sorts']['stock_id']['id'] = 'stock_id';
  223. $handler->display->display_options['sorts']['stock_id']['table'] = 'stock';
  224. $handler->display->display_options['sorts']['stock_id']['field'] = 'stock_id';
  225. $handler->display->display_options['sorts']['stock_id']['order'] = 'DESC';
  226. /* Filter criterion: Chado Organism: Common Name */
  227. $handler->display->display_options['filters']['common_name']['id'] = 'common_name';
  228. $handler->display->display_options['filters']['common_name']['table'] = 'organism';
  229. $handler->display->display_options['filters']['common_name']['field'] = 'common_name';
  230. $handler->display->display_options['filters']['common_name']['value'] = 'All';
  231. $handler->display->display_options['filters']['common_name']['group'] = '0';
  232. $handler->display->display_options['filters']['common_name']['exposed'] = TRUE;
  233. $handler->display->display_options['filters']['common_name']['expose']['operator_id'] = 'common_name_op';
  234. $handler->display->display_options['filters']['common_name']['expose']['label'] = 'Organism';
  235. $handler->display->display_options['filters']['common_name']['expose']['operator'] = 'common_name_op';
  236. $handler->display->display_options['filters']['common_name']['expose']['identifier'] = 'organism_common_name';
  237. $handler->display->display_options['filters']['common_name']['expose']['remember_roles'] = [
  238. 2 => '2',
  239. 1 => 0,
  240. 3 => 0,
  241. ];
  242. /* Filter criterion: Chado Stock: Type Id */
  243. $handler->display->display_options['filters']['type_id']['id'] = 'type_id';
  244. $handler->display->display_options['filters']['type_id']['table'] = 'stock';
  245. $handler->display->display_options['filters']['type_id']['field'] = 'type_id';
  246. $handler->display->display_options['filters']['type_id']['value'] = 'All';
  247. $handler->display->display_options['filters']['type_id']['group'] = '0';
  248. $handler->display->display_options['filters']['type_id']['exposed'] = TRUE;
  249. $handler->display->display_options['filters']['type_id']['expose']['operator_id'] = 'type_id_op';
  250. $handler->display->display_options['filters']['type_id']['expose']['label'] = 'Type';
  251. $handler->display->display_options['filters']['type_id']['expose']['operator'] = 'type_id_op';
  252. $handler->display->display_options['filters']['type_id']['expose']['identifier'] = 'type_id';
  253. $handler->display->display_options['filters']['type_id']['expose']['remember_roles'] = [
  254. 2 => '2',
  255. 1 => 0,
  256. 3 => 0,
  257. ];
  258. /* Filter criterion: Chado Stock: Name */
  259. $handler->display->display_options['filters']['name']['id'] = 'name';
  260. $handler->display->display_options['filters']['name']['table'] = 'stock';
  261. $handler->display->display_options['filters']['name']['field'] = 'name';
  262. $handler->display->display_options['filters']['name']['operator'] = 'contains';
  263. $handler->display->display_options['filters']['name']['group'] = '0';
  264. $handler->display->display_options['filters']['name']['exposed'] = TRUE;
  265. $handler->display->display_options['filters']['name']['expose']['operator_id'] = 'name_op';
  266. $handler->display->display_options['filters']['name']['expose']['label'] = 'Name Contains';
  267. $handler->display->display_options['filters']['name']['expose']['operator'] = 'name_op';
  268. $handler->display->display_options['filters']['name']['expose']['identifier'] = 'name';
  269. $handler->display->display_options['filters']['name']['expose']['remember_roles'] = [
  270. 2 => '2',
  271. 1 => 0,
  272. 3 => 0,
  273. ];
  274. /** MANUALLY ADD since filter handler no exporting correctly */
  275. $handler->display->display_options['filters']['common_name']['expose']['values_form_type'] = 'select';
  276. $handler->display->display_options['filters']['common_name']['expose']['select_multiple'] = FALSE;
  277. $handler->display->display_options['filters']['common_name']['expose']['select_optional'] = TRUE;
  278. $handler->display->display_options['filters']['common_name']['expose']['max_length'] = 40;
  279. $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
  280. $handler->display->display_options['filters']['type_id']['expose']['select_multiple'] = FALSE;
  281. $handler->display->display_options['filters']['type_id']['expose']['select_optional'] = TRUE;
  282. $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
  283. /* Display: Page */
  284. $handler = $view->new_display('page', 'Page', 'page_1');
  285. $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_stock/stocks';
  286. $handler->display->display_options['menu']['type'] = 'default tab';
  287. $handler->display->display_options['menu']['title'] = 'Stocks';
  288. $handler->display->display_options['menu']['description'] = 'A stock is the physical entities, either living or preserved';
  289. $handler->display->display_options['menu']['weight'] = '-10';
  290. $handler->display->display_options['menu']['context'] = 0;
  291. $handler->display->display_options['menu']['context_only_inline'] = 0;
  292. $handler->display->display_options['tab_options']['weight'] = '0';
  293. /** MANUALLY ADD since filter handler no exporting correctly
  294. * $handler->display->display_options['filters']['common_name']['expose']['values_form_type'] = 'select';
  295. * $handler->display->display_options['filters']['common_name']['expose']['select_multiple'] = FALSE;
  296. * $handler->display->display_options['filters']['common_name']['expose']['select_optional'] = TRUE;
  297. * $handler->display->display_options['filters']['common_name']['expose']['max_length'] = 40;
  298. * $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
  299. * $handler->display->display_options['filters']['type_id']['expose']['select_multiple'] = FALSE;
  300. * $handler->display->display_options['filters']['type_id']['expose']['select_optional'] = TRUE;
  301. * $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
  302. */
  303. return $view;
  304. }