tripal_stock.views_default.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <?php
  2. /**
  3. *
  4. * @ingroup tripal_stock_views
  5. */
  6. function tripal_stock_views_default_views() {
  7. $views = array();
  8. if (!module_exists('tripal_views')) {
  9. return $views;
  10. }
  11. // Main default view
  12. $view = new view;
  13. $view->name = 'stock_listing';
  14. $view->description = 'This view lists all stocks by default.';
  15. $view->tag = 'chado default';
  16. $view->base_table = 'stock';
  17. $view->core = 0;
  18. $view->api_version = '2';
  19. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  20. $handler = $view->new_display('default', 'Defaults', 'default');
  21. $handler->override_option('fields', array(
  22. 'uniquename' => array(
  23. 'label' => 'Unique Name',
  24. 'alter' => array(
  25. 'alter_text' => 0,
  26. 'text' => '',
  27. 'make_link' => 0,
  28. 'path' => '',
  29. 'link_class' => '',
  30. 'alt' => '',
  31. 'prefix' => '',
  32. 'suffix' => '',
  33. 'target' => '',
  34. 'help' => '',
  35. 'trim' => 0,
  36. 'max_length' => '',
  37. 'word_boundary' => 1,
  38. 'ellipsis' => 1,
  39. 'html' => 0,
  40. 'strip_tags' => 0,
  41. ),
  42. 'empty' => '',
  43. 'hide_empty' => 0,
  44. 'empty_zero' => 0,
  45. 'link_to_node' => 1,
  46. 'exclude' => 0,
  47. 'id' => 'uniquename',
  48. 'table' => 'stock',
  49. 'field' => 'uniquename',
  50. 'relationship' => 'none',
  51. ),
  52. 'name_2' => array(
  53. 'label' => 'Name',
  54. 'alter' => array(
  55. 'alter_text' => 0,
  56. 'text' => '',
  57. 'make_link' => 0,
  58. 'path' => '',
  59. 'link_class' => '',
  60. 'alt' => '',
  61. 'prefix' => '',
  62. 'suffix' => '',
  63. 'target' => '',
  64. 'help' => '',
  65. 'trim' => 0,
  66. 'max_length' => '',
  67. 'word_boundary' => 1,
  68. 'ellipsis' => 1,
  69. 'html' => 0,
  70. 'strip_tags' => 0,
  71. ),
  72. 'empty' => '',
  73. 'hide_empty' => 0,
  74. 'empty_zero' => 0,
  75. 'link_to_node' => 1,
  76. 'exclude' => 0,
  77. 'id' => 'name_2',
  78. 'table' => 'stock',
  79. 'field' => 'name',
  80. 'relationship' => 'none',
  81. ),
  82. 'name' => array(
  83. 'label' => 'Type',
  84. 'alter' => array(
  85. 'alter_text' => 0,
  86. 'text' => '',
  87. 'make_link' => 0,
  88. 'path' => '',
  89. 'link_class' => '',
  90. 'alt' => '',
  91. 'prefix' => '',
  92. 'suffix' => '',
  93. 'target' => '',
  94. 'help' => '',
  95. 'trim' => 0,
  96. 'max_length' => '',
  97. 'word_boundary' => 1,
  98. 'ellipsis' => 1,
  99. 'html' => 0,
  100. 'strip_tags' => 0,
  101. ),
  102. 'empty' => '',
  103. 'hide_empty' => 0,
  104. 'empty_zero' => 0,
  105. 'exclude' => 0,
  106. 'id' => 'name',
  107. 'table' => 'cvterm',
  108. 'field' => 'name',
  109. 'relationship' => 'none',
  110. ),
  111. 'common_name' => array(
  112. 'label' => 'Organism',
  113. 'alter' => array(
  114. 'alter_text' => 0,
  115. 'text' => '',
  116. 'make_link' => 0,
  117. 'path' => '',
  118. 'link_class' => '',
  119. 'alt' => '',
  120. 'prefix' => '',
  121. 'suffix' => '',
  122. 'target' => '',
  123. 'help' => '',
  124. 'trim' => 0,
  125. 'max_length' => '',
  126. 'word_boundary' => 1,
  127. 'ellipsis' => 1,
  128. 'html' => 0,
  129. 'strip_tags' => 0,
  130. ),
  131. 'empty' => '',
  132. 'hide_empty' => 0,
  133. 'empty_zero' => 0,
  134. 'link_to_node' => 1,
  135. 'exclude' => 0,
  136. 'id' => 'common_name',
  137. 'table' => 'organism',
  138. 'field' => 'common_name',
  139. 'relationship' => 'none',
  140. ),
  141. ));
  142. $handler->override_option('sorts', array(
  143. 'common_name' => array(
  144. 'order' => 'ASC',
  145. 'id' => 'common_name',
  146. 'table' => 'organism',
  147. 'field' => 'common_name',
  148. 'relationship' => 'none',
  149. ),
  150. 'uniquename' => array(
  151. 'order' => 'ASC',
  152. 'id' => 'uniquename',
  153. 'table' => 'stock',
  154. 'field' => 'uniquename',
  155. 'relationship' => 'none',
  156. ),
  157. ));
  158. $handler->override_option('filters', array(
  159. 'common_name' => array(
  160. 'operator' => '=',
  161. 'value' => array(),
  162. 'group' => '0',
  163. 'exposed' => TRUE,
  164. 'expose' => array(
  165. 'use_operator' => 0,
  166. 'operator' => 'common_name_op',
  167. 'identifier' => 'organism_common_name',
  168. 'label' => 'Organism',
  169. 'remember' => 0,
  170. ),
  171. 'case' => 1,
  172. 'id' => 'common_name',
  173. 'table' => 'organism',
  174. 'field' => 'common_name',
  175. 'relationship' => 'none',
  176. 'values_form_type' => 'select',
  177. 'multiple' => 1,
  178. 'optional' => 0,
  179. 'agg' => array(
  180. 'records_with' => 1,
  181. 'aggregates_with' => 1,
  182. ),
  183. ),
  184. 'search_results' => array(
  185. 'operator' => '=',
  186. 'value' => '',
  187. 'group' => '0',
  188. 'exposed' => FALSE,
  189. 'expose' => array(
  190. 'operator' => FALSE,
  191. 'label' => '',
  192. ),
  193. 'id' => 'search_results',
  194. 'table' => 'views',
  195. 'field' => 'search_results',
  196. 'relationship' => 'none',
  197. 'apply_button' => 'Show',
  198. 'no_results_text' => 'Click "Show" to see a list of all stocks matching the entered criteria. If you leave a any of the criteria blank then the stocks will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all stocks will be listed.',
  199. ),
  200. 'type_id' => array(
  201. 'operator' => '=',
  202. 'value' => '',
  203. 'group' => '0',
  204. 'exposed' => TRUE,
  205. 'expose' => array(
  206. 'use_operator' => 0,
  207. 'operator' => 'type_id_op',
  208. 'identifier' => 'type_id',
  209. 'label' => 'Type',
  210. 'remember' => 0,
  211. ),
  212. 'case' => 1,
  213. 'id' => 'type_id',
  214. 'table' => 'stock',
  215. 'field' => 'type_id',
  216. 'relationship' => 'none',
  217. 'values_form_type' => 'select',
  218. 'multiple' => 1,
  219. 'optional' => 0,
  220. 'show_all' => 0,
  221. 'agg' => array(
  222. 'records_with' => 1,
  223. 'aggregates_with' => 1,
  224. ),
  225. ),
  226. 'name' => array(
  227. 'operator' => '~',
  228. 'value' => '',
  229. 'group' => '0',
  230. 'exposed' => TRUE,
  231. 'expose' => array(
  232. 'use_operator' => 0,
  233. 'operator' => 'name_op',
  234. 'identifier' => 'name',
  235. 'label' => 'Name Contains',
  236. 'remember' => 0,
  237. ),
  238. 'case' => 0,
  239. 'id' => 'name',
  240. 'table' => 'stock',
  241. 'field' => 'name',
  242. 'relationship' => 'none',
  243. 'agg' => array(
  244. 'records_with' => 1,
  245. 'aggregates_with' => 1,
  246. ),
  247. ),
  248. ));
  249. $handler->override_option('access', array(
  250. 'type' => 'perm',
  251. 'perm' => 'access chado_stock content',
  252. ));
  253. $handler->override_option('cache', array(
  254. 'type' => 'none',
  255. ));
  256. $handler->override_option('title', 'Stocks');
  257. $handler->override_option('header', 'Click "Show" to see a list of all stocks matching the entered criteria. If you leave a any of the criteria blank then the stocks will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all stocks will be listed.');
  258. $handler->override_option('header_format', '2');
  259. $handler->override_option('header_empty', 0);
  260. $handler->override_option('empty', 'No stocks match the supplied criteria.');
  261. $handler->override_option('empty_format', '1');
  262. $handler->override_option('items_per_page', 50);
  263. $handler->override_option('use_pager', '1');
  264. $handler->override_option('style_plugin', 'table');
  265. $handler->override_option('style_options', array(
  266. 'grouping' => '',
  267. 'override' => 1,
  268. 'sticky' => 0,
  269. 'order' => 'asc',
  270. 'columns' => array(
  271. 'uniquename' => 'uniquename',
  272. 'name_2' => 'name_2',
  273. 'name' => 'name',
  274. 'common_name' => 'common_name',
  275. 'all_dbxref' => 'all_dbxref',
  276. 'all_properties' => 'all_properties',
  277. 'all_relationships' => 'all_relationships',
  278. ),
  279. 'info' => array(
  280. 'uniquename' => array(
  281. 'sortable' => 1,
  282. 'separator' => '',
  283. ),
  284. 'name_2' => array(
  285. 'sortable' => 1,
  286. 'separator' => '',
  287. ),
  288. 'name' => array(
  289. 'sortable' => 1,
  290. 'separator' => '',
  291. ),
  292. 'common_name' => array(
  293. 'sortable' => 1,
  294. 'separator' => '',
  295. ),
  296. 'all_dbxref' => array(
  297. 'separator' => '',
  298. ),
  299. 'all_properties' => array(
  300. 'separator' => '',
  301. ),
  302. 'all_relationships' => array(
  303. 'separator' => '',
  304. ),
  305. ),
  306. 'default' => '-1',
  307. ));
  308. $default_handler = $handler;
  309. $handler = $view->new_display('page', 'Page', 'page_1');
  310. $handler->override_option('path', 'chado/stocks');
  311. $handler->override_option('menu', array(
  312. 'type' => 'normal',
  313. 'title' => 'Stocks',
  314. 'description' => 'A stock is the physical entities, either living or preserved, held by collections and can be globally identified by the combination of organism, uniquename and stock type.',
  315. 'weight' => '10',
  316. 'name' => 'navigation',
  317. ));
  318. $handler->override_option('tab_options', array(
  319. 'type' => 'none',
  320. 'title' => '',
  321. 'description' => '',
  322. 'weight' => 0,
  323. 'name' => 'navigation',
  324. ));
  325. // Add code specific to a local chado installation
  326. // NOTE: Edit $handler above to $default_handler for the default display
  327. if (tripal_core_chado_schema_exists()) {
  328. // Add nid field
  329. $fields = $view->get_items('field', 'default');
  330. $new_fields = array(
  331. 'nid' => array(
  332. 'label' => 'Nid',
  333. 'alter' => array(
  334. 'alter_text' => 0,
  335. 'text' => '',
  336. 'make_link' => 0,
  337. 'path' => '',
  338. 'absolute' => 0,
  339. 'link_class' => '',
  340. 'alt' => '',
  341. 'rel' => '',
  342. 'prefix' => '',
  343. 'suffix' => '',
  344. 'target' => '',
  345. 'help' => '',
  346. 'trim' => 0,
  347. 'max_length' => '',
  348. 'word_boundary' => 1,
  349. 'ellipsis' => 1,
  350. 'html' => 0,
  351. 'strip_tags' => 0,
  352. ),
  353. 'empty' => '',
  354. 'hide_empty' => 0,
  355. 'empty_zero' => 0,
  356. 'hide_alter_empty' => 1,
  357. 'link_to_node' => 0,
  358. 'exclude' => 1,
  359. 'id' => 'nid',
  360. 'table' => 'node',
  361. 'field' => 'nid',
  362. 'relationship' => 'none',
  363. )
  364. );
  365. $fields = $new_fields + $fields;
  366. // Change analysis.name to have a link to the node
  367. $fields['name_2']['alter']['link_to_node'] = 1;
  368. $default_handler->override_option('fields', $fields);
  369. // Adds stock => Node relationship
  370. $default_handler->override_option('relationships', array(
  371. 'nid' => array(
  372. 'label' => 'Stock to Node',
  373. 'required' => 0,
  374. 'id' => 'nid',
  375. 'table' => 'chado_stock',
  376. 'field' => 'nid',
  377. 'relationship' => 'none',
  378. ),
  379. ));
  380. // Only show records with published nodes
  381. /**
  382. $filters = $view->get_items('filter', 'default');
  383. $filters['status'] = array(
  384. 'operator' => '=',
  385. 'value' => '1',
  386. 'group' => '0',
  387. 'exposed' => FALSE,
  388. 'expose' => array(
  389. 'operator' => FALSE,
  390. 'label' => '',
  391. ),
  392. 'id' => 'status',
  393. 'table' => 'node',
  394. 'field' => 'status',
  395. 'relationship' => 'none',
  396. );
  397. $default_handler->override_option('filters', $filters);
  398. */
  399. }
  400. $views[$view->name] = $view;
  401. return $views;
  402. }