-
Notifications
You must be signed in to change notification settings - Fork 2
/
apachesolr_passthru.views.inc
120 lines (107 loc) · 3.51 KB
/
apachesolr_passthru.views.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
// $Id$
/**
* Implementation of hook_views_handlers().
*/
function apachesolr_passthru_views_data() {
$view = NULL;
$display_name = NULL;
$solr_servers = apachesolr_passthru_get_servers() ;
foreach($solr_servers as $solr_server) {
$table_name = 'solr_server_' . $solr_server['machine_name'];
// TODO: save human name as well
$data[$table_name]['table']['group'] = 'Solr Server';
$data[$table_name]['table']['base'] = array(
'title' => t('Solr Query on server: %server_name', array('%server_name' => $solr_server['human_name'])),
'help' => t('Solr search independent of Drupal schema.'),
'query class' => 'apachesolr_passthru_views_query',
);
// The solr search should have a search term
$data[$table_name]['text'] = array(
'title' => t('Search'),
'help' => t('Searches the content with Solr'),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_search',
),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument_search',
),
);
$fields = _get_apachesolr_passthru_field_list($solr_server['solr_host'],$solr_server['solr_port'],$solr_server['solr_path']);
foreach($fields as $field) {
$data[$table_name][$field[0]] = array(
'title' => t($field[0]),
'help' => t("Pass-thru index:" . $field[0]),
'argument' => array(
'handler' => 'apachesolr_passthru_handler_argument_text',
),
'field' => array(
'handler' => 'apachesolr_passthru_handler_field_text',
),
'filter' => array(
'handler' => 'apachesolr_passthru_handler_filter_text',
),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
}
}
return $data;
}
function apachesolr_passthru_views_handlers() {
$path = drupal_get_path('module', 'apachesolr_passthru') . '/handlers';
return array(
'info' => array(
'modulename' => 'apachesolr_views',
'path' => $path,
),
'handlers' => array(
'apachesolr_passthru_handler_argument_text' => array(
'parent' => 'views_handler_argument',
),
'apachesolr_passthru_handler_field_text' => array(
'parent' => 'views_handler_field',
),
'apachesolr_passthru_handler_filter_text' => array(
'parent' => 'views_handler_filter_string',
),
),
);
}
/* implements hook_views_plugins */
function apachesolr_passthru_views_plugins() {
$path = drupal_get_path('module', 'apachesolr_passthru') . '/handlers';
return array(
'module' => 'apachesolr_passthru',
'query' => array(
'apachesolr_passthru_views_query' => array(
'title' => t('Apache Passthru Solr Query'),
'help' => t('Query that allows you to search any solr server.'),
'handler' => 'apachesolr_passthru_views_query',
'parent' => 'apachesolr_views_query',
),
),
);
}
/**
* Implementation of hook_views_data_alter(&$data).
*/
function apachesolr_passthru_views_data_alter(&$data) {
$fields = _get_apachesolr_passthru_field_list();
foreach($fields as $field) {
$data['apachesolr_node'][$field[0]] = array(
'title' => t($field[0]),
'help' => t("Pass-thru index:" . $field[0]),
'argument' => array(
'handler' => 'apachesolr_passthru_handler_argument_text',
),
'field' => array(
'handler' => 'apachesolr_passthru_handler_field_text',
),
'filter' => array(
'handler' => 'apachesolr_passthru_handler_filter_text',
),
);
}
}