tripal_core.views_default.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * @file
  4. * Describes core default views
  5. */
  6. /**
  7. * Describes core default views
  8. *
  9. * @ingroup tripal_legacy_core
  10. */
  11. function tripal_core_views_default_views() {
  12. $views = [];
  13. // We only want to make this view available if the Search API module is installed
  14. // and the "Default Node Index has been enabled.
  15. if (module_exists('search_api')) {
  16. $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', [':name' => 'default_node_index'])->fetchField();
  17. if ($index_enabled) {
  18. $view = tripal_core_search_default_node_index();
  19. $views[$view->name] = $view;
  20. }
  21. }
  22. return $views;
  23. }
  24. /**
  25. * Provides a default search view for the Search API "Default Node Index".
  26. */
  27. function tripal_core_search_default_node_index() {
  28. $view = new view();
  29. $view->name = 'search_api_default_node_search';
  30. $view->description = 'A default keyword-based search view using the search API "Default node index".';
  31. $view->tag = 'search';
  32. $view->base_table = 'search_api_index_default_node_index';
  33. $view->human_name = 'Search';
  34. $view->core = 7;
  35. $view->api_version = '3.0';
  36. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  37. /* Display: Master */
  38. $handler = $view->new_display('default', 'Master', 'default');
  39. $handler->display->display_options['title'] = 'Search';
  40. $handler->display->display_options['use_more_always'] = FALSE;
  41. $handler->display->display_options['access']['type'] = 'none';
  42. $handler->display->display_options['cache']['type'] = 'none';
  43. $handler->display->display_options['query']['type'] = 'views_query';
  44. $handler->display->display_options['exposed_form']['type'] = 'input_required';
  45. $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
  46. $handler->display->display_options['exposed_form']['options']['expose_sort_order'] = FALSE;
  47. $handler->display->display_options['exposed_form']['options']['text_input_required'] = '';
  48. $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'filtered_html';
  49. $handler->display->display_options['pager']['type'] = 'full';
  50. $handler->display->display_options['pager']['options']['items_per_page'] = '25';
  51. $handler->display->display_options['pager']['options']['offset'] = '0';
  52. $handler->display->display_options['pager']['options']['id'] = '0';
  53. $handler->display->display_options['pager']['options']['quantity'] = '9';
  54. $handler->display->display_options['style_plugin'] = 'default';
  55. $handler->display->display_options['row_plugin'] = 'fields';
  56. /* Field: Content: Rendered Node */
  57. $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
  58. $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
  59. $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
  60. $handler->display->display_options['fields']['rendered_entity']['label'] = '';
  61. $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
  62. $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
  63. $handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
  64. $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'teaser';
  65. $handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
  66. /* Sort criterion: Search: Relevance */
  67. $handler->display->display_options['sorts']['search_api_relevance']['id'] = 'search_api_relevance';
  68. $handler->display->display_options['sorts']['search_api_relevance']['table'] = 'search_api_index_default_node_index';
  69. $handler->display->display_options['sorts']['search_api_relevance']['field'] = 'search_api_relevance';
  70. $handler->display->display_options['sorts']['search_api_relevance']['order'] = 'DESC';
  71. /* Filter criterion: Search: Fulltext search */
  72. $handler->display->display_options['filters']['search_api_views_fulltext']['id'] = 'search_api_views_fulltext';
  73. $handler->display->display_options['filters']['search_api_views_fulltext']['table'] = 'search_api_index_default_node_index';
  74. $handler->display->display_options['filters']['search_api_views_fulltext']['field'] = 'search_api_views_fulltext';
  75. $handler->display->display_options['filters']['search_api_views_fulltext']['operator'] = 'OR';
  76. $handler->display->display_options['filters']['search_api_views_fulltext']['exposed'] = TRUE;
  77. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator_id'] = 'search_api_views_fulltext_op';
  78. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['label'] = 'Keywords';
  79. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator'] = 'search_api_views_fulltext_op';
  80. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['identifier'] = 'keywords';
  81. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['remember_roles'] = [
  82. 2 => '2',
  83. 1 => 0,
  84. 3 => 0,
  85. ];
  86. /* Display: Page */
  87. $handler = $view->new_display('page', 'Page', 'page');
  88. $handler->display->display_options['path'] = 'chado';
  89. $handler->display->display_options['menu']['type'] = 'normal';
  90. $handler->display->display_options['menu']['title'] = 'Search';
  91. $handler->display->display_options['menu']['description'] = 'General keyword search of all content.';
  92. $handler->display->display_options['menu']['weight'] = '0';
  93. $handler->display->display_options['menu']['context'] = 0;
  94. $handler->display->display_options['menu']['context_only_inline'] = 0;
  95. return $view;
  96. }