tripal_core.views_default.inc 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * Describes core default views
  5. */
  6. /**
  7. * Describes core default views
  8. *
  9. * @ingroup tripal_core
  10. */
  11. function tripal_core_views_default_views() {
  12. $views = array();
  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', array(':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 Nodes';
  34. $view->core = 7;
  35. $view->api_version = '3.0';
  36. $view->disabled = TRUE; /* 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 Pages';
  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'] = '10';
  51. $handler->display->display_options['style_plugin'] = 'default';
  52. $handler->display->display_options['row_plugin'] = 'fields';
  53. /* Field: Content: Rendered Node */
  54. $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
  55. $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
  56. $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
  57. $handler->display->display_options['fields']['rendered_entity']['label'] = '';
  58. $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
  59. $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
  60. $handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
  61. $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'teaser';
  62. $handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
  63. /* Sort criterion: Search: Relevance */
  64. $handler->display->display_options['sorts']['search_api_relevance']['id'] = 'search_api_relevance';
  65. $handler->display->display_options['sorts']['search_api_relevance']['table'] = 'search_api_index_default_node_index';
  66. $handler->display->display_options['sorts']['search_api_relevance']['field'] = 'search_api_relevance';
  67. $handler->display->display_options['sorts']['search_api_relevance']['order'] = 'DESC';
  68. /* Filter criterion: Search: Fulltext search */
  69. $handler->display->display_options['filters']['search_api_views_fulltext']['id'] = 'search_api_views_fulltext';
  70. $handler->display->display_options['filters']['search_api_views_fulltext']['table'] = 'search_api_index_default_node_index';
  71. $handler->display->display_options['filters']['search_api_views_fulltext']['field'] = 'search_api_views_fulltext';
  72. $handler->display->display_options['filters']['search_api_views_fulltext']['operator'] = 'OR';
  73. $handler->display->display_options['filters']['search_api_views_fulltext']['exposed'] = TRUE;
  74. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator_id'] = 'search_api_views_fulltext_op';
  75. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['label'] = 'Keywords';
  76. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator'] = 'search_api_views_fulltext_op';
  77. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['identifier'] = 'keywords';
  78. $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['remember_roles'] = array(
  79. 2 => '2',
  80. 1 => 0,
  81. 3 => 0,
  82. );
  83. /* Display: Page */
  84. $handler = $view->new_display('page', 'Page', 'page');
  85. $handler->display->display_options['path'] = 'search/node';
  86. return $view;
  87. }