tripal_stock.views.inc 11 KB

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