tripal_library.views.inc 10 KB

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