tripal_pub.views.inc 10 KB

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