tripal_library.views.inc.orig 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. * @ingroup tripal_library
  15. */
  16. <<<<<<< HEAD
  17. =======
  18. require_once('views/library.views.inc');
  19. require_once('views/chado_library.views.inc');
  20. require_once('views/misc_tables.views.inc');
  21. >>>>>>> 6.x-0.4-dev
  22. /*************************************************************************
  23. * Implements hook_views_data()
  24. * Purpose: Describe chado/tripal tables & fields to views
  25. * @return: a data array which follows the structure outlined in the
  26. * views2 documentation for this hook. Essentially, it's an array of table
  27. * definitions keyed by chado/tripal table name. Each table definition
  28. * includes basic details about the table, fields in that table and
  29. * relationships between that table and others (joins)
  30. *
  31. * @ingroup tripal_library_views
  32. */
  33. function tripal_library_views_data() {
  34. $data = array();
  35. <<<<<<< HEAD
  36. if (module_exists('tripal_views')) {
  37. $tables = array(
  38. 'library'
  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. $tables = array(
  47. 'library_cvterm',
  48. 'library_feature',
  49. 'library_pub',
  50. 'library_synonym',
  51. 'libraryprop'
  52. );
  53. foreach ($tables as $tablename) {
  54. if (!tripal_views_is_integrated($tablename, 10)) {
  55. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
  56. tripal_views_integration_add_entry($table_integration_array);
  57. }
  58. }
  59. }
  60. =======
  61. $data = array_merge($data, retrieve_library_views_data());
  62. $data = array_merge($data, retrieve_chado_library_views_data());
  63. $data = array_merge($data, retrieve_library_misc_tables_views_data());
  64. >>>>>>> 6.x-0.4-dev
  65. return $data;
  66. }
  67. /*************************************************************************
  68. * Implements hook_views_handlers()
  69. * Purpose: Register all custom handlers with views
  70. * where a handler describes either "the type of field",
  71. * "how a field should be filtered", "how a field should be sorted"
  72. * @return: An array of handler definitions
  73. *
  74. * @ingroup tripal_library_views
  75. */
  76. function tripal_library_views_handlers() {
  77. return array(
  78. 'info' => array(
  79. 'path' => drupal_get_path('module', 'tripal_library') . '/views/handlers',
  80. ),
  81. 'handlers' => array(
  82. 'views_handler_field_computed_library_nid' => array(
  83. 'parent' => 'views_handler_field_numeric',
  84. ),
  85. ),
  86. );
  87. }
  88. /**
  89. * Implementation of hook_views_data_alter().
  90. */
  91. function tripal_library_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']['library_chado_nid'] = array(
  95. 'group' => 'Library',
  96. 'title' => 'Library Node',
  97. 'help' => 'Links Chado Library 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_library',
  105. 'base field' => 'nid'
  106. ),
  107. );
  108. }
  109. }
  110. /**
  111. *
  112. *
  113. * @ingroup tripal_library_views
  114. */
  115. function tripal_library_views_default_views() {
  116. $views = array();
  117. // Main default view
  118. // List all cvterms based on cv
  119. $view = new view;
  120. $view->name = 'all_libraries';
  121. $view->description = 'A listing of all libraries';
  122. $view->tag = 'chado';
  123. $view->view_php = '';
  124. $view->base_table = 'library';
  125. $view->is_cacheable = FALSE;
  126. $view->api_version = 2;
  127. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  128. $handler = $view->new_display('default', 'Defaults', 'default');
  129. $handler->override_option('fields', array(
  130. 'uniquename' => array(
  131. 'label' => 'Unique Name',
  132. 'alter' => array(
  133. 'alter_text' => 0,
  134. 'text' => '',
  135. 'make_link' => 0,
  136. 'path' => '',
  137. 'link_class' => '',
  138. 'alt' => '',
  139. 'prefix' => '',
  140. 'suffix' => '',
  141. 'target' => '',
  142. 'help' => '',
  143. 'trim' => 0,
  144. 'max_length' => '',
  145. 'word_boundary' => 1,
  146. 'ellipsis' => 1,
  147. 'html' => 0,
  148. 'strip_tags' => 0,
  149. ),
  150. 'empty' => '',
  151. 'hide_empty' => 0,
  152. 'empty_zero' => 0,
  153. 'link_to_node' => 1,
  154. 'exclude' => 0,
  155. 'id' => 'uniquename',
  156. 'table' => 'library',
  157. 'field' => 'uniquename',
  158. 'relationship' => 'none',
  159. ),
  160. 'name_1' => array(
  161. 'label' => 'Name',
  162. 'alter' => array(
  163. 'alter_text' => 0,
  164. 'text' => '',
  165. 'make_link' => 0,
  166. 'path' => '',
  167. 'link_class' => '',
  168. 'alt' => '',
  169. 'prefix' => '',
  170. 'suffix' => '',
  171. 'target' => '',
  172. 'help' => '',
  173. 'trim' => 0,
  174. 'max_length' => '',
  175. 'word_boundary' => 1,
  176. 'ellipsis' => 1,
  177. 'html' => 0,
  178. 'strip_tags' => 0,
  179. ),
  180. 'empty' => '',
  181. 'hide_empty' => 0,
  182. 'empty_zero' => 0,
  183. 'link_to_node' => 1,
  184. 'exclude' => 0,
  185. 'id' => 'name_1',
  186. 'table' => 'library',
  187. 'field' => 'name',
  188. 'relationship' => 'none',
  189. ),
  190. 'common_name' => array(
  191. 'label' => 'Organism',
  192. 'alter' => array(
  193. 'alter_text' => 0,
  194. 'text' => '',
  195. 'make_link' => 0,
  196. 'path' => '',
  197. 'link_class' => '',
  198. 'alt' => '',
  199. 'prefix' => '',
  200. 'suffix' => '',
  201. 'target' => '',
  202. 'help' => '',
  203. 'trim' => 0,
  204. 'max_length' => '',
  205. 'word_boundary' => 1,
  206. 'ellipsis' => 1,
  207. 'html' => 0,
  208. 'strip_tags' => 0,
  209. ),
  210. 'empty' => '',
  211. 'hide_empty' => 0,
  212. 'empty_zero' => 0,
  213. 'link_to_node' => 1,
  214. 'exclude' => 0,
  215. 'id' => 'common_name',
  216. 'table' => 'organism',
  217. 'field' => 'common_name',
  218. 'relationship' => 'none',
  219. ),
  220. 'name' => array(
  221. 'label' => 'Type',
  222. 'alter' => array(
  223. 'alter_text' => 0,
  224. 'text' => '',
  225. 'make_link' => 0,
  226. 'path' => '',
  227. 'link_class' => '',
  228. 'alt' => '',
  229. 'prefix' => '',
  230. 'suffix' => '',
  231. 'target' => '',
  232. 'help' => '',
  233. 'trim' => 0,
  234. 'max_length' => '',
  235. 'word_boundary' => 1,
  236. 'ellipsis' => 1,
  237. 'html' => 0,
  238. 'strip_tags' => 0,
  239. ),
  240. 'empty' => '',
  241. 'hide_empty' => 0,
  242. 'empty_zero' => 0,
  243. 'exclude' => 0,
  244. 'id' => 'name',
  245. 'table' => 'cvterm',
  246. 'field' => 'name',
  247. 'relationship' => 'none',
  248. ),
  249. 'is_obsolete' => array(
  250. 'label' => 'Is Obsolete?',
  251. 'alter' => array(
  252. 'alter_text' => 0,
  253. 'text' => '',
  254. 'make_link' => 0,
  255. 'path' => '',
  256. 'link_class' => '',
  257. 'alt' => '',
  258. 'prefix' => '',
  259. 'suffix' => '',
  260. 'target' => '',
  261. 'help' => '',
  262. 'trim' => 0,
  263. 'max_length' => '',
  264. 'word_boundary' => 1,
  265. 'ellipsis' => 1,
  266. 'html' => 0,
  267. 'strip_tags' => 0,
  268. ),
  269. 'empty' => '',
  270. 'hide_empty' => 0,
  271. 'empty_zero' => 0,
  272. 'type' => 'yes-no',
  273. 'not' => 0,
  274. 'exclude' => 0,
  275. 'id' => 'is_obsolete',
  276. 'table' => 'library',
  277. 'field' => 'is_obsolete',
  278. 'relationship' => 'none',
  279. ),
  280. 'num_features' => array(
  281. 'label' => 'Number of Features',
  282. 'alter' => array(
  283. 'alter_text' => 0,
  284. 'text' => '',
  285. 'make_link' => 0,
  286. 'path' => '',
  287. 'link_class' => '',
  288. 'alt' => '',
  289. 'prefix' => '',
  290. 'suffix' => '',
  291. 'target' => '',
  292. 'help' => '',
  293. 'trim' => 0,
  294. 'max_length' => '',
  295. 'word_boundary' => 1,
  296. 'ellipsis' => 1,
  297. 'html' => 0,
  298. 'strip_tags' => 0,
  299. ),
  300. 'empty' => '',
  301. 'hide_empty' => 0,
  302. 'empty_zero' => 0,
  303. 'exclude' => 0,
  304. 'id' => 'num_features',
  305. 'table' => 'library',
  306. 'field' => 'num_features',
  307. 'relationship' => 'none',
  308. ),
  309. ));
  310. $handler->override_option('filters', array(
  311. 'common_name' => array(
  312. 'operator' => '=',
  313. 'value' => 'All',
  314. 'group' => '0',
  315. 'exposed' => TRUE,
  316. 'expose' => array(
  317. 'use_operator' => 0,
  318. 'operator' => 'common_name_op',
  319. 'identifier' => 'organism_common_name',
  320. 'label' => 'Organism',
  321. 'optional' => 1,
  322. 'remember' => 0,
  323. ),
  324. 'case' => 1,
  325. 'id' => 'common_name',
  326. 'table' => 'organism',
  327. 'field' => 'common_name',
  328. 'relationship' => 'none',
  329. ),
  330. ));
  331. $handler->override_option('access', array(
  332. 'type' => 'perm',
  333. 'perm' => 'access chado_library content',
  334. ));
  335. $handler->override_option('cache', array(
  336. 'type' => 'none',
  337. ));
  338. $handler->override_option('title', 'Libraries');
  339. $handler->override_option('empty', 'There are no libraries matching the current criteria. If you think there should be, check that all chado libraries are sync\'d with your website.');
  340. $handler->override_option('empty_format', '1');
  341. $handler->override_option('use_pager', '1');
  342. $handler->override_option('style_plugin', 'table');
  343. $handler->override_option('style_options', array(
  344. 'grouping' => '',
  345. 'override' => 1,
  346. 'sticky' => 0,
  347. 'order' => 'asc',
  348. 'columns' => array(
  349. 'name' => 'name',
  350. 'timeaccessioned' => 'timeaccessioned',
  351. 'timelastmodified' => 'timelastmodified',
  352. 'is_obsolete' => 'is_obsolete',
  353. 'name_1' => 'name_1',
  354. 'uniquename' => 'uniquename',
  355. 'common_name' => 'common_name',
  356. 'num_libraries' => 'num_libraries',
  357. ),
  358. 'info' => array(
  359. 'name' => array(
  360. 'sortable' => 0,
  361. 'separator' => '',
  362. ),
  363. 'timeaccessioned' => array(
  364. 'sortable' => 0,
  365. 'separator' => '',
  366. ),
  367. 'timelastmodified' => array(
  368. 'sortable' => 0,
  369. 'separator' => '',
  370. ),
  371. 'is_obsolete' => array(
  372. 'sortable' => 0,
  373. 'separator' => '',
  374. ),
  375. 'name_1' => array(
  376. 'sortable' => 0,
  377. 'separator' => '',
  378. ),
  379. 'uniquename' => array(
  380. 'sortable' => 0,
  381. 'separator' => '',
  382. ),
  383. 'common_name' => array(
  384. 'sortable' => 0,
  385. 'separator' => '',
  386. ),
  387. 'num_libraries' => array(
  388. 'separator' => '',
  389. ),
  390. ),
  391. 'default' => '-1',
  392. ));
  393. $handler = $view->new_display('page', 'Page', 'page_1');
  394. $handler->override_option('path', 'libraries');
  395. $handler->override_option('menu', array(
  396. 'type' => 'normal',
  397. 'title' => 'Sequence Libraries',
  398. 'description' => '',
  399. 'weight' => '0',
  400. 'name' => 'primary-links',
  401. ));
  402. $handler->override_option('tab_options', array(
  403. 'type' => 'none',
  404. 'title' => '',
  405. 'description' => '',
  406. 'weight' => 0,
  407. 'name' => 'navigation',
  408. ));
  409. $views[$view->name] = $view;
  410. return $views;
  411. }