forked from easySuite/ting_subsearch_secondary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathting_subsearch_secondary.admin.inc
124 lines (109 loc) · 5.17 KB
/
ting_subsearch_secondary.admin.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
121
122
123
124
<?php
/**
* @file
* Configuration of module.
*/
/**
* Implements hook_form_FORM_ID_alter().
*/
function ting_subsearch_secondary_form_opensearch_admin_settings_alter(&$form, &$form_state) {
$facets = [];
foreach (variable_get('ding_facetbrowser_facets', []) as $facet) {
$facets[] = $facet['name'];
}
if (!in_array('facet.genreCategory', $facets)) {
drupal_set_message(
t(
'Secondary search requires !facet. Please insert on !adminpage',
[
'!facet' => 'facet.genreCategory',
'!adminpage' => l(
t('Configure facets'),
'admin/config/ting/facets'
),
]
),
'warning'
);
}
$form['subsearch_settings']['#type'] = 'fieldset';
$form['subsearch_settings']['#title'] = t('Ting Subsearch');
$form['subsearch_settings']['#description'] = t('Feature modules allow additional searches to be made based on predefined conditions.');
$form['subsearch_settings']['#tree'] = FALSE;
$form['subsearch_settings']['secondary_settings'] = [
'#type' => 'fieldset',
'#title' => t('Secondary Ting Search settings'),
];
$form['subsearch_settings']['secondary_settings']['trigger'] = [
'#type' => 'fieldset',
'#title' => t('Trigger'),
];
$form['subsearch_settings']['secondary_settings']['trigger']['ting_subsearch_secondary_max'] = [
'#type' => 'textfield',
'#title' => t('Maximum number of results'),
'#default_value' => variable_get('ting_subsearch_secondary_max', 100),
'#description' => t('How many is maximum in order to trigger secondary search.'),
'#element_validate' => ['ting_subsearch_common_sensitive_fields_validate'],
];
$form['subsearch_settings']['secondary_settings']['trigger']['ting_subsearch_secondary_factor'] = [
'#type' => 'textfield',
'#title' => t('Challenge: Factor for calculating ratio between nonfiction and fiction'),
'#default_value' => variable_get('ting_subsearch_secondary_factor', 2),
'#description' => t('The condition is as following (nonfiction / factor) > fiction'),
'#element_validate' => ['ting_subsearch_common_sensitive_fields_validate'],
];
$form['subsearch_settings']['secondary_settings']['trigger']['ting_subsearch_secondary_result_min'] = [
'#type' => 'textfield',
'#title' => t('Minimum number of results for secondary search'),
'#description' => t('Minimum of hits in order to trigger secondary search.'),
'#default_value' => variable_get('ting_subsearch_secondary_result_min', 100),
'#element_validate' => ['ting_subsearch_common_sensitive_fields_validate'],
];
$form['subsearch_settings']['secondary_settings']['trigger']['ting_subsearch_secondary_ps_factor'] = [
'#type' => 'textfield',
'#title' => t('Ratio between primary and secondary searches'),
'#default_value' => variable_get('ting_subsearch_secondary_ps_factor', 2),
'#description' => t('Factor between amount of results from primary and secondary search.'),
'#element_validate' => ['ting_subsearch_common_sensitive_fields_validate'],
];
$form['subsearch_settings']['secondary_settings']['ting_subsearch_secondary_agency'] = [
'#type' => 'textfield',
'#title' => t('Secondary Agency'),
'#default_value' => variable_get('ting_subsearch_secondary_agency', ''),
'#description' => t('The agency for the secondary well configuration'),
];
$form['subsearch_settings']['secondary_settings']['ting_subsearch_secondary_profile'] = [
'#type' => 'textfield',
'#title' => t('Secondary Search profile'),
'#default_value' => variable_get('ting_subsearch_secondary_profile', ''),
'#description' => t('The Search profile for the secondary well configuration'),
];
$form['subsearch_settings']['secondary_settings']['ting_subsearch_secondary_search_link'] = [
'#type' => 'textfield',
'#title' => t('Secondary link'),
'#description' => t('Could be something link https://bibliotek.dk/da/search/work?search_block_form=[keys] where [keys] are substituted with the search phrase.'),
'#default_value' => variable_get('ting_subsearch_secondary_search_link', ''),
];
$form['subsearch_settings']['secondary_settings']['ting_subsearch_secondary_search_link_text'] = [
'#type' => 'textfield',
'#title' => t('Secondary link text'),
'#default_value' => variable_get('ting_subsearch_secondary_search_link_text', ''),
'#description' => t('Name of the secondary provider. Could be bibliotek.dk'),
];
$form['subsearch_settings']['secondary_settings']['ting_subsearch_secondary_number_of_results'] = [
'#type' => 'textfield',
'#title' => t('Number of results to show'),
'#default_value' => variable_get('ting_subsearch_secondary_number_of_results', 4),
'#description' => t('How many results should be shown from secondary well provider.'),
];
$form['subsearch_settings']['secondary_settings']['ting_subsearch_secondary_position'] = [
'#type' => 'radios',
'#title' => t('Position of message'),
'#options' => [
'before' => t('Before'),
'after' => t('After'),
],
'#default_value' => variable_get('ting_subsearch_secondary_position', 'before'),
'#description' => t('Should the message be positioned before or after the search result?'),
];
}