tripal_pub.views_default.inc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <?php
  2. /**
  3. *
  4. * @ingroup tripal_pub_views
  5. */
  6. function tripal_pub_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 = 'pub_listing';
  14. $view->description = 'This view lists all pubs by default.';
  15. $view->tag = 'chado default';
  16. $view->base_table = 'pub';
  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. 'title' => array(
  23. 'label' => 'Title',
  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' => 'title',
  48. 'table' => 'pub',
  49. 'field' => 'title',
  50. 'relationship' => 'none',
  51. ),
  52. 'pyear' => array(
  53. 'label' => 'Year',
  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. 'exclude' => 0,
  76. 'id' => 'name',
  77. 'table' => 'pub',
  78. 'field' => 'pyear',
  79. 'relationship' => 'none',
  80. ),
  81. 'type' => array(
  82. 'label' => 'Type',
  83. 'alter' => array(
  84. 'alter_text' => 0,
  85. 'text' => '',
  86. 'make_link' => 0,
  87. 'path' => '',
  88. 'link_class' => '',
  89. 'alt' => '',
  90. 'prefix' => '',
  91. 'suffix' => '',
  92. 'target' => '',
  93. 'help' => '',
  94. 'trim' => 0,
  95. 'max_length' => '',
  96. 'word_boundary' => 1,
  97. 'ellipsis' => 1,
  98. 'html' => 0,
  99. 'strip_tags' => 0,
  100. ),
  101. 'empty' => '',
  102. 'hide_empty' => 0,
  103. 'empty_zero' => 0,
  104. 'exclude' => 0,
  105. 'id' => 'type',
  106. 'table' => 'cvterm',
  107. 'field' => 'name',
  108. 'relationship' => 'none',
  109. ),
  110. ));
  111. $handler->override_option('sorts', array(
  112. 'pyear' => array(
  113. 'order' => 'ASC',
  114. 'id' => 'year',
  115. 'table' => 'pub',
  116. 'field' => 'pyear',
  117. 'relationship' => 'none',
  118. ),
  119. 'title' => array(
  120. 'order' => 'ASC',
  121. 'id' => 'title',
  122. 'table' => 'pub',
  123. 'field' => 'title',
  124. 'relationship' => 'none',
  125. ),
  126. 'type' => array(
  127. 'order' => 'ASC',
  128. 'id' => 'type',
  129. 'table' => 'cvterm',
  130. 'field' => 'name',
  131. 'relationship' => 'none',
  132. ),
  133. ));
  134. $handler->override_option('filters', array(
  135. 'search_results' => array(
  136. 'operator' => '=',
  137. 'value' => '',
  138. 'group' => '0',
  139. 'exposed' => FALSE,
  140. 'expose' => array(
  141. 'operator' => FALSE,
  142. 'label' => '',
  143. ),
  144. 'id' => 'search_results',
  145. 'table' => 'views',
  146. 'field' => 'search_results',
  147. 'relationship' => 'none',
  148. 'apply_button' => 'Show',
  149. 'no_results_text' => 'Click "Show" to see a list of all pubs matching the entered criteria. If you leave a any of the criteria blank then the pubs will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all pubs will be listed.',
  150. ),
  151. 'title' => array(
  152. 'operator' => '=',
  153. 'value' => array(),
  154. 'group' => '0',
  155. 'exposed' => TRUE,
  156. 'expose' => array(
  157. 'use_operator' => 0,
  158. 'operator' => 'title_op',
  159. 'identifier' => 'pub_title',
  160. 'label' => 'Title',
  161. 'remember' => 0,
  162. ),
  163. 'case' => 1,
  164. 'id' => 'title',
  165. 'table' => 'pub',
  166. 'field' => 'title',
  167. 'relationship' => 'none',
  168. ),
  169. 'type_id' => array(
  170. 'operator' => '=',
  171. 'value' => '',
  172. 'group' => '0',
  173. 'exposed' => TRUE,
  174. 'expose' => array(
  175. 'use_operator' => 0,
  176. 'operator' => 'type_id_op',
  177. 'identifier' => 'type_id',
  178. 'label' => 'Type',
  179. 'remember' => 0,
  180. ),
  181. 'case' => 1,
  182. 'id' => 'type_id',
  183. 'table' => 'pub',
  184. 'field' => 'type_id',
  185. 'relationship' => 'none',
  186. 'values_form_type' => 'select',
  187. 'multiple' => 1,
  188. 'optional' => 0,
  189. 'show_all' => 0,
  190. 'agg' => array(
  191. 'records_with' => 1,
  192. 'aggregates_with' => 1,
  193. ),
  194. ),
  195. 'year' => array(
  196. 'operator' => '=',
  197. 'value' => '',
  198. 'group' => '0',
  199. 'exposed' => TRUE,
  200. 'expose' => array(
  201. 'use_operator' => 0,
  202. 'operator' => 'name_op',
  203. 'identifier' => 'name',
  204. 'label' => 'Name Contains',
  205. 'remember' => 0,
  206. ),
  207. 'case' => 0,
  208. 'id' => 'name',
  209. 'table' => 'pub',
  210. 'field' => 'name',
  211. 'relationship' => 'none',
  212. 'values_form_type' => 'select',
  213. 'multiple' => 1,
  214. 'optional' => 0,
  215. 'show_all' => 0,
  216. 'agg' => array(
  217. 'records_with' => 1,
  218. 'aggregates_with' => 1,
  219. ),
  220. ),
  221. ));
  222. $handler->override_option('access', array(
  223. 'type' => 'perm',
  224. 'perm' => 'access chado_pub content',
  225. ));
  226. $handler->override_option('cache', array(
  227. 'type' => 'none',
  228. ));
  229. $handler->override_option('title', 'Publications');
  230. $handler->override_option('header', 'Click "Show" to see a list of all publications matching the entered criteria. If you leave a any of the criteria blank then the pubs will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all publications will be listed.');
  231. $handler->override_option('header_format', '2');
  232. $handler->override_option('header_empty', 0);
  233. $handler->override_option('empty', 'No publications match the supplied criteria.');
  234. $handler->override_option('empty_format', '1');
  235. $handler->override_option('items_per_page', 50);
  236. $handler->override_option('use_pager', '1');
  237. $handler->override_option('style_plugin', 'table');
  238. $handler->override_option('style_options', array(
  239. 'grouping' => '',
  240. 'override' => 1,
  241. 'sticky' => 0,
  242. 'order' => 'asc',
  243. 'columns' => array(
  244. 'title' => 'title',
  245. 'pyear' => 'pyear',
  246. 'type' => 'type',
  247. 'all_dbxref' => 'all_dbxref',
  248. 'all_properties' => 'all_properties',
  249. 'all_relationships' => 'all_relationships',
  250. ),
  251. 'info' => array(
  252. 'title' => array(
  253. 'sortable' => 1,
  254. 'separator' => '',
  255. ),
  256. 'type' => array(
  257. 'sortable' => 1,
  258. 'separator' => '',
  259. ),
  260. 'pyear' => array(
  261. 'sortable' => 1,
  262. 'separator' => '',
  263. ),
  264. 'all_dbxref' => array(
  265. 'separator' => '',
  266. ),
  267. 'all_properties' => array(
  268. 'separator' => '',
  269. ),
  270. 'all_relationships' => array(
  271. 'separator' => '',
  272. ),
  273. ),
  274. 'default' => '-1',
  275. ));
  276. $default_handler = $handler;
  277. $handler = $view->new_display('page', 'Page', 'page_1');
  278. $handler->override_option('path', 'chado/pubs');
  279. $handler->override_option('menu', array(
  280. 'type' => 'normal',
  281. 'title' => 'Publications',
  282. 'description' => 'A published article, book, conference proceeding, etc.',
  283. 'weight' => '10',
  284. 'name' => 'navigation',
  285. ));
  286. $handler->override_option('tab_options', array(
  287. 'type' => 'none',
  288. 'title' => '',
  289. 'description' => '',
  290. 'weight' => 0,
  291. 'name' => 'navigation',
  292. ));
  293. // Add code specific to a local chado installation
  294. // NOTE: Edit $handler above to $default_handler for the default display
  295. if (tripal_core_chado_schema_exists()) {
  296. // Add nid field
  297. $fields = $view->get_items('field', 'default');
  298. $new_fields = array(
  299. 'nid' => array(
  300. 'label' => 'Nid',
  301. 'alter' => array(
  302. 'alter_text' => 0,
  303. 'text' => '',
  304. 'make_link' => 0,
  305. 'path' => '',
  306. 'absolute' => 0,
  307. 'link_class' => '',
  308. 'alt' => '',
  309. 'rel' => '',
  310. 'prefix' => '',
  311. 'suffix' => '',
  312. 'target' => '',
  313. 'help' => '',
  314. 'trim' => 0,
  315. 'max_length' => '',
  316. 'word_boundary' => 1,
  317. 'ellipsis' => 1,
  318. 'html' => 0,
  319. 'strip_tags' => 0,
  320. ),
  321. 'empty' => '',
  322. 'hide_empty' => 0,
  323. 'empty_zero' => 0,
  324. 'hide_alter_empty' => 1,
  325. 'link_to_node' => 0,
  326. 'exclude' => 1,
  327. 'id' => 'nid',
  328. 'table' => 'node',
  329. 'field' => 'nid',
  330. 'relationship' => 'none',
  331. )
  332. );
  333. $fields = $new_fields + $fields;
  334. // Change analysis.name to have a link to the node
  335. $fields['name_2']['alter']['link_to_node'] = 1;
  336. $default_handler->override_option('fields', $fields);
  337. // Adds pub => Node relationship
  338. $default_handler->override_option('relationships', array(
  339. 'nid' => array(
  340. 'label' => 'Publication to Node',
  341. 'required' => 0,
  342. 'id' => 'nid',
  343. 'table' => 'chado_pub',
  344. 'field' => 'nid',
  345. 'relationship' => 'none',
  346. ),
  347. ));
  348. // Only show records with published nodes
  349. /**
  350. $filters = $view->get_items('filter', 'default');
  351. $filters['status'] = array(
  352. 'operator' => '=',
  353. 'value' => '1',
  354. 'group' => '0',
  355. 'exposed' => FALSE,
  356. 'expose' => array(
  357. 'operator' => FALSE,
  358. 'label' => '',
  359. ),
  360. 'id' => 'status',
  361. 'table' => 'node',
  362. 'field' => 'status',
  363. 'relationship' => 'none',
  364. );
  365. $default_handler->override_option('filters', $filters);
  366. */
  367. }
  368. $views[$view->name] = $view;
  369. return $views;
  370. }