Newer
Older
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
<?php
/**
* @file
* Contains the SearchApiViewsHandlerFilterLanguage class.
*/
/**
* Views filter handler class for handling the special "Item language" field.
*
* Definition items:
* - options: An array of possible values for this field.
*/
class SearchApiViewsHandlerFilterLanguage extends SearchApiViewsHandlerFilterOptions {
/**
* Provide a form for setting options.
*/
public function value_form(&$form, &$form_state) {
parent::value_form($form, $form_state);
$form['value']['#options'] = array(
'current' => t("Current user's language"),
'default' => t('Default site language'),
) + $form['value']['#options'];
}
/**
* Provides a summary of this filter's value for the admin UI.
*/
function admin_summary() {
$tmp = $this->definition['options'];
$this->definition['options']['current'] = t('current');
$this->definition['options']['default'] = t('default');
$ret = parent::admin_summary();
$this->definition['options'] = $tmp;
return $ret;
}
/**
* Add this filter to the query.
*/
public function query() {
global $language_content;
foreach ($this->value as $i => $v) {
if ($v == 'current') {
$this->value[$i] = $language_content->language;
}
elseif ($v == 'default') {
$this->value[$i] = language_default('language');
}
}
parent::query();
}
}