tripal_featuremap.views.inc 10 KB

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