tripal_organism.views.inc.orig 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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_organism_views Organism Views Integration
  13. * @ingroup views
  14. * @ingroup tripal_organism
  15. */
  16. <<<<<<< HEAD
  17. =======
  18. require_once('views/organism.views.inc');
  19. require_once('views/chado_organism.views.inc');
  20. >>>>>>> 6.x-0.4-dev
  21. /**
  22. * Implements hook_views_data()
  23. * Purpose: Describe chado/tripal tables & fields to views
  24. * @return: a data array which follows the structure outlined in the
  25. * views2 documentation for this hook. Essentially, it's an array of table
  26. * definitions keyed by chado/tripal table name. Each table definition
  27. * includes basic details about the table, fields in that table and
  28. * relationships between that table and others (joins)
  29. *
  30. * @ingroup tripal_organism_views
  31. */
  32. function tripal_organism_views_data() {
  33. $data = array();
  34. <<<<<<< HEAD
  35. if (module_exists('tripal_views')) {
  36. // Base Table
  37. $tables = array(
  38. 'organism'
  39. );
  40. foreach ($tables as $tablename) {
  41. if (!tripal_views_is_integrated($tablename, 10)) {
  42. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
  43. tripal_views_integration_add_entry($table_integration_array);
  44. }
  45. }
  46. // Additional Tables
  47. $tables = array(
  48. 'organismprop',
  49. 'organism_dbxref'
  50. );
  51. foreach ($tables as $tablename) {
  52. if (!tripal_views_is_integrated($tablename, 10)) {
  53. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
  54. tripal_views_integration_add_entry($table_integration_array);
  55. }
  56. }
  57. }
  58. =======
  59. $data = array_merge($data, retrieve_organism_views_data());
  60. $data = array_merge($data, retrieve_chado_organism_views_data());
  61. >>>>>>> 6.x-0.4-dev
  62. return $data;
  63. }
  64. /**
  65. * Implements hook_views_handlers()
  66. * Purpose: Register all custom handlers with views
  67. * where a handler describes either "the type of field",
  68. * "how a field should be filtered", "how a field should be sorted"
  69. * @return: An array of handler definitions
  70. *
  71. * @ingroup tripal_organism_views
  72. */
  73. function tripal_organism_views_handlers() {
  74. return array(
  75. 'info' => array(
  76. 'path' => drupal_get_path('module', 'tripal_organism') . '/views/handlers',
  77. ),
  78. 'handlers' => array(
  79. 'views_handler_field_computed_organism_nid' => array(
  80. 'parent' => 'views_handler_field_numeric',
  81. ),
  82. 'views_handler_filter_organism_common_name' => array(
  83. 'parent' => 'views_handler_filter_string',
  84. ),
  85. ),
  86. );
  87. }
  88. /**
  89. * Implementation of hook_views_data_alter().
  90. */
  91. function tripal_organism_views_data_alter(&$data) {
  92. if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
  93. // Add featuer relationship to node
  94. $data['node']['organism_chado_nid'] = array(
  95. 'group' => 'Organism',
  96. 'title' => 'Organism Node',
  97. 'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
  98. 'real field' => 'nid',
  99. 'relationship' => array(
  100. 'handler' => 'views_handler_relationship',
  101. 'title' => t('Node => Chado'),
  102. 'label' => t('Node => Chado'),
  103. 'real field' => 'nid',
  104. 'base' => 'chado_organism',
  105. 'base field' => 'nid'
  106. ),
  107. );
  108. }
  109. }
  110. /**
  111. *
  112. * @ingroup tripal_organism_views
  113. */
  114. function tripal_organism_views_default_views() {
  115. $views = array();
  116. // Main default view
  117. // List all cvterms based on cv
  118. $view = new view;
  119. $view->name = 'all_organisms';
  120. $view->description = 'A listing of all organism in chado';
  121. $view->tag = 'chado';
  122. $view->view_php = '';
  123. $view->base_table = 'organism';
  124. $view->is_cacheable = FALSE;
  125. $view->api_version = 2;
  126. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  127. $handler = $view->new_display('default', 'Defaults', 'default');
  128. $handler->override_option('fields', array(
  129. 'common_name' => array(
  130. 'label' => 'Common Name',
  131. 'alter' => array(
  132. 'alter_text' => 0,
  133. 'text' => '',
  134. 'make_link' => 0,
  135. 'path' => '',
  136. 'link_class' => '',
  137. 'alt' => '',
  138. 'prefix' => '',
  139. 'suffix' => '',
  140. 'target' => '',
  141. 'help' => '',
  142. 'trim' => 0,
  143. 'max_length' => '',
  144. 'word_boundary' => 1,
  145. 'ellipsis' => 1,
  146. 'html' => 0,
  147. 'strip_tags' => 0,
  148. ),
  149. 'empty' => '',
  150. 'hide_empty' => 0,
  151. 'empty_zero' => 0,
  152. 'link_to_node' => 1,
  153. 'exclude' => 0,
  154. 'id' => 'common_name',
  155. 'table' => 'organism',
  156. 'field' => 'common_name',
  157. 'relationship' => 'none',
  158. ),
  159. 'abbreviation' => array(
  160. 'label' => 'Abbreviation',
  161. 'alter' => array(
  162. 'alter_text' => 0,
  163. 'text' => '',
  164. 'make_link' => 0,
  165. 'path' => '',
  166. 'link_class' => '',
  167. 'alt' => '',
  168. 'prefix' => '',
  169. 'suffix' => '',
  170. 'target' => '',
  171. 'help' => '',
  172. 'trim' => 0,
  173. 'max_length' => '',
  174. 'word_boundary' => 1,
  175. 'ellipsis' => 1,
  176. 'html' => 0,
  177. 'strip_tags' => 0,
  178. ),
  179. 'empty' => '',
  180. 'hide_empty' => 0,
  181. 'empty_zero' => 0,
  182. 'link_to_node' => 0,
  183. 'exclude' => 0,
  184. 'id' => 'abbreviation',
  185. 'table' => 'organism',
  186. 'field' => 'abbreviation',
  187. 'relationship' => 'none',
  188. ),
  189. 'genus' => array(
  190. 'label' => 'Genus',
  191. 'alter' => array(
  192. 'alter_text' => 0,
  193. 'text' => '',
  194. 'make_link' => 0,
  195. 'path' => '',
  196. 'link_class' => '',
  197. 'alt' => '',
  198. 'prefix' => '',
  199. 'suffix' => '',
  200. 'target' => '',
  201. 'help' => '',
  202. 'trim' => 0,
  203. 'max_length' => '',
  204. 'word_boundary' => 1,
  205. 'ellipsis' => 1,
  206. 'html' => 0,
  207. 'strip_tags' => 0,
  208. ),
  209. 'empty' => '',
  210. 'hide_empty' => 0,
  211. 'empty_zero' => 0,
  212. 'exclude' => 0,
  213. 'id' => 'genus',
  214. 'table' => 'organism',
  215. 'field' => 'genus',
  216. 'relationship' => 'none',
  217. ),
  218. 'species' => array(
  219. 'label' => 'Species',
  220. 'alter' => array(
  221. 'alter_text' => 0,
  222. 'text' => '',
  223. 'make_link' => 0,
  224. 'path' => '',
  225. 'link_class' => '',
  226. 'alt' => '',
  227. 'prefix' => '',
  228. 'suffix' => '',
  229. 'target' => '',
  230. 'help' => '',
  231. 'trim' => 0,
  232. 'max_length' => '',
  233. 'word_boundary' => 1,
  234. 'ellipsis' => 1,
  235. 'html' => 0,
  236. 'strip_tags' => 0,
  237. ),
  238. 'empty' => '',
  239. 'hide_empty' => 0,
  240. 'empty_zero' => 0,
  241. 'exclude' => 0,
  242. 'id' => 'species',
  243. 'table' => 'organism',
  244. 'field' => 'species',
  245. 'relationship' => 'none',
  246. ),
  247. 'num_features' => array(
  248. 'label' => 'Number of Features',
  249. 'alter' => array(
  250. 'alter_text' => 0,
  251. 'text' => '',
  252. 'make_link' => 0,
  253. 'path' => '',
  254. 'link_class' => '',
  255. 'alt' => '',
  256. 'prefix' => '',
  257. 'suffix' => '',
  258. 'target' => '',
  259. 'help' => '',
  260. 'trim' => 0,
  261. 'max_length' => '',
  262. 'word_boundary' => 1,
  263. 'ellipsis' => 1,
  264. 'html' => 0,
  265. 'strip_tags' => 0,
  266. ),
  267. 'empty' => '',
  268. 'hide_empty' => 0,
  269. 'empty_zero' => 0,
  270. 'exclude' => 0,
  271. 'id' => 'num_features',
  272. 'table' => 'organism',
  273. 'field' => 'num_features',
  274. 'relationship' => 'none',
  275. ),
  276. 'num_stocks' => array(
  277. 'label' => 'Number of Stocks',
  278. 'alter' => array(
  279. 'alter_text' => 0,
  280. 'text' => '',
  281. 'make_link' => 0,
  282. 'path' => '',
  283. 'link_class' => '',
  284. 'alt' => '',
  285. 'prefix' => '',
  286. 'suffix' => '',
  287. 'target' => '',
  288. 'help' => '',
  289. 'trim' => 0,
  290. 'max_length' => '',
  291. 'word_boundary' => 1,
  292. 'ellipsis' => 1,
  293. 'html' => 0,
  294. 'strip_tags' => 0,
  295. ),
  296. 'empty' => '',
  297. 'hide_empty' => 0,
  298. 'empty_zero' => 0,
  299. 'exclude' => 0,
  300. 'id' => 'num_stocks',
  301. 'table' => 'organism',
  302. 'field' => 'num_stocks',
  303. 'relationship' => 'none',
  304. ),
  305. 'num_libraries' => array(
  306. 'label' => 'Number of Libraries',
  307. 'alter' => array(
  308. 'alter_text' => 0,
  309. 'text' => '',
  310. 'make_link' => 0,
  311. 'path' => '',
  312. 'link_class' => '',
  313. 'alt' => '',
  314. 'prefix' => '',
  315. 'suffix' => '',
  316. 'target' => '',
  317. 'help' => '',
  318. 'trim' => 0,
  319. 'max_length' => '',
  320. 'word_boundary' => 1,
  321. 'ellipsis' => 1,
  322. 'html' => 0,
  323. 'strip_tags' => 0,
  324. ),
  325. 'empty' => '',
  326. 'hide_empty' => 0,
  327. 'empty_zero' => 0,
  328. 'exclude' => 0,
  329. 'id' => 'num_libraries',
  330. 'table' => 'organism',
  331. 'field' => 'num_libraries',
  332. 'relationship' => 'none',
  333. ),
  334. ));
  335. $handler->override_option('access', array(
  336. 'type' => 'perm',
  337. 'perm' => 'access chado_organism content',
  338. ));
  339. $handler->override_option('cache', array(
  340. 'type' => 'none',
  341. ));
  342. $handler->override_option('title', 'Organisms');
  343. $handler->override_option('empty', 'No organism currently in your chado database.');
  344. $handler->override_option('empty_format', '1');
  345. $handler->override_option('items_per_page', 0);
  346. $handler->override_option('style_plugin', 'table');
  347. $handler->override_option('style_options', array(
  348. 'grouping' => '',
  349. 'override' => 1,
  350. 'sticky' => 0,
  351. 'order' => 'asc',
  352. 'columns' => array(
  353. 'abbreviation' => 'abbreviation',
  354. 'common_name' => 'common_name',
  355. 'genus' => 'genus',
  356. 'species' => 'species',
  357. ),
  358. 'info' => array(
  359. 'abbreviation' => array(
  360. 'sortable' => 0,
  361. 'separator' => '',
  362. ),
  363. 'common_name' => array(
  364. 'sortable' => 0,
  365. 'separator' => '',
  366. ),
  367. 'genus' => array(
  368. 'sortable' => 0,
  369. 'separator' => '',
  370. ),
  371. 'species' => array(
  372. 'sortable' => 0,
  373. 'separator' => '',
  374. ),
  375. ),
  376. 'default' => '-1',
  377. ));
  378. $handler = $view->new_display('page', 'Page', 'page_1');
  379. $handler->override_option('path', 'organisms');
  380. $handler->override_option('menu', array(
  381. 'type' => 'normal',
  382. 'title' => 'Organisms',
  383. 'description' => '',
  384. 'weight' => '0',
  385. 'name' => 'primary-links',
  386. ));
  387. $handler->override_option('tab_options', array(
  388. 'type' => 'none',
  389. 'title' => '',
  390. 'description' => '',
  391. 'weight' => 0,
  392. 'name' => 'navigation',
  393. ));
  394. $views[$view->name] = $view;
  395. return $views;
  396. }